feat: add parameterized query support - #2
Draft
brettm-elastiflow wants to merge 13 commits into
Draft
brettm-elastiflow wants to merge 13 commits into
brettm-elastiflow wants to merge 13 commits into
Conversation
brettm-elastiflow
force-pushed
the
feat-add-parameterized-query-support
branch
from
August 27, 2026 12:32
aa3b147 to
e80365d
Compare
larry-c-ef
approved these changes
Aug 27, 2026
larry-c-ef
left a comment
Collaborator
There was a problem hiding this comment.
Several questions, but the code looks good.
brettm-elastiflow
force-pushed
the
feat-add-parameterized-query-support
branch
from
August 28, 2026 00:06
116ea92 to
cae8656
Compare
larry-c-ef
approved these changes
Aug 31, 2026
larry-c-ef
force-pushed
the
feat-add-arrow-streaming
branch
from
September 9, 2026 15:19
c5ba5eb to
7efb7b4
Compare
feat(streaming): add query result and arrow batch streaming
Wire a typed QueryParam surface through Connection, Session, and the
stateless execute helpers before implementing the libchdb FFI. Values
encode as strings; SQL still declares {name:Type}. Text and Arrow
stream entry points are included.
- src/query_param.rs: Added QueryParam/QueryParams with scalar, option,
array, and raw literal encoding
- src/connection.rs: Stubbed query_with_params,
query_stream_with_params, and query_stream_arrow_with_params
- src/session.rs: Stubbed execute_with_params,
execute_stream_with_params, and execute_stream_arrow_with_params
- src/lib.rs: Exported query_param types and stubbed
execute_with_params / execute_stream_with_params /
execute_stream_arrow_with_params
- src/query_stream.rs: Stubbed parameterized stream constructors for
chdb_stream_query_with_params
- src/arrow_query_stream.rs: Stubbed parameterized Arrow stream
constructors for chdb_stream_query_arrow_with_params
Implement the materialized parameterized query path so typed QueryParam values bind through chdb_query_with_params instead of remaining a stub. - src/query_param.rs: Added EncodedParams to build parallel NUL-terminated name/value CString arrays for the C ABI - src/connection.rs: Implemented query_with_params via chdb_query_with_params, including empty-params fallthrough Co-authored-by: Cursor <cursoragent@cursor.com>
Parameterized text streams can bind {name:Type} placeholders through
the same EncodedParams path as materialized queries.
libchdb reports missing-parameter errors on the first fetch rather than
stream start, so the substitution-error test asserts on next_chunk.
- src/query_stream.rs: Implemented start_query_with_params via
chdb_stream_query_with_params
- tests/query_with_params.rs: Assert missing-param Substitution error
on next_chunk for text streams
Co-authored-by: Cursor <cursoragent@cursor.com>
Parameterized Arrow streams bind {name:Type} placeholders through
EncodedParams, matching the materialized and text-stream paths.
- src/arrow_query_stream.rs: Implemented start_query_with_params via
chdb_stream_query_arrow_with_params
- tests/query_with_params.rs: Assert missing-param Substitution error
on next_batch for Arrow streams
Co-authored-by: Cursor <cursoragent@cursor.com>
Show Session::execute_with_params with a warehouse stock table, including tuple arrays for same-typed binds and QueryParams for mixed types. - examples/12_query_with_params.rs: Added inventory lookup example - examples/README.md: Listed the new example Co-authored-by: Cursor <cursoragent@cursor.com>
brettm-elastiflow
force-pushed
the
feat-add-parameterized-query-support
branch
from
September 9, 2026 17:39
cae8656 to
7b7b1f0
Compare
The engine cannot run two queries on one connection. Parameterized stream entry points still took `&self` after the rebase onto main, and text-stream start still called a removed error helper instead of destroying the C handle. - docs/examples.md: Linked example 13 next to the streaming examples - src/arrow_query_stream.rs: Borrow mutably; destroy failed starts; cover empty filters, retry-after-error, and syntax errors - src/connection.rs: Take `&mut self` on parameterized stream methods - src/query_stream.rs: Borrow mutably; destroy failed starts; cover retry-after-error and syntax errors - src/session.rs: Take `&mut self` on parameterized streams; unwrap the optional connection like the non-parameterized paths - tests/query_with_params.rs: Use mutable connections and sessions for stream cases Co-authored-by: Cursor <cursoragent@cursor.com>
brettm-elastiflow
force-pushed
the
feat-add-parameterized-query-support
branch
from
September 9, 2026 20:14
13a67d9 to
3dd29e0
Compare
A first-time visitor will find this API on docs.rs and in docs/examples.md, not in the crate README. The README covers install and engine constraints; parameterized queries are a query API. - docs/examples.md: Added a top-level Parameterized Queries section with execute_with_params and QueryParams samples - src/lib.rs: Listed parameterized queries in crate Features; documented errors and stream fetch-time substitution on execute_*_with_params - src/query_param.rs: Documented QueryParams::new/bind, QueryParam variants, and that encoding does not change the SQL type - src/connection.rs: Documented exclusive borrow, empty params, and stream substitution-on-fetch for the with_params methods - src/session.rs: Added examples and Errors for execute_with_params and the parameterized stream methods Co-authored-by: Cursor <cursoragent@cursor.com>
brettm-elastiflow
force-pushed
the
feat-add-parameterized-query-support
branch
from
September 9, 2026 20:36
3dd29e0 to
c70d262
Compare
chDB parses parameter strings with deserializeTextEscaped, so a value like C:\temp became C: + TAB + emp. Text is a literal; Raw stays pass-through for already-escaped input. - src/query_param.rs: Encode backslash, tab, and newline on Text; do the same plus quotes for nested array elements - tests/query_with_params.rs: Added chDB round-trips for C:\temp and a literal tab Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Do not merge, this branch is intended to be merged upstream. This PR is only for internal review.
This adds two things:
with_paramsvariants of chDB query APIs:execute_with_paramsexecute_stream_with_paramsexecute_stream_arrow_with_paramsNot done:
serdeintegration for chDB serialization: I considered this to be out of scope for now. Practically speaking,/ though, this is going to be required for custom types to be used.