dsl-query-executor: route _search through DslCalciteGrammar with codec fallback - #22597
dsl-query-executor: route _search through DslCalciteGrammar with codec fallback#22597aggarwalmayank wants to merge 2 commits into
Conversation
PR Reviewer Guide 🔍(Review updated until commit 9b52c28)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 9b52c28
Previous suggestionsSuggestions up to commit 556c612
|
Introduce DslCalciteGrammar as a request-level whitelist that classifies each _search DSL request. Supported requests dispatch to DslExecuteAction; grammar rejections and ConversionException at execution time fall back to the codec path unchanged. Wire a dsl.query_executor.calcite.enabled cluster setting (default true) as an operational escape hatch to force codec-only routing without redeploying. Additional cleanup: registry factories return process-wide singletons so the grammar and per-request converter share one populated map instead of each allocating their own. Signed-off-by: Mayank Aggarwal <aggmayan@amazon.com>
Signed-off-by: Mayank Aggarwal <aggmayan@amazon.com>
556c612 to
9b52c28
Compare
|
Persistent review updated to latest commit 9b52c28 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22597 +/- ##
============================================
- Coverage 71.43% 71.42% -0.02%
+ Complexity 76760 76745 -15
============================================
Files 6142 6142
Lines 357766 357794 +28
Branches 52148 52162 +14
============================================
- Hits 255581 255556 -25
- Misses 81861 81884 +23
- Partials 20324 20354 +30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Introduces a request-level routing gate between the DSL request and the Calcite execution path in the
dsl-query-executorsandbox plugin.Today the plugin's
SearchActionFilterunconditionally intercepts every_searchrequest and dispatches it toDslExecuteAction. This changeadds two layers of gating so requests the Calcite path can't handle (or shouldn't handle yet) fall back to the codec path transparently.
Design
Layer 1 — master switch (
dsl.query_executor.calcite.enabled, dynamic, defaulttrue): cluster-scoped setting; whenfalse, every requestpasses through to the codec path unchanged. Serves as an operational escape hatch — a persistent
PUT _cluster/settingsupdate flips routingwithout redeploy.
Layer 2 — request-shape whitelist (
DslCalciteGrammar): walks theSearchSourceBuilderand classifies it. The gate is registry-lookup +per-parameter checks:
queryRegistry.hasTranslator(class)/aggRegistry.hasTranslator(class). Any query or aggregation whose class isn'tregistered rejects immediately with a short reason code (
query:match,agg:cardinality,pipeline_agg:cumulative_sum, etc.).early instead of failing at conversion time. E.g.
range.boost,range.name,range.no_bounds;terms.terms_lookup,terms.boost,terms.no_values;exists.boost;prefix.boost,prefix.rewrite;wildcard.boost,wildcard.rewrite.boolandconstant_scoreare transparent to the registry; the walker recurses into their children.response translator's exact request-shape support is reviewed.
Fallback —
ConversionExceptionat execution time: schema-side checks the grammar can't run (field existence, binary-field guards,date_nanosprecision, etc.) may still fail duringSearchSourceConverterconversion.SearchActionFilterwraps theDslExecuteActionlistener; on any
ConversionException(including wrapped causes, guarded by a seen-set traversal), the request retries viachain.proceed(...)to the codec path. Non-conversion errors (engine timeouts, runtime failures) surface to the caller so they can be diagnosed.
Behavior matrix
ConversionExceptionAdditional cleanup
Registry factories (
QueryRegistryFactory,AggregationRegistryFactory) now return process-wide singletons. The grammar (long-lived) and theper-request
SearchSourceConvertershare a single populated map instead of each allocating their own translator instances.Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.