feat(query): parameterized async /v1/queries submit + options - #80
Merged
Conversation
The async /v1/queries API (added in #68/#70) could only submit a bare SQL string. Add parameterized submit and submit options, matching the Spice v2 API (verified against spiceai/spiceai@v2.1.0): - SpiceClient::query_with_bindings(sql, QueryParameters) — mirrors the sync sql_with_bindings; positional $1, $2, ... scalar bindings. - SpiceClient::query_with_options(sql, QuerySubmitOptions) — bindings plus timeout_seconds and maximum_size. - QueryParameters::to_json_values() encodes scalar bindings as the JSON array the HTTP API expects; non-scalar/binary/non-finite params fail fast with QueryError::InvalidParameter. - Export QuerySubmitOptions; add README example. Tests: +9 (6 param-encoding unit tests, 3 client wiremock tests). All lib tests and doctests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
phillipleblanc
approved these changes
Jul 13, 2026
There was a problem hiding this comment.
Pull request overview
This PR completes the async /v1/queries submit API in the Spice.ai Rust SDK by exposing parameter bindings and submit-time controls (timeout and max result size), bringing parity with the sync Flight sql_with_bindings path.
Changes:
- Add
QuerySubmitOptions(bindings/timeout_seconds/maximum_size) and surfacequery_with_bindings+query_with_optionson the async HTTP query client API. - Implement
QueryParameters::to_json_values()to encode scalar bindings as the JSON array expected by/v1/queries, with fast-fail errors for unsupported parameter kinds. - Re-export
QuerySubmitOptionsfrom the crate root and document the new async query usage (README + rustdoc).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/query.rs | Adds QuerySubmitOptions and extends HTTP submit to accept parameters + submit controls. |
| src/params.rs | Adds JSON encoding for scalar parameters used by async /v1/queries bindings. |
| src/lib.rs | Re-exports QuerySubmitOptions from the crate root. |
| src/client.rs | Adds query_with_bindings / query_with_options and updates submit wiring + tests. |
| README.md | Documents async query bindings and submit options usage. |
Comments suppressed due to low confidence (1)
src/client.rs:335
- This note links to
SpiceClientBuilder::http_url, but the builder is exported publicly asClientBuilder. Referring to the public API name avoids broken/confusing rustdoc links for external users.
/// **Note:** Requires [`http_url()`](SpiceClientBuilder::http_url) to be configured.
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.
Summary
Completes the async
/v1/queriesAPI for Spice v2. The API (added in #68/#70) already covered submit / list / status / results / cancel, but submit hardcodedparameters/timeout_seconds/maximum_sizetoNone, so parameterized async distributed queries weren't exposed — even though the sync Flight path already hassql_with_bindings.Verified against the handler at
spiceai/spiceai@v2.1.0(crates/runtime/src/http/v1/queries.rs).New API
QuerySubmitOptionsbuilder (bindings/timeout_seconds/maximum_size), exported from the crate root.QueryParameters::to_json_values()encodes scalar bindings as the JSON array the HTTP API expects; binary/array/non-finite params fail fast withQueryError::InvalidParameterbefore any request.query(sql)unchanged as the no-args shortcut.Tests
cargo test --lib— 187 passed (+9: 6 param-encoding unit tests incl. reject-binary/array/NaN, 3 wiremock tests asserting the exact request body).cargo test --doc— README + rustdoc examples compile.Note on #79
This branch is cut from the current (unformatted)
trunk. #79 (cargo fmt --all+ rustfmt CI gate) reformats pre-existing lines inparams.rs/client.rs, so whichever of the two merges second will need a trivial rebase — I can handle that. My added code is already rustfmt-clean, so it will pass the new fmt gate once rebased.🤖 Generated with Claude Code