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

MCOL-271 empty strings should not be NULLs (#2794)

This patch improves handling of NULLs in textual fields in ColumnStore.
Previously empty strings were considered NULLs and it could be a problem
if data scheme allows for empty strings. It was also one of major
reasons of behavior difference between ColumnStore and other engines in
MariaDB family.

Also, this patch fixes some other bugs and incorrect behavior, for
example, incorrect comparison for "column <= ''" which evaluates to
constant True for all purposes before this patch.
This commit is contained in:
Sergey Zefirov
2023-03-30 17:26:45 +01:00
committed by Roman Nozdrin
parent 0ea592da80
commit b53c231ca6
417 changed files with 12459 additions and 3520 deletions

View File

@@ -532,11 +532,16 @@ mcsv1_UDAF::ReturnCode Moda_impl_T<string>::nextValue(mcsv1Context* context, Col
return mcsv1_UDAF::SUCCESS; // Ought not happen when UDAF_IGNORE_NULLS is on.
}
string val;
utils::NullString val;
if (valIn.compatible(strTypeId))
val = valIn.cast<string>();
val = valIn.cast<utils::NullString>();
(*map)[val]++;
if (val.isNull())
{
return mcsv1_UDAF::SUCCESS; // Ought not happen when UDAF_IGNORE_NULLS is on.
}
(*map)[val.safeString("")]++;
return mcsv1_UDAF::SUCCESS;
}
@@ -572,7 +577,7 @@ mcsv1_UDAF::ReturnCode Moda_impl_T<string>::evaluate(mcsv1Context* context, stat
if (map->size() == 0)
{
valOut = string();
valOut = utils::NullString();
return mcsv1_UDAF::SUCCESS;
}
@@ -601,7 +606,8 @@ mcsv1_UDAF::ReturnCode Moda_impl_T<string>::evaluate(mcsv1Context* context, stat
if (context->getScale() > 0)
context->setResultType(execplan::CalpontSystemCatalog::DECIMAL);
valOut = val;
utils::NullString ns(val);
valOut = ns;
return mcsv1_UDAF::SUCCESS;
}
@@ -616,6 +622,7 @@ mcsv1_UDAF::ReturnCode Moda_impl_T<string>::dropValue(mcsv1Context* context, Col
return mcsv1_UDAF::SUCCESS; // Ought not happen when UDAF_IGNORE_NULLS is on.
}
idbassert(0 && "incorrect logic - does not account for NullString");
string val = convertAnyTo<string>(valDropped);
--data->fCount;