szehon-ho commented on code in PR #50960:
URL: https://github.com/apache/spark/pull/50960#discussion_r2099088917


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/ColumnDefinition.scala:
##########
@@ -162,43 +163,27 @@ object ColumnDefinition {
           col.defaultValue.foreach { default =>
             checkDefaultColumnConflicts(col)
             validateDefaultValueExpr(default, statement, col.name, 
col.dataType)
-            if (!default.deterministic) {
-              throw QueryCompilationErrors.defaultValueNonDeterministicError(
-                "CREATE TABLE", col.name, default.originalSQL)
-            }
           }
         }
 
       case cmd: AddColumns if cmd.columnsToAdd.exists(_.default.isDefined) =>
-        // Wrap analysis errors for default values in a more user-friendly 
message.
+        val statement = "ALTER TABLE ADD COLUMNS"
         cmd.columnsToAdd.foreach { c =>
           c.default.foreach { d =>
-            if (!d.resolved) {
-              throw QueryCompilationErrors.defaultValuesUnresolvedExprError(
-                "ALTER TABLE", c.colName, d.originalSQL, null)
-            }
-            validateDefaultValueExpr(d, "ALTER TABLE", c.colName, c.dataType)
-            if (!d.deterministic) {
-              throw QueryCompilationErrors.defaultValueNonDeterministicError(
-                "ALTER TABLE", c.colName, d.originalSQL)
-            }
+            validateDefaultValueExpr(d, statement, c.colName, c.dataType)
           }
         }
 
       case cmd: AlterColumns if 
cmd.specs.exists(_.newDefaultExpression.isDefined) =>
-        // Wrap analysis errors for default values in a more user-friendly 
message.
+        val statement = "ALTER TABLE ALTER COLUMN"
         cmd.specs.foreach { c =>
           c.newDefaultExpression.foreach { d =>
+            // Eagerly check resolved, as accessing datatype requires it to be 
resolved

Review Comment:
   the AlterColumnSpec object is a bit different than the rest (it doesnt have 
a type).  If i dont eagerly check here check if d is resolved, the d.dataType 
call to get the argument for validateDefaultValueExpr() itself throws another 
UnresolvedError, in the cases where the default value is an unresvoled 
expression like 'badvalue'



-- 
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

Reply via email to