diff --git a/utils/funcexp/func_from_unixtime.cpp b/utils/funcexp/func_from_unixtime.cpp index 933bc3f36..85aef442b 100644 --- a/utils/funcexp/func_from_unixtime.cpp +++ b/utils/funcexp/func_from_unixtime.cpp @@ -145,6 +145,7 @@ int64_t Func_from_unixtime::getIntVal(rowgroup::Row& row, bool& isNull, CalpontSystemCatalog::ColType& ct) { +#if 0 DateTime dt = getDateTime(row, parm, isNull); if (*reinterpret_cast(&dt) == 0) { @@ -156,7 +157,8 @@ int64_t Func_from_unixtime::getIntVal(rowgroup::Row& row, dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second ); return atoll(buf); -// return getDatetimeIntVal(row, parm, isNull, ct); +#endif + return getDatetimeIntVal(row, parm, isNull, ct); } double Func_from_unixtime::getDoubleVal(rowgroup::Row& row, diff --git a/utils/funcexp/func_nullif.cpp b/utils/funcexp/func_nullif.cpp index 8afe16dba..3ab91b95d 100644 --- a/utils/funcexp/func_nullif.cpp +++ b/utils/funcexp/func_nullif.cpp @@ -92,7 +92,17 @@ int64_t Func_nullif::getIntVal(rowgroup::Row& row, } case execplan::CalpontSystemCatalog::DATE: { - exp2 = parm[1]->data()->getDateIntVal(row, isNull); + if (parm[0]->data()->resultType().colDataType == + execplan::CalpontSystemCatalog::DATETIME) + { + // If we're comparing to a datetime field, promote. + exp2 = parm[0]->data()->getDatetimeIntVal(row, isNull); + } + else + { + exp2 = parm[1]->data()->getDateIntVal(row, isNull); + } + if (isNull) { isNull = false; return exp1; @@ -104,6 +114,20 @@ int64_t Func_nullif::getIntVal(rowgroup::Row& row, case execplan::CalpontSystemCatalog::DATETIME: { exp2 = parm[1]->data()->getDatetimeIntVal(row, isNull); + if (parm[0]->data()->resultType().colDataType == + execplan::CalpontSystemCatalog::DATE) + { + // When comparing exp1 as a Date, we can't simply promote. We have + // to be careful of the return value in case of not null return. + int64_t exp1 = parm[0]->data()->getDatetimeIntVal(row, isNull); + if ( exp1 == exp2 ) + { + isNull = true; + return 0; + } + // since exp1 here is inside the block, when we leave the block, the + // original (Date) value is restored. + } if (isNull) { isNull = false; return exp1;