1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-08 14:22:09 +03:00

Replace underlying type for avg and sum for int types from long double to wide decimal

This commit is contained in:
Leonid Fedorov
2021-04-13 21:15:33 +00:00
parent 123d602296
commit f81f743282
5 changed files with 159 additions and 142 deletions

View File

@@ -361,6 +361,13 @@ void wideDecimalOrLongDouble(const uint64_t colProj,
precisionAgg.push_back(precisionProj[colProj]);
widthAgg.push_back(width[colProj]);
}
else if (datatypes::hasUnderlyingWideDecimalForSumAndAvg(type))
{
typeAgg.push_back(CalpontSystemCatalog::DECIMAL);
scaleAgg.push_back(0);
precisionAgg.push_back(datatypes::INT128MAXPRECISION);
widthAgg.push_back(datatypes::MAXDECIMALWIDTH);
}
else
{
typeAgg.push_back(CalpontSystemCatalog::LONGDOUBLE);
@@ -1683,6 +1690,14 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
// for count column of average function
map<uint32_t, SP_ROWAGG_FUNC_t> avgFuncMap, avgDistFuncMap;
// collect the projected column info, prepare for aggregation
vector<uint32_t> width;
for (uint64_t i = 0; i < keysProj.size(); i++)
{
width.push_back(projRG.getColumnWidth(i));
}
// associate the columns between projected RG and aggregate RG on UM
// populated the aggregate columns
// the groupby columns are put in front, even not a returned column
@@ -1934,11 +1949,10 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
oidsAgg.push_back(oidsProj[colProj]);
keysAgg.push_back(aggKey);
typeAgg.push_back(CalpontSystemCatalog::LONGDOUBLE);
csNumAgg.push_back(8);
precisionAgg.push_back(-1);
widthAgg.push_back(sizeof(long double));
scaleAgg.push_back(0);
wideDecimalOrLongDouble(colProj, typeProj[colProj],
precisionProj, scaleProj, width,
typeAgg, scaleAgg, precisionAgg, widthAgg);
colAgg++;
// has distinct step, put the count column for avg next to the sum
@@ -2265,11 +2279,10 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
oidsAggDist.push_back(oidsAgg[colAgg]);
keysAggDist.push_back(retKey);
typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE);
wideDecimalOrLongDouble(colAgg, typeAgg[colAgg],
precisionAgg, scaleAgg, widthAgg,
typeAggDist, scaleAggDist, precisionAggDist, widthAggDist);
csNumAggDist.push_back(8);
precisionAggDist.push_back(-1);
widthAggDist.push_back(sizeof(long double));
scaleAggDist.push_back(0);
}
break;
@@ -2343,11 +2356,10 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
{
oidsAggDist.push_back(oidsAgg[colAgg]);
keysAggDist.push_back(retKey);
scaleAggDist.push_back(0);
typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE);
csNumAggDist.push_back(8);
precisionAggDist.push_back(-1);
widthAggDist.push_back(sizeof(long double));
wideDecimalOrLongDouble(colAgg, typeAgg[colAgg],
precisionAgg, scaleAgg, widthAgg,
typeAggDist, scaleAggDist, precisionAggDist, widthAggDist);
}
else
{
@@ -4166,11 +4178,10 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
oidsAggPm.push_back(oidsProj[colProj]);
keysAggPm.push_back(aggKey);
typeAggPm.push_back(CalpontSystemCatalog::LONGDOUBLE);
csNumAggPm.push_back(8);
precisionAggPm.push_back(-1);
widthAggPm.push_back(sizeof(long double));
scaleAggPm.push_back(0);
wideDecimalOrLongDouble(colProj, typeProj[colProj],
precisionProj, scaleProj, width,
typeAggPm, scaleAggPm, precisionAggPm, widthAggPm);
colAggPm++;
}
@@ -4546,11 +4557,10 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
oidsAggDist.push_back(oidsAggUm[colUm]);
keysAggDist.push_back(retKey);
typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE);
csNumAggDist.push_back(8);
precisionAggDist.push_back(-1);
widthAggDist.push_back(sizeof(long double));
scaleAggDist.push_back(0);
wideDecimalOrLongDouble(colUm, typeAggPm[colUm],
precisionAggPm, scaleAggPm, widthAggPm,
typeAggDist, scaleAggDist, precisionAggDist, widthAggDist);
}
// PM: put the count column for avg next to the sum
// let fall through to add a count column for average function
@@ -4614,11 +4624,10 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
{
oidsAggDist.push_back(oidsAggUm[colUm]);
keysAggDist.push_back(retKey);
scaleAggDist.push_back(0);
typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE);
csNumAggDist.push_back(8);
precisionAggDist.push_back(-1);
widthAggDist.push_back(sizeof(long double));
wideDecimalOrLongDouble(colUm, typeAggUm[colUm],
precisionAggUm, scaleAggUm, widthAggUm,
typeAggDist, scaleAggDist, precisionAggDist, widthAggDist);
}
else
{