-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(optimizer)!: simplify AND/OR with static BOOLEAN type #6152
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
base: main
Are you sure you want to change the base?
Conversation
|
Discussed offline– we should check whether all engines evaluate connectors into boolean values, instead of treating them as control flow. If |
306b884 to
66ffdd7
Compare
|
We discovered that post-simplifying we lose some types. That is a bug and we decided to address it in this PR instead of postponing, because that will reduce the PR's complexity as a side-effect. |
|
@barakalon @tobymao curious what your thoughts are on this. The problem: today we infer types & then run other rules that transform the AST, resulting in building new, untyped, expressions. This is a bug on its own, and it also affects type-sensitive rules. E.g., My worry is that fixing each call site introduces a new pattern where we have to be alert for rules after |
e5d9ed2 to
052bdcc
Compare
|
/benchmark |
Benchmark ResultsLegend:
Parsing Benchmark
Benchmark hidden because not significant (1): parse_sqlglot_crazy Optimization Benchmark
Benchmark hidden because not significant (2): optimize_condition_10, optimize_condition_1000 |
|
/benchmark |
Benchmark ResultsLegend:
Parsing Benchmark
Benchmark hidden because not significant (6): parse_sqlglot_tpch, parse_sqlglot_short, parse_sqlglot_crazy, parse_sqlglotrs_tpch, parse_sqlglotrs_short, parse_sqlglotrs_crazy Optimization Benchmark
Benchmark hidden because not significant (3): optimize_tpch, optimize_condition_10, optimize_condition_1000 |
|
Current benchmarks don't show a significant performance slow down. On the other hand, queries like the following (create a lot of AST transformation due to the Old simplify (using the New simplify (using the |
|
I see, so stressing the "unhappy" code paths can result in a ~1.4x slowdown.. That's annoying, although somewhat expected. Let's pause for a bit and disuss to see how we can improve this- FYI @tobymao. |
bea403f to
5fb0d4b
Compare
Fixes #6137
We should avoid simplifying cases like
SELECT 1 AND xorSELECT 0 or x.So, this PR makes this check tighter by checking if the LHS or RHS is
Booleantype.