You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-3959 1.5 make from_unixtimestamp msec aware
When using the function with decimal or float types, the fractional portion is the msec.
This commit is contained in:
@ -45,7 +45,8 @@ DateTime getDateTime(rowgroup::Row& row,
|
||||
FunctionParm& parm,
|
||||
bool& isNull)
|
||||
{
|
||||
int64_t val;
|
||||
int64_t val = 0;
|
||||
uint32_t msec = 0;
|
||||
|
||||
switch (parm[0]->data()->resultType().colDataType)
|
||||
{
|
||||
@ -54,13 +55,10 @@ DateTime getDateTime(rowgroup::Row& row,
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
{
|
||||
double value = parm[0]->data()->getDoubleVal(row, isNull);
|
||||
|
||||
if (value > 0)
|
||||
value += 0.5;
|
||||
else if (value < 0)
|
||||
value -= 0.5;
|
||||
|
||||
val = (int64_t)value;
|
||||
double fracpart, intpart;
|
||||
fracpart = modf(value, &intpart);
|
||||
val = (int64_t)intpart;
|
||||
msec = (uint32_t)(fracpart * IDB_pow[parm[0]->data()->resultType().scale]);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -84,7 +82,7 @@ DateTime getDateTime(rowgroup::Row& row,
|
||||
dt.hour = (int64_t) tmp_tm.tm_hour;
|
||||
dt.minute = (int64_t) tmp_tm.tm_min;
|
||||
dt.second = (int64_t) tmp_tm.tm_sec;
|
||||
dt.msecond = 0;
|
||||
dt.msecond = msec;
|
||||
return dt;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user