MaxGekk commented on code in PR #41719:
URL: https://github.com/apache/spark/pull/41719#discussion_r1242113076
##########
sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala:
##########
@@ -5179,7 +5179,7 @@ class DataFrameFunctionsSuite extends QueryTest with
SharedSparkSession {
exception = intercept[AnalysisException] {
df.selectExpr("zip_with(a1, a2, x -> x)")
},
- errorClass = "_LEGACY_ERROR_TEMP_2300",
+ errorClass = "INVALID_LAMBDA_FUNCTION_CALL.ARGUMENTS_NUMBER_MISMATCH",
Review Comment:
Let's make it consistent to already existing error classes:
- NUM_COLUMNS_MISMATCH
- WRONG_NUM_ARGS
and make it shorter slightly: `NUM_ARGS_MISMATCH`
##########
core/src/main/resources/error/error-classes.json:
##########
@@ -1209,6 +1226,23 @@
],
"sqlState" : "22032"
},
+ "INVALID_LAMBDA_FUNCTION_CALL" : {
+ "message" : [
+ "Invalid lambda function call."
+ ],
+ "subClass" : {
+ "ARGUMENTS_NUMBER_MISMATCH" : {
+ "message" : [
+ "The number of lambda function arguments '<namesSize>' does not
match the number of arguments expected by the higher order function
'<argInfoSize>'."
+ ]
+ },
+ "ARGUMENT_NAMES_EXISTS_SAME_SEMANTIC" : {
+ "message" : [
+ "Lambda function arguments should not have names that are
semantically the same."
Review Comment:
Could you make the error message clear and more precise. From the
implementation:
```
if (!conf.caseSensitiveAnalysis) {
// scalastyle:off caselocale
s: String => s.toLowerCase
// scalastyle:on caselocale
} else {
s: String => s
}
```
Like:
```
A lambda function has duplicate arguments: <dupArgs>. Consider to rename the
arguments or to set the SQL config <caseSensitiveConfig> to \"false\".
```
##########
core/src/main/resources/error/error-classes.json:
##########
@@ -1197,6 +1192,28 @@
],
"sqlState" : "22003"
},
+ "INVALID_INLINE_TABLE" : {
+ "message" : [
+ "Invalid inline table."
+ ],
+ "subClass" : {
+ "CANNOT_EVALUATE_EXPRESSION_IN_INLINE_TABLE" : {
+ "message" : [
+ "cannot evaluate expression <sqlExpr> in inline table definition."
Review Comment:
```suggestion
"Cannot evaluate the expression <expr> in inline table definition."
```
##########
core/src/main/resources/error/error-classes.json:
##########
@@ -1654,6 +1688,11 @@
],
"sqlState" : "42803"
},
+ "MULTI_SOURCES_UNSUPPORTED_FOR_EXPRESSION" : {
+ "message" : [
+ "'<name>' does not support more than one sources."
Review Comment:
```suggestion
"The expression <expr> does not support more than one source."
```
##########
sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala:
##########
@@ -5189,6 +5189,18 @@ class DataFrameFunctionsSuite extends QueryTest with
SharedSparkSession {
stop = 22)
)
+ checkError(
+ exception = intercept[AnalysisException] {
+ df.selectExpr("zip_with(a1, a2, (x, x) -> x)")
+ },
+ errorClass =
"INVALID_LAMBDA_FUNCTION_CALL.ARGUMENT_NAMES_EXISTS_SAME_SEMANTIC",
Review Comment:
The error class name confuses slightly. Let's improve it.
##########
core/src/main/resources/error/error-classes.json:
##########
@@ -1209,6 +1226,23 @@
],
"sqlState" : "22032"
},
+ "INVALID_LAMBDA_FUNCTION_CALL" : {
+ "message" : [
+ "Invalid lambda function call."
+ ],
+ "subClass" : {
+ "ARGUMENTS_NUMBER_MISMATCH" : {
+ "message" : [
+ "The number of lambda function arguments '<namesSize>' does not
match the number of arguments expected by the higher order function
'<argInfoSize>'."
Review Comment:
```suggestion
"A higher order function expects <expectedNumArgs> arguments, but
got <actualNumArgs>."
```
##########
core/src/main/resources/error/error-classes.json:
##########
@@ -1197,6 +1192,28 @@
],
"sqlState" : "22003"
},
+ "INVALID_INLINE_TABLE" : {
+ "message" : [
+ "Invalid inline table."
+ ],
+ "subClass" : {
+ "CANNOT_EVALUATE_EXPRESSION_IN_INLINE_TABLE" : {
+ "message" : [
+ "cannot evaluate expression <sqlExpr> in inline table definition."
+ ]
+ },
+ "FAILED_SQL_EXPRESSION_EVALUATION" : {
+ "message" : [
+ "Failed to evaluate the SQL expression: <sqlExpr>. Please check your
syntax and ensure all required tables and columns are available."
+ ]
+ },
+ "INCOMPATIBLE_TYPES_IN_INLINE_TABLE" : {
+ "message" : [
+ "incompatible types found in column <name> for inline table."
Review Comment:
```suggestion
"Incompatible types found in column <name> for inline table."
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]