Skip to content

Commit 2639792

Browse files
pan3793dongjoon-hyun
authored andcommitted
[SPARK-53523][SQL][FOLLOWUP] Udpate scaladocs and add tests in ProcedureSuite
### What changes were proposed in this pull request? As title. ### Why are the changes needed? Address comments #52269 (review) ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? This PR adds new UTs. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #52381 from pan3793/SPARK-53523-followup. Authored-by: Cheng Pan <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 49a3c13 commit 2639792

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/FunctionBuilderBase.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ trait FunctionBuilderBase[T] {
6363
* @param expectedSignature The method signature which we rearrange our arguments according to
6464
* @param providedArguments The list of arguments passed from function invocation
6565
* @param functionName The name of the function
66+
* @param resolver The resolver used to match the arguments
6667
* @return The rearranged argument list with arguments in positional order
6768
*/
6869
def rearrange(
@@ -86,15 +87,15 @@ object NamedParametersSupport {
8687
* - the named arguments don't contains positional arguments once keyword arguments start
8788
* - the named arguments don't use the duplicated names
8889
*
89-
* @param functionSignature The function signature that defines the positional ordering
9090
* @param args The argument list provided in function invocation
91+
* @param functionName The name of the function
92+
* @param resolver The resolver used to match the arguments
9193
* @return A tuple of a list of positional arguments and a list of keyword arguments
9294
*/
9395
def splitAndCheckNamedArguments(
9496
args: Seq[Expression],
9597
functionName: String,
96-
resolver: Resolver):
97-
(Seq[Expression], Seq[NamedArgumentExpression]) = {
98+
resolver: Resolver): (Seq[Expression], Seq[NamedArgumentExpression]) = {
9899
val (positionalArgs, namedArgs) = args.span(!_.isInstanceOf[NamedArgumentExpression])
99100

100101
val namedParametersSet = collection.mutable.Set[String]()
@@ -123,6 +124,7 @@ object NamedParametersSupport {
123124
* @param functionSignature The function signature that defines the positional ordering
124125
* @param args The argument list provided in function invocation
125126
* @param functionName The name of the function
127+
* @param resolver The resolver used to match the arguments
126128
* @return A list of arguments rearranged in positional order defined by the provided signature
127129
*/
128130
final def defaultRearrange(

sql/core/src/test/scala/org/apache/spark/sql/connector/ProcedureSuite.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import org.apache.spark.sql.connector.expressions.{Expression, GeneralScalarExpr
3333
import org.apache.spark.sql.connector.read.{LocalScan, Scan}
3434
import org.apache.spark.sql.errors.DataTypeErrors.{toSQLType, toSQLValue}
3535
import org.apache.spark.sql.internal.SQLConf
36+
import org.apache.spark.sql.internal.SQLConf.CASE_SENSITIVE
3637
import org.apache.spark.sql.test.SharedSparkSession
3738
import org.apache.spark.sql.types.{DataType, DataTypes, IntegerType, StructField, StructType}
3839
import org.apache.spark.unsafe.types.UTF8String
@@ -67,6 +68,24 @@ class ProcedureSuite extends QueryTest with SharedSparkSession with BeforeAndAft
6768
checkAnswer(sql("CALL cat.ns.sum(in2 => 3, in1 => 5)"), Row(8) :: Nil)
6869
}
6970

71+
test("SPARK-53523: named arguments respect spark.sql.caseSensitive") {
72+
catalog.createProcedure(Identifier.of(Array("ns"), "sum"), UnboundSum)
73+
withSQLConf(CASE_SENSITIVE.key -> "true") {
74+
checkError(
75+
exception = intercept[AnalysisException](
76+
sql("CALL cat.ns.sum(IN1 => 3, in2 => 5)")
77+
),
78+
condition = "UNRECOGNIZED_PARAMETER_NAME",
79+
parameters = Map(
80+
"routineName" -> toSQLId("sum"),
81+
"argumentName" -> toSQLId("IN1"),
82+
"proposal" -> (toSQLId("in1") + " " + toSQLId("in2"))))
83+
}
84+
withSQLConf(CASE_SENSITIVE.key -> "false") {
85+
checkAnswer(sql("CALL cat.ns.sum(IN1 => 3, in2 => 5)"), Row(8) :: Nil)
86+
}
87+
}
88+
7089
test("position and named arguments") {
7190
catalog.createProcedure(Identifier.of(Array("ns"), "sum"), UnboundSum)
7291
checkAnswer(sql("CALL cat.ns.sum(3, in2 => 1)"), Row(4) :: Nil)

0 commit comments

Comments
 (0)