diff --git a/fe/fe-core/src/test/java/com/starrocks/sql/plan/OuterJoinReorderTest.java b/fe/fe-core/src/test/java/com/starrocks/sql/plan/OuterJoinReorderTest.java index dcf62a6d07715..1ee62ef61307d 100644 --- a/fe/fe-core/src/test/java/com/starrocks/sql/plan/OuterJoinReorderTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/sql/plan/OuterJoinReorderTest.java @@ -16,10 +16,13 @@ import com.google.common.collect.Lists; import com.starrocks.common.FeConstants; -import org.junit.Test; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.util.List; +import java.util.stream.Stream; public class OuterJoinReorderTest extends PlanTestBase { @@ -30,8 +33,14 @@ public static void beforeClass() throws Exception { FeConstants.runningUnitTest = true; } - @Test - public void joinAssocRuleSqls() throws Exception { + @ParameterizedTest(name = "sql_{index}: {0}.") + @MethodSource("joinAssocRuleSqls") + void joinAssociativityRuleSql(String sql, String expectedPlan) throws Exception { + String plan = getFragmentPlan(sql); + assertContains(plan, expectedPlan); + } + + public static Stream joinAssocRuleSqls() { List sqlList = Lists.newArrayList(); List planList = Lists.newArrayList(); sqlList.add("select t1.* from t0 join t1 on v1 > v4 left join t2 on v1 < v7 "); @@ -52,7 +61,7 @@ public void joinAssocRuleSqls() throws Exception { sqlList.add("select * from t0 left join (select v4 from t1 union select v7 from t2) t1 on v2 > v4 " + "left semi join t2 on v1 = v7"); planList.add("3:HASH JOIN\n" + - " | join op: LEFT SEMI JOIN (BROADCAST)\n" + + " | join op: LEFT SEMI JOIN (BUCKET_SHUFFLE)\n" + " | colocate: false, reason: \n" + " | equal join conjunct: 1: v1 = 11: v7"); sqlList.add("select subq_0.v1 as c0 from (select 88 as v1 from t0 as ref_0) as subq_0 inner join t1 as ref_1 " + @@ -84,7 +93,7 @@ public void joinAssocRuleSqls() throws Exception { sqlList.add("select tmp.a, t0.v3 from t0 left join (select * from tarray, unnest(v3) as unnest_tbl(a)) " + "tmp on t0.v1 = tmp.a join t1 on t0.v2 = t1.v4"); planList.add("8:HASH JOIN\n" + - " | join op: LEFT OUTER JOIN (BROADCAST)\n" + + " | join op: LEFT OUTER JOIN (BUCKET_SHUFFLE)\n" + " | colocate: false, reason: \n" + " | equal join conjunct: 1: v1 = 7: a\n" + " | \n" + @@ -97,12 +106,12 @@ public void joinAssocRuleSqls() throws Exception { " 3:HASH JOIN"); sqlList.add("select t0.* from t0 left join t1 on t0.v1 = t1.v4 join t2 on t0.v1 = t2.v7 " + "where t0.v2 in (select max(v10) from t3) and t1.v5 is null;"); - planList.add(" 12:HASH JOIN\n" + + planList.add(" 14:HASH JOIN\n" + " | join op: LEFT SEMI JOIN (BROADCAST)\n" + " | colocate: false, reason: \n" + " | equal join conjunct: 2: v2 = 13: max\n" + " | \n" + - " |----11:EXCHANGE\n" + + " |----13:EXCHANGE\n" + " | \n" + " 8:Project\n" + " | : 1: v1\n" + @@ -110,25 +119,25 @@ public void joinAssocRuleSqls() throws Exception { " | : 3: v3\n" + " | \n" + " 7:HASH JOIN\n" + - " | join op: LEFT OUTER JOIN (BROADCAST)\n" + + " | join op: LEFT OUTER JOIN (BUCKET_SHUFFLE)\n" + " | colocate: false, reason: \n" + " | equal join conjunct: 1: v1 = 4: v4\n" + " | other predicates: 5: v5 IS NULL"); sqlList.add("select t0.*, t1.v5 from t0 join t1 on t0.v1 = t1.v4 left join t2 on t1.v5 = t2.v7 " + "where t2.v8 <=> t0.v2 and t0.v3 in (select max(v10) from t3) and t1.v5 is null"); - planList.add("13:Project\n" + + planList.add("15:Project\n" + " | : 1: v1\n" + " | : 2: v2\n" + " | : 3: v3\n" + " | : 5: v5\n" + " | \n" + - " 12:HASH JOIN\n" + + " 14:HASH JOIN\n" + " | join op: LEFT OUTER JOIN (BROADCAST)\n" + " | colocate: false, reason: \n" + " | equal join conjunct: 5: v5 = 7: v7\n" + " | other predicates: 8: v8 <=> 2: v2\n" + " | \n" + - " |----11:EXCHANGE"); + " |----13:EXCHANGE"); sqlList.add("select * from (select t0.*, concat(abs(abs(v7)), ifnull(v8, 1), null) from colocate_t0 t0 left join" + " t2 on v2 = v7) t left join colocate_t1 on v1 = v4"); planList.add("4:Project\n" + @@ -141,11 +150,7 @@ public void joinAssocRuleSqls() throws Exception { " | join op: LEFT OUTER JOIN (BROADCAST)\n" + " | colocate: false, reason: \n" + " | equal join conjunct: 2: v2 = 4: v7"); - for (int i = 0; i < sqlList.size(); i++) { - String sql = sqlList.get(i); - String expectedPlan = planList.get(i); - String plan = getFragmentPlan(sql); - assertContains(plan, expectedPlan); - } + List zips = zipSqlAndPlan(sqlList, planList); + return zips.stream(); } }