I work on ClickHouse proxy which would validate and modify query before sending it to ClickHouse. To implement validation logic and I need to know what columns user request. The problem comes in when user uses *
in select's.
For simple queries like select * from table
I can expand *
by myself and transform original query to e.g. select a,b,c from table
.
Knowing table and column names and can check against user's permissions if he can access those columns. But how to deal with complicated queries with many join, subqueries etc. I was hoping that maybe there is functionality in ClickHouse which would allow to dry-run
query before executing it, then ClickHouse would parse, analyze, optimize original SQL and produce expand one without *
.
I couldn't find anything like that in ClickhHouse documentation. I use sqlglot library to transform AST. Any ideas how resolve my problem?
Thank you in advance
I asked someone working in ClickHouse. You can run
EXPLAIN <query>
in the ClickHouse, but not aware of such parser independently outside ClickHouse. As this results require the table schema definition.