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-1822 Intermediate checkin. DISTINCT not working.
This commit is contained in:
@ -42,7 +42,9 @@ namespace
|
||||
|
||||
using namespace funcexp;
|
||||
|
||||
inline void decimalPlaceDouble(FunctionParm& fp, int64_t& s, double& p, Row& row, bool& isNull)
|
||||
// P should be double or long double
|
||||
template <typename P>
|
||||
inline void decimalPlaceDouble(FunctionParm& fp, int64_t& s, P& p, Row& row, bool& isNull)
|
||||
{
|
||||
s = fp[1]->data()->getIntVal(row, isNull);
|
||||
int64_t d = s;
|
||||
@ -57,9 +59,9 @@ inline void decimalPlaceDouble(FunctionParm& fp, int64_t& s, double& p, Row& row
|
||||
r *= 10;
|
||||
|
||||
if (d >= 0)
|
||||
p = (double) r;
|
||||
p = (P) r;
|
||||
else
|
||||
p = 1.0 / ((double) r);
|
||||
p = 1.0 / ((P) r);
|
||||
}
|
||||
|
||||
}
|
||||
@ -223,6 +225,60 @@ double Func_truncate::getDoubleVal(Row& row,
|
||||
return d;
|
||||
}
|
||||
|
||||
long double Func_truncate::getLongDoubleVal(Row& row,
|
||||
FunctionParm& parm,
|
||||
bool& isNull,
|
||||
CalpontSystemCatalog::ColType& op_ct)
|
||||
{
|
||||
if (execplan::CalpontSystemCatalog::LONGDOUBLE == op_ct.colDataType)
|
||||
{
|
||||
int64_t d = 0;
|
||||
long double p = 1;
|
||||
decimalPlaceDouble(parm, d, p, row, isNull);
|
||||
|
||||
if (isNull)
|
||||
return 0.0;
|
||||
|
||||
long double x = parm[0]->data()->getLongDoubleVal(row, isNull);
|
||||
|
||||
if (!isNull)
|
||||
{
|
||||
x *= p;
|
||||
|
||||
if (x > 0)
|
||||
x = floor(x);
|
||||
else
|
||||
x = ceil(x);
|
||||
|
||||
if (p != 0.0)
|
||||
x /= p;
|
||||
else
|
||||
x = 0.0;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
IDB_Decimal x = getDecimalVal(row, parm, isNull, op_ct);
|
||||
|
||||
if (isNull)
|
||||
return 0.0;
|
||||
|
||||
double d = x.value;
|
||||
|
||||
if (x.scale > 0)
|
||||
{
|
||||
while (x.scale-- > 0)
|
||||
d /= 10.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (x.scale++ < 0)
|
||||
d *= 10.0;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
IDB_Decimal Func_truncate::getDecimalVal(Row& row,
|
||||
FunctionParm& parm,
|
||||
@ -325,6 +381,26 @@ IDB_Decimal Func_truncate::getDecimalVal(Row& row,
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::LONGDOUBLE:
|
||||
{
|
||||
int64_t s = 0;
|
||||
long double p = 1;
|
||||
decimalPlaceDouble(parm, s, p, row, isNull);
|
||||
|
||||
if (isNull)
|
||||
break;
|
||||
|
||||
long double x = parm[0]->data()->getLongDoubleVal(row, isNull);
|
||||
|
||||
if (!isNull)
|
||||
{
|
||||
x *= p;
|
||||
decimal.value = (int64_t) x;
|
||||
decimal.scale = s;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATE:
|
||||
{
|
||||
int32_t s = 0;
|
||||
|
Reference in New Issue
Block a user