Repository navigation
feat(query): add query_arrow for Arrow results in one request - #189
Merged
Merged
Conversation
POST /v1/query can answer with an Arrow IPC stream and carries the run id, result id, row count, timing, warning and rollup outcome as response headers. Add Client::query_arrow / query_arrow_with, which make that one request and return an ArrowQueryResult. 429 is retried as in query(). A result too large to send inline (202 with X-Result-Id) is read from the Results API off the socket, under the max_auto_rows guard; with auto_follow off it returns ResultError::NotInline. Mirrors QueryApi.query_arrow in the Python SDK.
- A 200 that is not Arrow returns its body (ArrowError::Http) instead of a decode error, so the run id of a query that already ran is not lost. - The follow path enforces max_auto_bytes as well as max_auto_rows, on the size of each batch's own data. - ArrowQueryResult is #[non_exhaustive], so fields can be added later. - Tests for a non-Arrow 200, a cut-off Arrow body, and the byte guard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
Client::query_arrowandClient::query_arrow_with(behind thearrowfeature), which run a query and return the rows as Arrow in one request. MirrorsQueryApi.query_arrowin the Python SDK (hotdata-dev/sdk-python#238).POST /v1/queryalready answers with an Arrow IPC stream when asked, and sends the values the JSON body would carry as response headers.query_to_arrowdoes not use that: it runs the query, then fetches the stored result in further requests.Behaviour
ArrowQueryResult:batches,schema,query_run_id,result_id,total_row_count,execution_time_ms,warning,rollup(RollupUsage),followed.dialectand the otherQueryRequestfields work as inquery.RetryPolicyasquery.X-Result-Id) is awaited and read from the Results API off the socket, asking for at mostmax_auto_rows + 1rows.max_auto_bytesapplies too, measured on the decoded batches' data; past either guard it returnsResultError::TooLarge. Withauto_followoff it returns the newResultError::NotInline, which carries the ids.async = trueis rejected withQueryError::AsyncRequested; a 202 that names no result isQueryError::Async.QueryError::Submitwith the status, as inquery.QueryError::Arrowvariant (feature-gated) for read/decode failures. Both error enums are#[non_exhaustive], and so isArrowQueryResult.ArrowError::Httpwith its body, not as a decode error, so the run id of a query that already ran is kept.query_to_arrowis unchanged: it pages withoffset/limitand has its own error type.Tests
src/query_arrow.rs(wiremock, real Arrow IPC bytes).tests/query_arrow.rs: inline result, ClickHouse dialect, large-result follow, and theauto_follow-off refusal. Passes against a live workspace.