Skip to content

Return executed query string as part of ResultSet #846

Description

@erikwlarsen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions