Skip to content

Commit

Permalink
add regression
Browse files Browse the repository at this point in the history
  • Loading branch information
feiniaofeiafei committed Dec 25, 2024
1 parent 609ee04 commit a6d2c1c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import org.apache.doris.nereids.rules.rewrite.CountLiteralRewrite;
import org.apache.doris.nereids.rules.rewrite.CreatePartitionTopNFromWindow;
import org.apache.doris.nereids.rules.rewrite.DeferMaterializeTopNResult;
import org.apache.doris.nereids.rules.rewrite.SplitMultiDistinct;
import org.apache.doris.nereids.rules.rewrite.EliminateAggCaseWhen;
import org.apache.doris.nereids.rules.rewrite.EliminateAggregate;
import org.apache.doris.nereids.rules.rewrite.EliminateAssertNumRows;
Expand Down Expand Up @@ -136,6 +135,7 @@
import org.apache.doris.nereids.rules.rewrite.SimplifyEncodeDecode;
import org.apache.doris.nereids.rules.rewrite.SimplifyWindowExpression;
import org.apache.doris.nereids.rules.rewrite.SplitLimit;
import org.apache.doris.nereids.rules.rewrite.SplitMultiDistinct;
import org.apache.doris.nereids.rules.rewrite.SumLiteralRewrite;
import org.apache.doris.nereids.rules.rewrite.TransposeSemiJoinAgg;
import org.apache.doris.nereids.rules.rewrite.TransposeSemiJoinAggProject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ private LogicalAggregate checkDistinct(LogicalAggregate<? extends Plan> aggregat
}

if (distinctMultiColumns && distinctFunctionNum > 1) {
// throw new AnalysisException(
// "The query contains multi count distinct or sum distinct, each can't have multi columns");
throw new AnalysisException(
"The query contains multi count distinct or sum distinct, each can't have multi columns");
}
return aggregate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@
2 3 3 2 3 1 3 2 3 2
2 3 3 2 3 1 3 2 3 2

-- !2_agg_count_distinct --
2 2

-- !3_agg_count_distinct --
1 1

-- !multi_count_without_gby --
PhysicalCteAnchor ( cteId=CTEId#0 )
--PhysicalCteProducer ( cteId=CTEId#0 )
Expand Down Expand Up @@ -450,6 +456,23 @@ PhysicalCteAnchor ( cteId=CTEId#0 )
--------hashAgg[LOCAL]
----------PhysicalCteConsumer ( cteId=CTEId#0 )

-- !2_agg --
PhysicalCteAnchor ( cteId=CTEId#0 )
--PhysicalCteProducer ( cteId=CTEId#0 )
----PhysicalOlapScan[test_distinct_multi]
--PhysicalResultSink
----hashAgg[GLOBAL]
------hashAgg[LOCAL]
--------hashJoin[INNER_JOIN] hashCondition=((.c = .c)) otherCondition=()
----------hashAgg[DISTINCT_LOCAL]
------------hashAgg[GLOBAL]
--------------hashAgg[LOCAL]
----------------PhysicalCteConsumer ( cteId=CTEId#0 )
----------hashAgg[DISTINCT_LOCAL]
------------hashAgg[GLOBAL]
--------------hashAgg[LOCAL]
----------------PhysicalCteConsumer ( cteId=CTEId#0 )

-- !multi_count_with_gby --
PhysicalResultSink
--hashAgg[GLOBAL]
Expand All @@ -468,3 +491,10 @@ PhysicalResultSink
----hashAgg[LOCAL]
------PhysicalOlapScan[test_distinct_multi]

-- !has_grouping --
PhysicalResultSink
--hashAgg[GLOBAL]
----hashAgg[LOCAL]
------PhysicalRepeat
--------PhysicalOlapScan[test_distinct_multi]

Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ suite("distinct_split") {
select * from tmp, (select sum(distinct a), count(distinct b,c) from test_distinct_multi) t, (select sum(distinct a), count(distinct b,c) from test_distinct_multi group by d) tt order by 1,2,3,4,5,6,7,8,9,10
"""

// multi aggregate
qt_2_agg_count_distinct """select count(distinct c1) c3, count(distinct c2) c4 from (select count(distinct a,b) c1, count(distinct a,c) c2 from test_distinct_multi group by c) t"""
qt_3_agg_count_distinct """select count(distinct c3), count(distinct c4) from (select count(distinct c1) c3, count(distinct c2) c4 from (select count(distinct a,b) c1, count(distinct a,c) c2 from test_distinct_multi group by c) t) tt"""

// shape
sql "SET ignore_shape_nodes='PhysicalDistribute,PhysicalProject'"
qt_multi_count_without_gby """explain shape plan select count(distinct b), count(distinct a) from test_distinct_multi"""
Expand All @@ -191,9 +195,16 @@ suite("distinct_split") {
qt_three_count_mulitcols_without_gby """explain shape plan select count(distinct b,c), count(distinct a,b), count(distinct a,b,c) from test_distinct_multi"""
qt_four_count_mulitcols_with_gby """explain shape plan select count(distinct b,c), count(distinct a,b),count(distinct b,c,d), count(distinct a,b,c) from test_distinct_multi group by d"""
qt_has_other_func "explain shape plan select count(distinct b), count(distinct a), max(b),sum(c),min(a) from test_distinct_multi"
qt_2_agg """explain shape plan select max(c1), min(c2) from (select count(distinct a,b) c1, count(distinct a,c) c2 from test_distinct_multi group by c) t"""

// should not rewrite
qt_multi_count_with_gby """explain shape plan select count(distinct b), count(distinct a) from test_distinct_multi group by c"""
qt_multi_sum_with_gby """explain shape plan select sum(distinct b), sum(distinct a) from test_distinct_multi group by c"""
qt_sum_count_with_gby """explain shape plan select sum(distinct b), count(distinct a) from test_distinct_multi group by a"""
qt_has_grouping """explain shape plan select count(distinct b), count(distinct a) from test_distinct_multi group by grouping sets((a,b),(c));"""
test {
sql """select count(distinct a,b), count(distinct a) from test_distinct_multi
group by grouping sets((a,b),(c));"""
exception "The query contains multi count distinct or sum distinct, each can't have multi columns"
}
}

0 comments on commit a6d2c1c

Please sign in to comment.