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

Add simplifier additional between #10463

Closed
wants to merge 1 commit into from
Closed

Conversation

yyy1000
Copy link
Contributor

@yyy1000 yyy1000 commented May 12, 2024

Which issue does this PR close?

Closes #.

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the optimizer Optimizer rules label May 12, 2024
@yyy1000
Copy link
Contributor Author

yyy1000 commented May 12, 2024

The example in #10456 in this PR like below

> create table t (c int) as values (1), (3), (5);
0 row(s) fetched. 
Elapsed 0.031 seconds.

> explain verbose select struct(c) from t where c between 3 and 1;
+------------------------------------------------------------+--------------------------------------------------------------------+
| plan_type                                                  | plan                                                               |
+------------------------------------------------------------+--------------------------------------------------------------------+
| initial_logical_plan                                       | Projection: struct(t.c)                                            |
|                                                            |   Filter: t.c BETWEEN Int64(3) AND Int64(1)                        |
|                                                            |     TableScan: t                                                   |
| logical_plan after apply_function_rewrites                 | SAME TEXT AS ABOVE                                                 |
| logical_plan after inline_table_scan                       | SAME TEXT AS ABOVE                                                 |
| logical_plan after type_coercion                           | Projection: struct(t.c)                                            |
|                                                            |   Filter: CAST(t.c AS Int64) BETWEEN Int64(3) AND Int64(1)         |
|                                                            |     TableScan: t                                                   |
| logical_plan after count_wildcard_rule                     | SAME TEXT AS ABOVE                                                 |
| analyzed_logical_plan                                      | SAME TEXT AS ABOVE                                                 |
| logical_plan after eliminate_nested_union                  | SAME TEXT AS ABOVE                                                 |
| logical_plan after simplify_expressions                    | Projection: struct(t.c)                                            |
|                                                            |   Filter: Boolean(false)                                           |
|                                                            |     TableScan: t                                                   |
| logical_plan after unwrap_cast_in_comparison               | SAME TEXT AS ABOVE                                                 |
| logical_plan after replace_distinct_aggregate              | SAME TEXT AS ABOVE                                                 |
| logical_plan after eliminate_join                          | SAME TEXT AS ABOVE                                                 |
| logical_plan after decorrelate_predicate_subquery          | SAME TEXT AS ABOVE                                                 |
| logical_plan after scalar_subquery_to_join                 | SAME TEXT AS ABOVE                                                 |
| logical_plan after extract_equijoin_predicate              | SAME TEXT AS ABOVE                                                 |
| logical_plan after simplify_expressions                    | SAME TEXT AS ABOVE                                                 |
| logical_plan after rewrite_disjunctive_predicate           | SAME TEXT AS ABOVE                                                 |
| logical_plan after eliminate_duplicated_expr               | SAME TEXT AS ABOVE                                                 |
| logical_plan after eliminate_filter                        | Projection: struct(t.c)                                            |
|                                                            |   EmptyRelation                                                    |
| logical_plan after eliminate_cross_join                    | SAME TEXT AS ABOVE                                                 |
| logical_plan after common_sub_expression_eliminate         | SAME TEXT AS ABOVE                                                 |
| logical_plan after eliminate_limit                         | SAME TEXT AS ABOVE                                                 |
| logical_plan after propagate_empty_relation                | EmptyRelation                                                      |
| logical_plan after eliminate_one_union                     | SAME TEXT AS ABOVE                                                 |
| logical_plan after filter_null_join_keys                   | SAME TEXT AS ABOVE                                                 |
| logical_plan after eliminate_outer_join                    | SAME TEXT AS ABOVE                                                 |
| logical_plan after push_down_limit                         | SAME TEXT AS ABOVE                                                 |
| logical_plan after push_down_filter                        | SAME TEXT AS ABOVE                                                 |
| logical_plan after single_distinct_aggregation_to_group_by | SAME TEXT AS ABOVE                                                 |
| logical_plan after simplify_expressions                    | SAME TEXT AS ABOVE                                                 |
| logical_plan after unwrap_cast_in_comparison               | SAME TEXT AS ABOVE                                                 |
| logical_plan after common_sub_expression_eliminate         | SAME TEXT AS ABOVE                                                 |
| logical_plan after optimize_projections                    | SAME TEXT AS ABOVE                                                 |
| logical_plan after eliminate_nested_union                  | SAME TEXT AS ABOVE                                                 |
| logical_plan after simplify_expressions                    | SAME TEXT AS ABOVE                                                 |
| logical_plan after unwrap_cast_in_comparison               | SAME TEXT AS ABOVE                                                 |
| logical_plan after replace_distinct_aggregate              | SAME TEXT AS ABOVE                                                 |
| logical_plan after eliminate_join                          | SAME TEXT AS ABOVE                                                 |
| logical_plan after decorrelate_predicate_subquery          | SAME TEXT AS ABOVE                                                 |
| logical_plan after scalar_subquery_to_join                 | SAME TEXT AS ABOVE                                                 |
| logical_plan after extract_equijoin_predicate              | SAME TEXT AS ABOVE                                                 |
| logical_plan after simplify_expressions                    | SAME TEXT AS ABOVE                                                 |
| logical_plan after rewrite_disjunctive_predicate           | SAME TEXT AS ABOVE                                                 |
| logical_plan after eliminate_duplicated_expr               | SAME TEXT AS ABOVE                                                 |
| logical_plan after eliminate_filter                        | SAME TEXT AS ABOVE                                                 |
| logical_plan after eliminate_cross_join                    | SAME TEXT AS ABOVE                                                 |
| logical_plan after common_sub_expression_eliminate         | SAME TEXT AS ABOVE                                                 |
| logical_plan after eliminate_limit                         | SAME TEXT AS ABOVE                                                 |
| logical_plan after propagate_empty_relation                | SAME TEXT AS ABOVE                                                 |
| logical_plan after eliminate_one_union                     | SAME TEXT AS ABOVE                                                 |
| logical_plan after filter_null_join_keys                   | SAME TEXT AS ABOVE                                                 |
| logical_plan after eliminate_outer_join                    | SAME TEXT AS ABOVE                                                 |
| logical_plan after push_down_limit                         | SAME TEXT AS ABOVE                                                 |
| logical_plan after push_down_filter                        | SAME TEXT AS ABOVE                                                 |
| logical_plan after single_distinct_aggregation_to_group_by | SAME TEXT AS ABOVE                                                 |
| logical_plan after simplify_expressions                    | SAME TEXT AS ABOVE                                                 |
| logical_plan after unwrap_cast_in_comparison               | SAME TEXT AS ABOVE                                                 |
| logical_plan after common_sub_expression_eliminate         | SAME TEXT AS ABOVE                                                 |
| logical_plan after optimize_projections                    | SAME TEXT AS ABOVE                                                 |
| logical_plan                                               | EmptyRelation                                                      |
| initial_physical_plan                                      | EmptyExec                                                          |
|                                                            |                                                                    |
| initial_physical_plan_with_stats                           | EmptyExec, statistics=[Rows=Exact(0), Bytes=Exact(0), [(Col[0]:)]] |
|                                                            |                                                                    |
| physical_plan after OutputRequirements                     | OutputRequirementExec                                              |
|                                                            |   EmptyExec                                                        |
|                                                            |                                                                    |
| physical_plan after aggregate_statistics                   | SAME TEXT AS ABOVE                                                 |
| physical_plan after join_selection                         | SAME TEXT AS ABOVE                                                 |
| physical_plan after LimitedDistinctAggregation             | SAME TEXT AS ABOVE                                                 |
| physical_plan after EnforceDistribution                    | SAME TEXT AS ABOVE                                                 |
| physical_plan after CombinePartialFinalAggregate           | SAME TEXT AS ABOVE                                                 |
| physical_plan after EnforceSorting                         | SAME TEXT AS ABOVE                                                 |
| physical_plan after OptimizeAggregateOrder                 | SAME TEXT AS ABOVE                                                 |
| physical_plan after ProjectionPushdown                     | SAME TEXT AS ABOVE                                                 |
| physical_plan after coalesce_batches                       | SAME TEXT AS ABOVE                                                 |
| physical_plan after OutputRequirements                     | EmptyExec                                                          |
|                                                            |                                                                    |
| physical_plan after PipelineChecker                        | SAME TEXT AS ABOVE                                                 |
| physical_plan after LimitAggregation                       | SAME TEXT AS ABOVE                                                 |
| physical_plan after ProjectionPushdown                     | SAME TEXT AS ABOVE                                                 |
| physical_plan                                              | EmptyExec                                                          |
|                                                            |                                                                    |
| physical_plan_with_stats                                   | EmptyExec, statistics=[Rows=Exact(0), Bytes=Exact(0), [(Col[0]:)]] |
|                                                            |                                                                    |
+------------------------------------------------------------+--------------------------------------------------------------------+
77 row(s) fetched. 
Elapsed 0.012 seconds.

However, I was thinking whether it's good to simplify like this or we just throw an error if low > high? I'm not quiet clear under what circumstance will the low > high except error situation. 🤔

@yyy1000 yyy1000 marked this pull request as draft May 12, 2024 00:25
@yyy1000 yyy1000 closed this May 12, 2024
@yyy1000 yyy1000 deleted the between branch May 14, 2024 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimizer Optimizer rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant