viirya commented on a change in pull request #24599: [SPARK-27701][SQL] Extend 
NestedColumnAliasing to general nested field cases including GetArrayStructField
URL: https://github.com/apache/spark/pull/24599#discussion_r292329802
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/NestedColumnAliasing.scala
 ##########
 @@ -86,32 +86,39 @@ object NestedColumnAliasing {
   }
 
   /**
-   * Return root references that are individually accessed as a whole, and 
`GetStructField`s.
+   * Return root references that are individually accessed as a whole, and 
`GetStructField`s
+   * or `GetArrayStructField`s which on top of other `ExtractValue`s or 
special expressions.
+   * Check `SelectedField` to see which expressions should be listed here.
    */
-  private def collectRootReferenceAndGetStructField(e: Expression): 
Seq[Expression] = e match {
-    case _: AttributeReference | _: GetStructField => Seq(e)
-    case es if es.children.nonEmpty => 
es.children.flatMap(collectRootReferenceAndGetStructField)
+  private def collectRootReferenceAndExtractValue(e: Expression): 
Seq[Expression] = e match {
+    case _: AttributeReference |
+         GetStructField(_: ExtractValue | _: AttributeReference, _, _) |
+         GetArrayStructFields(_: MapValues |
+                              _: MapKeys |
+                              _: ExtractValue |
+                              _: AttributeReference, _, _, _, _) => Seq(e)
 
 Review comment:
   Ur? I already split it to `AttributeReference`, `GetStructField` and 
`GetArrayStructFields` cases.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to