You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/08/19 23:49:58 UTC

[GitHub] [spark] viirya commented on a change in pull request #24525: [SPARK-27633][SQL] Remove redundant aliases in NestedColumnAliasing

viirya commented on a change in pull request #24525: [SPARK-27633][SQL] Remove redundant aliases in NestedColumnAliasing
URL: https://github.com/apache/spark/pull/24525#discussion_r315457433
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/NestedColumnAliasing.scala
 ##########
 @@ -119,9 +119,21 @@ object NestedColumnAliasing {
       .filter(!_.references.subsetOf(AttributeSet(otherRootReferences)))
       .groupBy(_.references.head)
       .flatMap { case (attr, nestedFields: Seq[ExtractValue]) =>
+        // Remove redundant `ExtractValue`s if they share the same parent nest field.
+        // For example, when `a.b` and `a.b.c` are in project list, we only need to alias `a.b`.
+        // We only need to deal with two `ExtractValue`: `GetArrayStructFields` and
+        // `GetStructField`. Please refer to the method `collectRootReferenceAndExtractValue`.
+        val dedupNestedFields = nestedFields.filter {
+          case a @ GetArrayStructFields(child, _, _, _, _) =>
+            nestedFields.forall(f => f == a || child.find(_.semanticEquals(f)).isEmpty)
+          case n @ GetStructField(child, _, _) =>
+            nestedFields.forall(f => f == n || child.find(_.semanticEquals(f)).isEmpty)
 
 Review comment:
   I think f == a condition is not necessary now. It should be left here by previous commit.

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