Skip to content

Conversation

@lidavidm
Copy link
Member

Closes #3262.

@lidavidm
Copy link
Member Author

The Python side is not fully wired up yet but I would appreciate opinions on using an option to tell drivers to bind parameters by name and not position. @zeroshade @amoeba @WillAyd @paleolimbot

My reasoning:

  • I'm not sure we can auto-detect what the user intends. At least for SQLite, we can detect whether parameter names are in play and then check if the schema matches? But this is more complicated (especially if the order doesn't match) and fragile. So I think explicitly opting in to this behavior is best.
  • We could flag this in the schema metadata, which is attractive as it's stateless. But also it can silently be ignored if the driver doesn't support the option and requires fiddling with the schema (and potentially copying it depending on your Arrow implementation). So an explicit option is better.

The tests in this PR aren't complete yet on the Python side.

table, or record batch reader (to provide multiple
parameters, which will each be bound in turn).
Parameters to bind. Can be a Python sequence (to bind a single
set of parameters), a Python dictionary (to bind a single set of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does providing a dictionary automatically set the option to bind by name? If not, should it?

Copy link
Member Author

@lidavidm lidavidm Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will, yes. It's only when using Arrow data that you have to manage it explicitly.

Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems great! I'll wire it up in R after this merges (not sure there's a good way to pass through statement options to read_adbc() or execute_adbc() yet).

"adbc.sqlite.load_extension.entrypoint";
/// The batch size for query results (and for initial type inference)
constexpr std::string_view kStatementOptionBatchRows = "adbc.sqlite.query.batch_rows";
constexpr std::string_view kStatementOptionBindByName = "adbc.statement.bind_by_name";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this unique to SQLite or maybe there's another good place for "well known but also we don't really want to update adbc.h" parameters? (I recall there's a Postgres one like that too but I forget what it's called).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should maybe make such a header 😬 arrow-adbc/experimental.h?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another day!

@lidavidm lidavidm marked this pull request as ready for review September 1, 2025 09:02
@github-actions github-actions bot added this to the ADBC Libraries 20 milestone Sep 1, 2025
@lidavidm
Copy link
Member Author

lidavidm commented Sep 5, 2025

Any other comments?

Copy link
Contributor

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work!

"adbc.sqlite.load_extension.entrypoint";
/// The batch size for query results (and for initial type inference)
constexpr std::string_view kStatementOptionBatchRows = "adbc.sqlite.query.batch_rows";
constexpr std::string_view kStatementOptionBindByName = "adbc.statement.bind_by_name";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another day!

@lidavidm lidavidm merged commit d44e361 into apache:main Sep 6, 2025
69 of 70 checks passed
@lidavidm lidavidm deleted the gh-3262 branch September 6, 2025 06:55
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.

Python: Parameterised query with dict produces results deviating from standard library sqlite driver

4 participants