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
@ -1805,6 +1805,14 @@ int64_t DataConvert::intToDate(int64_t data)
|
|||||||
//snprintf( buf, 10, "%llu", (long long unsigned int)data);
|
//snprintf( buf, 10, "%llu", (long long unsigned int)data);
|
||||||
//string date = buf;
|
//string date = buf;
|
||||||
char buf[21] = {0};
|
char buf[21] = {0};
|
||||||
|
Date aday;
|
||||||
|
if (data == 0)
|
||||||
|
{
|
||||||
|
aday.year = 0;
|
||||||
|
aday.month = 0;
|
||||||
|
aday.day = 0;
|
||||||
|
return *(reinterpret_cast<uint32_t*>(&aday));
|
||||||
|
}
|
||||||
snprintf( buf, 15, "%llu", (long long unsigned int)data);
|
snprintf( buf, 15, "%llu", (long long unsigned int)data);
|
||||||
|
|
||||||
string year, month, day, hour, min, sec, msec;
|
string year, month, day, hour, min, sec, msec;
|
||||||
@ -1866,7 +1874,6 @@ int64_t DataConvert::intToDate(int64_t data)
|
|||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Date aday;
|
|
||||||
if (year.empty())
|
if (year.empty())
|
||||||
{
|
{
|
||||||
// MMDD format. assume current year
|
// MMDD format. assume current year
|
||||||
@ -1900,6 +1907,20 @@ int64_t DataConvert::intToDatetime(int64_t data, bool* date)
|
|||||||
{
|
{
|
||||||
bool isDate = false;
|
bool isDate = false;
|
||||||
char buf[21] = {0};
|
char buf[21] = {0};
|
||||||
|
DateTime adaytime;
|
||||||
|
if (data == 0)
|
||||||
|
{
|
||||||
|
adaytime.year = 0;
|
||||||
|
adaytime.month = 0;
|
||||||
|
adaytime.day = 0;
|
||||||
|
adaytime.hour = 0;
|
||||||
|
adaytime.minute = 0;
|
||||||
|
adaytime.second = 0;
|
||||||
|
adaytime.msecond = 0;
|
||||||
|
if (date)
|
||||||
|
*date = true;
|
||||||
|
return *(reinterpret_cast<uint64_t*>(&adaytime));
|
||||||
|
}
|
||||||
snprintf( buf, 15, "%llu", (long long unsigned int)data);
|
snprintf( buf, 15, "%llu", (long long unsigned int)data);
|
||||||
//string date = buf;
|
//string date = buf;
|
||||||
string year, month, day, hour, min, sec, msec;
|
string year, month, day, hour, min, sec, msec;
|
||||||
@ -1964,7 +1985,7 @@ int64_t DataConvert::intToDatetime(int64_t data, bool* date)
|
|||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
DateTime adaytime;
|
|
||||||
if (year.empty())
|
if (year.empty())
|
||||||
{
|
{
|
||||||
// MMDD format. assume current year
|
// MMDD format. assume current year
|
||||||
|
@ -510,20 +510,12 @@ int32_t Func_cast_date::getDateIntVal(rowgroup::Row& row,
|
|||||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||||
{
|
{
|
||||||
if (parm[0]->data()->resultType().scale != 0)
|
val = dataconvert::DataConvert::intToDate(parm[0]->data()->getIntVal(row, isNull));
|
||||||
{
|
if (val == -1)
|
||||||
isNull = true;
|
isNull = true;
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
return val;
|
||||||
val = dataconvert::DataConvert::intToDate(parm[0]->data()->getIntVal(row, isNull));
|
break;
|
||||||
if (val == -1)
|
|
||||||
isNull = true;
|
|
||||||
else
|
|
||||||
return val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||||
case execplan::CalpontSystemCatalog::CHAR:
|
case execplan::CalpontSystemCatalog::CHAR:
|
||||||
@ -715,18 +707,11 @@ int64_t Func_cast_datetime::getDatetimeIntVal(rowgroup::Row& row,
|
|||||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||||
{
|
{
|
||||||
if (parm[0]->data()->resultType().scale)
|
val = dataconvert::DataConvert::intToDatetime(parm[0]->data()->getIntVal(row, isNull));
|
||||||
{
|
if (val == -1)
|
||||||
val = dataconvert::DataConvert::intToDatetime(parm[0]->data()->getIntVal(row, isNull));
|
|
||||||
if (val == -1)
|
|
||||||
isNull = true;
|
|
||||||
else
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
isNull = true;
|
isNull = true;
|
||||||
}
|
else
|
||||||
|
return val;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||||
|
@ -78,8 +78,15 @@ uint64_t makedate(rowgroup::Row& row,
|
|||||||
isNull = true;
|
isNull = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (year < 70)
|
||||||
if (year < 1000 || year > 9999) {
|
{
|
||||||
|
year = 2000 + year;
|
||||||
|
}
|
||||||
|
else if (year < 100)
|
||||||
|
{
|
||||||
|
year = 1900 + year;
|
||||||
|
}
|
||||||
|
else if (year < 1000 || year > 9999) {
|
||||||
isNull = true;
|
isNull = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,8 @@ int64_t Func_year::getIntVal(rowgroup::Row& row,
|
|||||||
case CalpontSystemCatalog::SMALLINT:
|
case CalpontSystemCatalog::SMALLINT:
|
||||||
case CalpontSystemCatalog::TINYINT:
|
case CalpontSystemCatalog::TINYINT:
|
||||||
case CalpontSystemCatalog::INT:
|
case CalpontSystemCatalog::INT:
|
||||||
|
case CalpontSystemCatalog::FLOAT:
|
||||||
|
case CalpontSystemCatalog::DOUBLE:
|
||||||
val = dataconvert::DataConvert::intToDatetime(parm[0]->data()->getIntVal(row, isNull));
|
val = dataconvert::DataConvert::intToDatetime(parm[0]->data()->getIntVal(row, isNull));
|
||||||
if (val == -1)
|
if (val == -1)
|
||||||
{
|
{
|
||||||
@ -85,7 +87,7 @@ int64_t Func_year::getIntVal(rowgroup::Row& row,
|
|||||||
{
|
{
|
||||||
return (unsigned)((val >> 48) & 0xffff);
|
return (unsigned)((val >> 48) & 0xffff);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CalpontSystemCatalog::DECIMAL:
|
case CalpontSystemCatalog::DECIMAL:
|
||||||
if (parm[0]->data()->resultType().scale == 0)
|
if (parm[0]->data()->resultType().scale == 0)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user