Repository navigation
fix(plan): preserve join pushdown for independent CTE consumers - #29793
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of 21151a9 against d2a0055: APPROVE. All six changed files reviewed; no blocking findings.
Design/ownership: this is a focused planner regression fix. Barrier admission now consumes the same existing CTE parameterization predicate as the lowering path. This removes the inconsistent second decision without adding state or another execution path. The Q15 producer remains shared; independent consumers regain the supplier join predicate instead of filtering a Cartesian join. Predicate-only decorrelation remains owned by the existing decorrelator.
Adversarial closure: traced independent/nested and predicate-only CTEs against projected outer references and recursive SourceStep dependencies, including reversed WHERE conjuncts, conditional/throwing expressions, and unsafe-domain rejection. bindWhere binds the complete predicate set before selecting the domain, so protection does not depend on conjunct order. Parameterization admission, atomic rejection, and guarded-expression checks remain intact. Followed FilterIsBarrier through predicate pushdown to the actual join condition.
Validation: reviewer ran the Q15 reuse/join test, eight barrier-admission cases, existing executable correlated-CTE cases (including reversed predicates), and unsafe-domain rejection cases on this exact head: PASS, 3.132s, Go 1.27.1/macOS arm64 with repository-built native libraries. Reused the explicitly revisioned author evidence for full planner tests, Q1-Q22 inventory, real SQL/EXPLAIN ANALYZE, same-instance BVT rerun/teardown and 296/296 CTE statements. Latest ALL CI run37939091647 is completed/success on this exact SHA; superseded cancelled checks were not treated as current failures.
Incremental quality: implementation +28/-15 across two files; tests +165 across four files; no documentation delta. Existing Q15 fixture is extended rather than duplicated. The SQL regression independently checks tied maxima, NULL/empty input and both join forms; the existing negative correlated suite supplies the adjacent unhappy-path controls.
Performance: extra graph inspection/allocation is confined to planning CTE subqueries; ordinary non-CTE and already executing TP paths gain no per-row work. Avoiding the demonstrated Q15 Cartesian join is a concrete benefit. The reduced local 14.237s -> 0.033s result is not a production/TKE or general TP throughput claim; the original full TKE workload remains external validation.
Comment audit: there were no earlier substantive inline/review findings on this PR. Issue #29783's causal boundary is addressed; original-topology performance validation is still explicitly distinguished from the local regression proof.
Merge Queue Status
This pull request spent 13 seconds in the queue, including 1 second running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #29783
What this PR does / why we need it:
Root cause
bindWheretreated any subquery containing a CTE as requiring an outer demand domain. For independent CTE consumers such as TPC-H Q15, this installed aFilterIsBarrierabove the supplier/revenue join and prevented the supplier equality from becoming a join condition. The shared CTE producer was still reused, but the join produced a Cartesian product before filtering.Changes
parameterizeLocalCTEs.SourceStepdependencies.Local reproduction
Using the repository's Q15 SQL on macOS arm64, with 10,000 suppliers and 20,000 lineitems:
The query results were identical. These measurements were collected before the latest-main merge, against
d7621ea017and this fix. They include local client/connection overhead and are reduced-data local observations, not a reproduction of the original TKE Family 10G/100G benchmark.The final regression assertions also fail against the unfixed production sources: Q15 loses its supplier join predicate, and independent CTE scenarios incorrectly acquire a barrier.
Validation
Re-run at
21151a902b, after mergingmo/main(d2a0055ebe), using Go 1.27.1 and repository CGo tooling:pkg/sql/plantests: 84.1% package statement coverage; 16/16 changed statements covered (100%).TestTPCHNumericEligibilityInventoryinpkg/sql/plan/substrait(Q1–Q22).gofmt, incrementalgo vet, and CI-version golangci-lint 2.14.0.The
.resultwas generated with mo-tester on the unfixed service, manually checked against the expected rows, and then verified in comparison mode on the fixed service.Remaining external validation: the original TKE Family concurrent topology and full TPCH 10G/100G workloads have not been re-run locally.