871765337 opened a new issue, #61186:
URL: https://github.com/apache/doris/issues/61186

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Version
   
   3.1.4
   
   ### What's Wrong?
   
   1. mtmv not choosed when useing GROUPING SETS and select fileds has a alias
   2. mtmv not choosed when useing GROUPING SETS and CET and select from CET 
with filter grouping_id fileds
   
   ### What You Expected?
   
   sql2 and sql5 should choose the mtmv mv_table_a
   
   ### How to Reproduce?
   
   create database if not exists test;
   drop table if exists test.table_a force;
   CREATE TABLE test.table_a (
     `g` varchar(20) NULL,
     `value_1` bigint NULL,
     `date_1` varchar(20) NULL
   ) ENGINE=OLAP
   DUPLICATE KEY(`g`)
   AUTO PARTITION BY LIST (`date_1`)()
   PROPERTIES ("replication_allocation" = "tag.location.default: 1");
   
   insert into test.table_a select 'g1' g,300 value_1,'2025-10-22' as date_1;
   
   drop materialized view if exists test.mv_table_a;
   CREATE MATERIALIZED VIEW mv_table_a BUILD IMMEDIATE REFRESH AUTO ON COMMIT
   PARTITION by(date_1) DISTRIBUTED BY HASH(g) BUCKETS 17 PROPERTIES 
('replication_num'='1')
   as select date_1,g,sum(value_1) from test.table_a a  group by date_1,g;
   
   -- sql 1
   --choose mv_table_a
   explain
   SELECT date_1,grouping_id(date_1),g,sum(value_1) x FROM test.table_a a group 
by GROUPING SETS ((g),(date_1,g));
   
   --sql 2
   --not choose mv_table_a, just add alias `l` for date_1 base on sql 1
   -- FailSummary: View struct info is invalid, View dimensions doesn't not 
cover the query dimensions
   explain
   SELECT date_1 l,grouping_id(date_1),g,sum(value_1) x FROM test.table_a a 
group by GROUPING SETS ((g),(date_1,g));
   
   --sql 3
   --choose mv_table_a, just remove grouping_id base on sql 2
   explain
   SELECT date_1 l,g,sum(value_1) x FROM test.table_a a group by GROUPING SETS 
((g),(date_1,g));
   
   --sql 4
   --choose mv_table_a
   explain
   with temp as(SELECT date_1,grouping_id(date_1) AS g_id,g,sum(value_1) x FROM 
test.table_a  group by GROUPING SETS ((g),(date_1,g)))
   select * from temp;
   
   --sql 5
   --FailSummary: View struct info is invalid, Rewrite compensate predicate by 
view fail, RewrittenPlan output logical properties is different with target 
group
   explain
   with temp as( SELECT date_1,grouping_id(date_1) AS g_id,g,sum(value_1) x 
FROM test.table_a  group by GROUPING SETS ((g),(date_1,g)))
   select * from temp where g_id=1;
   
   ### Anything Else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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