cloud-fan commented on code in PR #50960: URL: https://github.com/apache/spark/pull/50960#discussion_r2102738375
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/ResolveDefaultColumnsUtil.scala: ########## @@ -583,21 +583,29 @@ object ResolveDefaultColumns extends QueryErrorsBase default: DefaultValueExpression, statement: String, colName: String, - targetType: DataType): Unit = { + targetTypeOption: Option[DataType]): Unit = { if (default.containsPattern(PLAN_EXPRESSION)) { throw QueryCompilationErrors.defaultValuesMayNotContainSubQueryExpressions( statement, colName, default.originalSQL) } else if (default.resolved) { - val dataType = CharVarcharUtils.replaceCharVarcharWithString(targetType) - if (!Cast.canUpCast(default.child.dataType, dataType) && - defaultValueFromWiderTypeLiteral(default.child, dataType, colName).isEmpty) { - throw QueryCompilationErrors.defaultValuesDataTypeError( - statement, colName, default.originalSQL, targetType, default.child.dataType) + targetTypeOption match { + case Some(targetType) => + CharVarcharUtils.replaceCharVarcharWithString(targetType) + if (!Cast.canUpCast(default.child.dataType, targetType) && + defaultValueFromWiderTypeLiteral(default.child, targetType, colName).isEmpty) { + throw QueryCompilationErrors.defaultValuesDataTypeError( + statement, colName, default.originalSQL, targetType, default.child.dataType) + } + case _ => () Review Comment: too minor, you can address it in your next 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: 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