Commit fc9f146
authored
fix: validate trailing ORDER BY keys in free RANGE frames (#25518)
## Which issue does this PR close?
- Closes #25557.
## Rationale for this change
A free `RANGE` window frame determines peers using every `ORDER BY`
expression. However, when the first expression had an offset target
type, the
analyzer did not validate the remaining expressions.
Consequently, an unsupported trailing `Map` expression could reach
execution
and rows with different map values could incorrectly be treated as
peers.
## What changes are included in this PR?
Validate all trailing `ORDER BY` expressions when the first expression
establishes the RANGE target type.
This preserves the existing behavior that accepts a `List` as the first
`ORDER BY` expression, while rejecting unsupported trailing expressions.
A SQL logic regression test for `ORDER BY int_col, map_col` is included.
## What is the testing strategy for this PR?
- Added a regression test in `window.slt`.
- Verified that the old code returns incorrect peer counts while the
fixed
code reports a planning error.
- Verified existing first-`List` and supported multi-key cases.
- Ran `cargo fmt --all -- --check`.
- Ran `cargo clippy -p datafusion-optimizer --all-targets --all-features
-- -D warnings`.
## Are there any user-facing changes?
Yes. Free `RANGE` frames with an unsupported trailing `ORDER BY` type
are now
rejected during planning instead of potentially producing incorrect
results.
There are no public API changes.1 parent 19d422f commit fc9f146
2 files changed
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1200 | 1200 | | |
1201 | 1201 | | |
1202 | 1202 | | |
1203 | | - | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
1204 | 1211 | | |
1205 | 1212 | | |
1206 | 1213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7129 | 7129 | | |
7130 | 7130 | | |
7131 | 7131 | | |
| 7132 | + | |
| 7133 | + | |
| 7134 | + | |
| 7135 | + | |
| 7136 | + | |
| 7137 | + | |
7132 | 7138 | | |
7133 | 7139 | | |
7134 | 7140 | | |
| |||
0 commit comments