spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [spark] cloud-fan commented on a change in pull request #27580: [SPARK-27619][SQL]MapType should be prohibited in hash expressions
Date Tue, 25 Feb 2020 12:02:18 GMT
cloud-fan commented on a change in pull request #27580: [SPARK-27619][SQL]MapType should be
prohibited in hash expressions
URL: https://github.com/apache/spark/pull/27580#discussion_r383836608
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
 ##########
 @@ -249,10 +247,20 @@ abstract class HashExpression[E] extends Expression {
 
   override def nullable: Boolean = false
 
+  private def hasMapType(dt: DataType): Boolean = {
+    dt.existsRecursively(_.isInstanceOf[MapType])
+  }
+
   override def checkInputDataTypes(): TypeCheckResult = {
     if (children.length < 1) {
       TypeCheckResult.TypeCheckFailure(
         s"input to function $prettyName requires at least one argument")
+    } else if (children.forall(child => hasMapType(child.dataType)) &&
+      !SQLConf.get.getConf(SQLConf.LEGACY_USE_HASH_ON_MAPTYPE)) {
+      TypeCheckResult.TypeCheckFailure(
+        s"input to function $prettyName cannot contain elements of MapType. Logically same
maps " +
+          "may have different hashcode, thus hash expressions are prohibited on MapType "
+
+          "elements. To restore previous behavior set spark.sql.legacy.useHashOnMapType to
true.")
 
 Review comment:
   We should not hardcode the config name. Better to use `${SQLConf.LEGACY_USE_HASH_ON_MAPTYPE.key}`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message