You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Query with recursive CTE hangs while trying to collect stream originated from WorkTableExec -- this might occur when recursive part contains HashJoin/CrossJoin/NestedLoopJoin, and WorkTableExec should be collected in memory as a join build side.
WITH RECURSIVE "recursive_cte" AS (
SELECT 1 as "val"
UNION ALL (
WITH "sub_cte" AS (
SELECT 2 as "val"
)
SELECT
2 as "val"
FROM "recursive_cte"
CROSS JOIN "sub_cte"
WHERE "recursive_cte"."val" < 2
)
)
SELECT * FROM "recursive_cte";
Produces following plan, and is unable to complete, constantly executing CrossJoinExec
In the same time, identical query with swapped inputs works as expected
WITH RECURSIVE "recursive_cte" AS (
SELECT 1 as "val"
UNION ALL (
WITH "sub_cte" AS (
SELECT 2 as "val"
)
SELECT
2 as "val"
FROM "sub_cte"
CROSS JOIN "recursive_cte"
WHERE "recursive_cte"."val" < 2
)
)
SELECT * FROM "recursive_cte";
Expected behavior
Ideally, recursive CTE should be able to handle collect() stream, created by WorkTableExec.
Another option might be tracking calls to CTE temp table, and throw runtime error in case their number increases some preconfigured threshold value.
Third option is to forbid recursive CTE temp tables to be used as build-side join inputs (not preferrable as it looks like too much unnecessary optimizer(s) modifications, and not reliable -- same issue might occur in case of aggregations/sorts/maybe some other "blocking" operators).
Additional context
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
Query with recursive CTE hangs while trying to collect stream originated from
WorkTableExec
-- this might occur when recursive part contains HashJoin/CrossJoin/NestedLoopJoin, andWorkTableExec
should be collected in memory as a join build side.To Reproduce
Reproducer based on this test query:
Produces following plan, and is unable to complete, constantly executing
CrossJoinExec
In the same time, identical query with swapped inputs works as expected
Expected behavior
Ideally, recursive CTE should be able to handle
collect()
stream, created byWorkTableExec
.Another option might be tracking calls to CTE temp table, and throw runtime error in case their number increases some preconfigured threshold value.
Third option is to forbid recursive CTE temp tables to be used as build-side join inputs (not preferrable as it looks like too much unnecessary optimizer(s) modifications, and not reliable -- same issue might occur in case of aggregations/sorts/maybe some other "blocking" operators).
Additional context
No response
The text was updated successfully, but these errors were encountered: