Skip to content

Commit

Permalink
Adapting aggsplit in multi stage agg
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaqizho authored and my-ship-it committed Jan 24, 2025
1 parent 7bc6fd4 commit 62b6955
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/backend/gpopt/translate/CTranslatorDXLToPlStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2703,23 +2703,38 @@ CTranslatorDXLToPlStmt::TranslateDXLAgg(
// Set the aggsplit for the agg node
ListCell *lc;
INT aggsplit = 0;
foreach (lc, plan->targetlist)
int idx = 0;
ForEach (lc, plan->targetlist)
{
TargetEntry *te = (TargetEntry *) lfirst(lc);
if (IsA(te->expr, Aggref))
{
Aggref *aggref = (Aggref *) te->expr;

aggsplit |= aggref->aggsplit;

if (AGGSPLIT_INTERMEDIATE == aggsplit)
if (AGGSPLIT_INTERMEDIATE != aggsplit)
{
break;
aggsplit |= aggref->aggsplit;
}

aggref->aggno = idx;
aggref->aggtransno = idx;
idx++;
}
}
agg->aggsplit = (AggSplit) aggsplit;

ForEach (lc, plan->qual)
{
Expr *expr = (Expr *) lfirst(lc);
if (IsA(expr, Aggref))
{
Aggref *aggref = (Aggref *) expr;
aggref->aggno = idx;
aggref->aggtransno = idx;
idx++;
}
}

plan->lefttree = child_plan;

// translate aggregation strategy
Expand Down

0 comments on commit 62b6955

Please sign in to comment.