Commit e5c29fd
committed
Fix SQL query routing to analytics engine for composite-dataformat indices
The SQL path in RestUnifiedQueryAction.isAnalyticsIndex() was failing to
route queries to the analytics engine because:
1. extractIndexName() used context.getParser() which returns SqlV2QueryParser
(producing UnresolvedPlan), but the SQL branch expected a Calcite SqlNode.
The V2 parser also treats 'score' as a reserved keyword, causing parse
failures on common column names.
2. SqlTableNameExtractor did not handle SqlOrderBy, which Calcite wraps
around SELECT...LIMIT queries.
3. Calcite's default parser uppercases unquoted identifiers, but index
names in OpenSearch are lowercase.
Fix:
- Use SqlParser.create(query).parseQuery() (Calcite parser) for the SQL
branch, which correctly returns SqlNode and handles standard SQL without
reserved-word conflicts.
- Add SqlOrderBy handling in SqlTableNameExtractor to unwrap LIMIT queries.
- Lowercase the extracted table name before cluster state lookup.
Signed-off-by: Finn Carroll <carrofin@amazon.com>1 parent 817f7f3 commit e5c29fd
2 files changed
Lines changed: 33 additions & 3 deletions
File tree
- plugin/src
- main/java/org/opensearch/sql/plugin/rest
- test/java/org/opensearch/sql/plugin/rest
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
20 | 22 | | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
217 | | - | |
| 220 | + | |
218 | 221 | | |
219 | 222 | | |
220 | 223 | | |
221 | 224 | | |
222 | | - | |
223 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
224 | 228 | | |
225 | 229 | | |
226 | 230 | | |
| |||
235 | 239 | | |
236 | 240 | | |
237 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
238 | 245 | | |
239 | 246 | | |
240 | 247 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
68 | 91 | | |
69 | 92 | | |
70 | 93 | | |
| |||
0 commit comments