Skip to content
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

Improve EXPLAIN SYNTAX with ASTSelectWithUnionQuery #21027

Closed
wants to merge 1 commit into from

Conversation

ucasfl
Copy link
Collaborator

@ucasfl ucasfl commented Feb 21, 2021

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Improve EXPLAIN SYNTAX with ASTSelectWithUnionQuery.

Detailed description / Documentation draft:

InterpreterSelectWithUnionQuery normalizes the ASTSelectWithUnionQuery, so we need improve ExplainAnalyzedSyntaxVisitor in InterpreterExplainQuery to show the correct syntax.

For example:

before

EXPLAIN SYNTAX                                                                                                                            [1/1807]
SELECT 1                                                                                                                                          
UNION ALL
(
    SELECT 1
    UNION ALL
    (
        SELECT 1
        UNION ALL
        SELECT 1
    )
    UNION ALL
    SELECT 1
)

Query id: c542fb59-4fe7-4c9d-93c4-b0e34528f564

┌─explain───────────┐
│ SELECT 1          │
│ UNION ALL         │
│ (                 │
│     SELECT 1      │
│     UNION ALL     │
│     (             │
│         SELECT 1  │
│         UNION ALL │
│         SELECT 1  │
│     )             │
│     UNION ALL     │
│     SELECT 1      │
│ )                 │
└───────────────────┘

13 rows in set. Elapsed: 0.022 sec.  

EXPLAIN SYNTAX                                                                                                                                    
SELECT 1                                                                                                                                          
UNION ALL
(
    SELECT 1
    UNION DISTINCT
    (
        SELECT 1
        UNION ALL
        SELECT 1
    )
    UNION ALL
    SELECT 1
)

Query id: 5f1995c3-8883-4535-b8ab-30ce99b69090

┌─explain────────────┐
│ SELECT 1           │
│ UNION ALL          │
│ (                  │
│     SELECT 1       │
│     UNION DISTINCT │
│     (              │
│         SELECT 1   │
│         UNION ALL  │
│         SELECT 1   │
│     )              │
│     UNION ALL      │
│     SELECT 1       │
│ )                  │
└────────────────────┘

now

EXPLAIN SYNTAX
SELECT 1
UNION ALL
(
    SELECT 1
    UNION ALL
    (
        SELECT 1
        UNION ALL
        SELECT 1
    )
    UNION ALL
    SELECT 1
)

Query id: 3b872702-4558-455c-9a00-e2905288e1f8

┌─explain───┐
│ SELECT 1  │
│ UNION ALL │
│ SELECT 1  │
│ UNION ALL │
│ SELECT 1  │
│ UNION ALL │
│ SELECT 1  │
│ UNION ALL │
│ SELECT 1  │
└───────────┘

9 rows in set. Elapsed: 0.029 sec. 

EXPLAIN SYNTAX
SELECT 1
UNION ALL
(
    SELECT 1
    UNION DISTINCT
    (
        SELECT 1
        UNION ALL
        SELECT 1
    )
    UNION ALL
    SELECT 1
)

Query id: f902ac63-7f88-4439-a316-315de09b3731

┌─explain────────────┐
│ SELECT 1           │
│ UNION ALL          │
│ (                  │
│     SELECT 1       │
│     UNION DISTINCT │
│     SELECT 1       │
│     UNION DISTINCT │
│     SELECT 1       │
│ )                  │
│ UNION ALL          │
│ SELECT 1           │
└────────────────────┘

11 rows in set. Elapsed: 0.038 sec.

@robot-clickhouse robot-clickhouse added the pr-improvement Pull request with some product improvements label Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-improvement Pull request with some product improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants