[RFC] Extend Analytics Engine execution to regular indices for analytical SQL/PPL queries
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 30/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Attiva
- Ambito
- backend, databases, distributed-systems
Direzione di ricerca
Inizia leggendo i punti di ingresso del routing e dell’esecuzione indicati nell’RFC: RestUnifiedQueryAction e AnalyticsExecutionEngine, quindi esamina le dipendenze M1–M3 e le issue correlate. Il lavoro non è ancora pronto per un’implementazione mirata finché non saranno decisi il predicato di routing, l’ambito dell’impostazione, i test di parità semantica, il comportamento in caso di errore e l’insieme iniziale di funzionalità.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem Statement
Today SQL/PPL compiles a Calcite relational plan into Query DSL, which causes three coupled problems:
-
Translation complexity. A relational plan is a composable operator tree; DSL is one flat, fixed-shape request. Translation therefore has to collapse a whole subtree into a single document, and that mismatch is absorbed by two large analyzers (~3,000 lines) re-encoding every expression form and mapping quirk. The script engine only helps expressions but can never add an operator DSL lacks.
-
Performance cliff. Whatever cannot be expressed — a missing rule, or a genuine DSL limitation — silently falls back to shipping raw documents to the coordinator (#5483, #5673). Not a graceful slowdown, and invisible to the user. Coverage is combinatorial and hard to test (#5598).
-
PIT exhaustion (#5698). A query that falls off the pushdown path needs more than
index.max_result_windowrows, so the plugin opens a PIT per matching shard; a wildcard pattern exhausts the 300-context cap (#5634). This is a side effect of (2), not an independent defect.
Current State
PPL/SQL → Calcite RelNode → pushdown rules → a single OpenSearchIndexScan carrying DSL (plus optional script), with the residual plan executed on the coordinator. An Analytics Engine path already exists, but it is gated to composite (Parquet-backed) indices, so a query over a regular index never reaches it and always compiles to DSL. Therefore, DSL is the only vehicle for shard-local work; there is no way to execute an arbitrary relational fragment on a data node.
Long-Term Goals
A query's capability should be determined by its plan, not by what Query DSL can express — adding a PPL command should not require inventing a translation for it. Over time, pushdown coverage should stop being a complexity this plugin maintains alone and instead improve as the shared execution layer improves.
Proposal
Instead of routing queries for composite index only, use the OpenSearch Analytics Engine as a second execution path for analytical queries on Lucene index too, coexisting with the current DSL pushdown path rather than replacing it. Route by plan shape, gated by a plugin setting: the fast DSL path keeps serving the queries it already serves well, and only shapes DSL handles badly — partitioned window operators, unbounded scans, deep multi-stage pipelines — go to AE.
- Pros: The plugin inherits Lucene-level optimizations it does not have to write, plus AE's own execution work — multi-stage DAGs in opensearch-project/OpenSearch#21844, Arrow streaming transport in opensearch-project/OpenSearch#21418, vectorized execution — and everything added to either in the future. The coverage problem changes shape: instead of translating N operators into DSL, we execute a plan, so new commands work by default rather than after a bespoke rule.
- Cons: It takes a dependency on AE's maturity: stability and reliability are unproven for this workload. Native execution moves memory off the JVM heap, so overhead, accounting and failure modes differ from the search path. Two execution paths also means two behaviors to keep semantically identical, and any fix on the AE side needs a core release.
Approach
M1 — AE reads a plain Lucene index. AE today only reads composite (Parquet-primary) indices. Add a doc-values scan capability so a plain shard is a value-producing source: implement reader acquisition, declare the capability, and scope it so composite indices are unaffected.
M2 — distributed DAG cut rules for the operators that matter. Extend the planner beyond join and aggregation. For example, add high-value subtree rules: per-group top-k for dedup (exact by rank monotonicity; cf. Spark InsertWindowGroupLimit/SPARK-37099, Trino TopNRankingNode.partial, ClickHouse LIMIT n BY), and agg-then-annotate for eventstats (Window(count OVER (PARTITION BY k)) ≡ Join(rows, Aggregate(count BY k)), moving only the small grouped result — top-k pushdown does not apply here, since eventstats retains every row).
M3 — routing. Enable AE as a selectable path in the plugin: relax the composite-index gate in RestUnifiedQueryAction, extend AnalyticsExecutionEngine wiring to admit plain indices, add the plan-shape rules that choose AE vs DSL, and put it behind a setting, default off.
Dependencies: M1 → M3. M2 is what makes routing worthwhile, but a narrow initial rule set can ship first.
Alternatives
(A) A new MPP layer inside the SQL plugin.
- Prior art: #5380 (closed) and #4812 (open)
- Pros: full control, no core dependency or core release timeline.
- Cons: largest effort, duplicates work core has already merged, and the hard part is not the engine but re-earning Lucene's optimizations plus the security/FGAC, thread-pool and memory-isolation story core already owns.
(B) A custom DSL aggregation as the shard-local vehicle.
- Ships the shard fragment as base64 RelJson inside a plugin-registered aggregation, executes a Janino-compiled Calcite Bindable over doc_values with
_sourcefallback, and reduces in two tiers at the coordinator. - Pros: works on an ordinary index today with no core change.
- Cons: an aggregation is an unnatural carrier for row-producing operators; custom aggregation may have its limitation; no shuffle.
(C) Keep widening DSL pushdown rule by rule
- Mitigate #5698 with one of its own narrower options.
- Pros: incremental, low risk per step.
- Cons: the coverage problem and the cliff both remain; the PIT fix treats the symptom.
Implementation Discussion
- What the routing predicate keys on — plan shape, estimated cardinality, presence of a non-pushable operator, or an explicit user hint.
- Setting scope and lifecycle: cluster, index, or per-request; what evidence would promote the default from off to on.
- How semantic parity between the paths is guaranteed and tested — same query, same result, on both paths.
- What happens when a routed query fails or is rejected: transparent fallback to the DSL path, or a surfaced error.
- Whether users can tell which path ran, e.g. in
explainoutput. - The minimum capability set that makes routing worthwhile for a first release, and which PPL commands it covers.
- Lingua principale
- Java
- Stelle
- 175
- Fork
- 233
- Merge medio
- 2g 19h
- PR unite (30g)
- 37
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di opensearch-project/sql
-
[Enhancement] Make the flat_object read depth cap configurable instead of a constantForse già presa @RyanL1997 l’ha presa 16 giorni fa. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
opensearch-project/sql#5842 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] PromQL queries fail with InvalidTypeIdException when metric has a label named "type"Forse già presa @nagendramohan l’ha presa 79 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
opensearch-project/sql#5684 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[DOC] Calcite settings documentation missing examplesForse già presa @AzazelSensei l’ha presa 36 giorni fa. Apertadocumentation PPL
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
opensearch-project/sql#4806 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Feature][PPL] Admit every query through one scheduler before it reaches the SQL worker poolsApertaenhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
opensearch-project/sql#5912 ·
I maintainer di solito rispondono entro 1 giorno
-
untriaged
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
opensearch-project/sql#5911 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di opensearch-project/sql
Issue simili
-
Component: Frontend Component: Web Component Type: Maintenance
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
it-at-m/refarch-templates#1944 ·
I maintainer di solito rispondono entro 2 giorni
-
priority: p2 type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
googleapis/java-genai#1372 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
-
GeoSeries scale and skew tests fail with pytest 9.2.0Forse già presa @jiayuasu l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
priority: medium Review effort [1-5]: 3 status: needs-triage type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
carlos-emr/carlos#5431 ·
I maintainer di solito rispondono entro 1 giorno