You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-07 03:22:57 +03:00
Merge pull request #31 from mariadb-corporation/MCOL-328-mk2
MCOL-328 Fix func float -> str conversion
This commit is contained in:
@@ -90,22 +90,37 @@ protected:
|
|||||||
// Bug3788, use the shorter of fixed or scientific notation for floating point values.
|
// Bug3788, use the shorter of fixed or scientific notation for floating point values.
|
||||||
// [ the default format in treenode.h is fixed-point notation ]
|
// [ the default format in treenode.h is fixed-point notation ]
|
||||||
char buf[20];
|
char buf[20];
|
||||||
|
double floatVal;
|
||||||
|
int exponent;
|
||||||
|
double base;
|
||||||
switch (fp->data()->resultType().colDataType)
|
switch (fp->data()->resultType().colDataType)
|
||||||
{
|
{
|
||||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||||
snprintf(buf, 20, "%.10g", fp->data()->getDoubleVal(row, isNull));
|
floatVal = fp->data()->getDoubleVal(row, isNull);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case execplan::CalpontSystemCatalog::FLOAT:
|
case execplan::CalpontSystemCatalog::FLOAT:
|
||||||
snprintf(buf, 20, "%g", fp->data()->getFloatVal(row, isNull));
|
floatVal = fp->data()->getFloatVal(row, isNull);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fp->data()->getStrVal(row, isNull);
|
return fp->data()->getStrVal(row, isNull);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
exponent = (int)floor(log10( fabs(floatVal)));
|
||||||
|
base = floatVal * pow(10, -1.0*exponent);
|
||||||
|
if (isnan(exponent) || isnan(base))
|
||||||
|
{
|
||||||
|
snprintf(buf, 20, "%f", floatVal);
|
||||||
|
fFloatStr = execplan::removeTrailing0(buf, 20);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snprintf(buf, 20, "%.5f", base);
|
||||||
|
fFloatStr = execplan::removeTrailing0(buf, 20);
|
||||||
|
snprintf(buf, 20, "e%02d", exponent);
|
||||||
|
fFloatStr += buf;
|
||||||
|
}
|
||||||
|
|
||||||
fFloatStr = std::string(buf);
|
|
||||||
return fFloatStr;
|
return fFloatStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user