raviston commented on PR #60296: URL: https://github.com/apache/spark/pull/60296#issuecomment-6788347275
I ran items 1-4 of @dongjoon-hyun's [review](https://github.com/apache/spark/pull/60296#pullrequestreview-5854212460), and all four reproduce. I used the same setup as in my comment above: master at e540d564a21, then the same build with this PR's catalyst classes (e77a0ba7ae1), in a regular PySpark session with ANSI on. ```sql CREATE OR REPLACE TEMP VIEW a(k) AS VALUES (1), (2); CREATE OR REPLACE TEMP VIEW b(k, v) AS VALUES (1, 100), (1, 200), (2, 300); CREATE OR REPLACE TEMP VIEW d(z, y) AS VALUES (2, 5), (1, 7); CREATE OR REPLACE TEMP VIEW t1(a1, a2) AS VALUES (1, 1), (2, 2); CREATE OR REPLACE TEMP VIEW t2(b1, b2) AS VALUES (1, 1), (2, 2); -- [4] spark.udf.register("inv", lambda x: 1 / x, "double") ``` | Item | Query | master | this PR | |---|---|---|---| | [1] | `SELECT a.k, (SELECT c + (SELECT MAX(d.y) FROM d WHERE d.z = c) FROM (SELECT COUNT(*) c FROM b WHERE b.k = a.k)) FROM a` | `(1, 7), (2, 8)` | `INTERNAL_ERROR: Cannot generate code for expression: outer(c#18L)` | | [2] | `SELECT a.k, (SELECT MAX(10 / c) FROM (SELECT COUNT(*) c FROM b WHERE b.k = a.k)) FROM a` | `(1, 5.0), (2, 10.0)` | `DIVIDE_BY_ZERO` | | [3] | `SELECT a1, (SELECT s * s FROM (SELECT c + 1 AS s FROM (SELECT COUNT(*) c FROM t2 WHERE t2.b1 = t1.a1 AND t2.b2 > 10))) FROM t1` | `(1, 1), (2, 1)` | **`(1, NULL), (2, NULL)`** | | [4] | `SELECT a.k, (SELECT inv(c) FROM (SELECT COUNT(*) c FROM b WHERE b.k = a.k)) FROM a` | `(1, 0.5), (2, 1.0)` | `ZeroDivisionError: division by zero` | Every key of `a` has rows in `b` in [1], [2] and [4], so none of them should divide by zero. [3] is a silent wrong result, not an error. As noted in the review, it needs `ConvertToLocalRelation`, which a regular session has, so the golden files would not catch it as they are. This supports keeping only change 1 here and moving changes 2 and 3 to a separate PR for `master` (item 5). -- 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]
