Commit 40cb73b
authored
Add explain support for analytics engine path (#5275)
* [Mustang] Add explain support and integration tests for analytics path (#5247)
Add explain support for the analytics engine path:
- AnalyticsExecutionEngine.explain(RelNode, ExplainMode, ...): returns
logical plan via RelOptUtil.toString() with mode-aware SqlExplainLevel
(SIMPLE/STANDARD/COST). Physical and extended plans are null since the
analytics engine is not yet available.
- RestUnifiedQueryAction.explain(): new entry point for explain requests,
delegates to AnalyticsExecutionEngine.explain() with ExplainMode.STANDARD.
Response formatted via JsonResponseFormatter with normalizeLf().
- TransportPPLQueryAction: routes explain requests for analytics indices
to unifiedQueryHandler.explain() instead of unifiedQueryHandler.execute().
Integration tests (AnalyticsPPLIT):
- testExplainResponseStructure: verifies JSON shape (calcite.logical,
calcite.physical=null, calcite.extended=null)
- testExplainProjectAndScan: LogicalProject + LogicalTableScan + table name
- testExplainFilterPlan: LogicalFilter with condition value
- testExplainAggregationPlan: LogicalAggregate with COUNT()
- testExplainSortPlan: LogicalSort
Unit tests (AnalyticsExecutionEngineTest):
- explainRelNode_returnsLogicalPlan
- explainRelNode_errorPropagation
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>
* Add AnalyticsExplainIT with expected output files
Add dedicated explain integration test class following the CalciteExplainIT
pattern: each test compares actual explain JSON against expected output
files in resources/expectedOutput/analytics/. Tests cover simple scan,
project, filter+project, aggregation, sort (with collation propagation
to LogicalSystemLimit), and eval.
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>
* Fix explain unit test to verify actual logical plan content
Use a real Calcite LogicalValues node instead of a mock so
RelOptUtil.toString() produces a deterministic plan. Assert the exact
expected logical plan string instead of just checking non-null.
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>
* Remove explain unit tests in favor of AnalyticsExplainIT
Explain is thoroughly covered by AnalyticsExplainIT with expected output
file comparison (6 tests). Remove redundant explain unit tests and
unused captureExplainListener helper. Execute unit tests unchanged.
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>
* Remove explain tests from AnalyticsPPLIT in favor of AnalyticsExplainIT
Explain is covered by AnalyticsExplainIT with expected output file
comparison (6 tests). Remove redundant explain tests and
extractLogicalPlan helper from AnalyticsPPLIT.
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>
* Switch explain tests to YAML format with format-aware listener
- Add YAML format support to createExplainListener() by checking
pplRequest.getFormat(), matching TransportPPLQueryAction pattern
- Switch AnalyticsExplainIT from explainQueryToString (JSON) to
explainQueryYaml (YAML) with assertYamlEqualsIgnoreId
- Replace JSON expected files with YAML expected files
- YAML serializer omits null fields (physical/extended), so expected
files only contain the logical plan
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>
* Use request explain mode instead of hardcoded STANDARD
Pass pplRequest.mode() to analyticsEngine.explain() so the user's
?mode= parameter (simple, standard, cost, extended) is respected.
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>
* Fix normalizeLf inconsistency with existing PPL explain path
Only apply normalizeLf() for YAML format, return response directly for
JSON format. Matches TransportPPLQueryAction.createExplainResponseListener()
which uses normalizeLf for YAML but returns response as-is for JSON.
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>
* Add toExplainLevel() to ExplainMode enum
Encapsulate the ExplainMode to SqlExplainLevel mapping in the enum
itself instead of repeating ternary logic in each execution engine.
AnalyticsExecutionEngine now uses mode.toExplainLevel() directly.
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>
* Remove logging from AnalyticsExplainIT
Remove LOG.info calls and Logger field. The YAML comparison assertion
already provides clear output on failure.
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>
* Remove explain coverage comments
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>
* Reuse TransportPPLQueryAction.createExplainResponseListener for explain formatting
Remove duplicate createExplainListener from RestUnifiedQueryAction.
explain() now returns ExplainResponse via ResponseListener, and
TransportPPLQueryAction wraps it with its existing
createExplainResponseListener for format-aware (JSON/YAML) formatting.
This avoids duplicating the format selection logic.
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>
---------
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>1 parent 23227fd commit 40cb73b
11 files changed
Lines changed: 200 additions & 4 deletions
File tree
- core/src/main/java/org/opensearch/sql
- ast/statement
- executor/analytics
- integ-test/src/test
- java/org/opensearch/sql/ppl
- resources/expectedOutput/analytics
- plugin/src/main/java/org/opensearch/sql/plugin
- rest
- transport
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
29 | 39 | | |
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
80 | 96 | | |
81 | 97 | | |
82 | 98 | | |
| |||
Lines changed: 77 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 55 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
88 | 108 | | |
89 | 109 | | |
90 | 110 | | |
| |||
104 | 124 | | |
105 | 125 | | |
106 | 126 | | |
107 | | - | |
108 | | - | |
109 | 127 | | |
110 | 128 | | |
111 | 129 | | |
| |||
123 | 141 | | |
124 | 142 | | |
125 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
126 | 179 | | |
127 | 180 | | |
128 | 181 | | |
| |||
0 commit comments