aokolnychyi commented on code in PR #50593: URL: https://github.com/apache/spark/pull/50593#discussion_r2069001807
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/ColumnDefinition.scala: ########## @@ -194,16 +195,29 @@ object ColumnDefinition { /** * A fake expression to hold the column/variable default value expression and its original SQL text. */ -case class DefaultValueExpression(child: Expression, originalSQL: String) - extends UnaryExpression with Unevaluable { +case class DefaultValueExpression( + child: Expression, + originalSQL: String, + analyzedChild: Option[Expression] = None) + extends UnaryExpression + with Unevaluable + with AnalysisAwareExpression[DefaultValueExpression] { + + final override val nodePatterns: Seq[TreePattern] = Seq(ANALYSIS_AWARE_EXPRESSION) + override def dataType: DataType = child.dataType + override def stringArgs: Iterator[Any] = Iterator(child, originalSQL) + override def markAsAnalyzed(): DefaultValueExpression = + copy(analyzedChild = Some(child)) override protected def withNewChildInternal(newChild: Expression): Expression = copy(child = newChild) // Convert the default expression to ColumnDefaultValue, which is required by DS v2 APIs. def toV2(statement: String, colName: String): ColumnDefaultValue = child match { case Literal(value, dataType) => - new ColumnDefaultValue(originalSQL, LiteralValue(value, dataType)) + val currentDefault = analyzedChild.flatMap(new V2ExpressionBuilder(_).build()) + val existsDefault = LiteralValue(value, dataType) + new ColumnDefaultValue(originalSQL, currentDefault.orNull, existsDefault) Review Comment: The V2 expression can be null if a Catalyst expression can't be converted. In that case, the connector has no other option other than to parse the SQL string or fail. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org