Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
#include <decimal-operators.h>
Public Types | |
enum | DecimalRoundOp { TRUNCATE, FLOOR, CEIL, ROUND } |
Static Private Member Functions | |
static DecimalVal | IntToDecimalVal (FunctionContext *context, const ColumnType &type, int64_t val) |
Converts 'val' to a DecimalVal according to 'type'. 'type' must be a decimal type. More... | |
static DecimalVal | FloatToDecimalVal (FunctionContext *context, const ColumnType &type, double val) |
static DecimalVal | ScaleDecimalValue (FunctionContext *context, const Decimal4Value &val, const ColumnType &val_type, const ColumnType &output_type) |
Returns the value of 'val' scaled to 'output_type'. More... | |
static DecimalVal | ScaleDecimalValue (FunctionContext *context, const Decimal8Value &val, const ColumnType &val_type, const ColumnType &output_type) |
static DecimalVal | ScaleDecimalValue (FunctionContext *context, const Decimal16Value &val, const ColumnType &val_type, const ColumnType &output_type) |
template<typename T > | |
static T | RoundDelta (const DecimalValue< T > &v, int src_scale, int target_scale, const DecimalRoundOp &op) |
Implementation of the decimal operators. These include the cast, arithmetic and binary operators.
Definition at line 33 of file decimal-operators.h.
The rounding rule when converting decimals. These only apply going from a higher scale to a lower one.
Definition at line 81 of file decimal-operators.h.
|
static |
|
static |
|
static |
Definition at line 534 of file decimal-operators.cc.
References impala_udf::FunctionContext::GetArgType(), impala::ColumnType::GetByteSize(), impala_udf::AnyVal::is_null, impala::ColumnType::type, impala::TYPE_DECIMAL, impala::AnyValUtil::TypeDescToColumnType(), impala_udf::DecimalVal::val16, impala_udf::DecimalVal::val4, and impala_udf::DecimalVal::val8.
|
static |
Definition at line 435 of file decimal-operators.cc.
References RoundDecimal(), and TRUNCATE.
Referenced by impala::Expr::InitBuiltinsDummy().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 440 of file decimal-operators.cc.
References impala::ColumnType::GetByteSize(), impala_udf::FunctionContext::GetReturnType(), impala_udf::AnyVal::is_null, impala_udf::StringVal::len, impala::StringParser::PARSE_SUCCESS, impala::StringParser::PARSE_UNDERFLOW, impala_udf::StringVal::ptr, impala::AnyValUtil::TypeDescToColumnType(), and impala::DecimalValue< T >::value().
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 478 of file decimal-operators.cc.
References impala_udf::FunctionContext::GetArgType(), impala::ColumnType::GetByteSize(), impala_udf::AnyVal::is_null, impala::DecimalValue< T >::ToString(), impala::AnyValUtil::TypeDescToColumnType(), impala_udf::DecimalVal::val16, impala_udf::DecimalVal::val4, and impala_udf::DecimalVal::val8.
|
static |
Definition at line 502 of file decimal-operators.cc.
References impala_udf::FunctionContext::GetArgType(), impala::ColumnType::GetByteSize(), impala_udf::AnyVal::is_null, impala::DecimalValue< T >::ToDouble(), impala::TimestampValue::ToTimestampVal(), impala::ColumnType::type, impala::TYPE_DECIMAL, impala::AnyValUtil::TypeDescToColumnType(), impala_udf::DecimalVal::val16, impala_udf::DecimalVal::val4, and impala_udf::DecimalVal::val8.
|
static |
|
static |
|
static |
|
inlinestaticprivate |
Definition at line 66 of file decimal-operators.cc.
References impala::DecimalValue< int32_t >::FromDouble(), impala::DecimalValue< int128_t >::FromDouble(), impala::DecimalValue< int64_t >::FromDouble(), impala::ColumnType::GetByteSize(), RETURN_IF_OVERFLOW, impala::ColumnType::type, impala::TYPE_DECIMAL, and impala::DecimalValue< T >::value().
|
static |
|
static |
|
inlinestaticprivate |
Converts 'val' to a DecimalVal according to 'type'. 'type' must be a decimal type.
Definition at line 40 of file decimal-operators.cc.
References impala::DecimalValue< int32_t >::FromInt(), impala::DecimalValue< int128_t >::FromInt(), impala::DecimalValue< int64_t >::FromInt(), impala::ColumnType::GetByteSize(), RETURN_IF_OVERFLOW, impala::ColumnType::type, impala::TYPE_DECIMAL, and impala::DecimalValue< T >::value().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Evaluates a round from 'val' and returns the result, using the rounding rule of 'type'.
Definition at line 377 of file decimal-operators.cc.
References impala::ColumnType::GetByteSize(), impala_udf::AnyVal::is_null, RoundDelta(), impala::ColumnType::scale, ScaleDecimalValue(), impala::ColumnType::type, impala::TYPE_DECIMAL, impala_udf::DecimalVal::val16, impala_udf::DecimalVal::val4, and impala_udf::DecimalVal::val8.
Referenced by CastToDecimalVal(), impala::DecimalFunctions::Ceil(), impala::DecimalFunctions::Floor(), impala::DecimalFunctions::Round(), RoundDecimal(), impala::DecimalFunctions::RoundTo(), and impala::DecimalFunctions::Truncate().
|
static |
Same as above but infers 'val_type' from the first argument type and 'output_type' from the return type according to 'context'.
Definition at line 425 of file decimal-operators.cc.
References impala_udf::FunctionContext::GetArgType(), impala_udf::FunctionContext::GetReturnType(), RoundDecimal(), and impala::AnyValUtil::TypeDescToColumnType().
|
static |
Handles the case of rounding to a negative scale. This means rounding to a digit before the decimal point. rounding_scale is the number of digits before the decimal to round to. TODO: can this code be reorganized to combine the two version of RoundDecimal()? The implementation is similar but not quite the same. This code is, in general, harder to read because there are multiple input/output types to handle and all combinations are valid. Another option might be to use templates to generate each pair: Decimal4Value Round(const Decimal4Value&); Decimal8Value Round(const Decimal4Value&); Decimal4Value Round(const Decimal8Value&); etc.
Definition at line 306 of file decimal-operators.cc.
References impala::abs(), impala_udf::AnyVal::is_null, impala::DecimalUtil::MAX_UNSCALED_DECIMAL, impala_udf::DecimalVal::val16, impala_udf::DecimalVal::val4, impala_udf::DecimalVal::val8, and impala::DecimalValue< T >::value().
Referenced by impala::DecimalFunctions::RoundTo().
|
inlinestaticprivate |
Returns the delta that needs to be added when the source decimal is rounded to target scale. Returns 0, if no rounding is necessary, or -1/1 if rounding is required.
Definition at line 147 of file decimal-operators.h.
References impala::abs(), and impala::DecimalValue< T >::value().
Referenced by RoundDecimal().
|
inlinestaticprivate |
Returns the value of 'val' scaled to 'output_type'.
Definition at line 99 of file decimal-operators.cc.
References impala::ColumnType::GetByteSize(), RETURN_IF_OVERFLOW, impala::DecimalValue< T >::ScaleTo(), impala::ToDecimal16(), impala::ToDecimal8(), impala::ColumnType::type, impala::TYPE_DECIMAL, and impala::DecimalValue< T >::value().
Referenced by RoundDecimal().
|
inlinestaticprivate |
Definition at line 129 of file decimal-operators.cc.
References impala::ColumnType::GetByteSize(), RETURN_IF_OVERFLOW, impala::DecimalValue< T >::ScaleTo(), impala::ToDecimal16(), impala::ToDecimal4(), impala::ColumnType::type, impala::TYPE_DECIMAL, and impala::DecimalValue< T >::value().
|
inlinestaticprivate |
Definition at line 159 of file decimal-operators.cc.
References impala::ColumnType::GetByteSize(), RETURN_IF_OVERFLOW, impala::DecimalValue< T >::ScaleTo(), impala::ToDecimal4(), impala::ToDecimal8(), impala::ColumnType::type, impala::TYPE_DECIMAL, and impala::DecimalValue< T >::value().
|
static |