You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-07 03:22:57 +03:00
MCOL-265 Add support for TIMESTAMP data type
This commit is contained in:
@@ -212,6 +212,15 @@ int64_t Func_cast_signed::getIntVal(Row& row,
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
int64_t time = parm[0]->data()->getTimestampIntVal(row, isNull);
|
||||
|
||||
TimeStamp dt(time);
|
||||
return dt.convertToMySQLint(fTimeZone);
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::TIME:
|
||||
{
|
||||
int64_t time = parm[0]->data()->getTimeIntVal(row, isNull);
|
||||
@@ -363,6 +372,15 @@ uint64_t Func_cast_unsigned::getUintVal(Row& row,
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
int64_t time = parm[0]->data()->getTimestampIntVal(row, isNull);
|
||||
|
||||
TimeStamp dt(time);
|
||||
return dt.convertToMySQLint(fTimeZone);
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::TIME:
|
||||
{
|
||||
int64_t time = parm[0]->data()->getTimeIntVal(row, isNull);
|
||||
@@ -487,6 +505,12 @@ string Func_cast_char::getStrVal(Row& row,
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
return dataconvert::DataConvert::timestampToString(parm[0]->data()->getTimestampIntVal(row, isNull), fTimeZone).substr(0, length);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@@ -647,6 +671,13 @@ int32_t Func_cast_date::getDateIntVal(rowgroup::Row& row,
|
||||
{
|
||||
return parm[0]->data()->getDateIntVal(row, isNull);
|
||||
}
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
int64_t val1 = parm[0]->data()->getTimestampIntVal(row, isNull);
|
||||
string value = dataconvert::DataConvert::timestampToString(val1, fTimeZone);
|
||||
value = value.substr(0, 10);
|
||||
return dataconvert::DataConvert::stringToDate(value);
|
||||
}
|
||||
case execplan::CalpontSystemCatalog::TIME:
|
||||
{
|
||||
int64_t val1;
|
||||
@@ -765,6 +796,22 @@ int64_t Func_cast_date::getDatetimeIntVal(rowgroup::Row& row,
|
||||
val1.msecond = 0;
|
||||
return *(reinterpret_cast<uint64_t*>(&val1));
|
||||
}
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
MySQLTime m_time;
|
||||
gmtSecToMySQLTime(seconds, m_time, fTimeZone);
|
||||
DateTime dt;
|
||||
dt.year = m_time.year;
|
||||
dt.month = m_time.month;
|
||||
dt.day = m_time.day;
|
||||
dt.hour = 0;
|
||||
dt.minute = 0;
|
||||
dt.second = 0;
|
||||
dt.msecond = 0;
|
||||
return *(reinterpret_cast<uint64_t*>(&dt));
|
||||
}
|
||||
case CalpontSystemCatalog::TIME:
|
||||
{
|
||||
DateTime aDateTime = static_cast<DateTime>(nowDatetime());
|
||||
@@ -931,6 +978,23 @@ int64_t Func_cast_datetime::getDatetimeIntVal(rowgroup::Row& row,
|
||||
return parm[0]->data()->getDatetimeIntVal(row, isNull);
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
MySQLTime m_time;
|
||||
gmtSecToMySQLTime(seconds, m_time, fTimeZone);
|
||||
DateTime dt;
|
||||
dt.year = m_time.year;
|
||||
dt.month = m_time.month;
|
||||
dt.day = m_time.day;
|
||||
dt.hour = m_time.hour;
|
||||
dt.minute = m_time.minute;
|
||||
dt.second = m_time.second;
|
||||
dt.msecond = timestamp.msecond;
|
||||
return *(reinterpret_cast<int64_t*>(&dt));
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::TIME:
|
||||
{
|
||||
DateTime aDateTime = static_cast<DateTime>(nowDatetime());
|
||||
@@ -1028,6 +1092,22 @@ int64_t Func_cast_datetime::getTimeIntVal(rowgroup::Row& row,
|
||||
return parm[0]->data()->getTimeIntVal(row, isNull);
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
MySQLTime m_time;
|
||||
gmtSecToMySQLTime(seconds, m_time, fTimeZone);
|
||||
Time time;
|
||||
time.hour = m_time.hour;
|
||||
time.minute = m_time.minute;
|
||||
time.second = m_time.second;
|
||||
time.is_neg = 0;
|
||||
time.day = 0;
|
||||
time.msecond = 0;
|
||||
return *(reinterpret_cast<int64_t*>(&time));
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
isNull = true;
|
||||
@@ -1392,6 +1472,25 @@ IDB_Decimal Func_cast_decimal::getDecimalVal(Row& row,
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
int32_t s = 0;
|
||||
|
||||
string value = dataconvert::DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), fTimeZone);
|
||||
|
||||
//strip off micro seconds
|
||||
string date = value.substr(0, 14);
|
||||
|
||||
int64_t x = atoll(date.c_str());
|
||||
|
||||
if (!isNull)
|
||||
{
|
||||
decimal.value = x;
|
||||
decimal.scale = s;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::TIME:
|
||||
{
|
||||
int32_t s = 0;
|
||||
@@ -1495,6 +1594,18 @@ double Func_cast_double::getDoubleVal(Row& row,
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
string str =
|
||||
DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), fTimeZone);
|
||||
|
||||
// strip off micro seconds
|
||||
str = str.substr(0, 14);
|
||||
|
||||
dblval = atof(str.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::UBIGINT:
|
||||
case execplan::CalpontSystemCatalog::UINT:
|
||||
case execplan::CalpontSystemCatalog::UMEDINT:
|
||||
|
Reference in New Issue
Block a user