Skip to content

branch-3.0: [fix](nereids) EliminateGroupByConstant should replace agg's group by after removing constant group by keys #49473 - #50043

Merged
dataroaring merged 1 commit into
branch-3.0from
auto-pick-49473-branch-3.0
Apr 22, 2025
Merged

branch-3.0: [fix](nereids) EliminateGroupByConstant should replace agg's group by after removing constant group by keys #49473#50043
dataroaring merged 1 commit into
branch-3.0from
auto-pick-49473-branch-3.0

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Cherry-picked from #49473

… after removing constant group by keys (#49473)
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
### Release note
```sql
SELECT
IF(
t.`gender` IN ('女'),
(
TIMESTAMPDIFF(
YEAR,
NOW(),
NOW()
)
),
1
) AS x0,
TIMESTAMPDIFF(
YEAR,
NOW(),
NOW()
) AS x1
FROM
t1 AS t
GROUP BY
x0,
x1;
```
after EliminateGroupByConstant, this sql will be rewritten to
```sql
SELECT
IF(
t.`gender` IN ('女'),
0,
1
) AS x0,
0 AS x1
FROM
t1 AS t
GROUP BY
IF(
t.`gender` IN ('女'),
(
TIMESTAMPDIFF(
YEAR,
NOW(),
NOW()
)
),
1
) ;
```
The select expression and the group by expression is different, and will
report error in normalizeagg.
This pr changes using the foldmap rewrite the group by expresssion, and
after change the sql after EliminateGroupByConstant become:
```sql
SELECT
IF(
t.`gender` IN ('女'),
0,
1
) AS x0,
0 AS x1
FROM
t1 AS t
GROUP BY
IF(
t.`gender` IN ('女'),
0,
1
) ;
```
the select expression and the group by expression becomes same.
@Thearas

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@Thearas

Copy link
Copy Markdown
Contributor

run buildall

@dataroaringdataroaring left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actionsgithub-actionsBot added the approved Indicates a PR has been approved by one committer. label Apr 22, 2025
@github-actions

Copy link
Copy Markdown
ContributorAuthor

PR approved by at least one committer and no changes requested.

@github-actions

Copy link
Copy Markdown
ContributorAuthor

PR approved by anyone and no changes requested.

@dataroaring
dataroaring merged commit 52c31d5 into branch-3.0Apr 22, 2025
@github-actions
github-actionsBot deleted the auto-pick-49473-branch-3.0 branch April 22, 2025 04:11
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by one committer.reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Thearas@dataroaring@feiniaofeiafei