dtenedor commented on code in PR #46594:
URL: https://github.com/apache/spark/pull/46594#discussion_r1628294419


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/ResolveDefaultColumnsUtil.scala:
##########
@@ -284,6 +284,11 @@ object ResolveDefaultColumns extends QueryErrorsBase
       throw 
QueryCompilationErrors.defaultValuesMayNotContainSubQueryExpressions(
         statementType, colName, defaultSQL)
     }
+
+    if (!parsed.foldable) {
+      throw QueryCompilationErrors.defaultValueIsNotFoldable(colName, 
defaultSQL)

Review Comment:
   The `ConstantFolding` rule can apply even if the expression is not foldable. 
For example [1]:
   
   ```
       // Replace ScalarSubquery with null if its maxRows is 0
       case s: ScalarSubquery if s.plan.maxRows.contains(0) =>
         Literal(null, s.dataType)
   ```
   
   For this reason, it seems best to apply the `ConstantFolding` rule first and 
then check if the result is a `Literal` before returning this error.
   
   [1] 
https://github.com/apache/spark/blob/34ac7de897115caada7330aed32f03aca4796299/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala#L92



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