From 1b7fea9a1202f21980fba9166d927442f358e42c Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 3 Nov 2020 15:36:51 -0600 Subject: [PATCH] MCOL-4255 dev fix ROUND(datecolumn) The behavior of Server changed --- utils/funcexp/func_round.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/utils/funcexp/func_round.cpp b/utils/funcexp/func_round.cpp index 0064ae8df..65887fd5a 100644 --- a/utils/funcexp/func_round.cpp +++ b/utils/funcexp/func_round.cpp @@ -136,7 +136,18 @@ uint64_t Func_round::getUintVal(Row& row, bool& isNull, CalpontSystemCatalog::ColType& op_ct) { - return parm[0]->data()->getUintVal(row, isNull); + uint64_t x; + if (UNLIKELY(op_ct.colDataType == execplan::CalpontSystemCatalog::DATE)) + { + IDB_Decimal d = getDecimalVal(row, parm, isNull, op_ct); + x = static_cast(d.value); + } + else + { + x = parm[0]->data()->getUintVal(row, isNull); + } + + return x; } @@ -432,15 +443,9 @@ IDB_Decimal Func_round::getDecimalVal(Row& row, { s = parm[1]->data()->getIntVal(row, isNull); - if ( s > 11 ) - s = 0; - if ( s > 0 ) { - for ( int i = 0 ; i < s ; i++) - { - value = value + "0"; - } + s = 0; // Dates don't have digits after int part } else {