Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Support mv rewrite when select only with mv's group by key (backport #47648) #47917

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jul 5, 2024

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
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

Checklist:

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

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

This is an automatic backport of pull request #47648 done by [Mergify](https://mergify.com). ## 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
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

Checklist:

  • 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

…key (#47648)

Signed-off-by: kaijian.ding <[email protected]>
(cherry picked from commit 75dbc13)
Copy link

sonarcloud bot commented Jul 5, 2024

@wanpengfei-git wanpengfei-git merged commit 8ec2cfd into branch-3.3 Jul 8, 2024
36 of 38 checks passed
@wanpengfei-git wanpengfei-git deleted the mergify/bp/branch-3.3/pr-47648 branch July 8, 2024 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants