Skip to content

Conversation

@niyue
Copy link
Contributor

@niyue niyue commented Dec 7, 2025

Description

This PR adds support for ClickHouse query parameters and addresses #436.
It enables users to execute parameterized queries without manual string interpolation, resulting in more reusable query templates and reducing the risk of SQL injection.

Changelog category

  • New Feature

Changelog entry

Add support for ClickHouse query parameters, allowing generic queries with typed placeholders.

Documentation entry for user-facing changes

Query parameters is a native ClickHouse feature, and the official documentation already covers their usage in detail, for example:

This PR enables chdb users to take advantage of this feature directly.
A brief introduction and examples have been added to both README.md and README-zh.md.

Test

Several Python unit tests have been added to validate this functionality.

@CLAassistant
Copy link

CLAassistant commented Dec 7, 2025

CLA assistant check
All committers have signed the CLA.

@niyue niyue changed the title feat: add support for ClickHouse's query parameters feat: add support for ClickHouse's query parameters in python binding Dec 7, 2025
@niyue
Copy link
Contributor Author

niyue commented Dec 7, 2025

chdb is still quite new to me, so please pardon me if I’ve overlooked anything obvious — I’m happy to make any adjustments needed.

@wudidapaopao
Copy link
Contributor

wudidapaopao commented Dec 8, 2025

Hi @niyue, thank you so much for your PR. Currently, there are two categories of test failures:
One category consists of query failures caused by network issues, which can be temporarily ignored.
The other category is failures occurring on musl Linux. The cause is that, due to implementation-specific limitations of musl Linux at present, all exceptions will trigger the error: RuntimeError: Caught an unknown exception.
A quick workaround is to add a conditional check in the test cases: if the current environment is musl Linux (you can use the utility function is_musl_linux provided in the test cases), directly treat all exception messages as containing the string "Caught an unknown exception".

@niyue niyue force-pushed the feature/parameterized-query branch from 3c6e4d5 to 3aaa73f Compare December 9, 2025 04:57
@niyue
Copy link
Contributor Author

niyue commented Dec 9, 2025

@wudidapaopao

Thanks for the detailed information. I’ve updated the tests, but I don’t have a musl Linux environment to verify locally, so I’ll have to rely on the CI to validate the changes. Hopefully this fixes the CI issues.

@niyue
Copy link
Contributor Author

niyue commented Dec 12, 2025

@wudidapaopao This PR is ready for review. Please let me know if there’s anything else I should revise. Thanks!

@auxten auxten merged commit 5777f95 into chdb-io:main Dec 13, 2025
10 checks passed
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.

4 participants