Skip to content

API for query rewrite (RFC) #29922

@alexey-milovidov

Description

@alexey-milovidov

Use case

Some user interfaces may need to modify queries without the risk of implementing their own ad-hoc parsers and corrupting the structure of SQL queries.

Examples:

  • query formatting;
  • adding and modifying the LIMIT clause;
  • adding a condition to WHERE to filter the resultset;
  • changing ORDER BY elements.

Describe the solution you'd like

Several variants to discuss:

  1. ClickHouse HTTP API can have a dedicated handler for this, the settings are passed by URL parameters.
  2. Integrate it to SQL dialect similar to EXPLAIN query or even integrate it as an option to the EXPLAIN query.

Variant 1 is more simple and more separated from SQL. For example, imagine what happens when we want to do the EXPLAIN ... EXPLAIN ... FORMAT ... FORMAT ... query.

Variant 2 is more versatile and can be used from all available ClickHouse interfaces.

Describe alternatives you've considered

We can cover some use cases by out-of-band modifications of the query via settings.
We already have #16176. We can also add the additional_filter setting for adding extra conditions to PREWHERE. But it has many tricky implementation details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicatefeaturewarmup taskThe task for new ClickHouse team members. Low risk, moderate complexity, no urgency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions