-
Notifications
You must be signed in to change notification settings - Fork 8.3k
API for query rewrite (RFC) #29922
Description
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:
- ClickHouse HTTP API can have a dedicated handler for this, the settings are passed by URL parameters.
- 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.