Commit 9ed9b1a
authored
Recover ANY-typed column schema on the analytics route (fixes eval max/min) (#5557)
* Recover concrete schema type for ANY-typed columns on the analytics route
The analytics-engine response schema was built purely from the planned
RelDataType, so a column whose planned type is ANY (e.g. the SCALAR_MAX /
SCALAR_MIN UDFs behind PPL eval max()/min(), which declare ANY because they
accept mixed numeric/string operands) was reported as 'undefined'. The
v2/Calcite path already rescues this in OpenSearchExecutionEngine.buildResultSet
by reading the actual runtime ExprValue type.
Mirror that on the analytics path: when a column's converted type is UNDEFINED
and there is a result row, take the concrete type from the first row's value.
The rows are already converted before the schema is built, so no extra work is
needed. Behavior is unchanged on the v2 path.
This fixes eval max()/min() over homogeneous operands on the analytics route
(e.g. max('apple','sam',dog_name) now reports 'string' instead of 'undefined').
Signed-off-by: Kai Huang <ahkcs@amazon.com>
* Skip the residual eval max/min divergences on the analytics route
With the ANY-rescue fix, five of CalcitePPLEvalMaxMinFunctionIT's eight tests
now pass on the analytics route. Skip the three that still diverge via the
assumeNotAnalytics(...) registry plus matching excludeTestsMatching entries:
- EVAL_MAX_MIN_MIXED_TYPES: mixed numeric+string operands throw 'Cannot infer
return type for GREATEST' (the DataFusion GREATEST/LEAST can't unify
heterogeneous operand types) — testEvalMax/MinNumericAndString.
- EVAL_MAX_MIN_INT_WIDENING: max() over int operands reports bigint on the
route (DataFusion widens integers to Int64) where v2/Calcite reports int —
testEvalMaxNumeric.
Results (-Dtests.analytics.parquet_indices=true against the analytics route):
CalcitePPLEvalMaxMinFunctionIT: 0/8 -> 5/8 pass, 3 excluded, 0 fail
v2/Calcite route unchanged: 8/8 pass.
Signed-off-by: Kai Huang <ahkcs@amazon.com>
---------
Signed-off-by: Kai Huang <ahkcs@amazon.com>1 parent 4c1165a commit 9ed9b1a
5 files changed
Lines changed: 92 additions & 4 deletions
File tree
- core/src
- main/java/org/opensearch/sql/executor/analytics
- test/java/org/opensearch/sql/executor/analytics
- integ-test
- src/test/java/org/opensearch/sql
- calcite/remote
- util
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
126 | | - | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| |||
193 | 194 | | |
194 | 195 | | |
195 | 196 | | |
196 | | - | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
199 | 200 | | |
200 | 201 | | |
201 | 202 | | |
| |||
265 | 266 | | |
266 | 267 | | |
267 | 268 | | |
268 | | - | |
| 269 | + | |
269 | 270 | | |
270 | 271 | | |
271 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
272 | 283 | | |
273 | 284 | | |
274 | 285 | | |
| |||
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
170 | 203 | | |
171 | 204 | | |
172 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1164 | 1164 | | |
1165 | 1165 | | |
1166 | 1166 | | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
1167 | 1179 | | |
1168 | 1180 | | |
1169 | 1181 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| 33 | + | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| |||
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| 56 | + | |
| 57 | + | |
52 | 58 | | |
53 | 59 | | |
54 | 60 | | |
| |||
83 | 89 | | |
84 | 90 | | |
85 | 91 | | |
| 92 | + | |
| 93 | + | |
86 | 94 | | |
87 | 95 | | |
88 | 96 | | |
| |||
Lines changed: 25 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
172 | 196 | | |
173 | 197 | | |
174 | 198 | | |
| |||
0 commit comments