MaxGekk commented on code in PR #44336:
URL: https://github.com/apache/spark/pull/44336#discussion_r1431830689
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala:
##########
@@ -1300,14 +1300,16 @@ trait ComplexTypeMergingExpression extends Expression {
lazy val inputTypesForMerging: Seq[DataType] = children.map(_.dataType)
def dataTypeCheck: Unit = {
- require(
- inputTypesForMerging.nonEmpty,
- "The collection of input data types must not be empty.")
- require(
- TypeCoercion.haveSameType(inputTypesForMerging),
- "All input types must be the same except nullable, containsNull,
valueContainsNull flags. " +
- s"The expression is: $this. " +
- s"The input types found
are\n\t${inputTypesForMerging.mkString("\n\t")}.")
+ SparkException.require(
+ requirement = inputTypesForMerging.nonEmpty,
+ errorClass = "COMPLEX_EXPRESSION_UNSUPPORTED_INPUT.NO_INPUTS",
+ messageParameters = Map("expression" -> this.toString))
Review Comment:
Please, quote the expression:
```suggestion
messageParameters = Map("expression" -> toSQLExpr(this)))
```
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala:
##########
@@ -1300,14 +1300,16 @@ trait ComplexTypeMergingExpression extends Expression {
lazy val inputTypesForMerging: Seq[DataType] = children.map(_.dataType)
def dataTypeCheck: Unit = {
- require(
- inputTypesForMerging.nonEmpty,
- "The collection of input data types must not be empty.")
- require(
- TypeCoercion.haveSameType(inputTypesForMerging),
- "All input types must be the same except nullable, containsNull,
valueContainsNull flags. " +
- s"The expression is: $this. " +
- s"The input types found
are\n\t${inputTypesForMerging.mkString("\n\t")}.")
+ SparkException.require(
+ requirement = inputTypesForMerging.nonEmpty,
+ errorClass = "COMPLEX_EXPRESSION_UNSUPPORTED_INPUT.NO_INPUTS",
+ messageParameters = Map("expression" -> this.toString))
+ SparkException.require(
+ requirement = TypeCoercion.haveSameType(inputTypesForMerging),
+ errorClass = "COMPLEX_EXPRESSION_UNSUPPORTED_INPUT.MISMATCHED_TYPES",
+ messageParameters = Map(
+ "expression" -> this.toString,
+ "inputTypes" -> inputTypesForMerging.mkString("\n\t")))
Review Comment:
```suggestion
"inputTypes" -> inputTypesForMerging.map(toSQLType).mkString(", ")))
```
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala:
##########
@@ -1300,14 +1300,16 @@ trait ComplexTypeMergingExpression extends Expression {
lazy val inputTypesForMerging: Seq[DataType] = children.map(_.dataType)
def dataTypeCheck: Unit = {
- require(
- inputTypesForMerging.nonEmpty,
- "The collection of input data types must not be empty.")
- require(
- TypeCoercion.haveSameType(inputTypesForMerging),
- "All input types must be the same except nullable, containsNull,
valueContainsNull flags. " +
- s"The expression is: $this. " +
- s"The input types found
are\n\t${inputTypesForMerging.mkString("\n\t")}.")
+ SparkException.require(
+ requirement = inputTypesForMerging.nonEmpty,
+ errorClass = "COMPLEX_EXPRESSION_UNSUPPORTED_INPUT.NO_INPUTS",
+ messageParameters = Map("expression" -> this.toString))
+ SparkException.require(
+ requirement = TypeCoercion.haveSameType(inputTypesForMerging),
+ errorClass = "COMPLEX_EXPRESSION_UNSUPPORTED_INPUT.MISMATCHED_TYPES",
+ messageParameters = Map(
+ "expression" -> this.toString,
Review Comment:
```suggestion
"expression" -> toSQLExpr(this),
```
##########
common/utils/src/main/resources/error/error-classes.json:
##########
@@ -500,6 +500,25 @@
],
"sqlState" : "22004"
},
+ "COMPLEX_EXPRESSION_UNSUPPORTED_INPUT" : {
+ "message" : [
+ "Cannot process input data types for expression: <expression>."
Review Comment:
```suggestion
"Cannot process input data types for the expression: <expression>."
```
##########
common/utils/src/main/resources/error/error-classes.json:
##########
@@ -500,6 +500,25 @@
],
"sqlState" : "22004"
},
+ "COMPLEX_EXPRESSION_UNSUPPORTED_INPUT" : {
+ "message" : [
+ "Cannot process input data types for expression: <expression>."
+ ],
+ "subClass" : {
+ "MISMATCHED_TYPES" : {
+ "message" : [
+ "All input types must be the same except nullable, containsNull,
valueContainsNull flags.",
+ "The input types found are <inputTypes>."
Review Comment:
```suggestion
"All input types must be the same except nullable, containsNull,
valueContainsNull flags, but found the input types <inputTypes>."
```
--
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]