Peter Toth created SPARK-61255:
----------------------------------
Summary: Recursive CTE fails with INTERNAL_ERROR when its
recursive step triggers dynamic partition pruning
Key: SPARK-61255
URL: https://issues.apache.org/jira/browse/SPARK-61255
Project: Spark
Issue Type: Bug
Components: SQL
Affects Versions: 5.0.0
Reporter: Peter Toth
A recursive CTE fails with an internal error when its recursive step joins a
partitioned table on the partition key, so that dynamic partition pruning
applies. With default settings on master:
{code:sql}
CREATE TABLE items (id BIGINT, name STRING) USING parquet;
INSERT INTO items VALUES (1, 'aa'), (2, 'bb'), (3, 'cc');
CREATE TABLE purchases (price FLOAT, item_id BIGINT) USING parquet PARTITIONED
BY (item_id);
INSERT INTO purchases VALUES (42.0, 1), (19.5, 3);
WITH RECURSIVE r(id, lvl) AS (
SELECT id, 0 FROM items
UNION ALL
SELECT r.id, r.lvl + 1 FROM r JOIN purchases p ON r.id = p.item_id
WHERE r.lvl < 3)
SELECT id, lvl, count(*) FROM r GROUP BY id, lvl;
{code}
{noformat}
[INTERNAL_ERROR] Found the unresolved operator: 'Filter (isnotnull(item_id#20L)
AND dynamicpruning#34 [item_id#20L]) SQLSTATE: XX000
{noformat}
It fails the same way with AQE on and off, and with a DataSource V2 partitioned
table in place of {{purchases}}. With
{{spark.sql.optimizer.dynamicPartitionPruning.enabled=false}} the query returns
the expected 9 rows.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]