cloud-fan commented on code in PR #50408:
URL: https://github.com/apache/spark/pull/50408#discussion_r2022397263
##########
sql/api/src/main/scala/org/apache/spark/sql/catalyst/parser/DataTypeAstBuilder.scala:
##########
@@ -45,6 +45,78 @@ class DataTypeAstBuilder extends
SqlBaseParserBaseVisitor[AnyRef] {
withOrigin(ctx)(StructType(visitColTypeList(ctx.colTypeList)))
}
+ override def visitSingleRoutineParamList(ctx:
SingleRoutineParamListContext): StructType = {
+
withOrigin(ctx)(StructType(visitSimplifiedColDefinitionList(ctx.colDefinitionList())))
+ }
+
+ private def visitSimplifiedColDefinitionList(
+ ctx: ColDefinitionListContext): Seq[StructField] = withOrigin(ctx) {
+ ctx.colDefinition().asScala.map(visitStructField).toSeq
+ }
+
+ /**
+ * Create a [[StructField]] from a column definition which allows options
like COMMENT and
+ * DEFAULT.
+ *
+ * Don't handle generation expression since this function is currently only
used for creating
+ * SQL functions which don't support generation expressions. The rejection
logic is in
+ * [[SqlBaseParserVisitor#visitCreateUserDefinedFunction()]] implementation.
+ */
+ private def visitStructField(
Review Comment:
This method looks very similar to `visitColDefinition`. shall we invoke
`visitColDefinition` here, fail if
`ColumnDefinition#generationExpression/identityColumnSpec` is defined, and call
`ColumnDefinition#toV1Column` to get `StructField`.
--
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]