Skip to content

fix: preserve hash join dynamic filters across recursive CTE iterations - #26669

Open
Kristofferjoha wants to merge 4 commits into
apache:mainfrom
Kristofferjoha:fix/hashjoin-recursive-26641
Open

Kristofferjoha wants to merge 4 commits into
apache:mainfrom
Kristofferjoha:fix/hashjoin-recursive-26641

Conversation

@Kristofferjoha

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #26641.

Rationale for this change

Hash joins inside recursive CTEs read every probe-side row on each iteration because their dynamic filters stop updating the scan. This prevents pruning during recursive queries such as graph walks.

What changes are included in this PR?

  • Reset the existing shared dynamic filter instead of dropping it.
  • Clear the build accumulator for each execution.
  • Update prepared-build test callers to propagate reset errors.
  • Add a recursive join regression test in cte.slt.

Depends on #26056 for DynamicFilterPhysicalExpr::reset(). It hasnt been merged yet, however it has been approved, so i tought i was safe to use its implementation.

What is the testing strategy for this PR?

The new cte.slt case checks that the recursive query returns 1–5 and that the probe scan outputs 4 rows and prunes 396 rows across four iterations.

Are there any user-facing changes?

The public HashJoinExecBuilder::reset_state method now returns Result<Self>; callers must handle the result.

@github-actions github-actions Bot added physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt) physical-plan Changes to the physical-plan crate labels Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-expr Changes to the physical-expr crates physical-plan Changes to the physical-plan crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hash join dynamic filters don't prune inside recursive CTEs

2 participants