dtenedor commented on a change in pull request #35690:
URL: https://github.com/apache/spark/pull/35690#discussion_r818916692
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -2756,6 +2763,41 @@ class AstBuilder extends SqlBaseBaseVisitor[AnyRef] with
SQLConfHelper with Logg
metadata = builder.build())
}
+ /**
+ * Create a [[StructType]] from a number of CREATE TABLE column definitions.
+ */
+ override def visitCreateOrReplaceTableColTypeList(
+ ctx: CreateOrReplaceTableColTypeListContext): Seq[StructField] =
withOrigin(ctx) {
+
ctx.createOrReplaceTableColType().asScala.map(visitCreateOrReplaceTableColType).toSeq
+ }
+
+ /**
+ * Create a top level [[StructField]] from a CREATE TABLE column definition.
+ */
+ override def visitCreateOrReplaceTableColType(
+ ctx: CreateOrReplaceTableColTypeContext): StructField = withOrigin(ctx) {
+ import ctx._
+
+ val builder = new MetadataBuilder
+ // Add comment to metadata
+ Option(commentSpec()).map(visitCommentSpec).foreach {
+ builder.putString("comment", _)
+ }
+
+ // Process the 'DEFAULT expression' clause in the column definition, if
any.
+ val name: String = colName.getText
+ val defaultExpr =
Option(ctx.defaultExpression()).map(visitDefaultExpression)
+ if (defaultExpr != None) {
Review comment:
Done. Thanks for your reviews!
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/DDLParserSuite.scala
##########
@@ -1448,6 +1448,7 @@ class DDLParserSuite extends AnalysisTest {
Assignment(UnresolvedAttribute("target.col2"),
UnresolvedAttribute("source.col2")))))))
}
+
Review comment:
Done.
--
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]