You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-4180 Add some missing support for wide decimals to dbcon/execplan
classes.
This commit is contained in:
@ -347,12 +347,31 @@ class Decimal: public TSInt128
|
|||||||
return toDouble();
|
return toDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline long double toLongDouble() const
|
inline float toFloat() const
|
||||||
{
|
{
|
||||||
datatypes::TFloat128 y(s128Value);
|
int128_t scaleDivisor;
|
||||||
return static_cast<long double>(y);
|
getScaleDivisor(scaleDivisor, scale);
|
||||||
|
datatypes::TFloat128 tmpval((__float128) s128Value / scaleDivisor);
|
||||||
|
return static_cast<float>(tmpval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline operator float() const
|
||||||
|
{
|
||||||
|
return toFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline long double toLongDouble() const
|
||||||
|
{
|
||||||
|
int128_t scaleDivisor;
|
||||||
|
getScaleDivisor(scaleDivisor, scale);
|
||||||
|
datatypes::TFloat128 tmpval((__float128) s128Value / scaleDivisor);
|
||||||
|
return static_cast<long double>(tmpval);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline operator long double() const
|
||||||
|
{
|
||||||
|
return toLongDouble();
|
||||||
|
}
|
||||||
|
|
||||||
// This method returns integral part as a TSInt128 and
|
// This method returns integral part as a TSInt128 and
|
||||||
// fractional part as a TFloat128
|
// fractional part as a TFloat128
|
||||||
|
@ -102,6 +102,21 @@ class TFloat128
|
|||||||
return toLongDouble();
|
return toLongDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline operator float() const
|
||||||
|
{
|
||||||
|
return toFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float toFloat() const
|
||||||
|
{
|
||||||
|
if (value > static_cast<__float128>(FLT_MAX))
|
||||||
|
return FLT_MAX;
|
||||||
|
else if (value < -static_cast<__float128>(FLT_MAX))
|
||||||
|
return -FLT_MAX;
|
||||||
|
|
||||||
|
return static_cast<float>(value);
|
||||||
|
}
|
||||||
|
|
||||||
inline int64_t toTSInt64() const
|
inline int64_t toTSInt64() const
|
||||||
{
|
{
|
||||||
if (value > static_cast<__float128>(INT64_MAX))
|
if (value > static_cast<__float128>(INT64_MAX))
|
||||||
|
@ -127,7 +127,8 @@ bool ArithmeticOperator::operator!=(const TreeNode* t) const
|
|||||||
|
|
||||||
void ArithmeticOperator::adjustResultType(const CalpontSystemCatalog::ColType& m)
|
void ArithmeticOperator::adjustResultType(const CalpontSystemCatalog::ColType& m)
|
||||||
{
|
{
|
||||||
if (m.colDataType != CalpontSystemCatalog::DECIMAL)
|
if (m.colDataType != CalpontSystemCatalog::DECIMAL &&
|
||||||
|
m.colDataType != CalpontSystemCatalog::UDECIMAL)
|
||||||
{
|
{
|
||||||
fResultType = m;
|
fResultType = m;
|
||||||
}
|
}
|
||||||
|
@ -246,11 +246,12 @@ inline void ArithmeticOperator::evaluate(rowgroup::Row& row, bool& isNull, Parse
|
|||||||
case execplan::CalpontSystemCatalog::LONGDOUBLE:
|
case execplan::CalpontSystemCatalog::LONGDOUBLE:
|
||||||
fResult.longDoubleVal = execute(lop->getLongDoubleVal(row, isNull), rop->getLongDoubleVal(row, isNull), isNull);
|
fResult.longDoubleVal = execute(lop->getLongDoubleVal(row, isNull), rop->getLongDoubleVal(row, isNull), isNull);
|
||||||
break;
|
break;
|
||||||
// WIP MCOL-641
|
|
||||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||||
execute(fResult.decimalVal, lop->getDecimalVal(row, isNull), rop->getDecimalVal(row, isNull), isNull);
|
execute(fResult.decimalVal, lop->getDecimalVal(row, isNull), rop->getDecimalVal(row, isNull), isNull);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
|
@ -763,7 +763,14 @@ inline uint64_t TreeNode::getUintVal()
|
|||||||
case CalpontSystemCatalog::DECIMAL:
|
case CalpontSystemCatalog::DECIMAL:
|
||||||
case CalpontSystemCatalog::UDECIMAL:
|
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:
|
case CalpontSystemCatalog::DATE:
|
||||||
@ -829,8 +836,16 @@ inline float TreeNode::getFloatVal()
|
|||||||
return (float)fResult.doubleVal;
|
return (float)fResult.doubleVal;
|
||||||
|
|
||||||
case CalpontSystemCatalog::DECIMAL:
|
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:
|
case CalpontSystemCatalog::DATE:
|
||||||
@ -974,8 +989,15 @@ inline long double TreeNode::getLongDoubleVal()
|
|||||||
case CalpontSystemCatalog::DECIMAL:
|
case CalpontSystemCatalog::DECIMAL:
|
||||||
case CalpontSystemCatalog::UDECIMAL:
|
case CalpontSystemCatalog::UDECIMAL:
|
||||||
{
|
{
|
||||||
// this may not be accurate. if this is problematic, change to pre-calculated power array.
|
if (fResultType.colWidth == datatypes::MAXDECIMALWIDTH)
|
||||||
return (long double)(fResult.decimalVal.value / pow((long double)10, fResult.decimalVal.scale));
|
{
|
||||||
|
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:
|
case CalpontSystemCatalog::DATE:
|
||||||
|
Reference in New Issue
Block a user