szehon-ho commented on code in PR #52504:
URL: https://github.com/apache/spark/pull/52504#discussion_r2397133818


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ColumnResolutionHelper.scala:
##########
@@ -167,19 +167,22 @@ trait ColumnResolutionHelper extends Logging with 
DataTypeErrorsBase {
           }
         }
 
-        case u @ UnresolvedExtractValue(child, field) =>
+        case u @ UnresolvedExtractValue(child, fieldName) =>
           val newChild = innerResolve(child, isTopLevel = false)
-          val resolvedField = if 
(conf.getConf(SQLConf.PREFER_COLUMN_OVER_LCA_IN_ARRAY_INDEX)) {
-            innerResolve(field, isTopLevel = false)
-          } else {
-            field
-          }
           if (newChild.resolved) {
-            ExtractValue(child = newChild, extraction = resolvedField, 
resolver = resolver)
+            ExtractValue(newChild, fieldName, resolver)
           } else {
-            u.copy(child = newChild, extraction = resolvedField)
+            u.copy(child = newChild)
           }
 
+        case d @ DefaultValueExpression(u: UnresolvedAttribute, _, _) =>

Review Comment:
   Note: prior it would fall to UnresolvedAttribute above:
   
   ```
   case u @ UnresolvedAttribute(nameParts) =>
             val result = withPosition(u) {
               resolveColumnByName(nameParts)
                 .orElse(LiteralFunctionResolution.resolve(nameParts))
                 .map {
                   // We trim unnecessary alias here. Note that, we cannot trim 
the alias at top-level,
                   // as we should resolve `UnresolvedAttribute` to a named 
expression. The caller side
                   // can trim the top-level alias if it's safe to do so. Since 
we will call
                   // CleanupAliases later in Analyzer, trim non top-level 
unnecessary alias is safe.
                   case Alias(child, _) if !isTopLevel => child
                   case other => other
                 }
                 .getOrElse(u)
             }
             logDebug(s"Resolving $u to $result")
             result
   ```



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