siddharth234 commented on issue #66264:
URL: https://github.com/apache/doris/issues/66264#issuecomment-5128014535

   ## FE build
   
   ```sql
   Version: doris-4.0.7-rc02-35854e7e92a (Cloud Mode)
   (from `SHOW FRONTENDS`; matches `SHOW VARIABLES LIKE 'version_comment'`)
   ```
   
   ## Relevant variables (defaults, before any changes)
   
   ```sql
   mysql> SHOW VARIABLES LIKE 'pre_materialized_view_rewrite_strategy';
   
+-----------------------------------------+------------+---------------+---------+
   | Variable_name                           | Value      | Default_Value | 
Changed |
   
+-----------------------------------------+------------+---------------+---------+
   | pre_materialized_view_rewrite_strategy  | NOT_IN_RBO | NOT_IN_RBO    | 0   
    |
   
+-----------------------------------------+------------+---------------+---------+
   
   mysql> SHOW VARIABLES LIKE 'disable_nereids_rules';
   +------------------------+-------+---------------+---------+
   | Variable_name          | Value | Default_Value | Changed |
   +------------------------+-------+---------------+---------+
   | disable_nereids_rules  |       |               | 0       |
   +------------------------+-------+---------------+---------+
   ```
   
   ## Repro DDL
   
   ```sql
   CREATE DATABASE zzz_doris_bug_repro;
   
   CREATE TABLE zzz_doris_bug_repro.uniform_rollup_bug (
     dt   DATE        NOT NULL,
     grp  VARCHAR(64)  NOT NULL,
     id   VARCHAR(64)  NOT NULL,
     cnt  BIGINT SUM   NOT NULL
   )
   AGGREGATE KEY(dt, grp, id)
   DISTRIBUTED BY HASH(id) BUCKETS 4
   PROPERTIES ("replication_num" = "1");
   
   ALTER TABLE zzz_doris_bug_repro.uniform_rollup_bug
   ADD ROLLUP rollup_dt_grp (dt, grp, cnt);
   
   INSERT INTO zzz_doris_bug_repro.uniform_rollup_bug VALUES
     ('2026-01-01', 'g1', 'id1', 5),
     ('2026-01-01', 'g1', 'id2', 100),
     ('2026-01-01', 'g1', 'id3', 900);
   
   -- Scenario 1 - Baseline (pre_materialized_view_rewrite_strategy = 
NOT_IN_RBO, default). Bug reproduces.
   
   SELECT dt, id, SUM(cnt) FROM zzz_doris_bug_repro.uniform_rollup_bug
   WHERE grp = 'g1' AND id = 'id1' GROUP BY dt, id;
   -- Returns 1005 (wrong - should be 5).
   
   mysql> EXPLAIN VERBOSE
     -> SELECT dt, id, SUM(cnt)
     -> FROM zzz_doris_bug_repro.uniform_rollup_bug
     -> WHERE grp = 'g1'
     ->   AND id = 'id1'
     -> GROUP BY dt, id;
   
+------------------------------------------------------------------------------------------------------------------------------------------------------+
   | Explain String(Nereids Planner)                                            
                                                                          |
   
+------------------------------------------------------------------------------------------------------------------------------------------------------+
   | PLAN FRAGMENT 0                                                            
                                                                          |
   |   OUTPUT EXPRS:                                                            
                                                                          |
   |     dt[#13]                                                                
                                                                          |
   |     id[#14]                                                                
                                                                          |
   |     SUM(cnt)[#15]                                                          
                                                                          |
   |   PARTITION: HASH_PARTITIONED: dt[#9]                                      
                                                                          |
   |                                                                            
                                                                          |
   |   HAS_COLO_PLAN_NODE: true                                                 
                                                                          |
   |                                                                            
                                                                          |
   |   VRESULT SINK                                                             
                                                                          |
   |      MYSQL_PROTOCOL                                                        
                                                                          |
   |                                                                            
                                                                          |
   |   3:VAGGREGATE (merge finalize)(337)                                       
                                                                          |
   |   |  output: sum(partial_sum(cnt)[#10])[#12]                               
                                                                          |
   |   |  group by: dt[#9]                                                      
                                                                          |
   |   |  sortByGroupKey:false                                                  
                                                                          |
   |   |  cardinality=0                                                         
                                                                          |
   |   |  final projections: dt[#11], 'id1', sum(cnt)[#12]                      
                                                                          |
   |   |  final project output tuple id: 5                                      
                                                                          |
   |   |  distribute expr lists: dt[#9]                                         
                                                                          |
   |   |  tuple ids: 4                                                          
                                                                          |
   |   |                                                                        
                                                                          |
   |   2:VEXCHANGE                                                              
                                                                          |
   |      offset: 0                                                             
                                                                          |
   |      distribute expr lists:                                                
                                                                          |
   |      tuple ids: 3                                                          
                                                                          |
   |                                                                            
                                                                          |
   | PLAN FRAGMENT 1                                                            
                                                                          |
   |                                                                            
                                                                          |
   |   PARTITION: HASH_PARTITIONED: id[#5]                                      
                                                                          |
   |                                                                            
                                                                          |
   |   HAS_COLO_PLAN_NODE: false                                                
                                                                          |
   |                                                                            
                                                                          |
   |   STREAM DATA SINK                                                         
                                                                          |
   |     EXCHANGE ID: 02                                                        
                                                                          |
   |     HASH_PARTITIONED: dt[#9]                                               
                                                                          |
   |                                                                            
                                                                          |
   |   1:VAGGREGATE (update serialize)(329)                                     
                                                                          |
   |   |  STREAMING                                                             
                                                                          |
   |   |  output: partial_sum(cnt[#8])[#10]                                     
                                                                          |
   |   |  group by: dt[#7]                                                      
                                                                          |
   |   |  sortByGroupKey:false                                                  
                                                                          |
   |   |  cardinality=0                                                         
                                                                          |
   |   |  distribute expr lists:                                                
                                                                          |
   |   |  tuple ids: 3                                                          
                                                                          |
   |   |                                                                        
                                                                          |
   |   0:VOlapScanNode(317)                                                     
                                                                          |
   |      TABLE: zzz_doris_bug_repro.uniform_rollup_bug(rollup_dt_grp), 
PREAGGREGATION: ON                                                              
  |
   |      PREDICATES: (grp[#1] = 'g1')                                          
                                                                          |
   |      partitions=1/1 (uniform_rollup_bug)                                   
                                                                          |
   |      tablets=4/4, tabletList=1785156253975,1785156253977,1785156253979 ... 
                                                                          |
   |      cardinality=1, avgRowSize=6890.0, numNodes=3                          
                                                                          |
   |      pushAggOp=NONE                                                        
                                                                          |
   |      final projections: dt[#0], cnt[#2]                                    
                                                                          |
   |      final project output tuple id: 2                                      
                                                                          |
   |      tuple ids: 0                                                          
                                                                          |
   |                                                                            
                                                                          |
   | Tuples:                                                                    
                                                                          |
   | TupleDescriptor{id=0, tbl=uniform_rollup_bug}                              
                                                                          |
   |   SlotDescriptor{id=0, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}               |
   |   SlotDescriptor{id=1, col=grp, colUniqueId=1, type=varchar(64), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
    |
   |   SlotDescriptor{id=2, col=cnt, colUniqueId=2, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
         |
   |                                                                            
                                                                          |
   | TupleDescriptor{id=1, tbl=uniform_rollup_bug}                              
                                                                          |
   |   SlotDescriptor{id=3, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}               |
   |   SlotDescriptor{id=4, col=grp, colUniqueId=1, type=varchar(64), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
    |
   |   SlotDescriptor{id=5, col=id, colUniqueId=2, type=varchar(64), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
     |
   |   SlotDescriptor{id=6, col=cnt, colUniqueId=3, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
         |
   |                                                                            
                                                                          |
   | TupleDescriptor{id=2, tbl=uniform_rollup_bug}                              
                                                                          |
   |   SlotDescriptor{id=7, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}               |
   |   SlotDescriptor{id=8, col=cnt, colUniqueId=2, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
         |
   |                                                                            
                                                                          |
   | TupleDescriptor{id=3, tbl=null}                                            
                                                                          |
   |   SlotDescriptor{id=9, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}               |
   |   SlotDescriptor{id=10, col=null, colUniqueId=null, type=varchar(65533), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null} |
   |                                                                            
                                                                          |
   | TupleDescriptor{id=4, tbl=null}                                            
                                                                          |
   |   SlotDescriptor{id=11, col=dt, colUniqueId=0, type=datev2, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
         |
   |   SlotDescriptor{id=12, col=null, colUniqueId=null, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
    |
   |                                                                            
                                                                          |
   | TupleDescriptor{id=5, tbl=null}                                            
                                                                          |
   |   SlotDescriptor{id=13, col=dt, colUniqueId=0, type=datev2, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
         |
   |   SlotDescriptor{id=14, col=null, colUniqueId=null, type=varchar(3), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
|
   |   SlotDescriptor{id=15, col=null, colUniqueId=null, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
    |
   |                                                                            
                                                                          |
   |                                                                            
                                                                          |
   |                                                                            
                                                                          |
   | ========== MATERIALIZATIONS ==========                                     
                                                                          |
   |                                                                            
                                                                          |
   | MaterializedView                                                           
                                                                          |
   | MaterializedViewRewriteSuccessAndChose:                                    
                                                                          |
   |  CBO.internal.zzz_doris_bug_repro.uniform_rollup_bug.rollup_dt_grp chose   
                                                                          |
   |                                                                            
                                                                          |
   | MaterializedViewRewriteSuccessButNotChose:                                 
                                                                          |
   |                                                                            
                                                                          |
   | MaterializedViewRewriteFail:                                               
                                                                          |
   |                                                                            
                                                                          |
   |                                                                            
                                                                          |
   | ========== STATISTICS ==========                                           
                                                                          |
   | planned with unknown column statistics                                     
                                                                          |
   
+------------------------------------------------------------------------------------------------------------------------------------------------------+
   101 rows in set (0.25 sec)
   
   -- Scenario 2 - Baseline, control query (same filter, id not in output). 
Correct.
   
   SELECT dt, SUM(cnt) FROM zzz_doris_bug_repro.uniform_rollup_bug
   WHERE grp = 'g1' AND id = 'id1' GROUP BY dt;
   -- Returns 5 (correct).
   
   mysql> EXPLAIN VERBOSE
     -> SELECT dt, SUM(cnt)
     -> FROM zzz_doris_bug_repro.uniform_rollup_bug
     -> WHERE grp = 'g1'
     ->   AND id = 'id1'
     -> GROUP BY dt;
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------+
   | Explain String(Nereids Planner)                                            
                                                                         |
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------+
   | PLAN FRAGMENT 0                                                            
                                                                         |
   |   OUTPUT EXPRS:                                                            
                                                                         |
   |     dt[#8]                                                                 
                                                                         |
   |     SUM(cnt)[#9]                                                           
                                                                         |
   |   PARTITION: HASH_PARTITIONED: dt[#6]                                      
                                                                         |
   |                                                                            
                                                                         |
   |   HAS_COLO_PLAN_NODE: true                                                 
                                                                         |
   |                                                                            
                                                                         |
   |   VRESULT SINK                                                             
                                                                         |
   |      MYSQL_PROTOCOL                                                        
                                                                         |
   |                                                                            
                                                                         |
   |   3:VAGGREGATE (merge finalize)(174)                                       
                                                                         |
   |   |  output: sum(partial_sum(cnt)[#7])[#9]                                 
                                                                         |
   |   |  group by: dt[#6]                                                      
                                                                         |
   |   |  sortByGroupKey:false                                                  
                                                                         |
   |   |  cardinality=0                                                         
                                                                         |
   |   |  distribute expr lists: dt[#6]                                         
                                                                         |
   |   |  tuple ids: 3                                                          
                                                                         |
   |   |                                                                        
                                                                         |
   |   2:VEXCHANGE                                                              
                                                                         |
   |      offset: 0                                                             
                                                                         |
   |      distribute expr lists:                                                
                                                                         |
   |      tuple ids: 2                                                          
                                                                         |
   |                                                                            
                                                                         |
   | PLAN FRAGMENT 1                                                            
                                                                         |
   |                                                                            
                                                                         |
   |   PARTITION: HASH_PARTITIONED: id[#2]                                      
                                                                         |
   |                                                                            
                                                                         |
   |   HAS_COLO_PLAN_NODE: false                                                
                                                                         |
   |                                                                            
                                                                         |
   |   STREAM DATA SINK                                                         
                                                                         |
   |     EXCHANGE ID: 02                                                        
                                                                         |
   |     HASH_PARTITIONED: dt[#6]                                               
                                                                         |
   |                                                                            
                                                                         |
   |   1:VAGGREGATE (update serialize)(166)                                     
                                                                         |
   |   |  STREAMING                                                             
                                                                         |
   |   |  output: partial_sum(cnt[#5])[#7]                                      
                                                                         |
   |   |  group by: dt[#4]                                                      
                                                                         |
   |   |  sortByGroupKey:false                                                  
                                                                         |
   |   |  cardinality=0                                                         
                                                                         |
   |   |  distribute expr lists:                                                
                                                                         |
   |   |  tuple ids: 2                                                          
                                                                         |
   |   |                                                                        
                                                                         |
   |   0:VOlapScanNode(154)                                                     
                                                                         |
   |      TABLE: zzz_doris_bug_repro.uniform_rollup_bug(uniform_rollup_bug), 
PREAGGREGATION: ON                                                          |
   |      PREDICATES: ((grp[#1] = 'g1') AND (id[#2] = 'id1'))                   
                                                                         |
   |      partitions=1/1 (uniform_rollup_bug)                                   
                                                                         |
   |      tablets=1/4, tabletList=1785156253813                                 
                                                                         |
   |      cardinality=3, avgRowSize=1596.6667, numNodes=1                       
                                                                         |
   |      pushAggOp=NONE                                                        
                                                                         |
   |      final projections: dt[#0], cnt[#3]                                    
                                                                         |
   |      final project output tuple id: 1                                      
                                                                         |
   |      tuple ids: 0                                                          
                                                                         |
   |                                                                            
                                                                         |
   | Tuples:                                                                    
                                                                         |
   | TupleDescriptor{id=0, tbl=uniform_rollup_bug}                              
                                                                         |
   |   SlotDescriptor{id=0, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}              |
   |   SlotDescriptor{id=1, col=grp, colUniqueId=1, type=varchar(64), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
   |
   |   SlotDescriptor{id=2, col=id, colUniqueId=2, type=varchar(64), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
    |
   |   SlotDescriptor{id=3, col=cnt, colUniqueId=3, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
        |
   |                                                                            
                                                                         |
   | TupleDescriptor{id=1, tbl=uniform_rollup_bug}                              
                                                                         |
   |   SlotDescriptor{id=4, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}              |
   |   SlotDescriptor{id=5, col=cnt, colUniqueId=3, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
        |
   |                                                                            
                                                                         |
   | TupleDescriptor{id=2, tbl=null}                                            
                                                                         |
   |   SlotDescriptor{id=6, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}              |
   |   SlotDescriptor{id=7, col=null, colUniqueId=null, type=varchar(65533), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null} |
   |                                                                            
                                                                         |
   | TupleDescriptor{id=3, tbl=null}                                            
                                                                         |
   |   SlotDescriptor{id=8, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}              |
   |   SlotDescriptor{id=9, col=null, colUniqueId=null, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
    |
   |                                                                            
                                                                         |
   |                                                                            
                                                                         |
   |                                                                            
                                                                         |
   | ========== MATERIALIZATIONS ==========                                     
                                                                         |
   |                                                                            
                                                                         |
   | MaterializedView                                                           
                                                                         |
   | MaterializedViewRewriteSuccessAndChose:                                    
                                                                         |
   |                                                                            
                                                                         |
   | MaterializedViewRewriteSuccessButNotChose:                                 
                                                                         |
   |                                                                            
                                                                         |
   | MaterializedViewRewriteFail:                                               
                                                                         |
   |  CBO.internal.zzz_doris_bug_repro.uniform_rollup_bug.rollup_dt_grp fail    
                                                                         |
   |   FailInfo: View struct info is invalid, Rewrite compensate predicate by 
view fail                                                                  |
   |                                                                            
                                                                         |
   |                                                                            
                                                                         |
   | ========== STATISTICS ==========                                           
                                                                         |
   | planned with unknown column statistics                                     
                                                                         |
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------+
   89 rows in set (0.28 sec)
   
   -- Scenario 3 - SET pre_materialized_view_rewrite_strategy = 'TRY_IN_RBO'. 
Fixed.
   
   SELECT dt, id, SUM(cnt) FROM zzz_doris_bug_repro.uniform_rollup_bug
   WHERE grp = 'g1' AND id = 'id1' GROUP BY dt, id;
   -- Now returns 5 (correct).
   
   mysql> EXPLAIN VERBOSE
     -> SELECT dt, id, SUM(cnt)
     -> FROM zzz_doris_bug_repro.uniform_rollup_bug
     -> WHERE grp = 'g1'
     ->   AND id = 'id1'
     -> GROUP BY dt, id;
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------+
   | Explain String(Nereids Planner)                                            
                                                                         |
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------+
   | PLAN FRAGMENT 0                                                            
                                                                         |
   |   OUTPUT EXPRS:                                                            
                                                                         |
   |     dt[#10]                                                                
                                                                         |
   |     id[#11]                                                                
                                                                         |
   |     SUM(cnt)[#12]                                                          
                                                                         |
   |   PARTITION: HASH_PARTITIONED: dt[#6]                                      
                                                                         |
   |                                                                            
                                                                         |
   |   HAS_COLO_PLAN_NODE: true                                                 
                                                                         |
   |                                                                            
                                                                         |
   |   VRESULT SINK                                                             
                                                                         |
   |      MYSQL_PROTOCOL                                                        
                                                                         |
   |                                                                            
                                                                         |
   |   3:VAGGREGATE (merge finalize)(300)                                       
                                                                         |
   |   |  output: sum(partial_sum(cnt)[#7])[#9]                                 
                                                                         |
   |   |  group by: dt[#6]                                                      
                                                                         |
   |   |  sortByGroupKey:false                                                  
                                                                         |
   |   |  cardinality=0                                                         
                                                                         |
   |   |  final projections: dt[#8], 'id1', SUM(cnt)[#9]                        
                                                                         |
   |   |  final project output tuple id: 4                                      
                                                                         |
   |   |  distribute expr lists: dt[#6]                                         
                                                                         |
   |   |  tuple ids: 3                                                          
                                                                         |
   |   |                                                                        
                                                                         |
   |   2:VEXCHANGE                                                              
                                                                         |
   |      offset: 0                                                             
                                                                         |
   |      distribute expr lists:                                                
                                                                         |
   |      tuple ids: 2                                                          
                                                                         |
   |                                                                            
                                                                         |
   | PLAN FRAGMENT 1                                                            
                                                                         |
   |                                                                            
                                                                         |
   |   PARTITION: HASH_PARTITIONED: id[#2]                                      
                                                                         |
   |                                                                            
                                                                         |
   |   HAS_COLO_PLAN_NODE: false                                                
                                                                         |
   |                                                                            
                                                                         |
   |   STREAM DATA SINK                                                         
                                                                         |
   |     EXCHANGE ID: 02                                                        
                                                                         |
   |     HASH_PARTITIONED: dt[#6]                                               
                                                                         |
   |                                                                            
                                                                         |
   |   1:VAGGREGATE (update serialize)(292)                                     
                                                                         |
   |   |  STREAMING                                                             
                                                                         |
   |   |  output: partial_sum(cnt[#5])[#7]                                      
                                                                         |
   |   |  group by: dt[#4]                                                      
                                                                         |
   |   |  sortByGroupKey:false                                                  
                                                                         |
   |   |  cardinality=0                                                         
                                                                         |
   |   |  distribute expr lists:                                                
                                                                         |
   |   |  tuple ids: 2                                                          
                                                                         |
   |   |                                                                        
                                                                         |
   |   0:VOlapScanNode(280)                                                     
                                                                         |
   |      TABLE: zzz_doris_bug_repro.uniform_rollup_bug(uniform_rollup_bug), 
PREAGGREGATION: ON                                                          |
   |      PREDICATES: ((grp[#1] = 'g1') AND (id[#2] = 'id1'))                   
                                                                         |
   |      partitions=1/1 (uniform_rollup_bug)                                   
                                                                         |
   |      tablets=1/4, tabletList=1785156253813                                 
                                                                         |
   |      cardinality=3, avgRowSize=1596.6667, numNodes=1                       
                                                                         |
   |      pushAggOp=NONE                                                        
                                                                         |
   |      final projections: dt[#0], cnt[#3]                                    
                                                                         |
   |      final project output tuple id: 1                                      
                                                                         |
   |      tuple ids: 0                                                          
                                                                         |
   |                                                                            
                                                                         |
   | Tuples:                                                                    
                                                                         |
   | TupleDescriptor{id=0, tbl=uniform_rollup_bug}                              
                                                                         |
   |   SlotDescriptor{id=0, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}              |
   |   SlotDescriptor{id=1, col=grp, colUniqueId=1, type=varchar(64), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
   |
   |   SlotDescriptor{id=2, col=id, colUniqueId=2, type=varchar(64), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
    |
   |   SlotDescriptor{id=3, col=cnt, colUniqueId=3, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
        |
   |                                                                            
                                                                         |
   | TupleDescriptor{id=1, tbl=uniform_rollup_bug}                              
                                                                         |
   |   SlotDescriptor{id=4, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}              |
   |   SlotDescriptor{id=5, col=cnt, colUniqueId=3, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
        |
   |                                                                            
                                                                         |
   | TupleDescriptor{id=2, tbl=null}                                            
                                                                         |
   |   SlotDescriptor{id=6, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}              |
   |   SlotDescriptor{id=7, col=null, colUniqueId=null, type=varchar(65533), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null} |
   |                                                                            
                                                                         |
   | TupleDescriptor{id=3, tbl=null}                                            
                                                                         |
   |   SlotDescriptor{id=8, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}              |
   |   SlotDescriptor{id=9, col=null, colUniqueId=null, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
    |
   |                                                                            
                                                                         |
   | TupleDescriptor{id=4, tbl=null}                                            
                                                                         |
   |   SlotDescriptor{id=10, col=dt, colUniqueId=0, type=datev2, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
        |
   |   SlotDescriptor{id=11, col=null, colUniqueId=null, type=varchar(3), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}    |
   |   SlotDescriptor{id=12, col=null, colUniqueId=null, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
   |
   |                                                                            
                                                                         |
   |                                                                            
                                                                         |
   |                                                                            
                                                                         |
   | ========== MATERIALIZATIONS ==========                                     
                                                                         |
   |                                                                            
                                                                         |
   | MaterializedView                                                           
                                                                         |
   | MaterializedViewRewriteSuccessAndChose:                                    
                                                                         |
   |                                                                            
                                                                         |
   | MaterializedViewRewriteSuccessButNotChose:                                 
                                                                         |
   |                                                                            
                                                                         |
   | MaterializedViewRewriteFail:                                               
                                                                         |
   |  RBO.internal.zzz_doris_bug_repro.uniform_rollup_bug.rollup_dt_grp fail    
                                                                         |
   |   FailInfo: View struct info is invalid, Rewrite compensate predicate by 
view fail                                                                  |
   |                                                                            
                                                                         |
   |                                                                            
                                                                         |
   | ========== STATISTICS ==========                                           
                                                                         |
   | planned with unknown column statistics                                     
                                                                         |
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------+
   97 rows in set (0.26 sec)
   
   -- Scenario 4 - SET pre_materialized_view_rewrite_strategy = 
'AFTER_JOIN_REORDER', tested alongside disable_nereids_rules = 
'ELIMINATE_GROUP_BY_KEY_BY_UNIFORM'. Fixed.
   
   -- Note: this run had both variables set at once (not fully isolated at the 
time). Given Scenario 5 below independently shows disable_nereids_rules alone 
has no effect, the fix here is attributable to
   -- AFTER_JOIN_REORDER by elimination, but flagging the non-isolation for 
completeness.
   
   SELECT dt, id, SUM(cnt) FROM zzz_doris_bug_repro.uniform_rollup_bug
   WHERE grp = 'g1' AND id = 'id1' GROUP BY dt, id;
   -- Returns 5 (correct).
   
   mysql> EXPLAIN VERBOSE
     -> SELECT dt, id, SUM(cnt)
     -> FROM zzz_doris_bug_repro.uniform_rollup_bug
     -> WHERE grp = 'g1'
     ->   AND id = 'id1'
     -> GROUP BY dt, id;
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------+
   | Explain String(Nereids Planner)                                            
                                                                         |
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------+
   | PLAN FRAGMENT 0                                                            
                                                                         |
   |   OUTPUT EXPRS:                                                            
                                                                         |
   |     dt[#10]                                                                
                                                                         |
   |     id[#11]                                                                
                                                                         |
   |     SUM(cnt)[#12]                                                          
                                                                         |
   |   PARTITION: HASH_PARTITIONED: dt[#6]                                      
                                                                         |
   |                                                                            
                                                                         |
   |   HAS_COLO_PLAN_NODE: true                                                 
                                                                         |
   |                                                                            
                                                                         |
   |   VRESULT SINK                                                             
                                                                         |
   |      MYSQL_PROTOCOL                                                        
                                                                         |
   |                                                                            
                                                                         |
   |   3:VAGGREGATE (merge finalize)(300)                                       
                                                                         |
   |   |  output: sum(partial_sum(cnt)[#7])[#9]                                 
                                                                         |
   |   |  group by: dt[#6]                                                      
                                                                         |
   |   |  sortByGroupKey:false                                                  
                                                                         |
   |   |  cardinality=0                                                         
                                                                         |
   |   |  final projections: dt[#8], 'id1', SUM(cnt)[#9]                        
                                                                         |
   |   |  final project output tuple id: 4                                      
                                                                         |
   |   |  distribute expr lists: dt[#6]                                         
                                                                         |
   |   |  tuple ids: 3                                                          
                                                                         |
   |   |                                                                        
                                                                         |
   |   2:VEXCHANGE                                                              
                                                                         |
   |      offset: 0                                                             
                                                                         |
   |      distribute expr lists:                                                
                                                                         |
   |      tuple ids: 2                                                          
                                                                         |
   |                                                                            
                                                                         |
   | PLAN FRAGMENT 1                                                            
                                                                         |
   |                                                                            
                                                                         |
   |   PARTITION: HASH_PARTITIONED: id[#2]                                      
                                                                         |
   |                                                                            
                                                                         |
   |   HAS_COLO_PLAN_NODE: false                                                
                                                                         |
   |                                                                            
                                                                         |
   |   STREAM DATA SINK                                                         
                                                                         |
   |     EXCHANGE ID: 02                                                        
                                                                         |
   |     HASH_PARTITIONED: dt[#6]                                               
                                                                         |
   |                                                                            
                                                                         |
   |   1:VAGGREGATE (update serialize)(292)                                     
                                                                         |
   |   |  STREAMING                                                             
                                                                         |
   |   |  output: partial_sum(cnt[#5])[#7]                                      
                                                                         |
   |   |  group by: dt[#4]                                                      
                                                                         |
   |   |  sortByGroupKey:false                                                  
                                                                         |
   |   |  cardinality=0                                                         
                                                                         |
   |   |  distribute expr lists:                                                
                                                                         |
   |   |  tuple ids: 2                                                          
                                                                         |
   |   |                                                                        
                                                                         |
   |   0:VOlapScanNode(280)                                                     
                                                                         |
   |      TABLE: zzz_doris_bug_repro.uniform_rollup_bug(uniform_rollup_bug), 
PREAGGREGATION: ON                                                          |
   |      PREDICATES: ((grp[#1] = 'g1') AND (id[#2] = 'id1'))                   
                                                                         |
   |      partitions=1/1 (uniform_rollup_bug)                                   
                                                                         |
   |      tablets=1/4, tabletList=1785156253813                                 
                                                                         |
   |      cardinality=3, avgRowSize=1596.6667, numNodes=1                       
                                                                         |
   |      pushAggOp=NONE                                                        
                                                                         |
   |      final projections: dt[#0], cnt[#3]                                    
                                                                         |
   |      final project output tuple id: 1                                      
                                                                         |
   |      tuple ids: 0                                                          
                                                                         |
   |                                                                            
                                                                         |
   | Tuples:                                                                    
                                                                         |
   | TupleDescriptor{id=0, tbl=uniform_rollup_bug}                              
                                                                         |
   |   SlotDescriptor{id=0, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}              |
   |   SlotDescriptor{id=1, col=grp, colUniqueId=1, type=varchar(64), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
   |
   |   SlotDescriptor{id=2, col=id, colUniqueId=2, type=varchar(64), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
    |
   |   SlotDescriptor{id=3, col=cnt, colUniqueId=3, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
        |
   |                                                                            
                                                                         |
   | TupleDescriptor{id=1, tbl=uniform_rollup_bug}                              
                                                                         |
   |   SlotDescriptor{id=4, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}              |
   |   SlotDescriptor{id=5, col=cnt, colUniqueId=3, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
        |
   |                                                                            
                                                                         |
   | TupleDescriptor{id=2, tbl=null}                                            
                                                                         |
   |   SlotDescriptor{id=6, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}              |
   |   SlotDescriptor{id=7, col=null, colUniqueId=null, type=varchar(65533), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null} |
   |                                                                            
                                                                         |
   | TupleDescriptor{id=3, tbl=null}                                            
                                                                         |
   |   SlotDescriptor{id=8, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}              |
   |   SlotDescriptor{id=9, col=null, colUniqueId=null, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
    |
   |                                                                            
                                                                         |
   | TupleDescriptor{id=4, tbl=null}                                            
                                                                         |
   |   SlotDescriptor{id=10, col=dt, colUniqueId=0, type=datev2, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
        |
   |   SlotDescriptor{id=11, col=null, colUniqueId=null, type=varchar(3), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}    |
   |   SlotDescriptor{id=12, col=null, colUniqueId=null, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
   |
   |                                                                            
                                                                         |
   |                                                                            
                                                                         |
   |                                                                            
                                                                         |
   | ========== MATERIALIZATIONS ==========                                     
                                                                         |
   |                                                                            
                                                                         |
   | MaterializedView                                                           
                                                                         |
   | MaterializedViewRewriteSuccessAndChose:                                    
                                                                         |
   |                                                                            
                                                                         |
   | MaterializedViewRewriteSuccessButNotChose:                                 
                                                                         |
   |                                                                            
                                                                         |
   | MaterializedViewRewriteFail:                                               
                                                                         |
   |  RBO.internal.zzz_doris_bug_repro.uniform_rollup_bug.rollup_dt_grp fail    
                                                                         |
   |   FailInfo: View struct info is invalid, Rewrite compensate predicate by 
view fail                                                                  |
   |                                                                            
                                                                         |
   |                                                                            
                                                                         |
   | ========== STATISTICS ==========                                           
                                                                         |
   | planned with unknown column statistics                                     
                                                                         |
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------+
   97 rows in set (0.54 sec)
   
   -- Scenario 5 - SET disable_nereids_rules = 
'ELIMINATE_GROUP_BY_KEY_BY_UNIFORM' alone, 
pre_materialized_view_rewrite_strategy confirmed reset to true default 
NOT_IN_RBO beforehand. NOT fixed.
   
   mysql> SET pre_materialized_view_rewrite_strategy = 'NOT_IN_RBO';
   Query OK, 0 rows affected (0.23 sec)
   
   mysql> SET disable_nereids_rules = 'ELIMINATE_GROUP_BY_KEY_BY_UNIFORM';
   Query OK, 0 rows affected (0.23 sec)
   
   mysql> SHOW VARIABLES LIKE 'pre_materialized_view_rewrite_strategy';
   
+----------------------------------------+------------+---------------+---------+
   | Variable_name                          | Value      | Default_Value | 
Changed |
   
+----------------------------------------+------------+---------------+---------+
   | pre_materialized_view_rewrite_strategy | NOT_IN_RBO | NOT_IN_RBO    | 0    
   |
   
+----------------------------------------+------------+---------------+---------+
   
   mysql> SHOW VARIABLES LIKE 'disable_nereids_rules';
   
+-----------------------+-----------------------------------+---------------+---------+
   | Variable_name         | Value                             | Default_Value 
| Changed |
   
+-----------------------+-----------------------------------+---------------+---------+
   | disable_nereids_rules | ELIMINATE_GROUP_BY_KEY_BY_UNIFORM |               
| 1       |
   
+-----------------------+-----------------------------------+---------------+---------+
   
   SELECT dt, id, SUM(cnt) FROM zzz_doris_bug_repro.uniform_rollup_bug
   WHERE grp = 'g1' AND id = 'id1' GROUP BY dt, id;
   -- Still returns 1005 (wrong).
   
   mysql> EXPLAIN VERBOSE
     -> SELECT dt, id, SUM(cnt)
     -> FROM zzz_doris_bug_repro.uniform_rollup_bug
     -> WHERE grp = 'g1'
     ->   AND id = 'id1'
     -> GROUP BY dt, id;
   
+------------------------------------------------------------------------------------------------------------------------------------------------------+
   | Explain String(Nereids Planner)                                            
                                                                          |
   
+------------------------------------------------------------------------------------------------------------------------------------------------------+
   | PLAN FRAGMENT 0                                                            
                                                                          |
   |   OUTPUT EXPRS:                                                            
                                                                          |
   |     dt[#13]                                                                
                                                                          |
   |     id[#14]                                                                
                                                                          |
   |     SUM(cnt)[#15]                                                          
                                                                          |
   |   PARTITION: HASH_PARTITIONED: dt[#9]                                      
                                                                          |
   |                                                                            
                                                                          |
   |   HAS_COLO_PLAN_NODE: true                                                 
                                                                          |
   |                                                                            
                                                                          |
   |   VRESULT SINK                                                             
                                                                          |
   |      MYSQL_PROTOCOL                                                        
                                                                          |
   |                                                                            
                                                                          |
   |   3:VAGGREGATE (merge finalize)(337)                                       
                                                                          |
   |   |  output: sum(partial_sum(cnt)[#10])[#12]                               
                                                                          |
   |   |  group by: dt[#9]                                                      
                                                                          |
   |   |  sortByGroupKey:false                                                  
                                                                          |
   |   |  cardinality=0                                                         
                                                                          |
   |   |  final projections: dt[#11], 'id1', sum(cnt)[#12]                      
                                                                          |
   |   |  final project output tuple id: 5                                      
                                                                          |
   |   |  distribute expr lists: dt[#9]                                         
                                                                          |
   |   |  tuple ids: 4                                                          
                                                                          |
   |   |                                                                        
                                                                          |
   |   2:VEXCHANGE                                                              
                                                                          |
   |      offset: 0                                                             
                                                                          |
   |      distribute expr lists:                                                
                                                                          |
   |      tuple ids: 3                                                          
                                                                          |
   |                                                                            
                                                                          |
   | PLAN FRAGMENT 1                                                            
                                                                          |
   |                                                                            
                                                                          |
   |   PARTITION: HASH_PARTITIONED: id[#5]                                      
                                                                          |
   |                                                                            
                                                                          |
   |   HAS_COLO_PLAN_NODE: false                                                
                                                                          |
   |                                                                            
                                                                          |
   |   STREAM DATA SINK                                                         
                                                                          |
   |     EXCHANGE ID: 02                                                        
                                                                          |
   |     HASH_PARTITIONED: dt[#9]                                               
                                                                          |
   |                                                                            
                                                                          |
   |   1:VAGGREGATE (update serialize)(329)                                     
                                                                          |
   |   |  STREAMING                                                             
                                                                          |
   |   |  output: partial_sum(cnt[#8])[#10]                                     
                                                                          |
   |   |  group by: dt[#7]                                                      
                                                                          |
   |   |  sortByGroupKey:false                                                  
                                                                          |
   |   |  cardinality=0                                                         
                                                                          |
   |   |  distribute expr lists:                                                
                                                                          |
   |   |  tuple ids: 3                                                          
                                                                          |
   |   |                                                                        
                                                                          |
   |   0:VOlapScanNode(317)                                                     
                                                                          |
   |      TABLE: zzz_doris_bug_repro.uniform_rollup_bug(rollup_dt_grp), 
PREAGGREGATION: ON                                                              
  |
   |      PREDICATES: (grp[#1] = 'g1')                                          
                                                                          |
   |      partitions=1/1 (uniform_rollup_bug)                                   
                                                                          |
   |      tablets=4/4, tabletList=1785156253975,1785156253977,1785156253979 ... 
                                                                          |
   |      cardinality=1, avgRowSize=0.0, numNodes=3                             
                                                                          |
   |      pushAggOp=NONE                                                        
                                                                          |
   |      final projections: dt[#0], cnt[#2]                                    
                                                                          |
   |      final project output tuple id: 2                                      
                                                                          |
   |      tuple ids: 0                                                          
                                                                          |
   |                                                                            
                                                                          |
   | Tuples:                                                                    
                                                                          |
   | TupleDescriptor{id=0, tbl=uniform_rollup_bug}                              
                                                                          |
   |   SlotDescriptor{id=0, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}               |
   |   SlotDescriptor{id=1, col=grp, colUniqueId=1, type=varchar(64), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
    |
   |   SlotDescriptor{id=2, col=cnt, colUniqueId=2, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
         |
   |                                                                            
                                                                          |
   | TupleDescriptor{id=1, tbl=uniform_rollup_bug}                              
                                                                          |
   |   SlotDescriptor{id=3, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}               |
   |   SlotDescriptor{id=4, col=grp, colUniqueId=1, type=varchar(64), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
    |
   |   SlotDescriptor{id=5, col=id, colUniqueId=2, type=varchar(64), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
     |
   |   SlotDescriptor{id=6, col=cnt, colUniqueId=3, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
         |
   |                                                                            
                                                                          |
   | TupleDescriptor{id=2, tbl=uniform_rollup_bug}                              
                                                                          |
   |   SlotDescriptor{id=7, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}               |
   |   SlotDescriptor{id=8, col=cnt, colUniqueId=2, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
         |
   |                                                                            
                                                                          |
   | TupleDescriptor{id=3, tbl=null}                                            
                                                                          |
   |   SlotDescriptor{id=9, col=dt, colUniqueId=0, type=datev2, nullable=false, 
isAutoIncrement=false, subColPath=null, virtualColumn=null}               |
   |   SlotDescriptor{id=10, col=null, colUniqueId=null, type=varchar(65533), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null} |
   |                                                                            
                                                                          |
   | TupleDescriptor{id=4, tbl=null}                                            
                                                                          |
   |   SlotDescriptor{id=11, col=dt, colUniqueId=0, type=datev2, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
         |
   |   SlotDescriptor{id=12, col=null, colUniqueId=null, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
    |
   |                                                                            
                                                                          |
   | TupleDescriptor{id=5, tbl=null}                                            
                                                                          |
   |   SlotDescriptor{id=13, col=dt, colUniqueId=0, type=datev2, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
         |
   |   SlotDescriptor{id=14, col=null, colUniqueId=null, type=varchar(3), 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
|
   |   SlotDescriptor{id=15, col=null, colUniqueId=null, type=bigint, 
nullable=false, isAutoIncrement=false, subColPath=null, virtualColumn=null}     
    |
   |                                                                            
                                                                          |
   |                                                                            
                                                                          |
   |                                                                            
                                                                          |
   | ========== MATERIALIZATIONS ==========                                     
                                                                          |
   |                                                                            
                                                                          |
   | MaterializedView                                                           
                                                                          |
   | MaterializedViewRewriteSuccessAndChose:                                    
                                                                          |
   |  CBO.internal.zzz_doris_bug_repro.uniform_rollup_bug.rollup_dt_grp chose   
                                                                          |
   |                                                                            
                                                                          |
   | MaterializedViewRewriteSuccessButNotChose:                                 
                                                                          |
   |                                                                            
                                                                          |
   | MaterializedViewRewriteFail:                                               
                                                                          |
   |                                                                            
                                                                          |
   |                                                                            
                                                                          |
   | ========== STATISTICS ==========                                           
                                                                          |
   | planned with unknown column statistics                                     
                                                                          |
   
+------------------------------------------------------------------------------------------------------------------------------------------------------+
   101 rows in set (0.25 sec)
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to