Commit 727c48d
committed
Narrow native lowering in visitSearch to numeric / boolean RHS values
The visitor's native RexCall lowering routes structured search predicates
through CalciteScriptEngine on the v2/Calcite-with-Lucene path. The script
engine compiles a typed comparison directly, which is fine for numeric and
boolean RHS values — but it can't reproduce Lucene's analyzer-aware string
semantics that PPL `search` has always relied on:
- Text fields are tokenised; native `=` would compare against analyzed
terms and never match the raw literal (doctest `severityText="INFO"`).
- `!=` on text fields filters only documents that match the analyzed
token, not ones containing it — doctest
`instrumentationScope.name!="@opentelemetry/instrumentation-http"`
expects Lucene's "matches any token" semantics.
- `IN` lists need the same analyzer semantics for each value.
- `@timestamp >= "..."` literals reach the script engine as
java.lang.String vs long (date field) — Janino can't compile that
comparison and the query fails at shard time.
Restrict native lowering to INTEGER / LONG / SHORT / FLOAT / DOUBLE /
DECIMAL / BOOLEAN values via `isNativeLowerableValue`. Everything else
(STRING, DATE/TIME/TIMESTAMP, IP, NULL) falls back to the original
`query_string` path so Lucene handles it natively — on the analytics-engine
route via the composite-parquet Lucene secondary, on the v2/Calcite path
via the Lucene primary.
The same gate applies to `SearchIn` — string IN lists fall back too.
Drops the plan-time date-math resolver introduced in the prior iteration —
it emitted TIMESTAMP literals that tripped the same script-engine compile
failure on Lucene-backed shards, and the broader value-type gate subsumes
its narrower string-shape detection.
Update `explain_search_numeric_comparison.json` (both pushdown and
no-pushdown variants) to reflect the new native shape for the
`severityNumber > 15` example — pure numeric comparisons still lower to a
native RexCall, which is the intended PR behavior.
Update `CalcitePPLSearchTest.testSearchWithFilter` for the same reason —
`DEPTNO=20` now lowers natively since the RHS is an integer literal.
Signed-off-by: Kai Huang <ahkcs@amazon.com>1 parent 53c33ab commit 727c48d
5 files changed
Lines changed: 53 additions & 65 deletions
File tree
- core/src/main/java/org/opensearch/sql
- calcite
- executor/analytics
- integ-test/src/test/resources/expectedOutput
- calcite_no_pushdown
- calcite
- ppl/src/test/java/org/opensearch/sql/ppl/calcite
Lines changed: 32 additions & 44 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
| |||
384 | 385 | | |
385 | 386 | | |
386 | 387 | | |
387 | | - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
388 | 401 | | |
389 | 402 | | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
| 403 | + | |
| 404 | + | |
395 | 405 | | |
396 | 406 | | |
397 | | - | |
398 | | - | |
399 | | - | |
| 407 | + | |
400 | 408 | | |
401 | 409 | | |
402 | 410 | | |
| |||
405 | 413 | | |
406 | 414 | | |
407 | 415 | | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
408 | 420 | | |
409 | 421 | | |
410 | 422 | | |
| |||
417 | 429 | | |
418 | 430 | | |
419 | 431 | | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
426 | 437 | | |
427 | | - | |
| 438 | + | |
428 | 439 | | |
429 | 440 | | |
430 | 441 | | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
456 | 447 | | |
457 | 448 | | |
458 | 449 | | |
| |||
739 | 730 | | |
740 | 731 | | |
741 | 732 | | |
742 | | - | |
743 | | - | |
744 | | - | |
745 | 733 | | |
746 | 734 | | |
747 | 735 | | |
| |||
Lines changed: 11 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
180 | 180 | | |
181 | | - | |
182 | | - | |
| 181 | + | |
| 182 | + | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | | - | |
187 | | - | |
| 186 | + | |
| 187 | + | |
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | | - | |
49 | | - | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | | - | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
0 commit comments