Commit f861d02
DATE/TIME label and rendering for date-only / time-only fields (#5521)
* fix(core): cluster D — TIME-typed list elements format as HH:mm:ss
Companion to OpenSearch fix/ai/datetime-clusters @ 9009736c2dc.
list(<TIME-typed field>) now returns "HH:mm:ss[.fraction]" without the
1970-01-01 epoch-date prefix.
The analytics-engine path rewrites PPL list() to DataFusion's list_merge,
so the legacy ListAggFunction never fires. Instead, AnalyticsExecutionEngine
now post-processes List-typed cells in the result conversion: when an
element string matches "1970-01-01[ T]HH:mm:ss[.fraction]", only the time
portion is kept. Scalar cells are untouched, preserving the wider
timestamp-stringification regression baseline.
Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
* fix(core): cluster A — span() output column type for date/time UDT
Recognize the new sandbox DateOnlyType / TimeOnlyType UDT markers in:
- OpenSearchTypeFactory.convertAnalyticsEngineRelDataTypeToExprType:
DateOnlyType → ExprCoreType.DATE, TimeOnlyType → ExprCoreType.TIME so the
user-visible response schema labels span() bucket columns as `date` /
`time` instead of `timestamp`.
- AnalyticsExecutionEngine.toExprValue: when the column carries a
DateOnlyType marker, strip the trailing ` HH:MM:SS` from the
Timestamp(ms)-formatted wire value so dates render as `YYYY-MM-DD`.
Symmetric handling for TimeOnlyType strips the `1970-01-01 ` prefix.
Pairs with the sandbox schema-builder change in
opensearch-project/OpenSearch@b69c5ff8888.
Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
* Preserve DATE/TIME return type for ADDDATE/SUBDATE/ADDTIME/SUBTIME on date/time columns
On the analytics-engine route a 'date'/'time' column is a TIMESTAMP-backed
DateOnlyType/TimeOnlyType marker, so operand-conditional return-type inference
mis-read it as TIMESTAMP — ADDDATE(date_col, N) reported (and rendered) TIMESTAMP
instead of DATE. Add isDateExprType/isTimeExprType helpers recognizing those
markers (off the general conversion path, no substrait round-trip risk) and use
them in AddSubDateFunction and PPLReturnTypes.TIME_APPLY_RETURN_TYPE. Fixes the
6 *Null column-operand cases end-to-end.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
* Tighten ADDDATE/SUBDATE return-type helper comments
Comment trims on top of d12407b (Marc Handalian's cherry-pick) — collapse
the multi-line Javadoc on isDateExprType/isTimeExprType to one-line case
names, and drop the inline narration at the two call sites
(PPLReturnTypes.TIME_APPLY_RETURN_TYPE,
AddSubDateFunction#getReturnTypeInference) that restated the helper
contract. Behavior unchanged.
Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
* Fix tests
Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
---------
Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent f12e4c3 commit f861d02
5 files changed
Lines changed: 127 additions & 19 deletions
File tree
- core/src
- main/java/org/opensearch/sql
- calcite/utils
- executor/analytics
- expression/function/udf/datetime
- test/java/org/opensearch/sql/executor/analytics
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
277 | 279 | | |
278 | 280 | | |
279 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
280 | 292 | | |
281 | 293 | | |
282 | 294 | | |
| |||
293 | 305 | | |
294 | 306 | | |
295 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
296 | 315 | | |
297 | 316 | | |
298 | 317 | | |
| |||
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
39 | | - | |
40 | | - | |
| 38 | + | |
41 | 39 | | |
42 | 40 | | |
43 | 41 | | |
| |||
Lines changed: 43 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| |||
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
50 | 62 | | |
51 | 63 | | |
52 | 64 | | |
| |||
206 | 218 | | |
207 | 219 | | |
208 | 220 | | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
| 221 | + | |
224 | 222 | | |
225 | 223 | | |
226 | 224 | | |
| |||
234 | 232 | | |
235 | 233 | | |
236 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
237 | 252 | | |
238 | 253 | | |
239 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
240 | 268 | | |
241 | 269 | | |
242 | 270 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
Lines changed: 63 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
237 | 239 | | |
238 | 240 | | |
239 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
240 | 303 | | |
241 | 304 | | |
242 | 305 | | |
| |||
0 commit comments