Skip to content

Add StateStore-backed partial results for Calcite PPL - #6

Draft
penghuo wants to merge 1 commit into
mainfrom
feat/ppl-partial-results-state-store
Draft

penghuo wants to merge 1 commit into
mainfrom
feat/ppl-partial-results-state-store

Conversation

@penghuo

@penghuo penghuo commented Sep 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Introduces a unified StateStore with APPEND and REPLACE publication semantics.
  • Adds a cached Calcite state query whose OpenSearch leaf is replaced by StateStoreScan.
  • Compiles the already optimized Enumerable plan once on the first poll and reuses the Bindable on later polls.
  • Publishes finalized root rows for non-blocking and composite queries.
  • Publishes OpenSearch partial-reduce snapshots for fully pushed aggregations, then runs the retained Calcite coordinator suffix over each snapshot.
  • Keeps the original synchronous/final execution path unchanged when the opt-in listener is absent.

This branch is based directly on main and is independent of the earlier API/lifecycle/progress PR. It intentionally focuses only on the partial-result execution abstraction.

Design

See docs/dev/ppl-partial-results-state-store.md.

Validation

  • ./gradlew :opensearch:spotlessApply :opensearch:test
  • GRADLE_OPTS=-Xmx16g ./gradlew :integ-test:integTest :integ-test:yamlRestTest -DignorePrometheus
  • Integration tests: 7,292 tests, 0 failures, 242 skipped
  • YAML REST tests: 204 tests, 0 failures

Focused tests cover StateStore generations and isolation, cached plan reuse, coordinator post-processing, physical-plan classification, root APPEND publication, and aggregation partial-reduce publication.

penghuo added a commit that referenced this pull request Sep 29, 2026
Address the review checklist:

1. Hand-rolled JSON in asyncRunningResponse — replaced with JSONObject
   (safe escaping, matches the existing json library used elsewhere in
   this file). Renamed to runningSnapshot for clarity.

2. Duplicated tryParseAsJobId + forwardToOwner across two transport
   actions — extracted:
     - QueryJobId.tryParse(String) → Optional<QueryJobId> (on the record
       itself so callers pattern-match one abstraction).
     - AsyncQueryOwnerRouting.forwardToOwner(...) → shared helper in the
       async-query transport package.
   TransportGetAsyncQueryResultAction and TransportCancelAsyncQueryRequestAction
   collapse to two-line routing hops each.

3. Ad-hoc ExecutionException unwrap in submitAsync — replaced with the
   promoted-to-public QueryJob.unwrap(Throwable), the same helper the
   state machine already uses. One canonical unwrap for every consumer
   of QueryJob.completion().

4. effectiveKeepAlive() defined but unreachable — removed along with
   DEFAULT_KEEP_ALIVE constant until retention wiring makes the value
   observable. keep_alive still triggers isAsync() via field presence.
   No dead code promising behavior it does not deliver.

5. AsyncQueryExecutionResponse.explainJson set via @Setter on an
   otherwise immutable @DaTa class — now final. The one-arg constructor
   Lombok generated widens to include explainJson; existing callers pass
   null. Response shape is now immutable end-to-end.

7. submitAsync was ~55 lines and did four things — split:
     - submitAsync : construct runner, submit, dispatch to await path.
     - awaitOrReturnId : race the runner, hand off terminal / timeout.
     - renderTerminal : switch on QueryResult.Rows / Explain variant.
     - runningSnapshot : format the RUNNING response (was smell #1).
   Each new method is 5-15 lines with one job.

8. Trivial @provides AsyncQueryExecutorService(...) that returned the
   impl unchanged — replaced with a Guice bind() call inside configure().

Smell #6 (two-mode AsyncQueryExecutorServiceImpl driven by nullable
fields) is architectural; defer per the audit note. The pragmatic escape
around OpenSearch DI's runtime-type matching stays as-is.

Signed-off-by: Peng Huo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant