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

MCOL-4180 Add some missing support for wide decimals to dbcon/execplan

classes.
This commit is contained in:
Gagan Goel
2020-12-12 00:14:48 +00:00
parent 9c623a5434
commit ed7811e161
5 changed files with 67 additions and 9 deletions

View File

@ -127,7 +127,8 @@ bool ArithmeticOperator::operator!=(const TreeNode* t) const
void ArithmeticOperator::adjustResultType(const CalpontSystemCatalog::ColType& m)
{
if (m.colDataType != CalpontSystemCatalog::DECIMAL)
if (m.colDataType != CalpontSystemCatalog::DECIMAL &&
m.colDataType != CalpontSystemCatalog::UDECIMAL)
{
fResultType = m;
}

View File

@ -246,11 +246,12 @@ inline void ArithmeticOperator::evaluate(rowgroup::Row& row, bool& isNull, Parse
case execplan::CalpontSystemCatalog::LONGDOUBLE:
fResult.longDoubleVal = execute(lop->getLongDoubleVal(row, isNull), rop->getLongDoubleVal(row, isNull), isNull);
break;
// WIP MCOL-641
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
execute(fResult.decimalVal, lop->getDecimalVal(row, isNull), rop->getDecimalVal(row, isNull), isNull);
break;
default:
{
std::ostringstream oss;

View File

@ -763,7 +763,14 @@ inline uint64_t TreeNode::getUintVal()
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
return (uint64_t)(fResult.decimalVal.value / pow((double)10, fResult.decimalVal.scale));
if (fResultType.colWidth == datatypes::MAXDECIMALWIDTH)
{
return static_cast<uint64_t>(fResult.decimalVal.getIntegralPart());
}
else
{
return (uint64_t)(fResult.decimalVal.value / pow((double)10, fResult.decimalVal.scale));
}
}
case CalpontSystemCatalog::DATE:
@ -829,8 +836,16 @@ inline float TreeNode::getFloatVal()
return (float)fResult.doubleVal;
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
return (fResult.decimalVal.value / pow((double)10, fResult.decimalVal.scale));
if (fResultType.colWidth == datatypes::MAXDECIMALWIDTH)
{
return static_cast<float>(fResult.decimalVal);
}
else
{
return (fResult.decimalVal.value / pow((double)10, fResult.decimalVal.scale));
}
}
case CalpontSystemCatalog::DATE:
@ -974,8 +989,15 @@ inline long double TreeNode::getLongDoubleVal()
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
// this may not be accurate. if this is problematic, change to pre-calculated power array.
return (long double)(fResult.decimalVal.value / pow((long double)10, fResult.decimalVal.scale));
if (fResultType.colWidth == datatypes::MAXDECIMALWIDTH)
{
return static_cast<long double>(fResult.decimalVal);
}
else
{
// this may not be accurate. if this is problematic, change to pre-calculated power array.
return (long double)(fResult.decimalVal.value / pow((long double)10, fResult.decimalVal.scale));
}
}
case CalpontSystemCatalog::DATE: