Repository navigation
Commit 0e292dc
fix: allow free RANGE window frames over Duration and Interval ORDER BY types (#24916)
## Which issue does this PR close?
- Part of #24915. This PR covers `Duration` and `Interval` ORDER BY
types; `Struct` and `Map` stay rejected because their RANGE peer
comparison (`partial_cmp_struct` / `partial_cmp_map`) does not match the
sort order, and are left for a follow-up (fix the comparators, then
extend `supports_free_range_frame`).
## Rationale for this change
`OVER (ORDER BY x)` defaults to a free range frame with no offsets,
which only needs the ORDER BY values to be comparable.
`coerce_window_frame` nevertheless required an arithmetic target type
for the ORDER BY column first, so `row_number() OVER (ORDER BY x)` on a
`Duration` or `Interval` column failed with an internal error asking the
user to file a bug.
## What changes are included in this PR?
Only require the arithmetic target type for frames with a finite offset.
A free range frame whose ORDER BY expressions are all either arithmetic
types or `Duration` / `Interval` (also nested in `Dictionary` /
`RunEndEncoded`) is returned unchanged; every ORDER BY expression is
checked, since all of them take part in the peer comparison. Frames over
supported types are coerced exactly as before, so plans do not change.
The failure for unsupported types is now a planning error, `RANGE window
frames are not supported for ORDER BY type ...`, which fits both free
and offset frames.
## Are these changes tested?
Yes. `window.slt` gains `row_number` / `rank` / `count` over `Duration`
and `Interval` ORDER BY keys (default and explicit free range frame,
single and two-column ORDER BY), and checks that `Struct` and `Map`
keys, a `Map` after a `Duration`, and a finite offset over a `Struct`
are still rejected at planning time. The existing `Struct` case that
pinned the internal-error text now expects the planning error.
## Are there any user-facing changes?
Window functions ordered by `Duration` or `Interval` columns work with
the default frame. Unsupported ORDER BY types in a RANGE frame report a
planning error instead of an internal error.
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Co-authored-by: Kumar Ujjawal <ujjawalpathak6@gmail.com>1 parent 3b16a3d commit 0e292dc
2 files changed
Lines changed: 165 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1091 | 1091 | | |
1092 | 1092 | | |
1093 | 1093 | | |
1094 | | - | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
1095 | 1099 | | |
1096 | 1100 | | |
1097 | 1101 | | |
| |||
1106 | 1110 | | |
1107 | 1111 | | |
1108 | 1112 | | |
1109 | | - | |
| 1113 | + | |
1110 | 1114 | | |
1111 | | - | |
| 1115 | + | |
1112 | 1116 | | |
1113 | 1117 | | |
1114 | 1118 | | |
1115 | 1119 | | |
1116 | 1120 | | |
1117 | | - | |
| 1121 | + | |
1118 | 1122 | | |
1119 | 1123 | | |
1120 | 1124 | | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
1121 | 1187 | | |
1122 | 1188 | | |
1123 | 1189 | | |
| |||
1133 | 1199 | | |
1134 | 1200 | | |
1135 | 1201 | | |
1136 | | - | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
1137 | 1217 | | |
1138 | 1218 | | |
1139 | 1219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7018 | 7018 | | |
7019 | 7019 | | |
7020 | 7020 | | |
7021 | | - | |
7022 | | - | |
| 7021 | + | |
| 7022 | + | |
7023 | 7023 | | |
7024 | 7024 | | |
7025 | 7025 | | |
| |||
7094 | 7094 | | |
7095 | 7095 | | |
7096 | 7096 | | |
| 7097 | + | |
| 7098 | + | |
| 7099 | + | |
| 7100 | + | |
| 7101 | + | |
| 7102 | + | |
| 7103 | + | |
| 7104 | + | |
| 7105 | + | |
| 7106 | + | |
| 7107 | + | |
| 7108 | + | |
| 7109 | + | |
| 7110 | + | |
| 7111 | + | |
| 7112 | + | |
| 7113 | + | |
| 7114 | + | |
| 7115 | + | |
| 7116 | + | |
| 7117 | + | |
| 7118 | + | |
| 7119 | + | |
| 7120 | + | |
| 7121 | + | |
| 7122 | + | |
| 7123 | + | |
| 7124 | + | |
| 7125 | + | |
| 7126 | + | |
| 7127 | + | |
| 7128 | + | |
| 7129 | + | |
| 7130 | + | |
| 7131 | + | |
| 7132 | + | |
| 7133 | + | |
| 7134 | + | |
| 7135 | + | |
| 7136 | + | |
| 7137 | + | |
| 7138 | + | |
| 7139 | + | |
| 7140 | + | |
| 7141 | + | |
| 7142 | + | |
| 7143 | + | |
| 7144 | + | |
| 7145 | + | |
| 7146 | + | |
| 7147 | + | |
| 7148 | + | |
| 7149 | + | |
| 7150 | + | |
| 7151 | + | |
| 7152 | + | |
| 7153 | + | |
| 7154 | + | |
| 7155 | + | |
| 7156 | + | |
| 7157 | + | |
| 7158 | + | |
| 7159 | + | |
| 7160 | + | |
| 7161 | + | |
| 7162 | + | |
| 7163 | + | |
| 7164 | + | |
| 7165 | + | |
| 7166 | + | |
| 7167 | + | |
| 7168 | + | |
| 7169 | + | |
| 7170 | + | |
| 7171 | + | |
| 7172 | + | |
| 7173 | + | |
| 7174 | + | |
7097 | 7175 | | |
7098 | 7176 | | |
7099 | 7177 | | |
| |||
0 commit comments