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

fewer parens #206

Closed
wants to merge 2 commits into from
Closed

fewer parens #206

wants to merge 2 commits into from

Conversation

ruslandoga
Copy link
Contributor

@ruslandoga ruslandoga commented Oct 31, 2024

Context: plausible/analytics@6399cf5

Before:

0cdf854b7d84 :) explain ast SELECT 1 FROM values((1)) WHERE ((((((((1 AND 1) AND 1) AND 1) AND 1) AND 1) AND 1) AND 1) AND 1);

EXPLAIN AST
SELECT 1
FROM values(1)
WHERE (((((((1 AND 1) AND 1) AND 1) AND 1) AND 1) AND 1) AND 1) AND 1

Query id: 3bd5dd60-a3d0-410c-9ca2-50d0c10eb1b9

    ┌─explain───────────────────────────────────────┐
 1. │ SelectWithUnionQuery (children 1)             │
 2. │  ExpressionList (children 1)                  │
 3. │   SelectQuery (children 3)                    │
 4. │    ExpressionList (children 1)                │
 5. │     Literal UInt64_1                          │
 6. │    TablesInSelectQuery (children 1)           │
 7. │     TablesInSelectQueryElement (children 1)   │
 8. │      TableExpression (children 1)             │
 9. │       Function values (children 1)            │
10. │        ExpressionList (children 1)            │
11. │         Literal UInt64_1                      │
12. │    Function and (children 1)                  │
13. │     ExpressionList (children 2)               │
14. │      Function and (children 1)                │
15. │       ExpressionList (children 2)             │
16. │        Function and (children 1)              │
17. │         ExpressionList (children 2)           │
18. │          Function and (children 1)            │
19. │           ExpressionList (children 2)         │
20. │            Function and (children 1)          │
21. │             ExpressionList (children 2)       │
22. │              Function and (children 1)        │
23. │               ExpressionList (children 2)     │
24. │                Function and (children 1)      │
25. │                 ExpressionList (children 2)   │
26. │                  Function and (children 1)    │
27. │                   ExpressionList (children 2) │
28. │                    Literal UInt64_1           │
29. │                    Literal UInt64_1           │
30. │                  Literal UInt64_1             │
31. │                Literal UInt64_1               │
32. │              Literal UInt64_1                 │
33. │            Literal UInt64_1                   │
34. │          Literal UInt64_1                     │
35. │        Literal UInt64_1                       │
36. │      Literal UInt64_1                         │
    └───────────────────────────────────────────────┘

After

0cdf854b7d84 :) explain ast SELECT 1 FROM values((1)) WHERE 1 AND 1 AND 1 AND 1 AND 1 AND 1 AND 1 AND 1 AND 1;

EXPLAIN AST
SELECT 1
FROM values(1)
WHERE 1 AND 1 AND 1 AND 1 AND 1 AND 1 AND 1 AND 1 AND 1

Query id: 4939be02-0611-4d8b-a24f-79e9c5831ee7

    ┌─explain─────────────────────────────────────┐
 1. │ SelectWithUnionQuery (children 1)           │
 2. │  ExpressionList (children 1)                │
 3. │   SelectQuery (children 3)                  │
 4. │    ExpressionList (children 1)              │
 5. │     Literal UInt64_1                        │
 6. │    TablesInSelectQuery (children 1)         │
 7. │     TablesInSelectQueryElement (children 1) │
 8. │      TableExpression (children 1)           │
 9. │       Function values (children 1)          │
10. │        ExpressionList (children 1)          │
11. │         Literal UInt64_1                    │
12. │    Function and (children 1)                │
13. │     ExpressionList (children 9)             │
14. │      Literal UInt64_1                       │
15. │      Literal UInt64_1                       │
16. │      Literal UInt64_1                       │
17. │      Literal UInt64_1                       │
18. │      Literal UInt64_1                       │
19. │      Literal UInt64_1                       │
20. │      Literal UInt64_1                       │
21. │      Literal UInt64_1                       │
22. │      Literal UInt64_1                       │
    └─────────────────────────────────────────────┘

Related:

TODOs:

  • minimize changes
    • return parens where they weren't a problem (arithmetic, etc.), it seems only parens around AND are problematic

@ruslandoga
Copy link
Contributor Author

closing in favor of #207

@ruslandoga ruslandoga closed this Nov 2, 2024
@ruslandoga ruslandoga deleted the fewer-parens branch November 2, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant