Fix aggregate FILTER subquery scheduling#7414
Open
HavAnIdea wants to merge 1 commit into
Open
Conversation
Contributor
Fossier: Manual Review Requested
Score BreakdownTotal Score: 50.4/100 | Confidence: 100% | Outcome: REVIEW
|
Author
|
Quick verification update for reviewers:
Happy to adjust the regression shape or move the tests if maintainers prefer a narrower fixture. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #6807.
This fixes a panic when a grouped
HAVING/ORDER BYaggregateFILTERpredicate contains anIN (SELECT ...)subquery. Those subqueries were being scheduled for grouped-output evaluation, but aggregate filters run while rows are accumulated, before grouped output opens theINsubquery's ephemeral cursor.The patch keeps subqueries referenced by aggregate args or aggregate
FILTERpredicates on the pre-aggregation evaluation path. It also lets non-correlatedINsubquery expressions inside aggregate filters continue walking their left-hand side while collecting GROUP BY sorter leaf columns, so the filter reads row values from the pseudo cursor during aggregation instead of a stale base-table cursor.Motivation and context
The issue reproducer panicked with
cursor id 0 is Noneinstead of matching SQLite behavior. The added regression tests cover both the constant reproducer from #6807 and the grouped sorter case where theFILTERpredicate depends on a grouped input column.Validation
rustfmt --check core/translate/subquery.rs core/translate/group_by.rsgit diff --checkmake -C testing/sqltests run-rust ARGS='--filter grouped-having-aggregate-filter-constant-in-subquery'make -C testing/sqltests run-rust ARGS='--filter grouped-having-aggregate-filter-empty-in-subquery'make -C testing/sqltests run-rust ARGS='--filter grouped-having-aggregate-filter-column-in-subquery'cargo +stable run -q -p differential-fuzzer --bin differential_fuzzer -- --seed 735188941686177792 -n 220 -t 3 -c 5 -g sql-gen --keep-filesDescription of AI Usage
I used Codex to help reduce the fuzzer panic, inspect query translation paths, implement the targeted fix, and run the validation commands above. I reviewed the resulting diff and kept the change scoped to subquery scheduling/aggregate filter GROUP BY handling plus regression tests.