cloud-fan commented on code in PR #50408:
URL: https://github.com/apache/spark/pull/50408#discussion_r2034619792
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala:
##########
@@ -3885,6 +3882,34 @@ class AstBuilder extends DataTypeAstBuilder
* DataType parsing
*
********************************************************************************************
*/
+ override def visitSingleRoutineParamList(
+ ctx: SingleRoutineParamListContext): StructType = withOrigin(ctx) {
+ val (cols, constraints) = visitColDefinitionList(ctx.colDefinitionList())
+ assert(constraints.isEmpty)
+ for (col <- cols) {
+ assert(col.generationExpression.isEmpty)
+ assert(col.identityColumnSpec.isEmpty)
+ }
+ val schema = StructType(cols.map(_.toV1Column))
+ // Add the parameter default metadata and remove the column default
metadata.
+ val fields = for (field <- schema) yield {
+ // Generated columns should have been rejected by the parser.
+
assert(!field.metadata.contains(GeneratedColumn.GENERATION_EXPRESSION_METADATA_KEY))
+ field.getCurrentDefaultValue() match {
+ case Some(default) =>
+ val metadata = new MetadataBuilder()
+ .withMetadata(field.metadata)
+
.remove(ResolveDefaultColumnsUtils.CURRENT_DEFAULT_COLUMN_METADATA_KEY)
+
.remove(ResolveDefaultColumnsUtils.EXISTS_DEFAULT_COLUMN_METADATA_KEY)
Review Comment:
nit: this is a bad smell as we assume the function `toV1Column` adds these
two metadata fields. Shall we manually write code here to turn
`ColumnDefinition` into `StructField`? We only need to handle comment and
default value.
--
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]