Repository navigation
fix(query): block runtime filters across row-sensitive probe paths - #20805
dantengsky wants to merge 4 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 154ba57d61
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
⏱ CI timing · Devrun 39551875187 · 25.9 min (main p50 30.4 min, −4.5 min)
Minutes unless stated; durations exclude queue time unless stated; "max" = longest job in the group. Baseline = median of the last 10 successful runs (Dev: |
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Docker Image for PR
|
⏱ CI timing · Cloud (PR image)run 39552344373 · to image 23.7 min (recent p50 32.4 min, −8.6 min)Minutes unless stated; durations exclude queue time unless stated; "max" = longest job in the group. Baseline = median of the last 10 successful runs (Dev: |

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Motivation
Do not apply a join runtime filter below LIMIT, a window, or a scalar-subquery check. Removing rows there can change the answer or hide a required error.
Two small reproductions
Measured on a one-node OSS server: old base
5c09ab04fdc5, fixed code5cee5dafcbb5. Each result below was observed three times. Run each example in a fresh session/schema; runtime filters are enabled by default.1. LIMIT: expected no rows, old version returns
1The inner query must select
0first. It cannot matchkeep_t, so the result must be empty.1The old RF removes the block containing
0before LIMIT, allowing1to become the first row. The fix prevents that pushdown.No SET is required here. Both join-reorder settings were tested. Keep the two separate INSERTs: they create separate blocks, allowing the old RF to prune one. With both values in one block, this tiny case did not show the wrong result.
2. Scalar subquery: expected an error, old version returns
2 30For this plan, key
1has two scalar values. RF off reports:2 30— no errorThe old parent RF removes key
1before the scalar check, hiding the error. Although that intermediate join is labelled Inner, it still enforces scalar cardinality. The fix treats itssingle_to_innermarker as a barrier.Why the SET: this small example needs
disable_join_reorder = 1to keepqon the parent's probe side. With the default reordering, the measured plan swaps the sides; the RF targetskeep_ainstead, and even the old version reports the error. This SET exposes the bad path; it is not a requirement for the defect in general. The separate INSERTs intoaagain allow block pruning.enable_join_runtime_filter = 1is already the default, so neither example needs that SET. Setting it to0is only the control shown in the tables, not a reproduction requirement.Test coverage
Tests
Both SQL files fail at the intended assertions on the old version and pass over HTTP/MySQL on the fix. The complete RF module (7 tests), query all-targets clippy and formatting checks pass.
Type of change
AI assistance
This change is