Skip to content

Commit

Permalink
[fix](Nereids): fix regression-test (apache#24065)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwener authored Sep 8, 2023
1 parent 2965b9b commit 576855a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import org.apache.doris.nereids.rules.implementation.LogicalTopNToPhysicalTopN;
import org.apache.doris.nereids.rules.implementation.LogicalUnionToPhysicalUnion;
import org.apache.doris.nereids.rules.implementation.LogicalWindowToPhysicalWindow;
import org.apache.doris.nereids.rules.rewrite.ConvertOuterJoinToAntiJoin;
import org.apache.doris.nereids.rules.rewrite.EliminateOuterJoin;
import org.apache.doris.nereids.rules.rewrite.MergeFilters;
import org.apache.doris.nereids.rules.rewrite.MergeGenerates;
Expand All @@ -89,7 +90,6 @@
import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughWindow;
import org.apache.doris.nereids.rules.rewrite.PushdownJoinOtherCondition;
import org.apache.doris.nereids.rules.rewrite.PushdownProjectThroughLimit;
import org.apache.doris.nereids.rules.rewrite.TransformOuterJoinToAntiJoin;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
Expand Down Expand Up @@ -132,7 +132,7 @@ public class RuleSet {
new PushdownFilterThroughWindow(),
new PushdownProjectThroughLimit(),
new EliminateOuterJoin(),
new TransformOuterJoinToAntiJoin(),
new ConvertOuterJoinToAntiJoin(),
new MergeProjects(),
new MergeFilters(),
new MergeGenerates(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public enum RuleType {
ELIMINATE_OUTER_JOIN(RuleTypeClass.REWRITE),
ELIMINATE_DEDUP_JOIN_CONDITION(RuleTypeClass.REWRITE),
ELIMINATE_NULL_AWARE_LEFT_ANTI_JOIN(RuleTypeClass.REWRITE),
TRANSFORM_OUTER_JOIN_TO_ANTI(RuleTypeClass.REWRITE),
CONVERT_OUTER_JOIN_TO_ANTI(RuleTypeClass.REWRITE),
FIND_HASH_CONDITION_FOR_JOIN(RuleTypeClass.REWRITE),
MATERIALIZED_INDEX_AGG_SCAN(RuleTypeClass.REWRITE),
MATERIALIZED_INDEX_AGG_FILTER_SCAN(RuleTypeClass.REWRITE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
* project(A.*)
* - LeftAntiJoin(A, B)
*/
public class TransformOuterJoinToAntiJoin extends OneRewriteRuleFactory {
public class ConvertOuterJoinToAntiJoin extends OneRewriteRuleFactory {

@Override
public Rule build() {
return logicalProject(logicalFilter(logicalJoin()
.when(join -> join.getJoinType().isOuterJoin())))
.then(this::toAntiJoin)
.toRule(RuleType.TRANSFORM_OUTER_JOIN_TO_ANTI);
.toRule(RuleType.CONVERT_OUTER_JOIN_TO_ANTI);
}

private Plan toAntiJoin(LogicalProject<LogicalFilter<LogicalJoin<Plan, Plan>>> project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
import com.google.common.collect.ImmutableList;
import org.junit.jupiter.api.Test;

class TransformOuterJoinToAntiJoinTest implements MemoPatternMatchSupported {
class ConvertOuterJoinToAntiJoinTest implements MemoPatternMatchSupported {
private final LogicalOlapScan scan1;
private final LogicalOlapScan scan2;

public TransformOuterJoinToAntiJoinTest() throws Exception {
public ConvertOuterJoinToAntiJoinTest() throws Exception {
// clear id so that slot id keep consistent every running
StatementScopeIdGenerator.clear();
scan1 = PlanConstructor.newLogicalOlapScan(0, "t1", 0);
Expand All @@ -53,7 +53,7 @@ void testEliminateLeftWithProject() {

PlanChecker.from(MemoTestUtils.createConnectContext(), plan)
.applyTopDown(new InferFilterNotNull())
.applyTopDown(new TransformOuterJoinToAntiJoin())
.applyTopDown(new ConvertOuterJoinToAntiJoin())
.printlnTree()
.matches(logicalJoin().when(join -> join.getJoinType().isLeftAntiJoin()));
}
Expand All @@ -68,7 +68,7 @@ void testEliminateRightWithProject() {

PlanChecker.from(MemoTestUtils.createConnectContext(), plan)
.applyTopDown(new InferFilterNotNull())
.applyTopDown(new TransformOuterJoinToAntiJoin())
.applyTopDown(new ConvertOuterJoinToAntiJoin())
.printlnTree()
.matches(logicalJoin().when(join -> join.getJoinType().isRightAntiJoin()));
}
Expand Down
60 changes: 27 additions & 33 deletions regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query78.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,44 @@ PhysicalResultSink
----------------------PhysicalDistribute
------------------------hashAgg[LOCAL]
--------------------------PhysicalProject
----------------------------hashJoin[INNER_JOIN](store_sales.ss_sold_date_sk = date_dim.d_date_sk)
------------------------------PhysicalProject
--------------------------------filter(sr_ticket_number IS NULL)
----------------------------------hashJoin[LEFT_OUTER_JOIN](store_sales.ss_item_sk = store_returns.sr_item_sk)(store_returns.sr_ticket_number = store_sales.ss_ticket_number)
------------------------------------PhysicalProject
--------------------------------------PhysicalOlapScan[store_sales]
------------------------------------PhysicalProject
--------------------------------------PhysicalOlapScan[store_returns]
------------------------------PhysicalDistribute
----------------------------hashJoin[LEFT_ANTI_JOIN](store_sales.ss_item_sk = store_returns.sr_item_sk)(store_returns.sr_ticket_number = store_sales.ss_ticket_number)
------------------------------hashJoin[INNER_JOIN](store_sales.ss_sold_date_sk = date_dim.d_date_sk)
--------------------------------PhysicalProject
----------------------------------filter((date_dim.d_year = 2000))
------------------------------------PhysicalOlapScan[date_dim]
----------------------------------PhysicalOlapScan[store_sales]
--------------------------------PhysicalDistribute
----------------------------------PhysicalProject
------------------------------------filter((date_dim.d_year = 2000))
--------------------------------------PhysicalOlapScan[date_dim]
------------------------------PhysicalProject
--------------------------------PhysicalOlapScan[store_returns]
------------------PhysicalProject
--------------------hashAgg[GLOBAL]
----------------------PhysicalDistribute
------------------------hashAgg[LOCAL]
--------------------------PhysicalProject
----------------------------hashJoin[INNER_JOIN](web_sales.ws_sold_date_sk = date_dim.d_date_sk)
------------------------------PhysicalProject
--------------------------------filter(wr_order_number IS NULL)
----------------------------------hashJoin[LEFT_OUTER_JOIN](web_sales.ws_item_sk = web_returns.wr_item_sk)(web_returns.wr_order_number = web_sales.ws_order_number)
------------------------------------PhysicalProject
--------------------------------------PhysicalOlapScan[web_sales]
------------------------------------PhysicalProject
--------------------------------------PhysicalOlapScan[web_returns]
------------------------------PhysicalDistribute
----------------------------hashJoin[LEFT_ANTI_JOIN](web_sales.ws_item_sk = web_returns.wr_item_sk)(web_returns.wr_order_number = web_sales.ws_order_number)
------------------------------hashJoin[INNER_JOIN](web_sales.ws_sold_date_sk = date_dim.d_date_sk)
--------------------------------PhysicalProject
----------------------------------filter((date_dim.d_year = 2000))
------------------------------------PhysicalOlapScan[date_dim]
----------------------------------PhysicalOlapScan[web_sales]
--------------------------------PhysicalDistribute
----------------------------------PhysicalProject
------------------------------------filter((date_dim.d_year = 2000))
--------------------------------------PhysicalOlapScan[date_dim]
------------------------------PhysicalProject
--------------------------------PhysicalOlapScan[web_returns]
--------------PhysicalProject
----------------hashAgg[GLOBAL]
------------------PhysicalDistribute
--------------------hashAgg[LOCAL]
----------------------PhysicalProject
------------------------hashJoin[INNER_JOIN](catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)
--------------------------PhysicalProject
----------------------------filter(cr_order_number IS NULL)
------------------------------hashJoin[LEFT_OUTER_JOIN](catalog_sales.cs_item_sk = catalog_returns.cr_item_sk)(catalog_returns.cr_order_number = catalog_sales.cs_order_number)
--------------------------------PhysicalProject
----------------------------------PhysicalOlapScan[catalog_sales]
--------------------------------PhysicalProject
----------------------------------PhysicalOlapScan[catalog_returns]
--------------------------PhysicalDistribute
------------------------hashJoin[LEFT_ANTI_JOIN](catalog_sales.cs_item_sk = catalog_returns.cr_item_sk)(catalog_returns.cr_order_number = catalog_sales.cs_order_number)
--------------------------hashJoin[INNER_JOIN](catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)
----------------------------PhysicalProject
------------------------------filter((date_dim.d_year = 2000))
--------------------------------PhysicalOlapScan[date_dim]
------------------------------PhysicalOlapScan[catalog_sales]
----------------------------PhysicalDistribute
------------------------------PhysicalProject
--------------------------------filter((date_dim.d_year = 2000))
----------------------------------PhysicalOlapScan[date_dim]
--------------------------PhysicalProject
----------------------------PhysicalOlapScan[catalog_returns]

0 comments on commit 576855a

Please sign in to comment.