Commit 35bf78f
committed
fix: instantiate DatetimeUdt normalize/output-cast rules per plan() call
DatetimeUdtNormalizeRule and DatetimeOutputCastRule extend
RelHomogeneousShuttle, which inherits a stateful Deque<RelNode> stack
from RelShuttleImpl. DatetimeExtension.postAnalysisRules() returned
the static INSTANCE of each rule, sharing the same shuttle (and the
same stack) across every UnifiedQueryPlanner.plan() invocation.
If any traversal ever ends with an unbalanced stack, residual entries
persist to the next query. The next query's visitChild() then pops a
stale or empty stack and throws NoSuchElementException at
RelShuttleImpl.visitChild line 67 (the stack.pop() in the finally
block) — surfacing as the cluster-side stack trace reported on
analytics-engine-routed parquet indices for queries that combine
aggregations over datetime UDT columns (e.g.
"stats count() as field_count, distinct_count(field)").
Return fresh instances per plan() instead. Drop the INSTANCE
constants and the Lombok @NoArgsConstructor on both rules; document
the singleton-unsafety on each class JavaDoc.
Add a regression test that runs several plan() calls in sequence
against the same context, covering stats+distinct_count over both
schema-declared and eval-derived datetime columns.
Signed-off-by: Kai Huang <ahkcs@amazon.com>1 parent f1f39ef commit 35bf78f
4 files changed
Lines changed: 32 additions & 12 deletions
File tree
- api/src
- main/java/org/opensearch/sql/api/spec/datetime
- test/java/org/opensearch/sql/api/spec/datetime
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
| |||
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
24 | | - | |
25 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | | - | |
29 | | - | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
Lines changed: 3 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| |||
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | | - | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | 29 | | |
32 | 30 | | |
33 | 31 | | |
| |||
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
175 | 196 | | |
176 | 197 | | |
177 | 198 | | |
| |||
0 commit comments