-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support (EXPLAIN SELECT ...) as a subquery #40630
Conversation
I would prefer to add explain table function, because using EXPLAIN query as parameter breaks a lot of logic in parser (because EXPLAIN SELECT) is not an expression and it is impossible to analyze, because such EXPLAIN query need to be represented in query tree somehow. |
I would prefer to allow all query types that return results: EXPLAIN, DESCRIBE, SHOW, etc. |
I checked and in this pull request
Result of parser level rewrite:
@alexey-milovidov, @vdimir what do you think ? |
Additional examples:
Maybe we can even create some generic view that can have argument that identifies its type 'PROCESS_LIST', 'DESCRIBE'. |
e9da7f7
to
bada21c
Compare
I've changed the implementation to support EXPLAIN subquery directly It converts the query to If you are ok with implementation, let's finish this PR with |
@vdimir great solution, I am okay with implementation. Let finish this for EXPLAIN and merge. |
33017a9
to
fa254bc
Compare
CI failures on
|
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
(EXPLAIN SELECT ...)
in a subquery. Queries likeSELECT * FROM (EXPLAIN PIPELINE SELECT col FROM TABLE ORDER BY col)
became valid.We have some tests that do
clickhouse client -q "EXPLAIN ..." | grep ...
, this PR would allow to write pure.sql
tests for such cases.ClickHouse/tests/queries/0_stateless/02149_read_in_order_fixed_prefix_negative.sh
Line 15 in 13de3d0
ClickHouse/tests/queries/0_stateless/01582_distinct_optimization.sh
Line 11 in 13de3d0
It allows to work with the result of EXPLAIN e.g in tests