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 3597 Fix MCOL 3474 causing regression test failure. New impl for MCOL 3474
This commit is contained in:
@ -21,6 +21,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -108,6 +109,8 @@ string Func_timediff::getStrVal(rowgroup::Row& row,
|
|||||||
|
|
||||||
int64_t val1 = -1, val2 = -1;
|
int64_t val1 = -1, val2 = -1;
|
||||||
bool isDate1 = false, isDate2 = false;
|
bool isDate1 = false, isDate2 = false;
|
||||||
|
bool isTime1 = false, isTime2 = false;
|
||||||
|
std::string text;
|
||||||
|
|
||||||
switch (type1)
|
switch (type1)
|
||||||
{
|
{
|
||||||
@ -117,9 +120,12 @@ string Func_timediff::getStrVal(rowgroup::Row& row,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case execplan::CalpontSystemCatalog::TIME:
|
case execplan::CalpontSystemCatalog::TIME:
|
||||||
|
isTime1 = true;
|
||||||
case execplan::CalpontSystemCatalog::DATETIME:
|
case execplan::CalpontSystemCatalog::DATETIME:
|
||||||
// Diff between time and datetime returns NULL in MariaDB
|
// Diff between time and datetime returns NULL in MariaDB
|
||||||
if (type1 != type2)
|
if ((type2 == execplan::CalpontSystemCatalog::TIME ||
|
||||||
|
type2 == execplan::CalpontSystemCatalog::DATETIME) &&
|
||||||
|
type1 != type2)
|
||||||
{
|
{
|
||||||
isNull = true;
|
isNull = true;
|
||||||
break;
|
break;
|
||||||
@ -155,7 +161,9 @@ string Func_timediff::getStrVal(rowgroup::Row& row,
|
|||||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||||
case execplan::CalpontSystemCatalog::CHAR:
|
case execplan::CalpontSystemCatalog::CHAR:
|
||||||
case execplan::CalpontSystemCatalog::TEXT:
|
case execplan::CalpontSystemCatalog::TEXT:
|
||||||
val1 = dataconvert::DataConvert::stringToDatetime(parm[0]->data()->getStrVal(row, isNull), &isDate1);
|
text = parm[0]->data()->getStrVal(row, isNull);
|
||||||
|
isTime1 = std::count(text.begin(), text.end(), '-') <= 1; // Time can have at most 1 dash (signifies negative)
|
||||||
|
val1 = dataconvert::DataConvert::stringToDatetime(text, &isDate1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case execplan::CalpontSystemCatalog::BIGINT:
|
case execplan::CalpontSystemCatalog::BIGINT:
|
||||||
@ -190,6 +198,7 @@ string Func_timediff::getStrVal(rowgroup::Row& row,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case execplan::CalpontSystemCatalog::TIME:
|
case execplan::CalpontSystemCatalog::TIME:
|
||||||
|
isTime2 = true;
|
||||||
case execplan::CalpontSystemCatalog::DATETIME:
|
case execplan::CalpontSystemCatalog::DATETIME:
|
||||||
val2 = parm[1]->data()->getDatetimeIntVal(row, isNull);
|
val2 = parm[1]->data()->getDatetimeIntVal(row, isNull);
|
||||||
break;
|
break;
|
||||||
@ -216,7 +225,9 @@ string Func_timediff::getStrVal(rowgroup::Row& row,
|
|||||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||||
case execplan::CalpontSystemCatalog::CHAR:
|
case execplan::CalpontSystemCatalog::CHAR:
|
||||||
case execplan::CalpontSystemCatalog::TEXT:
|
case execplan::CalpontSystemCatalog::TEXT:
|
||||||
val2 = dataconvert::DataConvert::stringToDatetime(parm[1]->data()->getStrVal(row, isNull), &isDate2);
|
text = parm[1]->data()->getStrVal(row, isNull);
|
||||||
|
isTime2 = std::count(text.begin(), text.end(), '-') <= 1; // Time can have at most 1 dash (signifies negative)
|
||||||
|
val2 = dataconvert::DataConvert::stringToDatetime(text, &isDate2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case execplan::CalpontSystemCatalog::BIGINT:
|
case execplan::CalpontSystemCatalog::BIGINT:
|
||||||
@ -249,8 +260,8 @@ string Func_timediff::getStrVal(rowgroup::Row& row,
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// both date format or both datetime format
|
// both date format or both datetime format. Diff between time and datetime returns NULL in MariaDB
|
||||||
if ((isDate1 && isDate2) || (!isDate1 && !isDate2))
|
if ((isDate1 && isDate2) || ((!isDate1 && !isDate2) && (isTime1 == isTime2)))
|
||||||
return helpers::timediff( val1, val2);
|
return helpers::timediff( val1, val2);
|
||||||
|
|
||||||
isNull = true;
|
isNull = true;
|
||||||
|
Reference in New Issue
Block a user