clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

Query Parameters Refactor

Open BentsiLeviav opened this issue 2 years ago • 4 comments

Description:

In the current implementation, clickhouse-java manually parses query parameters, supporting both traditional question marks and named parameters. We propose refactoring this process to leverage ClickHouse's parameters binding capabilities for a more streamlined and efficient parameter parsing.

This refactoring aligns with the methods used by other connectors, including:

All of these clients have comprehensive test suites (Python, JS, and Go) that can serve as valuable references for testing the proposed refactoring.

BentsiLeviav avatar Jan 09 '24 11:01 BentsiLeviav

This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!

github-actions[bot] avatar Jan 09 '25 00:01 github-actions[bot]

@chernser @mzitnik @Paultagoras Do we plan to implement something similar in V2?

BentsiLeviav avatar Jan 09 '25 08:01 BentsiLeviav

@BentsiLeviav it is already implemented - https://clickhouse.com/docs/en/integrations/java/client-v2#querystring-sqlquery-mapstring-object-queryparams-querysettings-settings

chernser avatar Jan 09 '25 21:01 chernser

I'm glad to see queryParameters are supported, yet unfortunately, client-v2 makes no attempt to convert Java Objects into something ClickHouse server could actually parse (Currently using v0.7.2).

Seems HttpAPIClientHelper.addQueryParams just calls String.valueOf on values, so, for example, querying {param1:DateTime} and passing argument of any of the Java's date classes will likely fail. One has to guess what format server expects and convert parameters into Strings manually.

It would be much appreciated if smarter conversion / validation would be implemented in client-v2

andris-rauda avatar Jan 16 '25 15:01 andris-rauda