XieJiann commented on code in PR #15479:
URL: https://github.com/apache/doris/pull/15479#discussion_r1059810215


##########
fe/fe-core/src/test/java/org/apache/doris/nereids/rules/mv/SelectMvIndexTest.java:
##########
@@ -760,7 +760,7 @@ public void testBitmapUnionInSubquery() throws Exception {
         createMv(createUserTagMVSql);
         String query = "select user_id from " + USER_TAG_TABLE_NAME + " where 
user_id in (select user_id from "
                 + USER_TAG_TABLE_NAME + " group by user_id having 
bitmap_union_count(to_bitmap(tag_id)) >1 ) ;";
-        testMvWithTwoTable(query, "user_tags", "user_tags_mv");
+        testMvWithTwoTable(query, "user_tags_mv", "user_tags");

Review Comment:
   Because we generate bucket join. The join order in the new plan is changed:
   ```
   ---------------------------------------------------new 
plan---------------------------------------------------
   PhysicalHashJoin ( type=LEFT_SEMI_JOIN, hashJoinCondition=[(user_id#1 = 
user_id#5)], otherJoinCondition=[], stats=(rows=1, width=2, penalty=0.0) )
   |--PhysicalProject ( projects=[user_id#1], stats=(rows=1, width=1, 
penalty=0.0) )
   |  +--PhysicalOlapScan ( qualified=default_cluster:db1.user_tags, 
output=[time_col#0, user_id#1, user_name#2, tag_id#3], stats=(rows=1, width=1, 
penalty=0.0) )
   +--PhysicalDistribute ( distributionSpec=DistributionSpecReplicated, 
stats=(rows=1, width=1, penalty=1.0) )
      +--PhysicalProject ( projects=[user_id#5], stats=(rows=1, width=1, 
penalty=1.0) )
         +--PhysicalFilter ( 
predicates=(bitmap_union_count(to_bitmap(cast(tag_id as VARCHAR(*))))#8 > 1), 
stats=(rows=1, width=1, penalty=1.0) )
            +--PhysicalHashAggregate ( aggPhase=LOCAL, aggMode=INPUT_TO_RESULT, 
maybeUseStreaming=false, groupByExpr=[user_id#5], outputExpr=[user_id#5, 
bitmap_union_count(to_bitmap(cast(tag_id as VARCHAR(*)))#9) AS 
`bitmap_union_count(to_bitmap(cast(tag_id as VARCHAR(*))))`#8], 
partitionExpr=Optional[[user_id#5]], requireProperties=[DistributionSpecHash ( 
orderedShuffledColumns=[5], shuffleType=AGGREGATE, tableId=-1, partitionIds=[], 
equivalenceExprIds=[[5]], exprIdToEquivalenceSet={5=0} ) Order: ([])], 
stats=(rows=1, width=1, penalty=1.0) )
               +--PhysicalDistribute ( distributionSpec=DistributionSpecHash ( 
orderedShuffledColumns=[5], shuffleType=ENFORCED, tableId=-1, partitionIds=[], 
equivalenceExprIds=[[5]], exprIdToEquivalenceSet={5=0} ), stats=(rows=1, 
width=1, penalty=0.0) )
                  +--PhysicalProject ( projects=[user_id#5, 
mv_bitmap_union_tag_id#10 AS `to_bitmap(cast(tag_id as VARCHAR(*)))`#9], 
stats=(rows=1, width=1, penalty=0.0) )
                     +--PhysicalOlapScan ( 
qualified=default_cluster:db1.user_tags, output=[time_col#4, user_id#5, 
user_name#6, tag_id#7], stats=(rows=1, width=1, penalty=0.0) )
   
   
   ---------------------------------------------------old 
plan---------------------------------------------------
   PhysicalHashJoin ( type=RIGHT_SEMI_JOIN, hashJoinCondition=[(user_id#1 = 
user_id#5)], otherJoinCondition=[], stats=(rows=1, width=2, penalty=0.0) )
   |--PhysicalProject ( projects=[user_id#5], stats=(rows=1, width=1, 
penalty=1.0) )
   |  +--PhysicalFilter ( predicates=(bitmap_union_count(to_bitmap(cast(tag_id 
as VARCHAR(*))))#8 > 1), stats=(rows=1, width=1, penalty=1.0) )
   |     +--PhysicalHashAggregate ( aggPhase=LOCAL, aggMode=INPUT_TO_RESULT, 
maybeUseStreaming=false, groupByExpr=[user_id#5], outputExpr=[user_id#5, 
bitmap_union_count(to_bitmap(cast(tag_id as VARCHAR(*)))#9) AS 
`bitmap_union_count(to_bitmap(cast(tag_id as VARCHAR(*))))`#8], 
partitionExpr=Optional[[user_id#5]], requireProperties=[DistributionSpecHash ( 
orderedShuffledColumns=[5], shuffleType=AGGREGATE, tableId=-1, partitionIds=[], 
equivalenceExprIds=[[5]], exprIdToEquivalenceSet={5=0} ) Order: ([])], 
stats=(rows=1, width=1, penalty=1.0) )
   |        +--PhysicalDistribute ( distributionSpec=DistributionSpecHash ( 
orderedShuffledColumns=[5], shuffleType=ENFORCED, tableId=-1, partitionIds=[], 
equivalenceExprIds=[[5]], exprIdToEquivalenceSet={5=0} ), stats=(rows=1, 
width=1, penalty=0.0) )
   |           +--PhysicalProject ( projects=[user_id#5, 
mv_bitmap_union_tag_id#10 AS `to_bitmap(cast(tag_id as VARCHAR(*)))`#9], 
stats=(rows=1, width=1, penalty=0.0) )
   |              +--PhysicalOlapScan ( 
qualified=default_cluster:db1.user_tags, output=[time_col#4, user_id#5, 
user_name#6, tag_id#7], stats=(rows=1, width=1, penalty=0.0) )
   +--PhysicalDistribute ( distributionSpec=DistributionSpecHash ( 
orderedShuffledColumns=[1], shuffleType=ENFORCED, tableId=-1, partitionIds=[], 
equivalenceExprIds=[[1]], exprIdToEquivalenceSet={1=0} ), stats=(rows=1, 
width=1, penalty=0.0) )
      +--PhysicalProject ( projects=[user_id#1], stats=(rows=1, width=1, 
penalty=0.0) )
         +--PhysicalOlapScan ( qualified=default_cluster:db1.user_tags, 
output=[time_col#0, user_id#1, user_name#2, tag_id#3], stats=(rows=1, width=1, 
penalty=0.0) )
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to