From 3f4b05c3ced6b4a853548e37401aa660c90a8ba5 Mon Sep 17 00:00:00 2001 From: David Hall Date: Thu, 23 Apr 2020 16:56:17 -0500 Subject: [PATCH] MCOL-3959 Separate processing for decimal Preserves precision better than double --- utils/funcexp/func_from_unixtime.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/utils/funcexp/func_from_unixtime.cpp b/utils/funcexp/func_from_unixtime.cpp index fc649344c..d1168d2d6 100644 --- a/utils/funcexp/func_from_unixtime.cpp +++ b/utils/funcexp/func_from_unixtime.cpp @@ -52,7 +52,6 @@ DateTime getDateTime(rowgroup::Row& row, { case execplan::CalpontSystemCatalog::FLOAT: case execplan::CalpontSystemCatalog::DOUBLE: - case execplan::CalpontSystemCatalog::DECIMAL: { double value = parm[0]->data()->getDoubleVal(row, isNull); double fracpart, intpart; @@ -61,6 +60,13 @@ DateTime getDateTime(rowgroup::Row& row, msec = (uint32_t)(fracpart * IDB_pow[parm[0]->data()->resultType().scale]); break; } + case execplan::CalpontSystemCatalog::DECIMAL: + { + IDB_Decimal dec = parm[0]->data()->getDecimalVal(row, isNull); + val = dec.value / IDB_pow[dec.scale]; + msec = dec.value % IDB_pow[dec.scale]; + break; + } default: val = parm[0]->data()->getDatetimeIntVal(row, isNull);