starrocks
starrocks copied to clipboard
[Enhancement] Support mv rewrite when select only with mv's group by key
Why I'm doing:
CREATE TABLE `test_pt` (
`id` int(11) NULL COMMENT "id",
`pt` date NOT NULL COMMENT "",
`gmv` int(11) NULL COMMENT "gmv"
) ENGINE=OLAP
DUPLICATE KEY(`id`)
COMMENT "OLAP"
PARTITION BY date_trunc('day', pt)
DISTRIBUTED BY HASH(`pt`)
PROPERTIES (
"replication_num" = "1"
);
insert into test_pt values(1,'2024-06-28', 10);
CREATE MATERIALIZED VIEW `test_pt_mv`
PARTITION BY (`pt`)
DISTRIBUTED BY RANDOM
REFRESH ASYNC START("2024-03-08 03:00:00") EVERY(INTERVAL 1 MINUTE)
PROPERTIES (
"replication_num" = "1"
)
AS SELECT pt, id, sum(gmv) AS sum_gmv
FROM test_pt
GROUP BY pt,id;
explain select pt,max(id),sum(gmv) from test_pt group by pt;
select pt,max(id),sum(gmv) from test_pt group by pt should be rewritten by test_pt_mv
What I'm doing:
What type of PR is this:
- [ ] BugFix
- [ ] Feature
- [x] Enhancement
- [ ] Refactor
- [ ] UT
- [ ] Doc
- [ ] Tool
Does this PR entail a change in behavior?
- [ ] Yes, this PR will result in a change in behavior.
- [x] No, this PR will not result in a change in behavior.
Checklist:
- [x] I have added test cases for my bug fix or my new feature
- [ ] This pr needs user documentation (for new or modified features or behaviors)
- [ ] I have added documentation for my new feature or new function
- [ ] This is a backport pr
Bugfix cherry-pick branch check:
- [x] I have checked the version labels which the pr will be auto-backported to the target branch
- [x] 3.3
- [ ] 3.2
- [ ] 3.1
- [ ] 3.0
- [ ] 2.5
Quality Gate passed
Issues
1 New issue
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
[FE Incremental Coverage Report]
:white_check_mark: pass : 21 / 22 (95.45%)
file detail
| path | covered_line | new_line | coverage | not_covered_line_detail | |
|---|---|---|---|---|---|
| :large_blue_circle: | com/starrocks/sql/optimizer/rule/transformation/materialization/EquationRewriter.java | 8 | 9 | 88.89% | [82] |
| :large_blue_circle: | com/starrocks/sql/optimizer/rule/transformation/materialization/AggregateFunctionRollupUtils.java | 9 | 9 | 100.00% | [] |
| :large_blue_circle: | com/starrocks/sql/optimizer/rule/transformation/materialization/AggregatedMaterializedViewRewriter.java | 4 | 4 | 100.00% | [] |
[BE Incremental Coverage Report]
:white_check_mark: pass : 0 / 0 (0%)
@Mergifyio backport branch-3.3
backport branch-3.3
✅ Backports have been created
- #47917 [Enhancement] Support mv rewrite when select only with mv's group by key (backport #47648) has been created for branch
branch-3.3