Skip to content

Commit

Permalink
adjust rule position
Browse files Browse the repository at this point in the history
  • Loading branch information
feiniaofeiafei committed Sep 2, 2024
1 parent de1728a commit bde263e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
import org.apache.doris.nereids.rules.rewrite.LimitAggToTopNAgg;
import org.apache.doris.nereids.rules.rewrite.LimitSortToTopN;
import org.apache.doris.nereids.rules.rewrite.LogicalResultSinkToShortCircuitPointQuery;
import org.apache.doris.nereids.rules.rewrite.MaxMinFilterPushDown;
import org.apache.doris.nereids.rules.rewrite.MergeAggregate;
import org.apache.doris.nereids.rules.rewrite.MergeFilters;
import org.apache.doris.nereids.rules.rewrite.MergeOneRowRelationIntoUnion;
Expand Down Expand Up @@ -182,8 +181,7 @@ public class Rewriter extends AbstractBatchJobExecutor {
topDown(
// ExtractSingleTableExpressionFromDisjunction conflict to InPredicateToEqualToRule
// in the ExpressionNormalization, so must invoke in another job, otherwise dead loop.
new ExtractSingleTableExpressionFromDisjunction(),
new MaxMinFilterPushDown()
new ExtractSingleTableExpressionFromDisjunction()
)
),
// subquery unnesting relay on ExpressionNormalization to extract common factor expression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
import org.apache.doris.nereids.rules.rewrite.ConvertOuterJoinToAntiJoin;
import org.apache.doris.nereids.rules.rewrite.CreatePartitionTopNFromWindow;
import org.apache.doris.nereids.rules.rewrite.EliminateOuterJoin;
import org.apache.doris.nereids.rules.rewrite.MaxMinFilterPushDown;
import org.apache.doris.nereids.rules.rewrite.MergeFilters;
import org.apache.doris.nereids.rules.rewrite.MergeGenerates;
import org.apache.doris.nereids.rules.rewrite.MergeLimits;
Expand Down Expand Up @@ -132,6 +133,7 @@ public class RuleSet {
.build();

public static final List<RuleFactory> PUSH_DOWN_FILTERS = ImmutableList.of(
new MaxMinFilterPushDown(),
new CreatePartitionTopNFromWindow(),
new PushDownFilterThroughProject(),
new PushDownFilterThroughSort(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ PhysicalResultSink
------hashAgg[LOCAL]
--------PhysicalStorageLayerAggregate[max_min_filter_push_down1]

-- !depend_prune_column --
PhysicalResultSink
--hashAgg[GLOBAL]
----hashAgg[LOCAL]
------filter((max_min_filter_push_down1.value1 < 10))
--------PhysicalOlapScan[max_min_filter_push_down1]

-- !scalar_agg_empty_table_res --

-- !min_res --
Expand Down Expand Up @@ -187,6 +194,10 @@ PhysicalResultSink
-- !max_equal_scalar_agg_res --
73

-- !depend_prune_column_res --
10
19

-- !smallint --
PhysicalResultSink
--hashAgg[GLOBAL]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ suite("max_min_filter_push_down") {
select max(value1) from max_min_filter_push_down1 having max(value1) >=40;
"""

qt_depend_prune_column """
explain shape plan
select c1 from (select min(value1) c1,max(value2) from max_min_filter_push_down1 group by id having min(value1)<10) t
"""

qt_scalar_agg_empty_table_res """
select min(value1) from max_min_filter_push_down_empty having min(value1) <40 and min(value1) <20;
"""
Expand Down Expand Up @@ -167,7 +172,9 @@ suite("max_min_filter_push_down") {
qt_max_equal_scalar_agg_res """
select max(value1) from max_min_filter_push_down1 having max(value1) >=40;
"""

qt_depend_prune_column_res """
select c1 from (select min(value1) c1,max(value2) from max_min_filter_push_down1 group by id having min(value1)<20) t order by c1
"""

sql "drop table if exists max_min_filter_push_down2"
sql """create table max_min_filter_push_down2(d_int int, d_char100 char(100), d_smallint smallint, d_tinyint tinyint, d_char10 char(10),d_datetimev2 datetimev2, d_datev2 datev2)
Expand Down

0 comments on commit bde263e

Please sign in to comment.