Skip to content

Commit

Permalink
[test](Nereids): add regression test eliminate/infer rules (apache#27985
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jackwener authored and 胥剑旭 committed Dec 14, 2023
1 parent 837a8a0 commit 667e3d7
Show file tree
Hide file tree
Showing 7 changed files with 1,108 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
* change the plan:
* logicalFilter(logicalApply(any(), logicalAggregate()))
* to
* logicalProject((logicalFilter(logicalWindow(logicalFilter(any())))))
* logicalProject(logicalFilter(logicalWindow(logicalFilter(any()))))
* <p>
* refer paper: WinMagic - Subquery Elimination Using Window Aggregation
* <p>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !eliminate_not_null_basic_comparison --
PhysicalResultSink
--PhysicalDistribute
----filter(( not score IS NULL) and (t.score > 13))
------PhysicalOlapScan[t]

-- !eliminate_not_null_in_clause --
PhysicalResultSink
--PhysicalDistribute
----filter(( not id IS NULL) and id IN (1, 2, 3))
------PhysicalOlapScan[t]

-- !eliminate_not_null_not_equal --
PhysicalResultSink
--PhysicalDistribute
----filter(( not (score = 13)) and ( not score IS NULL))
------PhysicalOlapScan[t]

-- !eliminate_not_null_string_function --
PhysicalResultSink
--PhysicalDistribute
----filter(( not name IS NULL) and (length(name) > 0))
------PhysicalOlapScan[t]

-- !eliminate_not_null_aggregate --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashAgg[LOCAL]
--------PhysicalProject
----------filter(( not score IS NULL) and (t.score > 0))
------------PhysicalOlapScan[t]

-- !eliminate_not_null_between --
PhysicalResultSink
--PhysicalDistribute
----filter(( not score IS NULL) and (t.score <= 10) and (t.score >= 1))
------PhysicalOlapScan[t]

-- !eliminate_not_null_math_function --
PhysicalResultSink
--PhysicalDistribute
----filter(( not score IS NULL) and (abs(score) = 5))
------PhysicalOlapScan[t]

-- !eliminate_not_null_complex_logic --
PhysicalResultSink
--PhysicalDistribute
----filter(( not score IS NULL) and ((t.score > 5) OR (t.id < 10)))
------PhysicalOlapScan[t]

-- !eliminate_not_null_date_function --
PhysicalResultSink
--PhysicalDistribute
----filter(( not name IS NULL) and (year(cast(name as DATEV2)) = 2022))
------PhysicalOlapScan[t]

-- !eliminate_not_null_with_subquery --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_SEMI_JOIN] hashCondition=((t.score = t.score)) otherCondition=() build RFs:RF0 score->[score]
--------filter(( not score IS NULL) and (t.score > 0))
----------PhysicalOlapScan[t] apply RFs: RF0
--------PhysicalDistribute
----------PhysicalProject
------------filter((t.score > 0))
--------------PhysicalOlapScan[t]

Original file line number Diff line number Diff line change
@@ -0,0 +1,303 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !left_outer --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
--------PhysicalOlapScan[t] apply RFs: RF0
--------filter((t2.score > 10))
----------PhysicalOlapScan[t]

-- !right_outer --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
--------PhysicalOlapScan[t] apply RFs: RF0
--------filter((t1.score > 10))
----------PhysicalOlapScan[t]

-- !full_outer_join --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
--------PhysicalOlapScan[t] apply RFs: RF0
--------filter((t1.score > 10))
----------PhysicalOlapScan[t]

-- !full_outer_join --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
--------PhysicalOlapScan[t] apply RFs: RF0
--------filter((t2.score > 10))
----------PhysicalOlapScan[t]

-- !full_outer_join --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
--------filter((t1.score > 10))
----------PhysicalOlapScan[t] apply RFs: RF0
--------filter((t2.score > 10))
----------PhysicalOlapScan[t]

-- !left_outer --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
--------filter((t1.score > 10))
----------PhysicalOlapScan[t] apply RFs: RF0
--------filter((t2.score > 10))
----------PhysicalOlapScan[t]

-- !multiple_left_outer_1 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.id = t3.id)) otherCondition=()
--------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
----------PhysicalOlapScan[t] apply RFs: RF0
----------filter((t1.score > 10))
------------PhysicalOlapScan[t]
--------PhysicalOlapScan[t]

-- !multiple_left_outer_2 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.id = t3.id)) otherCondition=()
--------hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
----------PhysicalOlapScan[t] apply RFs: RF0
----------filter((t2.score > 10))
------------PhysicalOlapScan[t]
--------PhysicalOlapScan[t]

-- !multiple_right_outer_1 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((t1.id = t3.id)) otherCondition=() build RFs:RF1 id->[id]
--------PhysicalOlapScan[t] apply RFs: RF1
--------hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
----------PhysicalOlapScan[t] apply RFs: RF0
----------filter((t1.score > 10))
------------PhysicalOlapScan[t]

-- !multiple_right_outer_2 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((t1.id = t3.id)) otherCondition=() build RFs:RF1 id->[id]
--------PhysicalOlapScan[t] apply RFs: RF1
--------hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
----------PhysicalOlapScan[t] apply RFs: RF0
----------filter((t2.score > 10))
------------PhysicalOlapScan[t]

-- !multiple_full_outer_1 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.id = t3.id)) otherCondition=()
--------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
----------PhysicalOlapScan[t] apply RFs: RF0
----------filter((t1.score > 10))
------------PhysicalOlapScan[t]
--------PhysicalOlapScan[t]

-- !multiple_full_outer_2 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.id = t3.id)) otherCondition=()
--------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
----------PhysicalOlapScan[t] apply RFs: RF0
----------filter((t2.score > 10))
------------PhysicalOlapScan[t]
--------PhysicalDistribute
----------PhysicalOlapScan[t]

-- !left_outer_join_non_null_assertion --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
--------PhysicalOlapScan[t] apply RFs: RF0
--------filter(( not id IS NULL) and (t1.score > 5))
----------PhysicalOlapScan[t]

-- !right_outer_join_non_null_assertion --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
--------PhysicalOlapScan[t] apply RFs: RF0
--------filter(( not id IS NULL) and (t2.score > 5))
----------PhysicalOlapScan[t]

-- !full_outer_join_compound_conditions --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------filter(((t1.score > 5) OR (t2.score > 5)))
--------hashJoin[FULL_OUTER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=()
----------PhysicalOlapScan[t]
----------PhysicalOlapScan[t]

-- !multiple_joins_complex_conditions --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((t2.id = t3.id)) otherCondition=() build RFs:RF1 id->[id]
--------hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
----------PhysicalOlapScan[t] apply RFs: RF0 RF1
----------filter((t1.score > 5))
------------PhysicalOlapScan[t]
--------filter(( not score IS NULL))
----------PhysicalOlapScan[t]

-- !using_non_equijoin_conditions --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((expr_cast(score as BIGINT) = expr_(score + 10))) otherCondition=()
--------PhysicalProject
----------filter(( not id IS NULL))
------------PhysicalOlapScan[t]
--------PhysicalDistribute
----------PhysicalProject
------------PhysicalOlapScan[t]

-- !joining_multiple_tables_with_aggregate_functions --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------filter((count(id) > 1))
--------hashAgg[LOCAL]
----------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=()
------------PhysicalProject
--------------PhysicalOlapScan[t]
------------PhysicalProject
--------------PhysicalOlapScan[t]

-- !using_subqueries --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=()
--------filter(( not id IS NULL))
----------PhysicalOlapScan[t]
--------PhysicalProject
----------PhysicalOlapScan[t]

-- !left_outer --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
--------filter(( not name IS NULL))
----------PhysicalOlapScan[t] apply RFs: RF0
--------filter((t1.score > 10))
----------PhysicalOlapScan[t]

-- !right_outer --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
--------filter(( not name IS NULL))
----------PhysicalOlapScan[t] apply RFs: RF0
--------filter((t1.score > 10))
----------PhysicalOlapScan[t]

-- !full_outer --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
--------filter(( not name IS NULL))
----------PhysicalOlapScan[t] apply RFs: RF0
--------filter((t1.score > 10))
----------PhysicalOlapScan[t]

-- !self_left_outer --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((t1.id = t1_alias.id)) otherCondition=() build RFs:RF0 id->[id]
--------PhysicalOlapScan[t] apply RFs: RF0
--------filter((t1_alias.name > '2023-01-01'))
----------PhysicalOlapScan[t]

-- !right_outer_aggregate --
PhysicalResultSink
--PhysicalDistribute
----hashAgg[LOCAL]
------PhysicalProject
--------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=()
----------PhysicalProject
------------PhysicalOlapScan[t]
----------PhysicalProject
------------PhysicalOlapScan[t]

-- !full_outer_multiple_tables --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------filter(name IS NULL)
--------hashJoin[FULL_OUTER_JOIN] hashCondition=((t1.id = t3.id)) otherCondition=()
----------PhysicalDistribute
------------hashJoin[FULL_OUTER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=()
--------------PhysicalOlapScan[t]
--------------PhysicalOlapScan[t]
----------PhysicalDistribute
------------PhysicalOlapScan[t]

-- !left_outer_with_subquery --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
--------PhysicalOlapScan[t] apply RFs: RF0
--------PhysicalProject
----------filter((t2.score > 20))
------------PhysicalOlapScan[t]

-- !complex_join_conditions --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((expr_cast(score as BIGINT) = expr_(score * 2))) otherCondition=((t1.id < t2.id))
--------PhysicalProject
----------PhysicalOlapScan[t]
--------PhysicalDistribute
----------PhysicalProject
------------PhysicalOlapScan[t]

-- !multiple_outer_with_window_function --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------PhysicalWindow
--------PhysicalQuickSort[LOCAL_SORT]
----------PhysicalDistribute
------------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=()
--------------PhysicalProject
----------------PhysicalOlapScan[t]
--------------PhysicalProject
----------------PhysicalOlapScan[t]

-- !join_different_tables_non_null --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=() build RFs:RF0 id->[id]
--------PhysicalOlapScan[t] apply RFs: RF0
--------filter(( not name IS NULL))
----------PhysicalOlapScan[t]

Loading

0 comments on commit 667e3d7

Please sign in to comment.