Skip to content

Commit

Permalink
[Fix](Nereids) fix test leading change disable join reorder parameter (
Browse files Browse the repository at this point in the history
…apache#23657)

Problem:
when running pipeline, we get randomly failed of test_leading
Reason:
physical distribute was generated and choosed to be the best plan because we can not get any statistic information of empty table. So we would get some unexpect result because we can not expect the order in memo
Solved:
Add statistic of columns used in test_leading, try repeatly in pipeline
  • Loading branch information
LiBinfeng-01 committed Nov 30, 2023
1 parent 97412d8 commit 3e50dc6
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.doris.nereids.rules.rewrite;

import org.apache.doris.common.DdlException;
import org.apache.doris.nereids.hint.Hint;
import org.apache.doris.nereids.hint.LeadingHint;
import org.apache.doris.nereids.jobs.JobContext;
Expand All @@ -41,7 +42,12 @@ public Plan rewriteRoot(Plan plan, JobContext jobContext) {
(LeadingHint) leadingHint, ((LeadingHint) leadingHint)
.getLeadingTableBitmap(jobContext.getCascadesContext().getTables())));
if (leadingHint.isSuccess()) {
jobContext.getCascadesContext().getConnectContext().getSessionVariable().setDisableJoinReorder(true);
try {
jobContext.getCascadesContext().getConnectContext().getSessionVariable()
.disableNereidsJoinReorderOnce();
} catch (DdlException e) {
throw new RuntimeException(e);
}
} else {
return plan;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2668,6 +2668,14 @@ public void disableNereidsPlannerOnce() throws DdlException {
VariableMgr.setVar(this, new SetVar(SessionVariable.ENABLE_NEREIDS_PLANNER, new StringLiteral("false")));
}

public void disableNereidsJoinReorderOnce() throws DdlException {
if (!enableNereidsPlanner) {
return;
}
setIsSingleSetVar(true);
VariableMgr.setVar(this, new SetVar(SessionVariable.DISABLE_JOIN_REORDER, new StringLiteral("false")));
}

// return number of variables by given experimental type
public int getVariableNumByExperimentalType(ExperimentalType type) {
int num = 0;
Expand Down
151 changes: 75 additions & 76 deletions regression-test/data/nereids_p0/hint/test_leading.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t1.c1 = t2.c2)
------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
--------PhysicalOlapScan[t2]
--------PhysicalDistribute
----------PhysicalOlapScan[t1]
Expand All @@ -16,7 +16,7 @@ SyntaxError:
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t1.c1 = t2.c2)
------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
--------PhysicalOlapScan[t1]
--------PhysicalDistribute
----------PhysicalOlapScan[t2]
Expand All @@ -29,8 +29,8 @@ SyntaxError:
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t2.c2 = t3.c3)
--------hashJoin[INNER_JOIN](t1.c1 = t2.c2)
------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3))otherCondition=()
--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
----------PhysicalOlapScan[t1]
----------PhysicalDistribute
------------PhysicalOlapScan[t2]
Expand All @@ -45,13 +45,13 @@ SyntaxError:
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t1.c1 = t2.c2)
--------PhysicalOlapScan[t1]
------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3))otherCondition=()
----------PhysicalOlapScan[t2]
----------PhysicalDistribute
------------PhysicalOlapScan[t3]
--------PhysicalDistribute
----------hashJoin[INNER_JOIN](t2.c2 = t3.c3)
------------PhysicalOlapScan[t2]
------------PhysicalDistribute
--------------PhysicalOlapScan[t3]
----------PhysicalOlapScan[t1]

Used: leading(t1 { t2 t3 })
UnUsed:
Expand All @@ -61,15 +61,14 @@ SyntaxError:
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t3.c3 = t4.c4)
--------PhysicalDistribute
----------hashJoin[INNER_JOIN](t1.c1 = t2.c2)
------------PhysicalOlapScan[t1]
------hashJoin[INNER_JOIN] hashCondition=((t3.c3 = t4.c4))otherCondition=()
--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
----------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3))otherCondition=()
------------PhysicalOlapScan[t2]
------------PhysicalDistribute
--------------hashJoin[INNER_JOIN](t2.c2 = t3.c3)
----------------PhysicalOlapScan[t2]
----------------PhysicalDistribute
------------------PhysicalOlapScan[t3]
--------------PhysicalOlapScan[t3]
----------PhysicalDistribute
------------PhysicalOlapScan[t1]
--------PhysicalDistribute
----------PhysicalOlapScan[t4]

Expand All @@ -81,13 +80,13 @@ SyntaxError:
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t2.c2 = t3.c3)
--------hashJoin[INNER_JOIN](t1.c1 = t2.c2)
------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3))otherCondition=()
--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
----------PhysicalOlapScan[t1]
----------PhysicalDistribute
------------PhysicalOlapScan[t2]
--------PhysicalDistribute
----------hashJoin[INNER_JOIN](t3.c3 = t4.c4)
----------hashJoin[INNER_JOIN] hashCondition=((t3.c3 = t4.c4))otherCondition=()
------------PhysicalOlapScan[t3]
------------PhysicalDistribute
--------------PhysicalOlapScan[t4]
Expand All @@ -100,13 +99,13 @@ SyntaxError:
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t2.c2 = t3.c3)
--------hashJoin[INNER_JOIN](t1.c1 = t2.c2)
------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3))otherCondition=()
--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
----------PhysicalOlapScan[t1]
----------PhysicalDistribute
------------PhysicalOlapScan[t2]
--------PhysicalDistribute
----------hashJoin[INNER_JOIN](t3.c3 = t4.c4)
----------hashJoin[INNER_JOIN] hashCondition=((t3.c3 = t4.c4))otherCondition=()
------------PhysicalOlapScan[t3]
------------PhysicalDistribute
--------------PhysicalOlapScan[t4]
Expand All @@ -119,8 +118,8 @@ SyntaxError:
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t1.c1 = t3.c3)
--------hashJoin[LEFT_OUTER_JOIN](t1.c1 = t2.c2)
------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t3.c3))otherCondition=()
--------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
----------PhysicalOlapScan[t1]
----------PhysicalDistribute
------------PhysicalOlapScan[t2]
Expand All @@ -131,8 +130,8 @@ PhysicalResultSink
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN](t1.c1 = t2.c2)
--------hashJoin[INNER_JOIN](t1.c1 = t3.c3)
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t3.c3))otherCondition=()
----------PhysicalOlapScan[t1]
----------PhysicalDistribute
------------PhysicalOlapScan[t3]
Expand All @@ -147,8 +146,8 @@ SyntaxError:
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN](t1.c1 = t3.c3)
--------hashJoin[LEFT_OUTER_JOIN](t1.c1 = t2.c2)
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.c1 = t3.c3))otherCondition=()
--------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
----------PhysicalOlapScan[t1]
----------PhysicalDistribute
------------PhysicalOlapScan[t2]
Expand All @@ -159,8 +158,8 @@ PhysicalResultSink
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN](t1.c1 = t2.c2)
--------hashJoin[LEFT_OUTER_JOIN](t1.c1 = t3.c3)
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
--------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.c1 = t3.c3))otherCondition=()
----------PhysicalOlapScan[t1]
----------PhysicalDistribute
------------PhysicalOlapScan[t3]
Expand All @@ -175,14 +174,13 @@ SyntaxError:
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN](t2.c2 = t3.c3)
--------PhysicalDistribute
----------hashJoin[LEFT_OUTER_JOIN](t1.c1 = t2.c2)
------------PhysicalOlapScan[t1]
------------PhysicalDistribute
--------------PhysicalOlapScan[t2]
------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
--------hashJoin[LEFT_OUTER_JOIN] hashCondition=((t2.c2 = t3.c3))otherCondition=()
----------PhysicalOlapScan[t2]
----------PhysicalDistribute
------------PhysicalOlapScan[t3]
--------PhysicalDistribute
----------PhysicalOlapScan[t3]
----------PhysicalOlapScan[t1]

Used:
UnUsed: leading(t1 { t2 t3 })
Expand All @@ -192,13 +190,13 @@ SyntaxError:
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t1.c1 = t2.c2)
--------PhysicalOlapScan[t1]
------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3))otherCondition=()
----------PhysicalOlapScan[t2]
----------PhysicalDistribute
------------PhysicalOlapScan[t3]
--------PhysicalDistribute
----------hashJoin[INNER_JOIN](t2.c2 = t3.c3)
------------PhysicalOlapScan[t2]
------------PhysicalDistribute
--------------PhysicalOlapScan[t3]
----------PhysicalOlapScan[t1]

Used: leading(t1 { t2 t3 })
UnUsed:
Expand All @@ -208,25 +206,25 @@ SyntaxError:
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN](t1.c1 = tmp.c2)
--------PhysicalOlapScan[t1]
------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t1.c1 = tmp.c2))otherCondition=()
--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3))otherCondition=()
----------PhysicalOlapScan[t2]
----------PhysicalDistribute
------------PhysicalOlapScan[t3]
--------PhysicalDistribute
----------hashJoin[INNER_JOIN](t2.c2 = t3.c3)
------------PhysicalOlapScan[t2]
------------PhysicalDistribute
--------------PhysicalOlapScan[t3]
----------PhysicalOlapScan[t1]

-- !select15 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN](t1.c1 = tmp.c2)
--------PhysicalOlapScan[t1]
------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t1.c1 = tmp.c2))otherCondition=()
--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3))otherCondition=()
----------PhysicalOlapScan[t2]
----------PhysicalDistribute
------------PhysicalOlapScan[t3]
--------PhysicalDistribute
----------hashJoin[INNER_JOIN](t2.c2 = t3.c3)
------------PhysicalOlapScan[t2]
------------PhysicalDistribute
--------------PhysicalOlapScan[t3]
----------PhysicalOlapScan[t1]

Used:
UnUsed: leading(t1 t2 t3)
Expand All @@ -236,7 +234,7 @@ SyntaxError:
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_SEMI_JOIN](t1.c1 = t2.c2)
------hashJoin[LEFT_SEMI_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
--------PhysicalOlapScan[t1]
--------PhysicalDistribute
----------PhysicalProject
Expand All @@ -246,11 +244,11 @@ PhysicalResultSink
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[RIGHT_SEMI_JOIN](t1.c1 = t2.c2)
--------PhysicalProject
----------PhysicalOlapScan[t2]
------hashJoin[LEFT_SEMI_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
--------PhysicalOlapScan[t1]
--------PhysicalDistribute
----------PhysicalOlapScan[t1]
----------PhysicalProject
------------PhysicalOlapScan[t2]

Used: leading(t2 t1)
UnUsed:
Expand All @@ -274,10 +272,10 @@ PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------NestedLoopJoin[CROSS_JOIN]
--------PhysicalProject
----------PhysicalOlapScan[t2]
--------PhysicalOlapScan[t1]
--------PhysicalDistribute
----------PhysicalOlapScan[t1]
----------PhysicalProject
------------PhysicalOlapScan[t2]

Used: leading(t2 t1)
UnUsed:
Expand All @@ -288,7 +286,7 @@ PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------NestedLoopJoin[CROSS_JOIN]
--------hashJoin[INNER_JOIN](cte.c1 = cte.c2)
--------hashJoin[INNER_JOIN] hashCondition=((cte.c1 = cte.c2))otherCondition=()
----------PhysicalProject
------------PhysicalOlapScan[t1]
----------PhysicalDistribute
Expand Down Expand Up @@ -319,7 +317,7 @@ SyntaxError:
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t1.c1 = t2.c2)
------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
--------PhysicalOlapScan[t1]
--------PhysicalDistribute
----------PhysicalOlapScan[t2]
Expand All @@ -332,7 +330,7 @@ SyntaxError: leading(t66 t1) Msg:can not find table: t66
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t1.c1 = t2.c2)
------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
--------PhysicalOlapScan[t1]
--------PhysicalDistribute
----------PhysicalOlapScan[t2]
Expand All @@ -346,7 +344,7 @@ PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------NestedLoopJoin[CROSS_JOIN]
--------hashJoin[INNER_JOIN](cte.c1 = cte.c2)
--------hashJoin[INNER_JOIN] hashCondition=((cte.c1 = cte.c2))otherCondition=()
----------PhysicalProject
------------PhysicalOlapScan[t1]
----------PhysicalDistribute
Expand All @@ -363,8 +361,8 @@ SyntaxError: leading(t2 cte t1) Msg:Leading alias can only be table name alias
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t2.c2 = t3.c3)
--------hashJoin[INNER_JOIN](t1.c1 = t2.c2)
------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3))otherCondition=()
--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
----------PhysicalOlapScan[t1]
----------PhysicalDistribute
------------PhysicalOlapScan[t2]
Expand All @@ -379,8 +377,8 @@ SyntaxError: leading(t1 t2) Msg:tables should be same as join tables
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t2.c2 = t3.c3)
--------hashJoin[INNER_JOIN](t1.c1 = t2.c2)
------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3))otherCondition=()
--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2))otherCondition=()
----------PhysicalOlapScan[t1]
----------PhysicalDistribute
------------PhysicalOlapScan[t2]
Expand All @@ -395,7 +393,7 @@ SyntaxError: leading(t1 t1 t2 t3) Msg:duplicated table
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t1.c1 = t_2.c2)
------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t_2.c2))otherCondition=()
--------PhysicalOlapScan[t1]
--------PhysicalDistribute
----------PhysicalOlapScan[t2]
Expand All @@ -408,7 +406,7 @@ SyntaxError:
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t1.c1 = t_2.c2)
------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t_2.c2))otherCondition=()
--------PhysicalOlapScan[t1]
--------PhysicalDistribute
----------PhysicalOlapScan[t2]
Expand All @@ -421,10 +419,11 @@ SyntaxError: leading(t1 t2) Msg:can not find table: t2
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN](t1.c1 = t_1.c1)
------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t_1.c1))otherCondition=()
--------PhysicalOlapScan[t1]
--------PhysicalOlapScan[t1]

Used: leading(t1 t_1)
UnUsed:
SyntaxError:

Loading

0 comments on commit 3e50dc6

Please sign in to comment.