cloud-fan commented on code in PR #49840: URL: https://github.com/apache/spark/pull/49840#discussion_r1947410776
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/ResolveDefaultColumnsUtil.scala: ########## @@ -320,6 +330,29 @@ object ResolveDefaultColumns extends QueryErrorsBase coerceDefaultValue(analyzed, dataType, statementType, colName, defaultSQL) } + /** + * Analyze EXISTS_DEFAULT value. This skips some steps of analyze as most of the + * analysis has been done before. + */ + def analyzeExistingDefault(field: StructField, defaultSQL: String): Expression = { + val defaultSQL = field.metadata.getString(EXISTS_DEFAULT_COLUMN_METADATA_KEY) + + // Parse the expression. + val expr = Literal.fromSQL(defaultSQL) + + // Check invariants + if (expr.containsPattern(PLAN_EXPRESSION)) { + throw QueryCompilationErrors.defaultValuesMayNotContainSubQueryExpressions( + "", field.name, defaultSQL) + } + if (!expr.resolved) { + throw QueryCompilationErrors.defaultValuesUnresolvedExprError( + "", field.name, defaultSQL, null) + } + + expr Review Comment: shall we still call `coerceDefaultValue` at the end? -- 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