1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-392 Add initial TIME datatype support

This commit is contained in:
Andrew Hutchings
2018-04-23 19:20:31 +01:00
parent b584a7f555
commit 3c1ebd8b94
109 changed files with 2241 additions and 47 deletions

View File

@ -154,6 +154,20 @@ double Func_acos::getDoubleVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
int64_t value = parm[0]->data()->getTimeIntVal(row, isNull);
if (isNull || (value < -1.0 || value > 1.0))
{
isNull = true;
return doubleNullVal();
}
return acos((double)value);
}
break;
default:
{
std::ostringstream oss;
@ -244,6 +258,20 @@ double Func_asin::getDoubleVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
int64_t value = parm[0]->data()->getTimeIntVal(row, isNull);
if (isNull || (value < -1.0 || value > 1.0))
{
isNull = true;
return doubleNullVal();
}
return asin((double)value);
}
break;
default:
{
std::ostringstream oss;
@ -373,6 +401,34 @@ double Func_atan::getDoubleVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
int64_t value = parm[0]->data()->getTimeIntVal(row, isNull);
if (isNull)
{
isNull = true;
return doubleNullVal();
}
if (parm.size() > 1 )
{
double value2 = parm[1]->data()->getDoubleVal(row, isNull);
if (isNull)
{
isNull = true;
return doubleNullVal();
}
return atan2(value, value2);
}
return atan((double)value);
}
break;
default:
{
std::ostringstream oss;
@ -462,6 +518,20 @@ double Func_cos::getDoubleVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
int64_t value = parm[0]->data()->getTimeIntVal(row, isNull);
if (isNull)
{
isNull = true;
return doubleNullVal();
}
return cos((double)value);
}
break;
default:
{
std::ostringstream oss;
@ -578,6 +648,30 @@ double Func_cot::getDoubleVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
int64_t value = parm[0]->data()->getTimeIntVal(row, isNull);
if (value == 0)
{
Message::Args args;
args.add("cot");
args.add((uint64_t)value);
unsigned errcode = ERR_FUNC_OUT_OF_RANGE_RESULT;
throw IDBExcept(IDBErrorInfo::instance()->errorMsg(errcode, args), errcode);
}
if (isNull)
{
isNull = true;
return doubleNullVal();
}
return 1.0 / tan((double)value);
}
break;
default:
{
std::ostringstream oss;
@ -703,6 +797,33 @@ double Func_log::getDoubleVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
int64_t value = parm[0]->data()->getTimeIntVal(row, isNull);
if (isNull || value <= 0.0)
{
isNull = true;
return doubleNullVal();
}
if (parm.size() > 1 )
{
double value2 = parm[1]->data()->getDoubleVal(row, isNull);
if (isNull || (value2 <= 0.0 || value == 1.0) )
{
isNull = true;
return doubleNullVal();
}
return log(value2) / log((double)value);
}
return log((double)value);
}
break;
case execplan::CalpontSystemCatalog::VARCHAR:
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::TEXT:
@ -797,6 +918,20 @@ double Func_log2::getDoubleVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
int64_t value = parm[0]->data()->getTimeIntVal(row, isNull);
if (isNull || value <= 0.0)
{
isNull = true;
return doubleNullVal();
}
return log2(value);
}
break;
case execplan::CalpontSystemCatalog::VARCHAR:
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::TEXT:
@ -891,6 +1026,20 @@ double Func_log10::getDoubleVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
int64_t value = parm[0]->data()->getTimeIntVal(row, isNull);
if (isNull || value <= 0.0)
{
isNull = true;
return doubleNullVal();
}
return log10((double)value);
}
break;
case execplan::CalpontSystemCatalog::VARCHAR:
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::TEXT:
@ -988,6 +1137,20 @@ double Func_sin::getDoubleVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
int64_t value = parm[0]->data()->getTimeIntVal(row, isNull);
if (isNull)
{
isNull = true;
return doubleNullVal();
}
return sin((double)value);
}
break;
default:
{
std::ostringstream oss;
@ -1077,6 +1240,20 @@ double Func_sqrt::getDoubleVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
int64_t value = parm[0]->data()->getTimeIntVal(row, isNull);
if (isNull || value < 0)
{
isNull = true;
return doubleNullVal();
}
return sqrt((double)value);
}
break;
default:
{
std::ostringstream oss;
@ -1166,6 +1343,20 @@ double Func_tan::getDoubleVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
int64_t value = parm[0]->data()->getTimeIntVal(row, isNull);
if (isNull)
{
isNull = true;
return doubleNullVal();
}
return tan((double)value);
}
break;
default:
{
std::ostringstream oss;
@ -1253,6 +1444,12 @@ string Func_format::getStrVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
value = dataconvert::DataConvert::timeToString1(parm[0]->data()->getTimeIntVal(row, isNull));
}
break;
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
{
@ -1474,6 +1671,20 @@ double Func_radians::getDoubleVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
int64_t value = parm[0]->data()->getTimeIntVal(row, isNull);
if (isNull)
{
isNull = true;
return doubleNullVal();
}
return radians((double)value);
}
break;
default:
{
std::ostringstream oss;
@ -1563,6 +1774,20 @@ double Func_degrees::getDoubleVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
int64_t value = parm[0]->data()->getTimeIntVal(row, isNull);
if (isNull)
{
isNull = true;
return doubleNullVal();
}
return degrees((double)value);
}
break;
default:
{
std::ostringstream oss;