1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-3839 Update fix to work with NULLs and other constants

This commit is contained in:
Jose
2020-04-24 20:16:12 +00:00
parent 06312f4a3f
commit 08d9d40c6a

View File

@ -112,37 +112,57 @@ void WF_count<T>::operator()(int64_t b, int64_t e, int64_t c)
// for count(*), the column is optimized out, index[1] does not exist.
int64_t colIn = (fFunctionId == WF__COUNT_ASTERISK) ? 0 : fFieldIndex[1];
for (int64_t i = b; i <= e; i++)
// constant param will have fFieldIndex[1] of -1. Get value of constant param
if (colIn == -1)
{
if (i % 1000 == 0 && fStep->cancelled())
break;
ConstantColumn* cc = static_cast<ConstantColumn*>(fConstantParms[0].get());
if (fFunctionId == WF__COUNT_ASTERISK)
if (cc)
{
fCount++;
continue;
bool isNull = false;
int val = cc->getIntVal(fRow, isNull);
if (!isNull)
{
fCount = val;
}
}
}
else
{
fRow.setData(getPointer(fRowData->at(i)));
if (colIn == -1 || fRow.isNullValue(colIn) == true)
continue;
if (fFunctionId != WF__COUNT_DISTINCT)
for (int64_t i = b; i <= e; i++)
{
fCount++;
}
else
{
T valIn;
getValue(colIn, valIn);
if (i % 1000 == 0 && fStep->cancelled())
break;
if (fSet.find(valIn) == fSet.end())
if (fFunctionId == WF__COUNT_ASTERISK)
{
fCount++;
continue;
}
if (fFunctionId == WF__COUNT_DISTINCT)
fSet.insert(valIn);
fRow.setData(getPointer(fRowData->at(i)));
if (fRow.isNullValue(colIn) == true)
continue;
if (fFunctionId != WF__COUNT_DISTINCT)
{
fCount++;
}
else
{
T valIn;
getValue(colIn, valIn);
if (fSet.find(valIn) == fSet.end())
{
fCount++;
if (fFunctionId == WF__COUNT_DISTINCT)
fSet.insert(valIn);
}
}
}
}