From 5f336530c828b9dd0d364d7101e1cebfd63f3492 Mon Sep 17 00:00:00 2001 From: Cheng Pan Date: Thu, 18 Sep 2025 13:10:43 +0800 Subject: [PATCH] [SPARK-53523][SQL][FOLLOWUP] Udpate scaladocs and add tests in ProcedureSuite --- .../plans/logical/FunctionBuilderBase.scala | 8 +++++--- .../spark/sql/connector/ProcedureSuite.scala | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/FunctionBuilderBase.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/FunctionBuilderBase.scala index 26bf05d256b0..6c0a47537c90 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/FunctionBuilderBase.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/FunctionBuilderBase.scala @@ -63,6 +63,7 @@ trait FunctionBuilderBase[T] { * @param expectedSignature The method signature which we rearrange our arguments according to * @param providedArguments The list of arguments passed from function invocation * @param functionName The name of the function + * @param resolver The resolver used to match the arguments * @return The rearranged argument list with arguments in positional order */ def rearrange( @@ -86,15 +87,15 @@ object NamedParametersSupport { * - the named arguments don't contains positional arguments once keyword arguments start * - the named arguments don't use the duplicated names * - * @param functionSignature The function signature that defines the positional ordering * @param args The argument list provided in function invocation + * @param functionName The name of the function + * @param resolver The resolver used to match the arguments * @return A tuple of a list of positional arguments and a list of keyword arguments */ def splitAndCheckNamedArguments( args: Seq[Expression], functionName: String, - resolver: Resolver): - (Seq[Expression], Seq[NamedArgumentExpression]) = { + resolver: Resolver): (Seq[Expression], Seq[NamedArgumentExpression]) = { val (positionalArgs, namedArgs) = args.span(!_.isInstanceOf[NamedArgumentExpression]) val namedParametersSet = collection.mutable.Set[String]() @@ -123,6 +124,7 @@ object NamedParametersSupport { * @param functionSignature The function signature that defines the positional ordering * @param args The argument list provided in function invocation * @param functionName The name of the function + * @param resolver The resolver used to match the arguments * @return A list of arguments rearranged in positional order defined by the provided signature */ final def defaultRearrange( diff --git a/sql/core/src/test/scala/org/apache/spark/sql/connector/ProcedureSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/connector/ProcedureSuite.scala index 43bec881073a..618fb2465110 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/connector/ProcedureSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/connector/ProcedureSuite.scala @@ -33,6 +33,7 @@ import org.apache.spark.sql.connector.expressions.{Expression, GeneralScalarExpr import org.apache.spark.sql.connector.read.{LocalScan, Scan} import org.apache.spark.sql.errors.DataTypeErrors.{toSQLType, toSQLValue} import org.apache.spark.sql.internal.SQLConf +import org.apache.spark.sql.internal.SQLConf.CASE_SENSITIVE import org.apache.spark.sql.test.SharedSparkSession import org.apache.spark.sql.types.{DataType, DataTypes, IntegerType, StructField, StructType} import org.apache.spark.unsafe.types.UTF8String @@ -67,6 +68,24 @@ class ProcedureSuite extends QueryTest with SharedSparkSession with BeforeAndAft checkAnswer(sql("CALL cat.ns.sum(in2 => 3, in1 => 5)"), Row(8) :: Nil) } + test("SPARK-53523: named arguments respect spark.sql.caseSensitive") { + catalog.createProcedure(Identifier.of(Array("ns"), "sum"), UnboundSum) + withSQLConf(CASE_SENSITIVE.key -> "true") { + checkError( + exception = intercept[AnalysisException]( + sql("CALL cat.ns.sum(IN1 => 3, in2 => 5)") + ), + condition = "UNRECOGNIZED_PARAMETER_NAME", + parameters = Map( + "routineName" -> toSQLId("sum"), + "argumentName" -> toSQLId("IN1"), + "proposal" -> (toSQLId("in1") + " " + toSQLId("in2")))) + } + withSQLConf(CASE_SENSITIVE.key -> "false") { + checkAnswer(sql("CALL cat.ns.sum(IN1 => 3, in2 => 5)"), Row(8) :: Nil) + } + } + test("position and named arguments") { catalog.createProcedure(Identifier.of(Array("ns"), "sum"), UnboundSum) checkAnswer(sql("CALL cat.ns.sum(3, in2 => 1)"), Row(4) :: Nil)