You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-301 fix SUM() with constants
If SUM() has constants return the MAX() instead of constant * rows.
This commit is contained in:
@ -3546,6 +3546,10 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi)
|
||||
if (ac->aggOp() == AggregateColumn::COUNT)
|
||||
ac->aggOp(AggregateColumn::COUNT_ASTERISK);
|
||||
|
||||
// MCOL-301: treat SUM(1) as MAX(1) to get constant result
|
||||
if (ac->aggOp() == AggregateColumn::SUM)
|
||||
ac->aggOp(AggregateColumn::MAX);
|
||||
|
||||
ac->constCol(SRCP(buildReturnedColumn(sfitemp, gwi, gwi.fatalParseError)));
|
||||
break;
|
||||
}
|
||||
@ -3584,6 +3588,10 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi)
|
||||
ReturnedColumn* rc = buildReturnedColumn(sfitemp, gwi, gwi.fatalParseError);
|
||||
if (dynamic_cast<ConstantColumn*>(rc))
|
||||
{
|
||||
// MCOL-301: treat SUM(1) as MAX(1) to get constant result
|
||||
if (ac->aggOp() == AggregateColumn::SUM)
|
||||
ac->aggOp(AggregateColumn::MAX);
|
||||
|
||||
//@bug5229. handle constant function on aggregate argument
|
||||
ac->constCol(SRCP(rc));
|
||||
break;
|
||||
|
Reference in New Issue
Block a user