1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

fix(utils): MCOL-4605 handle negative decimals in FROM_UNIXTIME (#3466)

This commit is contained in:
Amr Elmohamady
2025-03-28 00:11:16 +02:00
committed by GitHub
parent 1fdeb740c9
commit 2d69b49ba0
3 changed files with 16 additions and 0 deletions

View File

@ -51,6 +51,12 @@ DateTime getDateTime(rowgroup::Row& row, FunctionParm& parm, bool& isNull)
case execplan::CalpontSystemCatalog::DOUBLE:
{
double value = parm[0]->data()->getDoubleVal(row, isNull);
if (value < 0)
{
isNull = true;
return 0;
}
double fracpart, intpart;
fracpart = modf(value, &intpart);
val = (int64_t)intpart;
@ -62,6 +68,12 @@ DateTime getDateTime(rowgroup::Row& row, FunctionParm& parm, bool& isNull)
{
IDB_Decimal dec = parm[0]->data()->getDecimalVal(row, isNull);
if (dec.value < 0)
{
isNull = true;
return 0;
}
if (parm[0]->data()->resultType().colWidth == datatypes::MAXDECIMALWIDTH)
{
auto integralAndFractional = dec.getIntegralAndFractional();