MaxGekk commented on code in PR #38332:
URL: https://github.com/apache/spark/pull/38332#discussion_r1002891939


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala:
##########
@@ -268,15 +269,17 @@ abstract class HashExpression[E] extends Expression {
 
   override def checkInputDataTypes(): TypeCheckResult = {
     if (children.length < 1) {
-      TypeCheckResult.TypeCheckFailure(
-        s"input to function $prettyName requires at least one argument")
+      DataTypeMismatch(
+        errorSubClass = "WRONG_NUM_PARAMS",
+        messageParameters = Map(
+          "functionName" -> prettyName,
+          "expectedNum" -> "> 0",
+          "actualNum" -> children.length.toString))
     } else if (children.exists(child => hasMapType(child.dataType)) &&
         !SQLConf.get.getConf(SQLConf.LEGACY_ALLOW_HASH_ON_MAPTYPE)) {
-      TypeCheckResult.TypeCheckFailure(
-        s"input to function $prettyName cannot contain elements of MapType. In 
Spark, same maps " +
-          "may have different hashcode, thus hash expressions are prohibited 
on MapType elements." +
-          s" To restore previous behavior set 
${SQLConf.LEGACY_ALLOW_HASH_ON_MAPTYPE.key} " +
-          "to true.")
+      DataTypeMismatch(
+        errorSubClass = "HASH_MAP_TYPE",
+        messageParameters = Map("functionName" -> prettyName))

Review Comment:
   Quote by `toSQLId()`



##########
core/src/main/resources/error/error-classes.json:
##########
@@ -143,6 +143,11 @@
           "Offset expression <offset> must be a literal."
         ]
       },
+      "HASH_MAP_TYPE" : {
+        "message" : [
+          "Input to function <functionName> cannot contain elements of MAP. In 
Spark, same maps may have different hashcode, thus hash expressions are 
prohibited on MapType elements. To restore previous behavior set 
\"spark.sql.legacy.allowHashOnMapType\" to \"true\".",

Review Comment:
   ```suggestion
             "Input to the function <functionName> cannot contain elements of 
the \"MAP\" type. In Spark, same maps may have different hashcode, thus hash 
expressions are prohibited on \"MAP\" elements. To restore previous behavior 
set \"spark.sql.legacy.allowHashOnMapType\" to \"true\".",
   ```



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala:
##########
@@ -268,15 +269,17 @@ abstract class HashExpression[E] extends Expression {
 
   override def checkInputDataTypes(): TypeCheckResult = {
     if (children.length < 1) {
-      TypeCheckResult.TypeCheckFailure(
-        s"input to function $prettyName requires at least one argument")
+      DataTypeMismatch(
+        errorSubClass = "WRONG_NUM_PARAMS",
+        messageParameters = Map(
+          "functionName" -> prettyName,

Review Comment:
   Please, quote the function id by `toSQLId()`



-- 
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]

Reply via email to