peter-toth commented on code in PR #60005:
URL: https://github.com/apache/spark/pull/60005#discussion_r4444344497


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveTableSpec.scala:
##########
@@ -103,6 +104,15 @@ object ResolveTableSpec extends Rule[LogicalPlan] {
               messageParameters = Map("checkCondition" -> check.condition)
             )
           }
+          check.child.collectFirst {
+            case e @ (_: AggregateExpression | _: Grouping | _: GroupingID |
+                _: WindowExpression | _: WindowFunction) => e

Review Comment:
   **Finding 1.** Generators have the same problem as the aggregate and window 
functions here. `ALTER TABLE ... ADD CONSTRAINT` rejects them in its `Filter`, 
because `PlanHelper.specialExpressionsInUnsupportedOperator` returns a 
`Generator` next to `AggregateExpression` and `WindowExpression`. `CREATE 
TABLE` and `REPLACE TABLE` still accept them. I ran this on the head and on the 
base commit, with the same result:
   
   ```sql
   CREATE TABLE cat.ns.t3 (id INT, CONSTRAINT c1 CHECK 
(size(explode(array(id))) > 0)) USING foo;  -- succeeds
   INSERT INTO cat.ns.t3 VALUES (1);  -- UNSUPPORTED_GENERATOR.OUTSIDE_SELECT
   ```
   
   `posexplode` and `inline` behave the same way. Adding `_: Generator` to this 
`collectFirst` would close it. The new error condition is unreleased, so its 
name and message could still be widened to cover generators. If you'd rather 
keep this PR to aggregates and windows, could you file a ticket?
   



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

Reply via email to