You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-07 03:22:57 +03:00
MCOL-3839 Update fix to work with NULLs and other constants
This commit is contained in:
@@ -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.
|
// for count(*), the column is optimized out, index[1] does not exist.
|
||||||
int64_t colIn = (fFunctionId == WF__COUNT_ASTERISK) ? 0 : fFieldIndex[1];
|
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())
|
ConstantColumn* cc = static_cast<ConstantColumn*>(fConstantParms[0].get());
|
||||||
break;
|
|
||||||
|
|
||||||
if (fFunctionId == WF__COUNT_ASTERISK)
|
if (cc)
|
||||||
{
|
{
|
||||||
fCount++;
|
bool isNull = false;
|
||||||
continue;
|
int val = cc->getIntVal(fRow, isNull);
|
||||||
|
|
||||||
|
if (!isNull)
|
||||||
|
{
|
||||||
|
fCount = val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
fRow.setData(getPointer(fRowData->at(i)));
|
for (int64_t i = b; i <= e; i++)
|
||||||
|
|
||||||
if (colIn == -1 || fRow.isNullValue(colIn) == true)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (fFunctionId != WF__COUNT_DISTINCT)
|
|
||||||
{
|
{
|
||||||
fCount++;
|
if (i % 1000 == 0 && fStep->cancelled())
|
||||||
}
|
break;
|
||||||
else
|
|
||||||
{
|
|
||||||
T valIn;
|
|
||||||
getValue(colIn, valIn);
|
|
||||||
|
|
||||||
if (fSet.find(valIn) == fSet.end())
|
if (fFunctionId == WF__COUNT_ASTERISK)
|
||||||
{
|
{
|
||||||
fCount++;
|
fCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (fFunctionId == WF__COUNT_DISTINCT)
|
fRow.setData(getPointer(fRowData->at(i)));
|
||||||
fSet.insert(valIn);
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user