Skip to content

Conversation

@seawinde
Copy link
Contributor

@seawinde seawinde commented Jul 21, 2025

pick #52993

…able with random distribute (apache#52993)

If agg table is random hash distribute, would add aggregate node on
scan.
The aggregate function alias expr id is same to the child expr id of
alias.

such as query sql is `select * from db1.tagg`
the query plan is as following, and the `sum(b#1) AS `b`#1`, alias expr
id is same to the child expr id of alias, the id is 1
this would cause hidden problems
```sql
LogicalResultSink[30] ( outputExprs=[a#0, b#1] )
+--LogicalAggregate[29] ( groupByExpr=[a#0], outputExpr=[a#0, sum(b#1) AS `b`#1], hasRepeat=false, stats=1 )
   +--LogicalOlapScan ( qualified=internal.db1.tagg, indexName=<index_not_selected>, selectedIndexId=1752042452160, preAgg=ON, operativeCol=[a#0, b#1], stats=1 )
```

the pr fix this, and the expression  change to `sum(b#1) AS `b`apache#4`  
```sql
LogicalResultSink[30] ( outputExprs=[a#0, b#4] )
+--LogicalAggregate[29] ( groupByExpr=[a#0], outputExpr=[a#0, sum(b#1) AS `b`apache#4], hasRepeat=false, stats=1 )
   +--LogicalOlapScan ( qualified=internal.db1.tagg, indexName=<index_not_selected>, selectedIndexId=1752042065062, preAgg=ON, operativeCol=[a#0, b#1], stats=1 )
```
@seawinde seawinde requested a review from yiguolei as a code owner July 21, 2025 03:54
@seawinde
Copy link
Contributor Author

run buildall

@Thearas
Copy link
Contributor

Thearas commented Jul 21, 2025

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?

@seawinde
Copy link
Contributor Author

run buildall

@seawinde
Copy link
Contributor Author

run p0

@morrySnow morrySnow changed the title [fix](nereids) Fix the expr id are same but different expr when agg table with random distribute #52993 branch-2.1: [fix](nereids) Fix the expr id are same but different expr when agg table with random distribute #52993 Jul 23, 2025
@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Aug 7, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2025

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

@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2025

PR approved by anyone and no changes requested.

@yiguolei yiguolei merged commit 8038906 into apache:branch-2.1 Aug 7, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants