Skip to content

PoC progressive query execution handle - #9

Open
penghuo wants to merge 4 commits into
feat/asyncquery-apifrom
feat/ppl-progressive-execution-handle-poc
Open

penghuo wants to merge 4 commits into
feat/asyncquery-apifrom
feat/ppl-progressive-execution-handle-poc

Conversation

@penghuo

@penghuo penghuo commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Purpose

Prototype Option B from the module-contract discussion: Lifecycle receives one execution handle immediately instead of directly participating in the execution callback/context handoff.

This PR is intentionally based on PR #8 so the diff isolates the contract change while reusing the same partial-result execution paths.

Contract

PPLService.executeProgressively(...) returns ProgressiveQueryExecution:

  • currentResult() reads the complete result currently visible, or empty before the execution context is ready.
  • completion() completes normally on query success and exceptionally on failure.
  • close() releases execution-owned current-result resources.

DefaultProgressiveQueryExecution keeps ProgressiveQueryResponseListener internal to the Execution side and bridges the existing engine callback into the returned handle.

PPLAsyncQueryService.Job owns the handle after attachment. POST timeout and GET read through currentResult(); terminal job transitions are driven by completion().

End-to-end partial-result execution matrix

The REST prototype uses a 12-shard, 400K-document dataset and verifies all partial-result producer/reader paths implemented by PR #8:

Query shape Producer / reader First data Final First rows Final rows Result
Fully pushed aggregation at physical root Partial reduce → REPLACE → direct read 2681 ms 2749 ms 1 1 Partial value is non-zero and smaller than final; final equals sync
Composite aggregation Composite pagination → root ResultSet.next() → APPEND 722 ms 1723 ms 46 100000 Non-empty partial; final schema/rows equal sync
Non-blocking REX/root rows Root ResultSet.next() → APPEND 296 ms 2030 ms 5 100000 Non-empty partial; final schema/rows equal sync
Pushed aggregation + Calcite post-processing Partial reduce → REPLACE → cached residual plan 102 ms 116 ms 1 1 Partial aggregate is smaller than final; final equals sync
count() standard mapper TotalHits mapper and final correctness Not observed (query completed in 78 ms) 78 ms 0 1 Final equals sync and count is 400000

All 5 REST tests passed. The first four paths assert meaningful running data before final completion. Every path asserts final equality with synchronous Calcite PPL output.

Lifecycle and handle validation

  • Handle returns no result before Context binding.
  • Context binding makes current results readable.
  • Success and failure propagate through completion().
  • Closing the handle before Context binding closes a late Context.
  • Fast completion, timeout, GET, DELETE, expiration, failure, and resource cleanup remain valid.
  • Lifecycle no longer implements or receives ProgressiveQueryResponseListener.

Validation commands

  • PPL handle and service unit tests: passed.
  • Async lifecycle and formatter unit tests: passed.
  • Spotless checks: passed.
  • ./gradlew :integ-test:integTest --tests 'org.opensearch.sql.ppl.PPLProgressiveQueryPrototypeIT' -Dppl.progressive.prototype=true -DignorePrometheus: 5/5 passed.

Known PoC limitations

  • The existing execution-engine callback remains internal to DefaultProgressiveQueryExecution; this PR validates that it no longer crosses the Lifecycle/Execution boundary.
  • The engine still materializes a terminal QueryResponse that the handle ignores.
  • Progress is not included in this comparison.

@penghuo
penghuo requested a review from dai-chen as a code owner September 22, 2026 21:50
@penghuo
penghuo changed the base branch from feat/ppl-progressive-integration-prototype to feat/asyncquery-api September 22, 2026 22:06
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