Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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]()
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down