cloud-fan commented on code in PR #39942:
URL: https://github.com/apache/spark/pull/39942#discussion_r1102393297


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala:
##########
@@ -3977,26 +3954,31 @@ class AstBuilder extends 
SqlBaseParserBaseVisitor[AnyRef] with SQLConfHelper wit
     }
   }
 
+  override def visitDefaultExpression(ctx: DefaultExpressionContext): 
Expression = withOrigin(ctx) {
+    expression(ctx.expression())
+  }
+
   /**
    * Parse new column info from ADD COLUMN into a QualifiedColType.
    */
   override def visitQualifiedColTypeWithPosition(
       ctx: QualifiedColTypeWithPositionContext): QualifiedColType = 
withOrigin(ctx) {
     val name = typedVisit[Seq[String]](ctx.name)
-    // Add the 'DEFAULT expression' clause in the column definition, if any, 
to the column metadata.
     val defaultExpr = 
Option(ctx.defaultExpression()).map(visitDefaultExpression)
     if (defaultExpr.isDefined && 
!conf.getConf(SQLConf.ENABLE_DEFAULT_COLUMNS)) {
       throw QueryParsingErrors.defaultColumnNotEnabledError(ctx)
     }
     QualifiedColType(
-      path = if (name.length > 1) Some(UnresolvedFieldName(name.init)) else 
None,
-      colName = name.last,
-      dataType = typedVisit[DataType](ctx.dataType),
-      nullable = ctx.NULL == null,
-      comment = Option(ctx.commentSpec()).map(visitCommentSpec),
+      path = if (name.length > 1) UnresolvedFieldName(name.init) else 
RootTableSchema,

Review Comment:
   This change is necessary to make `QualifiedColType` an expression, otherwise 
we can't properly implement `withChildren` as `QualifiedColType` has 2 optional 
children.



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