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-521 Some more fixes for multi-parm aggregates. Add regr slope
This commit is contained in:
@ -84,77 +84,12 @@ mcsv1_UDAF::ReturnCode regr_avgx::reset(mcsv1Context* context)
|
||||
|
||||
mcsv1_UDAF::ReturnCode regr_avgx::nextValue(mcsv1Context* context, ColumnDatum* valsIn)
|
||||
{
|
||||
static_any::any& valIn_y = valsIn[0].columnData;
|
||||
static_any::any& valIn_x = valsIn[1].columnData;
|
||||
struct regr_avgx_data* data = (struct regr_avgx_data*)context->getUserData()->data;
|
||||
DATATYPE val = 0.0;
|
||||
|
||||
if (context->isParamNull(0) || context->isParamNull(1))
|
||||
{
|
||||
return mcsv1_UDAF::SUCCESS; // Ought not happen when UDAF_IGNORE_NULLS is on.
|
||||
}
|
||||
|
||||
if (valIn_x.empty() || valIn_y.empty()) // Usually empty if NULL. Probably redundant
|
||||
{
|
||||
return mcsv1_UDAF::SUCCESS; // Ought not happen when UDAF_IGNORE_NULLS is on.
|
||||
}
|
||||
|
||||
if (valIn_x.compatible(longTypeId))
|
||||
{
|
||||
val = valIn_x.cast<long>();
|
||||
}
|
||||
else if (valIn_x.compatible(charTypeId))
|
||||
{
|
||||
val = valIn_x.cast<char>();
|
||||
}
|
||||
else if (valIn_x.compatible(scharTypeId))
|
||||
{
|
||||
val = valIn_x.cast<signed char>();
|
||||
}
|
||||
else if (valIn_x.compatible(shortTypeId))
|
||||
{
|
||||
val = valIn_x.cast<short>();
|
||||
}
|
||||
else if (valIn_x.compatible(intTypeId))
|
||||
{
|
||||
val = valIn_x.cast<int>();
|
||||
}
|
||||
else if (valIn_x.compatible(llTypeId))
|
||||
{
|
||||
val = valIn_x.cast<long long>();
|
||||
}
|
||||
else if (valIn_x.compatible(ucharTypeId))
|
||||
{
|
||||
val = valIn_x.cast<unsigned char>();
|
||||
}
|
||||
else if (valIn_x.compatible(ushortTypeId))
|
||||
{
|
||||
val = valIn_x.cast<unsigned short>();
|
||||
}
|
||||
else if (valIn_x.compatible(uintTypeId))
|
||||
{
|
||||
val = valIn_x.cast<unsigned int>();
|
||||
}
|
||||
else if (valIn_x.compatible(ulongTypeId))
|
||||
{
|
||||
val = valIn_x.cast<unsigned long>();
|
||||
}
|
||||
else if (valIn_x.compatible(ullTypeId))
|
||||
{
|
||||
val = valIn_x.cast<unsigned long long>();
|
||||
}
|
||||
else if (valIn_x.compatible(floatTypeId))
|
||||
{
|
||||
val = valIn_x.cast<float>();
|
||||
}
|
||||
else if (valIn_x.compatible(doubleTypeId))
|
||||
{
|
||||
val = valIn_x.cast<double>();
|
||||
}
|
||||
DATATYPE val = convertAnyTo<double>(valIn_x);
|
||||
|
||||
// For decimal types, we need to move the decimal point.
|
||||
uint32_t scale = valsIn[1].scale;
|
||||
|
||||
if (val != 0 && scale > 0)
|
||||
{
|
||||
val /= pow(10.0, (double)scale);
|
||||
@ -202,76 +137,12 @@ mcsv1_UDAF::ReturnCode regr_avgx::evaluate(mcsv1Context* context, static_any::an
|
||||
|
||||
mcsv1_UDAF::ReturnCode regr_avgx::dropValue(mcsv1Context* context, ColumnDatum* valsDropped)
|
||||
{
|
||||
static_any::any& valIn_y = valsDropped[0].columnData;
|
||||
static_any::any& valIn_x = valsDropped[1].columnData;
|
||||
struct regr_avgx_data* data = (struct regr_avgx_data*)context->getUserData()->data;
|
||||
DATATYPE val = 0.0;
|
||||
|
||||
if (context->isParamNull(0) || context->isParamNull(1))
|
||||
{
|
||||
return mcsv1_UDAF::SUCCESS; // Ought not happen when UDAF_IGNORE_NULLS is on.
|
||||
}
|
||||
if (valIn_x.empty() || valIn_y.empty())
|
||||
{
|
||||
return mcsv1_UDAF::SUCCESS; // Ought not happen when UDAF_IGNORE_NULLS is on.
|
||||
}
|
||||
|
||||
if (valIn_x.compatible(charTypeId))
|
||||
{
|
||||
val = valIn_x.cast<char>();
|
||||
}
|
||||
else if (valIn_x.compatible(scharTypeId))
|
||||
{
|
||||
val = valIn_x.cast<signed char>();
|
||||
}
|
||||
else if (valIn_x.compatible(shortTypeId))
|
||||
{
|
||||
val = valIn_x.cast<short>();
|
||||
}
|
||||
else if (valIn_x.compatible(intTypeId))
|
||||
{
|
||||
val = valIn_x.cast<int>();
|
||||
}
|
||||
else if (valIn_x.compatible(longTypeId))
|
||||
{
|
||||
val = valIn_x.cast<long>();
|
||||
}
|
||||
else if (valIn_x.compatible(llTypeId))
|
||||
{
|
||||
val = valIn_x.cast<long long>();
|
||||
}
|
||||
else if (valIn_x.compatible(ucharTypeId))
|
||||
{
|
||||
val = valIn_x.cast<unsigned char>();
|
||||
}
|
||||
else if (valIn_x.compatible(ushortTypeId))
|
||||
{
|
||||
val = valIn_x.cast<unsigned short>();
|
||||
}
|
||||
else if (valIn_x.compatible(uintTypeId))
|
||||
{
|
||||
val = valIn_x.cast<unsigned int>();
|
||||
}
|
||||
else if (valIn_x.compatible(ulongTypeId))
|
||||
{
|
||||
val = valIn_x.cast<unsigned long>();
|
||||
}
|
||||
else if (valIn_x.compatible(ullTypeId))
|
||||
{
|
||||
val = valIn_x.cast<unsigned long long>();
|
||||
}
|
||||
else if (valIn_x.compatible(floatTypeId))
|
||||
{
|
||||
val = valIn_x.cast<float>();
|
||||
}
|
||||
else if (valIn_x.compatible(doubleTypeId))
|
||||
{
|
||||
val = valIn_x.cast<double>();
|
||||
}
|
||||
double val = convertAnyTo<double>(valIn_x);
|
||||
|
||||
// For decimal types, we need to move the decimal point.
|
||||
uint32_t scale = valsDropped[1].scale;
|
||||
|
||||
if (val != 0 && scale > 0)
|
||||
{
|
||||
val /= pow(10.0, (double)scale);
|
||||
|
Reference in New Issue
Block a user