ClickHouse / ClickHouse/clickhouse-js
Return executed query string as part of ResultSet
- Dominant language
- TypeScript
- Stars
- 331
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Description
### Use case
Part of our product builds ClickHouse aggregation queries based on client configuration and executes them using the `ClickHouseClient.query` method. We inject client-supplied literal values and identifiers using the `query_params` parameter. Our queries can be quite complex, and during active development we sometimes encounter bugs in our query building code. Additionally, performance is a concern, so we take slow-running queries and run them on our ClickHouse database using EXPLAIN to debug the slowness.
This debugging and optimization is made more difficult by the fact that we cannot get the actual query strings executed on the ClickHouse server without doing the query_params substitutions ourselves, since the queries can get quite complicated.
### Describe the solution you'd like
We would like to see the actual server-executed query as part of the ResultSet returned from the ClickHouseClient JS library.
### Describe the alternatives you've considered
We could write a script to interpolate values ourselves, but this could be subject to bugs, since we don't actually know the techniques that ClickHouse is using to escape values. Additionally, we could probably check the query insights in our ClickHouse dashboard, but query volume is sufficient that this is not very user-friendly, and it does not integrate with our logging or APM platforms.
### Additional context
Contributor guide
Research direction
Start by tracing ClickHouseClient.query and the ResultSet returned by the JS library, then inspect how query_params are handled before requests reach ClickHouse. The issue is done when callers can obtain the actual server-executed query from ResultSet without performing their own substitutions, with coverage for complex queries and query parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100