cloud-fan commented on a change in pull request #31758:
URL: https://github.com/apache/spark/pull/31758#discussion_r589955898



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -1905,11 +1904,13 @@ class Analyzer(override val catalogManager: 
CatalogManager)
               .getOrElse(u)
           }
           val result = resolved match {
-            // When trimAlias = true, we will trim unnecessary alias of 
`GetStructField` and
-            // we won't trim the alias of top-level `GetStructField`. Since we 
will call
-            // CleanupAliases later in Analyzer, trim non top-level 
unnecessary alias of
-            // `GetStructField` here is safe.
-            case Alias(s: GetStructField, _) if trimAlias && !isTopLevel => s
+            // We trim unnecessary alias of `Get[Array]StructField` here. Note 
that, we cannot trim
+            // the alias of top-level `Get[Array]StructField`, as we should 
resolve
+            // `UnresolvedAttribute` to a named expression. The caller side 
can trim the alias of
+            // top-level `GetStructField` if it's safe to do so. Since we will 
call CleanupAliases
+            // later in Analyzer, trim non top-level unnecessary alias here is 
safe.
+            case Alias(s: GetStructField, _) if !isTopLevel => s
+            case Alias(s: GetArrayStructFields, _) if !isTopLevel => s

Review comment:
       good catch!




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



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

Reply via email to