Metin Hatipogullari created SPARK-61740:
-------------------------------------------

             Summary: DPP predicate pushed into a non-partitioned UNION branch 
fails with "IN dynamicpruning#N has not finished" without whole-stage codegen
                 Key: SPARK-61740
                 URL: https://issues.apache.org/jira/browse/SPARK-61740
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 3.5.9, 4.0.5, 4.1.4, 4.2.1, 5.0.0
            Reporter: Metin Hatipogullari


{code:sql}
CREATE TABLE p (x INT, k INT) USING parquet PARTITIONED BY (k);
INSERT INTO p VALUES (1, 1), (2, 2), (3, 3), (4, NULL);
CREATE TABLE n (k INT, v INT) USING parquet;
INSERT INTO n VALUES (1, 10), (2, 20), (5, 50);
CREATE TABLE d (k INT) USING parquet;
INSERT INTO d VALUES (1), (2), (7);
SET spark.sql.codegen.wholeStage=false;
SELECT u.k FROM (SELECT k FROM p UNION ALL SELECT k FROM n) u JOIN d ON u.k = 
d.k WHERE d.k IN (1, 2);
-- IllegalArgumentException: requirement failed: input[0, int, true] IN 
dynamicpruning#64 has not finished
{code}

Since SPARK-39217 the DPP filter is pushed into every UNION branch. On the 
non-partitioned branch it stays in a FilterExec. InSubqueryExec does not 
broadcast DPP results (driver-only), so the interpreted filter evaluates it in 
a task with no result. With codegen it is evaluated on the driver and works.

On 3.5.9–4.2.1 the same failure happens with default settings when the 
non-partitioned branch's key is a higher-order function (e.g. aggregate(arr, 0, 
(a, e) -> a + e)); that variant passes on master. The codegen-off repro still 
fails on master (f090eaca12).

Dropping DPP predicates from branches whose scan is not partitioned on the key 
(e.g. in CleanupDynamicPruningFilters) fixes it; I have a patch with a test.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to