Skip to content

Commit

Permalink
[Fix](Nereids) fix test leading suite and add tpch shape checking bas…
Browse files Browse the repository at this point in the history
…e on leading (apache#25842)

- fix test leading suite caused by sessionvariable setting error
- add tpch shape checking base on leading
  • Loading branch information
LiBinfeng-01 authored Oct 25, 2023
1 parent 235ae9d commit 3b9ae91
Show file tree
Hide file tree
Showing 38 changed files with 1,661 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ public Long getLeadingTableBitmap(List<TableIf> tables) {
this.setErrorMessage("duplicated table");
return totalBitmap;
}
if (getTablelist().size() != tables.size()) {
if (tables != null && getTablelist().size() != tables.size()) {
this.setStatus(HintStatus.SYNTAX_ERROR);
this.setErrorMessage("tables should be same as join tables");
return totalBitmap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2676,7 +2676,7 @@ public void disableNereidsJoinReorderOnce() throws DdlException {
return;
}
setIsSingleSetVar(true);
VariableMgr.setVar(this, new SetVar(SessionVariable.DISABLE_JOIN_REORDER, new StringLiteral("false")));
VariableMgr.setVar(this, new SetVar(SessionVariable.DISABLE_JOIN_REORDER, new StringLiteral("true")));
}

// return number of variables by given variable annotation
Expand Down
13 changes: 13 additions & 0 deletions regression-test/data/nereids_hint_tpch_p0/shape/q1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
PhysicalResultSink
--PhysicalQuickSort
----PhysicalDistribute
------PhysicalQuickSort
--------hashAgg[GLOBAL]
----------PhysicalDistribute
------------hashAgg[LOCAL]
--------------PhysicalProject
----------------filter((lineitem.l_shipdate <= '1998-09-02'))
------------------PhysicalOlapScan[lineitem]

34 changes: 34 additions & 0 deletions regression-test/data/nereids_hint_tpch_p0/shape/q10.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
PhysicalResultSink
--PhysicalTopN
----PhysicalDistribute
------PhysicalTopN
--------hashAgg[GLOBAL]
----------PhysicalDistribute
------------hashAgg[LOCAL]
--------------PhysicalProject
----------------hashJoin[INNER_JOIN] hashCondition=((lineitem.l_orderkey = orders.o_orderkey))otherCondition=()
------------------PhysicalProject
--------------------filter((lineitem.l_returnflag = 'R'))
----------------------PhysicalOlapScan[lineitem]
------------------PhysicalDistribute
--------------------PhysicalProject
----------------------hashJoin[INNER_JOIN] hashCondition=((customer.c_nationkey = nation.n_nationkey))otherCondition=()
------------------------PhysicalDistribute
--------------------------PhysicalProject
----------------------------hashJoin[INNER_JOIN] hashCondition=((customer.c_custkey = orders.o_custkey))otherCondition=()
------------------------------PhysicalProject
--------------------------------PhysicalOlapScan[customer]
------------------------------PhysicalDistribute
--------------------------------PhysicalProject
----------------------------------filter((orders.o_orderdate < '1994-01-01') and (orders.o_orderdate >= '1993-10-01'))
------------------------------------PhysicalOlapScan[orders]
------------------------PhysicalDistribute
--------------------------PhysicalProject
----------------------------PhysicalOlapScan[nation]

Used: leading(lineitem { { customer orders } nation })
UnUsed:
SyntaxError:

46 changes: 46 additions & 0 deletions regression-test/data/nereids_hint_tpch_p0/shape/q11.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
PhysicalResultSink
--PhysicalQuickSort
----PhysicalDistribute
------PhysicalQuickSort
--------PhysicalProject
----------NestedLoopJoin[INNER_JOIN](cast(value as DOUBLE) > cast((sum((ps_supplycost * ps_availqty)) * 0.000002) as DOUBLE))
------------hashAgg[GLOBAL]
--------------PhysicalDistribute
----------------hashAgg[LOCAL]
------------------PhysicalProject
--------------------hashJoin[INNER_JOIN](partsupp.ps_suppkey = supplier.s_suppkey)
----------------------PhysicalDistribute
------------------------PhysicalProject
--------------------------PhysicalOlapScan[partsupp]
----------------------PhysicalDistribute
------------------------hashJoin[INNER_JOIN](supplier.s_nationkey = nation.n_nationkey)
--------------------------PhysicalDistribute
----------------------------PhysicalProject
------------------------------PhysicalOlapScan[supplier]
--------------------------PhysicalDistribute
----------------------------PhysicalProject
------------------------------filter((nation.n_name = 'GERMANY'))
--------------------------------PhysicalOlapScan[nation]
------------PhysicalDistribute
--------------PhysicalAssertNumRows
----------------PhysicalProject
------------------hashAgg[GLOBAL]
--------------------PhysicalDistribute
----------------------hashAgg[LOCAL]
------------------------PhysicalProject
--------------------------hashJoin[INNER_JOIN](partsupp.ps_suppkey = supplier.s_suppkey)
----------------------------PhysicalDistribute
------------------------------PhysicalProject
--------------------------------PhysicalOlapScan[partsupp]
----------------------------PhysicalDistribute
------------------------------hashJoin[INNER_JOIN](supplier.s_nationkey = nation.n_nationkey)
--------------------------------PhysicalDistribute
----------------------------------PhysicalProject
------------------------------------PhysicalOlapScan[supplier]
--------------------------------PhysicalDistribute
----------------------------------PhysicalProject
------------------------------------filter((nation.n_name = 'GERMANY'))
--------------------------------------PhysicalOlapScan[nation]

21 changes: 21 additions & 0 deletions regression-test/data/nereids_hint_tpch_p0/shape/q12.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
PhysicalResultSink
--PhysicalQuickSort
----PhysicalDistribute
------PhysicalQuickSort
--------hashAgg[GLOBAL]
----------PhysicalDistribute
------------hashAgg[LOCAL]
--------------PhysicalProject
----------------hashJoin[INNER_JOIN] hashCondition=((orders.o_orderkey = lineitem.l_orderkey))otherCondition=()
------------------PhysicalProject
--------------------PhysicalOlapScan[orders]
------------------PhysicalProject
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
----------------------PhysicalOlapScan[lineitem]

Used: leading(orders lineitem)
UnUsed:
SyntaxError:

25 changes: 25 additions & 0 deletions regression-test/data/nereids_hint_tpch_p0/shape/q13.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
PhysicalResultSink
--PhysicalQuickSort
----PhysicalDistribute
------PhysicalQuickSort
--------hashAgg[GLOBAL]
----------PhysicalDistribute
------------hashAgg[LOCAL]
--------------PhysicalProject
----------------hashAgg[LOCAL]
------------------PhysicalProject
--------------------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((customer.c_custkey = orders.o_custkey))otherCondition=()
----------------------PhysicalDistribute
------------------------PhysicalProject
--------------------------filter(( not (o_comment like '%special%requests%')))
----------------------------PhysicalOlapScan[orders]
----------------------PhysicalDistribute
------------------------PhysicalProject
--------------------------PhysicalOlapScan[customer]

Used: leading(orders customer)
UnUsed:
SyntaxError:

20 changes: 20 additions & 0 deletions regression-test/data/nereids_hint_tpch_p0/shape/q14.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
PhysicalResultSink
--PhysicalProject
----hashAgg[GLOBAL]
------PhysicalDistribute
--------hashAgg[LOCAL]
----------PhysicalProject
------------hashJoin[INNER_JOIN] hashCondition=((lineitem.l_partkey = part.p_partkey))otherCondition=()
--------------PhysicalProject
----------------PhysicalOlapScan[part]
--------------PhysicalDistribute
----------------PhysicalProject
------------------filter((lineitem.l_shipdate < '1995-10-01') and (lineitem.l_shipdate >= '1995-09-01'))
--------------------PhysicalOlapScan[lineitem]

Used: leading(part lineitem)
UnUsed:
SyntaxError:

31 changes: 31 additions & 0 deletions regression-test/data/nereids_hint_tpch_p0/shape/q15.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
PhysicalResultSink
--PhysicalQuickSort
----PhysicalDistribute
------PhysicalQuickSort
--------PhysicalProject
----------hashJoin[INNER_JOIN](supplier.s_suppkey = revenue0.supplier_no)
------------PhysicalProject
--------------PhysicalOlapScan[supplier]
------------PhysicalDistribute
--------------hashJoin[INNER_JOIN](revenue0.total_revenue = max(total_revenue))
----------------hashAgg[GLOBAL]
------------------PhysicalDistribute
--------------------hashAgg[LOCAL]
----------------------PhysicalProject
------------------------filter((lineitem.l_shipdate >= 1996-01-01)(lineitem.l_shipdate < 1996-04-01))
--------------------------PhysicalOlapScan[lineitem]
----------------PhysicalDistribute
------------------PhysicalAssertNumRows
--------------------hashAgg[GLOBAL]
----------------------PhysicalDistribute
------------------------hashAgg[LOCAL]
--------------------------PhysicalProject
----------------------------hashAgg[GLOBAL]
------------------------------PhysicalDistribute
--------------------------------hashAgg[LOCAL]
----------------------------------PhysicalProject
------------------------------------filter((lineitem.l_shipdate >= 1996-01-01)(lineitem.l_shipdate < 1996-04-01))
--------------------------------------PhysicalOlapScan[lineitem]

27 changes: 27 additions & 0 deletions regression-test/data/nereids_hint_tpch_p0/shape/q16.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
PhysicalResultSink
--PhysicalQuickSort
----PhysicalDistribute
------PhysicalQuickSort
--------hashAgg[GLOBAL]
----------PhysicalDistribute
------------hashAgg[LOCAL]
--------------hashJoin[LEFT_ANTI_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
----------------PhysicalDistribute
------------------PhysicalProject
--------------------hashJoin[INNER_JOIN] hashCondition=((part.p_partkey = partsupp.ps_partkey))otherCondition=()
----------------------PhysicalProject
------------------------PhysicalOlapScan[partsupp]
----------------------PhysicalProject
------------------------filter(( not (p_brand = 'Brand#45')) and ( not (p_type like 'MEDIUM POLISHED%')) and p_size IN (14, 19, 23, 3, 36, 45, 49, 9))
--------------------------PhysicalOlapScan[part]
----------------PhysicalDistribute
------------------PhysicalProject
--------------------filter((s_comment like '%Customer%Complaints%'))
----------------------PhysicalOlapScan[supplier]

Used: leading(partsupp part supplier)
UnUsed:
SyntaxError:

21 changes: 21 additions & 0 deletions regression-test/data/nereids_hint_tpch_p0/shape/q17.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
PhysicalResultSink
--PhysicalProject
----hashAgg[GLOBAL]
------PhysicalDistribute
--------hashAgg[LOCAL]
----------PhysicalProject
------------filter((cast(l_quantity as DECIMALV3(38, 5)) < (0.2 * avg(cast(l_quantity as DECIMALV3(17, 4))) OVER(PARTITION BY p_partkey))))
--------------PhysicalWindow
----------------PhysicalQuickSort
------------------PhysicalDistribute
--------------------PhysicalProject
----------------------hashJoin[INNER_JOIN](part.p_partkey = lineitem.l_partkey)
------------------------PhysicalProject
--------------------------PhysicalOlapScan[lineitem]
------------------------PhysicalDistribute
--------------------------PhysicalProject
----------------------------filter((part.p_container = 'MED BOX')(part.p_brand = 'Brand#23'))
------------------------------PhysicalOlapScan[part]

26 changes: 26 additions & 0 deletions regression-test/data/nereids_hint_tpch_p0/shape/q18.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
PhysicalResultSink
--PhysicalTopN
----PhysicalDistribute
------PhysicalTopN
--------hashAgg[LOCAL]
----------PhysicalProject
------------hashJoin[INNER_JOIN](orders.o_orderkey = lineitem.l_orderkey)
--------------PhysicalProject
----------------PhysicalOlapScan[lineitem]
--------------PhysicalDistribute
----------------PhysicalProject
------------------hashJoin[INNER_JOIN](customer.c_custkey = orders.o_custkey)
--------------------PhysicalProject
----------------------PhysicalOlapScan[customer]
--------------------PhysicalDistribute
----------------------hashJoin[LEFT_SEMI_JOIN](orders.o_orderkey = lineitem.l_orderkey)
------------------------PhysicalProject
--------------------------PhysicalOlapScan[orders]
------------------------PhysicalProject
--------------------------filter((sum(l_quantity) > 300.00))
----------------------------hashAgg[LOCAL]
------------------------------PhysicalProject
--------------------------------PhysicalOlapScan[lineitem]

21 changes: 21 additions & 0 deletions regression-test/data/nereids_hint_tpch_p0/shape/q19.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
PhysicalResultSink
--hashAgg[GLOBAL]
----PhysicalDistribute
------hashAgg[LOCAL]
--------PhysicalProject
----------hashJoin[INNER_JOIN] hashCondition=((part.p_partkey = lineitem.l_partkey))otherCondition=(((((((part.p_brand = 'Brand#12') AND p_container IN ('SM BOX', 'SM CASE', 'SM PACK', 'SM PKG')) AND ((lineitem.l_quantity >= 1.00) AND (lineitem.l_quantity <= 11.00))) AND (part.p_size <= 5)) OR ((((part.p_brand = 'Brand#23') AND p_container IN ('MED BAG', 'MED BOX', 'MED PACK', 'MED PKG')) AND ((lineitem.l_quantity >= 10.00) AND (lineitem.l_quantity <= 20.00))) AND (part.p_size <= 10))) OR ((((part.p_brand = 'Brand#34') AND p_container IN ('LG BOX', 'LG CASE', 'LG PACK', 'LG PKG')) AND ((lineitem.l_quantity >= 20.00) AND (lineitem.l_quantity <= 30.00))) AND (part.p_size <= 15))))
------------PhysicalDistribute
--------------PhysicalProject
----------------filter(((((lineitem.l_quantity >= 1.00) AND (lineitem.l_quantity <= 11.00)) OR ((lineitem.l_quantity >= 10.00) AND (lineitem.l_quantity <= 20.00))) OR ((lineitem.l_quantity >= 20.00) AND (lineitem.l_quantity <= 30.00))) and (lineitem.l_shipinstruct = 'DELIVER IN PERSON') and l_shipmode IN ('AIR REG', 'AIR'))
------------------PhysicalOlapScan[lineitem]
------------PhysicalDistribute
--------------PhysicalProject
----------------filter((((((part.p_brand = 'Brand#12') AND p_container IN ('SM BOX', 'SM CASE', 'SM PACK', 'SM PKG')) AND (part.p_size <= 5)) OR (((part.p_brand = 'Brand#23') AND p_container IN ('MED BAG', 'MED BOX', 'MED PACK', 'MED PKG')) AND (part.p_size <= 10))) OR (((part.p_brand = 'Brand#34') AND p_container IN ('LG BOX', 'LG CASE', 'LG PACK', 'LG PKG')) AND (part.p_size <= 15))) and (part.p_size >= 1))
------------------PhysicalOlapScan[part]

Used: leading(lineitem part)
UnUsed:
SyntaxError:

39 changes: 39 additions & 0 deletions regression-test/data/nereids_hint_tpch_p0/shape/q2.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
PhysicalResultSink
--PhysicalTopN
----PhysicalDistribute
------PhysicalTopN
--------PhysicalProject
----------filter((partsupp.ps_supplycost = min(ps_supplycost) OVER(PARTITION BY p_partkey)))
------------PhysicalWindow
--------------PhysicalQuickSort
----------------PhysicalDistribute
------------------PhysicalProject
--------------------hashJoin[INNER_JOIN](nation.n_regionkey = region.r_regionkey)
----------------------PhysicalDistribute
------------------------PhysicalProject
--------------------------hashJoin[INNER_JOIN](supplier.s_nationkey = nation.n_nationkey)
----------------------------PhysicalDistribute
------------------------------PhysicalProject
--------------------------------hashJoin[INNER_JOIN](part.p_partkey = partsupp.ps_partkey)(supplier.s_suppkey = partsupp.ps_suppkey)
----------------------------------NestedLoopJoin[CROSS_JOIN]
------------------------------------PhysicalProject
--------------------------------------filter((part.p_size = 15)(p_type like '%BRASS'))
----------------------------------------PhysicalOlapScan[part]
------------------------------------PhysicalDistribute
--------------------------------------PhysicalOlapScan[supplier]
----------------------------------PhysicalProject
------------------------------------PhysicalOlapScan[partsupp]
----------------------------PhysicalDistribute
------------------------------PhysicalProject
--------------------------------PhysicalOlapScan[nation]
----------------------PhysicalDistribute
------------------------PhysicalProject
--------------------------filter((region.r_name = 'EUROPE'))
----------------------------PhysicalOlapScan[region]

Used: leading({ supplier { nation region } } { partsupp part })
UnUsed:
SyntaxError:

34 changes: 34 additions & 0 deletions regression-test/data/nereids_hint_tpch_p0/shape/q20.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
PhysicalResultSink
--PhysicalQuickSort
----PhysicalDistribute
------PhysicalQuickSort
--------PhysicalProject
----------hashJoin[RIGHT_SEMI_JOIN](supplier.s_suppkey = partsupp.ps_suppkey)
------------PhysicalDistribute
--------------PhysicalProject
----------------hashJoin[INNER_JOIN](lineitem.l_partkey = partsupp.ps_partkey)(lineitem.l_suppkey = partsupp.ps_suppkey)(cast(ps_availqty as DECIMALV3(38, 3)) > (0.5 * sum(l_quantity)))
------------------PhysicalProject
--------------------hashAgg[GLOBAL]
----------------------PhysicalDistribute
------------------------hashAgg[LOCAL]
--------------------------PhysicalProject
----------------------------filter((lineitem.l_shipdate < 1995-01-01)(lineitem.l_shipdate >= 1994-01-01))
------------------------------PhysicalOlapScan[lineitem]
------------------PhysicalDistribute
--------------------hashJoin[LEFT_SEMI_JOIN](partsupp.ps_partkey = part.p_partkey)
----------------------PhysicalProject
------------------------PhysicalOlapScan[partsupp]
----------------------PhysicalProject
------------------------filter((p_name like 'forest%'))
--------------------------PhysicalOlapScan[part]
------------PhysicalDistribute
--------------hashJoin[INNER_JOIN](supplier.s_nationkey = nation.n_nationkey)
----------------PhysicalProject
------------------PhysicalOlapScan[supplier]
----------------PhysicalDistribute
------------------PhysicalProject
--------------------filter((nation.n_name = 'CANADA'))
----------------------PhysicalOlapScan[nation]

Loading

0 comments on commit 3b9ae91

Please sign in to comment.