gengliangwang commented on PR #52504:
URL: https://github.com/apache/spark/pull/52504#issuecomment-3386501673

   Here is a detailed RCA:
   When parsing the default value expression, the expression in the 
reproduction will produce UnresolvedAttribute
   ```
     private def getDefaultExpression(
         exprCtx: ExpressionContext,
         place: String): DefaultValueExpression = {
       // Make sure it can be converted to Catalyst expressions.
       val expr = expression(exprCtx)
       if (expr.containsPattern(PARAMETER)) {
         throw QueryParsingErrors.parameterMarkerNotAllowed(place, expr.origin)
       }
       DefaultValueExpression(expr, getOriginalText(exprCtx))
     }
   ```
   
   ```
     override def visitCurrentLike(ctx: CurrentLikeContext): Expression = 
withOrigin(ctx) {
       ...
         UnresolvedAttribute.quoted(ctx.name.getText)
     }
   ```
   However, in ColumnResolutionHelper.innerResolve , Spark will try to resolve 
UnresolvedAttribute  as Literal Function if it fail to find the column  from 
the child node:
   ```
           case u @ UnresolvedAttribute(nameParts) =>
             val result = withPosition(u) {
               resolveColumnByName(nameParts)
                 .orElse(LiteralFunctionResolution.resolve(nameParts)) 
   ```
   
   After commit 
https://github.com/apache/spark/commit/fc1cb7867e5524fd1f632e086ecac8ced41b3f65,
 the child node of CreateTable has the output and Spark can find the column 
from it, thus it is resolved as a column instead of function.
   


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