aokolnychyi commented on code in PR #50593:
URL: https://github.com/apache/spark/pull/50593#discussion_r2044978604
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/ColumnDefinition.scala:
##########
@@ -203,8 +206,19 @@ case class DefaultValueExpression(child: Expression,
originalSQL: String)
// 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 literalV2 = LiteralValue(value, dataType)
+ val exprV2 = if (exposeCurrentDefaultAsExprV2) literalV2 else null
+ new ColumnDefaultValue(originalSQL, exprV2, literalV2)
case _ =>
throw QueryCompilationErrors.defaultValueNotConstantError(statement,
colName, originalSQL)
}
}
+
+object DefaultValueExpression {
+ def apply(expr: Expression, originalSQL: String): DefaultValueExpression = {
+ // only expose V2 expressions as current defaults if all Catalyst
expressions are evaluable
+ // Catalyst expressions like CURRENT_USER or CURRENT_DATE will require
special handling
Review Comment:
I will work on this in a separate PR.
--
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]