From 090b6a7eb62f479b2eeb31155697a43a959a4e03 Mon Sep 17 00:00:00 2001 From: Prudhvi Porandla Date: Tue, 9 Jul 2019 15:32:19 +0530 Subject: [PATCH 01/11] support function aliases --- cpp/src/gandiva/expression_registry.cc | 30 ++++-- cpp/src/gandiva/expression_registry.h | 12 ++- cpp/src/gandiva/expression_registry_test.cc | 9 +- cpp/src/gandiva/function_registry.cc | 8 +- cpp/src/gandiva/function_registry.h | 1 + .../gandiva/function_registry_arithmetic.cc | 77 ++++++------- cpp/src/gandiva/function_registry_common.h | 101 +++++++++--------- cpp/src/gandiva/function_registry_datetime.cc | 44 ++++---- cpp/src/gandiva/function_registry_hash.cc | 34 +++--- cpp/src/gandiva/function_registry_math_ops.cc | 72 ++++++------- cpp/src/gandiva/function_registry_string.cc | 58 +++++----- cpp/src/gandiva/function_registry_test.cc | 3 +- .../function_registry_timestamp_arithmetic.cc | 88 +++++++-------- cpp/src/gandiva/native_function.h | 18 ++-- 14 files changed, 300 insertions(+), 255 deletions(-) diff --git a/cpp/src/gandiva/expression_registry.cc b/cpp/src/gandiva/expression_registry.cc index d0629635530..ffdb67041f4 100644 --- a/cpp/src/gandiva/expression_registry.cc +++ b/cpp/src/gandiva/expression_registry.cc @@ -30,28 +30,46 @@ ExpressionRegistry::ExpressionRegistry() { ExpressionRegistry::~ExpressionRegistry() {} +ExpressionRegistry::FunctionSignatureIterator::FunctionSignatureIterator( + nf_iterator nf_it, nf_iterator nf_it_end) + : nf_it_(nf_it), nf_it_end_(nf_it_end), fs_it_(&(nf_it->signatures().front())) {} +ExpressionRegistry::FunctionSignatureIterator::FunctionSignatureIterator( + fs_iterator fs_it) + : fs_it_(fs_it) {} + const ExpressionRegistry::FunctionSignatureIterator ExpressionRegistry::function_signature_begin() { - return FunctionSignatureIterator(function_registry_->begin()); + return FunctionSignatureIterator(function_registry_->begin(), + function_registry_->end()); // nf_it ctr } const ExpressionRegistry::FunctionSignatureIterator ExpressionRegistry::function_signature_end() const { - return FunctionSignatureIterator(function_registry_->end()); + return FunctionSignatureIterator( + &(*(function_registry_->back()->signatures().end()))); // fs_it ctr } bool ExpressionRegistry::FunctionSignatureIterator::operator!=( const FunctionSignatureIterator& func_sign_it) { - return func_sign_it.it_ != this->it_; + return func_sign_it.fs_it_ != this->fs_it_; } FunctionSignature ExpressionRegistry::FunctionSignatureIterator::operator*() { - return (*it_).signature(); + return *fs_it_; } -ExpressionRegistry::iterator ExpressionRegistry::FunctionSignatureIterator::operator++( +ExpressionRegistry::fs_iterator ExpressionRegistry::FunctionSignatureIterator::operator++( int increment) { - return it_++; + ++fs_it_; + // point fs_it_ to first signature of next nativefunction if fs_it_ is pointing to end + if (fs_it_ == &(*nf_it_->signatures().end())) { + ++nf_it_; + if (nf_it_ == nf_it_end_) { // last native function + return fs_it_; + } + fs_it_ = &(nf_it_->signatures().front()); + } + return fs_it_; } DataTypeVector ExpressionRegistry::supported_types_ = diff --git a/cpp/src/gandiva/expression_registry.h b/cpp/src/gandiva/expression_registry.h index 97197f29004..3bf0f84cf2c 100644 --- a/cpp/src/gandiva/expression_registry.h +++ b/cpp/src/gandiva/expression_registry.h @@ -36,22 +36,26 @@ class FunctionRegistry; /// data types and functions supported by Gandiva. class GANDIVA_EXPORT ExpressionRegistry { public: - using iterator = const NativeFunction*; + using nf_iterator = const NativeFunction*; + using fs_iterator = const FunctionSignature*; ExpressionRegistry(); ~ExpressionRegistry(); static DataTypeVector supported_types() { return supported_types_; } class GANDIVA_EXPORT FunctionSignatureIterator { public: - explicit FunctionSignatureIterator(iterator it) : it_(it) {} + explicit FunctionSignatureIterator(nf_iterator nf_it, nf_iterator nf_it_end_); + explicit FunctionSignatureIterator(fs_iterator fs_it); bool operator!=(const FunctionSignatureIterator& func_sign_it); FunctionSignature operator*(); - iterator operator++(int); + fs_iterator operator++(int); private: - iterator it_; + nf_iterator nf_it_; + nf_iterator nf_it_end_; + fs_iterator fs_it_; }; const FunctionSignatureIterator function_signature_begin(); const FunctionSignatureIterator function_signature_end() const; diff --git a/cpp/src/gandiva/expression_registry_test.cc b/cpp/src/gandiva/expression_registry_test.cc index c50e136d69d..c254ff4f3aa 100644 --- a/cpp/src/gandiva/expression_registry_test.cc +++ b/cpp/src/gandiva/expression_registry_test.cc @@ -43,10 +43,11 @@ TEST_F(TestExpressionRegistry, VerifySupportedFunctions) { functions.push_back((*iter)); } for (auto& iter : registry_) { - auto function = iter.signature(); - auto element = std::find(functions.begin(), functions.end(), function); - EXPECT_NE(element, functions.end()) - << "function " << iter.pc_name() << " missing in supported functions.\n"; + for (auto& func_iter : iter.signatures()) { + auto element = std::find(functions.begin(), functions.end(), func_iter); + EXPECT_NE(element, functions.end()) << "function signature " << func_iter.ToString() + << " missing in supported functions.\n"; + } } } diff --git a/cpp/src/gandiva/function_registry.cc b/cpp/src/gandiva/function_registry.cc index 43eda4dee77..d5d015c10b4 100644 --- a/cpp/src/gandiva/function_registry.cc +++ b/cpp/src/gandiva/function_registry.cc @@ -37,6 +37,10 @@ FunctionRegistry::iterator FunctionRegistry::end() const { return &(*pc_registry_.end()); } +FunctionRegistry::iterator FunctionRegistry::back() const { + return &(pc_registry_.back()); +} + std::vector FunctionRegistry::pc_registry_; SignatureMap FunctionRegistry::pc_registry_map_ = InitPCMap(); @@ -62,7 +66,9 @@ SignatureMap FunctionRegistry::InitPCMap() { pc_registry_.insert(std::end(pc_registry_), v6.begin(), v6.end()); for (auto& elem : pc_registry_) { - map.insert(std::make_pair(&(elem.signature()), &elem)); + for (auto& func_signature : elem.signatures()) { + map.insert(std::make_pair(&(func_signature), &elem)); + } } return map; diff --git a/cpp/src/gandiva/function_registry.h b/cpp/src/gandiva/function_registry.h index f7aa3de4bb5..dadc8318a77 100644 --- a/cpp/src/gandiva/function_registry.h +++ b/cpp/src/gandiva/function_registry.h @@ -36,6 +36,7 @@ class GANDIVA_EXPORT FunctionRegistry { iterator begin() const; iterator end() const; + iterator back() const; private: static SignatureMap InitPCMap(); diff --git a/cpp/src/gandiva/function_registry_arithmetic.cc b/cpp/src/gandiva/function_registry_arithmetic.cc index f5d5ce77019..e919d0b5e9f 100644 --- a/cpp/src/gandiva/function_registry_arithmetic.cc +++ b/cpp/src/gandiva/function_registry_arithmetic.cc @@ -20,23 +20,24 @@ namespace gandiva { -#define BINARY_SYMMETRIC_FN(name) NUMERIC_TYPES(BINARY_SYMMETRIC_SAFE_NULL_IF_NULL, name) +#define BINARY_SYMMETRIC_FN(name, ALIASES) \ + NUMERIC_TYPES(BINARY_SYMMETRIC_SAFE_NULL_IF_NULL, name, ALIASES) -#define BINARY_RELATIONAL_BOOL_FN(name) \ - NUMERIC_BOOL_DATE_TYPES(BINARY_RELATIONAL_SAFE_NULL_IF_NULL, name) +#define BINARY_RELATIONAL_BOOL_FN(name, ALIASES) \ + NUMERIC_BOOL_DATE_TYPES(BINARY_RELATIONAL_SAFE_NULL_IF_NULL, name, ALIASES) -#define BINARY_RELATIONAL_BOOL_DATE_FN(name) \ - NUMERIC_DATE_TYPES(BINARY_RELATIONAL_SAFE_NULL_IF_NULL, name) +#define BINARY_RELATIONAL_BOOL_DATE_FN(name, ALIASES) \ + NUMERIC_DATE_TYPES(BINARY_RELATIONAL_SAFE_NULL_IF_NULL, name, ALIASES) -#define UNARY_CAST_TO_FLOAT64(name) UNARY_SAFE_NULL_IF_NULL(castFLOAT8, name, float64) +#define UNARY_CAST_TO_FLOAT64(name) UNARY_SAFE_NULL_IF_NULL(castFLOAT8, {}, name, float64) -#define UNARY_CAST_TO_FLOAT32(name) UNARY_SAFE_NULL_IF_NULL(castFLOAT4, name, float32) +#define UNARY_CAST_TO_FLOAT32(name) UNARY_SAFE_NULL_IF_NULL(castFLOAT4, {}, name, float32) std::vector GetArithmeticFunctionRegistry() { static std::vector arithmetic_fn_registry_ = { - UNARY_SAFE_NULL_IF_NULL(not, boolean, boolean), - UNARY_SAFE_NULL_IF_NULL(castBIGINT, int32, int64), - UNARY_SAFE_NULL_IF_NULL(castBIGINT, decimal128, int64), + UNARY_SAFE_NULL_IF_NULL(not, {}, boolean, boolean), + UNARY_SAFE_NULL_IF_NULL(castBIGINT, {}, int32, int64), + UNARY_SAFE_NULL_IF_NULL(castBIGINT, {}, decimal128, int64), // cast to float32 UNARY_CAST_TO_FLOAT32(int32), UNARY_CAST_TO_FLOAT32(int64), @@ -46,39 +47,39 @@ std::vector GetArithmeticFunctionRegistry() { UNARY_CAST_TO_FLOAT64(float32), UNARY_CAST_TO_FLOAT64(decimal128), // cast to decimal - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, int32, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, int64, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, float32, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, float64, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, decimal128, decimal128), - UNARY_UNSAFE_NULL_IF_NULL(castDECIMAL, utf8, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, int32, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, int64, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, float32, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, float64, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, decimal128, decimal128), + UNARY_UNSAFE_NULL_IF_NULL(castDECIMAL, {}, utf8, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDATE, int64, date64), + UNARY_SAFE_NULL_IF_NULL(castDATE, {}, int64, date64), // add/sub/multiply/divide/mod - BINARY_SYMMETRIC_FN(add), BINARY_SYMMETRIC_FN(subtract), - BINARY_SYMMETRIC_FN(multiply), - NUMERIC_TYPES(BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL, divide), - BINARY_GENERIC_SAFE_NULL_IF_NULL(mod, int64, int32, int32), - BINARY_GENERIC_SAFE_NULL_IF_NULL(mod, int64, int64, int64), - BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(add, decimal128), - BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(subtract, decimal128), - BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(multiply, decimal128), - BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(divide, decimal128), - BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(mod, decimal128), + BINARY_SYMMETRIC_FN(add, {}), BINARY_SYMMETRIC_FN(subtract, {}), + BINARY_SYMMETRIC_FN(multiply, {}), + NUMERIC_TYPES(BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL, divide, {"div"}), + BINARY_GENERIC_SAFE_NULL_IF_NULL(mod, {}, int64, int32, int32), + BINARY_GENERIC_SAFE_NULL_IF_NULL(mod, {}, int64, int64, int64), + BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(add, {}, decimal128), + BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(subtract, {}, decimal128), + BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(multiply, {}, decimal128), + BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(divide, {}, decimal128), + BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(mod, {}, decimal128), // compare functions - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(equal, decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(not_equal, decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(less_than, decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(less_than_or_equal_to, decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(greater_than, decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(greater_than_or_equal_to, decimal128), - BINARY_RELATIONAL_BOOL_FN(equal), BINARY_RELATIONAL_BOOL_FN(not_equal), - BINARY_RELATIONAL_BOOL_DATE_FN(less_than), - BINARY_RELATIONAL_BOOL_DATE_FN(less_than_or_equal_to), - BINARY_RELATIONAL_BOOL_DATE_FN(greater_than), - BINARY_RELATIONAL_BOOL_DATE_FN(greater_than_or_equal_to)}; + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(equal, {}, decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(not_equal, {}, decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(less_than, {}, decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(less_than_or_equal_to, {}, decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(greater_than, {}, decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(greater_than_or_equal_to, {}, decimal128), + BINARY_RELATIONAL_BOOL_FN(equal, {}), BINARY_RELATIONAL_BOOL_FN(not_equal, {}), + BINARY_RELATIONAL_BOOL_DATE_FN(less_than, {}), + BINARY_RELATIONAL_BOOL_DATE_FN(less_than_or_equal_to, {}), + BINARY_RELATIONAL_BOOL_DATE_FN(greater_than, {}), + BINARY_RELATIONAL_BOOL_DATE_FN(greater_than_or_equal_to, {})}; return arithmetic_fn_registry_; } diff --git a/cpp/src/gandiva/function_registry_common.h b/cpp/src/gandiva/function_registry_common.h index f6a3d14c56c..c0eaa8dc3b5 100644 --- a/cpp/src/gandiva/function_registry_common.h +++ b/cpp/src/gandiva/function_registry_common.h @@ -74,9 +74,9 @@ typedef std::unordered_map GetDateTimeFunctionRegistry() { static std::vector date_time_fn_registry_ = { DATE_EXTRACTION_FNS(extract), DATE_EXTRACTION_FNS(date_trunc_), - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractDoy), - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractDow), - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractEpoch), + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractDoy, {}), + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractDow, {}), + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractEpoch, {}), TIME_EXTRACTION_FNS(extract), - NativeFunction("castDATE", DataTypeVector{utf8()}, date64(), kResultNullIfNull, + NativeFunction("castDATE", {}, DataTypeVector{utf8()}, date64(), kResultNullIfNull, "castDATE_utf8", NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors), - NativeFunction("castTIMESTAMP", DataTypeVector{utf8()}, timestamp(), + NativeFunction("castTIMESTAMP", {}, DataTypeVector{utf8()}, timestamp(), kResultNullIfNull, "castTIMESTAMP_utf8", NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors), - NativeFunction("to_date", DataTypeVector{utf8(), utf8(), int32()}, date64(), + NativeFunction("to_date", {}, DataTypeVector{utf8(), utf8(), int32()}, date64(), kResultNullInternal, "gdv_fn_to_date_utf8_utf8_int32", NativeFunction::kNeedsContext | NativeFunction::kNeedsFunctionHolder | diff --git a/cpp/src/gandiva/function_registry_hash.cc b/cpp/src/gandiva/function_registry_hash.cc index a163a230eac..4184f50ba81 100644 --- a/cpp/src/gandiva/function_registry_hash.cc +++ b/cpp/src/gandiva/function_registry_hash.cc @@ -20,32 +20,32 @@ namespace gandiva { -#define HASH32_SAFE_NULL_NEVER_FN(name) \ - NUMERIC_BOOL_DATE_VAR_LEN_TYPES(HASH32_SAFE_NULL_NEVER, name) +#define HASH32_SAFE_NULL_NEVER_FN(name, ALIASES) \ + NUMERIC_BOOL_DATE_VAR_LEN_TYPES(HASH32_SAFE_NULL_NEVER, name, ALIASES) -#define HASH32_SEED_SAFE_NULL_NEVER_FN(name) \ - NUMERIC_BOOL_DATE_VAR_LEN_TYPES(HASH32_SEED_SAFE_NULL_NEVER, name) +#define HASH32_SEED_SAFE_NULL_NEVER_FN(name, ALIASES) \ + NUMERIC_BOOL_DATE_VAR_LEN_TYPES(HASH32_SEED_SAFE_NULL_NEVER, name, ALIASES) -#define HASH64_SAFE_NULL_NEVER_FN(name) \ - NUMERIC_BOOL_DATE_VAR_LEN_TYPES(HASH64_SAFE_NULL_NEVER, name) +#define HASH64_SAFE_NULL_NEVER_FN(name, ALIASES) \ + NUMERIC_BOOL_DATE_VAR_LEN_TYPES(HASH64_SAFE_NULL_NEVER, name, ALIASES) -#define HASH64_SEED_SAFE_NULL_NEVER_FN(name) \ - NUMERIC_BOOL_DATE_VAR_LEN_TYPES(HASH64_SEED_SAFE_NULL_NEVER, name) +#define HASH64_SEED_SAFE_NULL_NEVER_FN(name, ALIASES) \ + NUMERIC_BOOL_DATE_VAR_LEN_TYPES(HASH64_SEED_SAFE_NULL_NEVER, name, ALIASES) std::vector GetHashFunctionRegistry() { static std::vector hash_fn_registry_ = { - HASH32_SAFE_NULL_NEVER_FN(hash), - HASH32_SAFE_NULL_NEVER_FN(hash32), - HASH32_SAFE_NULL_NEVER_FN(hash32AsDouble), + HASH32_SAFE_NULL_NEVER_FN(hash, {}), + HASH32_SAFE_NULL_NEVER_FN(hash32, {}), + HASH32_SAFE_NULL_NEVER_FN(hash32AsDouble, {}), - HASH32_SEED_SAFE_NULL_NEVER_FN(hash32), - HASH32_SEED_SAFE_NULL_NEVER_FN(hash32AsDouble), + HASH32_SEED_SAFE_NULL_NEVER_FN(hash32, {}), + HASH32_SEED_SAFE_NULL_NEVER_FN(hash32AsDouble, {}), - HASH64_SAFE_NULL_NEVER_FN(hash64), - HASH64_SAFE_NULL_NEVER_FN(hash64AsDouble), + HASH64_SAFE_NULL_NEVER_FN(hash64, {}), + HASH64_SAFE_NULL_NEVER_FN(hash64AsDouble, {}), - HASH64_SEED_SAFE_NULL_NEVER_FN(hash64), - HASH64_SEED_SAFE_NULL_NEVER_FN(hash64AsDouble)}; + HASH64_SEED_SAFE_NULL_NEVER_FN(hash64, {}), + HASH64_SEED_SAFE_NULL_NEVER_FN(hash64AsDouble, {})}; return hash_fn_registry_; } diff --git a/cpp/src/gandiva/function_registry_math_ops.cc b/cpp/src/gandiva/function_registry_math_ops.cc index 2084b7bd04c..9c4079d4626 100644 --- a/cpp/src/gandiva/function_registry_math_ops.cc +++ b/cpp/src/gandiva/function_registry_math_ops.cc @@ -20,55 +20,55 @@ namespace gandiva { -#define MATH_UNARY_OPS(name) \ - UNARY_SAFE_NULL_IF_NULL(name, int32, float64), \ - UNARY_SAFE_NULL_IF_NULL(name, int64, float64), \ - UNARY_SAFE_NULL_IF_NULL(name, uint32, float64), \ - UNARY_SAFE_NULL_IF_NULL(name, uint64, float64), \ - UNARY_SAFE_NULL_IF_NULL(name, float32, float64), \ - UNARY_SAFE_NULL_IF_NULL(name, float64, float64) +#define MATH_UNARY_OPS(name, ALIASES) \ + UNARY_SAFE_NULL_IF_NULL(name, ALIASES, int32, float64), \ + UNARY_SAFE_NULL_IF_NULL(name, ALIASES, int64, float64), \ + UNARY_SAFE_NULL_IF_NULL(name, ALIASES, uint32, float64), \ + UNARY_SAFE_NULL_IF_NULL(name, ALIASES, uint64, float64), \ + UNARY_SAFE_NULL_IF_NULL(name, ALIASES, float32, float64), \ + UNARY_SAFE_NULL_IF_NULL(name, ALIASES, float64, float64) -#define MATH_BINARY_UNSAFE(name) \ - BINARY_UNSAFE_NULL_IF_NULL(name, int32, float64), \ - BINARY_UNSAFE_NULL_IF_NULL(name, int64, float64), \ - BINARY_UNSAFE_NULL_IF_NULL(name, uint32, float64), \ - BINARY_UNSAFE_NULL_IF_NULL(name, uint64, float64), \ - BINARY_UNSAFE_NULL_IF_NULL(name, float32, float64), \ - BINARY_UNSAFE_NULL_IF_NULL(name, float64, float64) +#define MATH_BINARY_UNSAFE(name, ALIASES) \ + BINARY_UNSAFE_NULL_IF_NULL(name, ALIASES, int32, float64), \ + BINARY_UNSAFE_NULL_IF_NULL(name, ALIASES, int64, float64), \ + BINARY_UNSAFE_NULL_IF_NULL(name, ALIASES, uint32, float64), \ + BINARY_UNSAFE_NULL_IF_NULL(name, ALIASES, uint64, float64), \ + BINARY_UNSAFE_NULL_IF_NULL(name, ALIASES, float32, float64), \ + BINARY_UNSAFE_NULL_IF_NULL(name, ALIASES, float64, float64) -#define UNARY_SAFE_NULL_NEVER_BOOL_FN(name) \ - NUMERIC_BOOL_DATE_TYPES(UNARY_SAFE_NULL_NEVER_BOOL, name) +#define UNARY_SAFE_NULL_NEVER_BOOL_FN(name, ALIASES) \ + NUMERIC_BOOL_DATE_TYPES(UNARY_SAFE_NULL_NEVER_BOOL, name, ALIASES) -#define BINARY_SAFE_NULL_NEVER_BOOL_FN(name) \ - NUMERIC_BOOL_DATE_TYPES(BINARY_SAFE_NULL_NEVER_BOOL, name) +#define BINARY_SAFE_NULL_NEVER_BOOL_FN(name, ALIASES) \ + NUMERIC_BOOL_DATE_TYPES(BINARY_SAFE_NULL_NEVER_BOOL, name, ALIASES) std::vector GetMathOpsFunctionRegistry() { static std::vector math_fn_registry_ = { - MATH_UNARY_OPS(cbrt), - MATH_UNARY_OPS(exp), - MATH_UNARY_OPS(log), - MATH_UNARY_OPS(log10), + MATH_UNARY_OPS(cbrt, {}), + MATH_UNARY_OPS(exp, {}), + MATH_UNARY_OPS(log, {}), + MATH_UNARY_OPS(log10, {}), - MATH_BINARY_UNSAFE(log), + MATH_BINARY_UNSAFE(log, {}), - BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(power, float64), + BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(power, {}, float64), - UNARY_SAFE_NULL_NEVER_BOOL_FN(isnull), - UNARY_SAFE_NULL_NEVER_BOOL_FN(isnotnull), + UNARY_SAFE_NULL_NEVER_BOOL_FN(isnull, {}), + UNARY_SAFE_NULL_NEVER_BOOL_FN(isnotnull, {}), - NUMERIC_TYPES(UNARY_SAFE_NULL_NEVER_BOOL, isnumeric), + NUMERIC_TYPES(UNARY_SAFE_NULL_NEVER_BOOL, isnumeric, {}), - BINARY_SAFE_NULL_NEVER_BOOL_FN(is_distinct_from), - BINARY_SAFE_NULL_NEVER_BOOL_FN(is_not_distinct_from), + BINARY_SAFE_NULL_NEVER_BOOL_FN(is_distinct_from, {}), + BINARY_SAFE_NULL_NEVER_BOOL_FN(is_not_distinct_from, {}), // decimal functions - UNARY_SAFE_NULL_IF_NULL(abs, decimal128, decimal128), - UNARY_SAFE_NULL_IF_NULL(ceil, decimal128, decimal128), - UNARY_SAFE_NULL_IF_NULL(floor, decimal128, decimal128), - UNARY_SAFE_NULL_IF_NULL(round, decimal128, decimal128), - UNARY_SAFE_NULL_IF_NULL(truncate, decimal128, decimal128), - BINARY_GENERIC_SAFE_NULL_IF_NULL(round, decimal128, int32, decimal128), - BINARY_GENERIC_SAFE_NULL_IF_NULL(truncate, decimal128, int32, decimal128), + UNARY_SAFE_NULL_IF_NULL(abs, {}, decimal128, decimal128), + UNARY_SAFE_NULL_IF_NULL(ceil, {}, decimal128, decimal128), + UNARY_SAFE_NULL_IF_NULL(floor, {}, decimal128, decimal128), + UNARY_SAFE_NULL_IF_NULL(round, {}, decimal128, decimal128), + UNARY_SAFE_NULL_IF_NULL(truncate, {}, decimal128, decimal128), + BINARY_GENERIC_SAFE_NULL_IF_NULL(round, {}, decimal128, int32, decimal128), + BINARY_GENERIC_SAFE_NULL_IF_NULL(truncate, {}, decimal128, int32, decimal128), }; return math_fn_registry_; diff --git a/cpp/src/gandiva/function_registry_string.cc b/cpp/src/gandiva/function_registry_string.cc index af1f37f2059..bd2fe18ccc5 100644 --- a/cpp/src/gandiva/function_registry_string.cc +++ b/cpp/src/gandiva/function_registry_string.cc @@ -20,53 +20,55 @@ namespace gandiva { -#define BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(name) \ - VAR_LEN_TYPES(BINARY_RELATIONAL_SAFE_NULL_IF_NULL, name) +#define BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(name, ALIASES) \ + VAR_LEN_TYPES(BINARY_RELATIONAL_SAFE_NULL_IF_NULL, name, ALIASES) -#define BINARY_RELATIONAL_SAFE_NULL_IF_NULL_UTF8_FN(name) \ - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(name, utf8) +#define BINARY_RELATIONAL_SAFE_NULL_IF_NULL_UTF8_FN(name, ALIASES) \ + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(name, ALIASES, utf8) -#define UNARY_OCTET_LEN_FN(name) \ - UNARY_SAFE_NULL_IF_NULL(name, utf8, int32), UNARY_SAFE_NULL_IF_NULL(name, binary, int32) +#define UNARY_OCTET_LEN_FN(name, ALIASES) \ + UNARY_SAFE_NULL_IF_NULL(name, ALIASES, utf8, int32), \ + UNARY_SAFE_NULL_IF_NULL(name, ALIASES, binary, int32) -#define UNARY_SAFE_NULL_NEVER_BOOL_FN(name) \ - VAR_LEN_TYPES(UNARY_SAFE_NULL_NEVER_BOOL, name) +#define UNARY_SAFE_NULL_NEVER_BOOL_FN(name, ALIASES) \ + VAR_LEN_TYPES(UNARY_SAFE_NULL_NEVER_BOOL, name, ALIASES) std::vector GetStringFunctionRegistry() { static std::vector string_fn_registry_ = { - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(equal), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(not_equal), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(less_than), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(less_than_or_equal_to), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(greater_than), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(greater_than_or_equal_to), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(equal, {}), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(not_equal, {}), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(less_than, {}), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(less_than_or_equal_to, {}), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(greater_than, {}), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(greater_than_or_equal_to, {}), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_UTF8_FN(starts_with), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_UTF8_FN(ends_with), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_UTF8_FN(starts_with, {}), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_UTF8_FN(ends_with, {}), - UNARY_OCTET_LEN_FN(octet_length), - UNARY_OCTET_LEN_FN(bit_length), + UNARY_OCTET_LEN_FN(octet_length, {}), + UNARY_OCTET_LEN_FN(bit_length, {}), - UNARY_UNSAFE_NULL_IF_NULL(char_length, utf8, int32), - UNARY_UNSAFE_NULL_IF_NULL(length, utf8, int32), - UNARY_UNSAFE_NULL_IF_NULL(lengthUtf8, binary, int32), + UNARY_UNSAFE_NULL_IF_NULL(char_length, {}, utf8, int32), + UNARY_UNSAFE_NULL_IF_NULL(length, {}, utf8, int32), + UNARY_UNSAFE_NULL_IF_NULL(lengthUtf8, {}, binary, int32), - UNARY_SAFE_NULL_NEVER_BOOL_FN(isnull), - UNARY_SAFE_NULL_NEVER_BOOL_FN(isnotnull), + UNARY_SAFE_NULL_NEVER_BOOL_FN(isnull, {}), + UNARY_SAFE_NULL_NEVER_BOOL_FN(isnotnull, {}), - NativeFunction("upper", DataTypeVector{utf8()}, utf8(), kResultNullIfNull, + NativeFunction("upper", {}, DataTypeVector{utf8()}, utf8(), kResultNullIfNull, "upper_utf8", NativeFunction::kNeedsContext), - NativeFunction("castVARCHAR", DataTypeVector{utf8(), int64()}, utf8(), + NativeFunction("castVARCHAR", {}, DataTypeVector{utf8(), int64()}, utf8(), kResultNullIfNull, "castVARCHAR_utf8_int64", NativeFunction::kNeedsContext), - NativeFunction("castVARCHAR", DataTypeVector{decimal128(), int64()}, utf8(), + NativeFunction("castVARCHAR", {}, DataTypeVector{decimal128(), int64()}, utf8(), kResultNullIfNull, "castVARCHAR_decimal128_int64", NativeFunction::kNeedsContext), - NativeFunction("like", DataTypeVector{utf8(), utf8()}, boolean(), kResultNullIfNull, - "gdv_fn_like_utf8_utf8", NativeFunction::kNeedsFunctionHolder)}; + NativeFunction("like", {}, DataTypeVector{utf8(), utf8()}, boolean(), + kResultNullIfNull, "gdv_fn_like_utf8_utf8", + NativeFunction::kNeedsFunctionHolder)}; return string_fn_registry_; } diff --git a/cpp/src/gandiva/function_registry_test.cc b/cpp/src/gandiva/function_registry_test.cc index 247d13ea46d..cb08aea7a2e 100644 --- a/cpp/src/gandiva/function_registry_test.cc +++ b/cpp/src/gandiva/function_registry_test.cc @@ -31,7 +31,8 @@ TEST_F(TestFunctionRegistry, TestFound) { const NativeFunction* function = registry_.LookupSignature(add_i32_i32); EXPECT_NE(function, nullptr); - EXPECT_EQ(function->signature(), add_i32_i32); + EXPECT_TRUE(std::find(function->signatures().begin(), function->signatures().end(), + add_i32_i32) != function->signatures().end()); EXPECT_EQ(function->pc_name(), "add_int32_int32"); } diff --git a/cpp/src/gandiva/function_registry_timestamp_arithmetic.cc b/cpp/src/gandiva/function_registry_timestamp_arithmetic.cc index 758721246d3..b9d41eaa7d9 100644 --- a/cpp/src/gandiva/function_registry_timestamp_arithmetic.cc +++ b/cpp/src/gandiva/function_registry_timestamp_arithmetic.cc @@ -20,60 +20,60 @@ namespace gandiva { -#define TIMESTAMP_ADD_FNS(name) \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, int32, timestamp, timestamp), \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, int32, date64, date64), \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, int64, timestamp, timestamp), \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, int64, date64, date64) +#define TIMESTAMP_ADD_FNS(name, ALIASES) \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, int32, timestamp, timestamp), \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, int32, date64, date64), \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, int64, timestamp, timestamp), \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, int64, date64, date64) -#define TIMESTAMP_DIFF_FN(name) \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, timestamp, timestamp, int32) +#define TIMESTAMP_DIFF_FN(name, ALIASES) \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, timestamp, timestamp, int32) -#define DATE_ADD_FNS(name) \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, date64, int32, date64), \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, timestamp, int32, timestamp), \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, date64, int64, date64), \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, timestamp, int64, timestamp), \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, int32, date64, date64), \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, int32, timestamp, timestamp), \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, int64, date64, date64), \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, int64, timestamp, timestamp) +#define DATE_ADD_FNS(name, ALIASES) \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, date64, int32, date64), \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, timestamp, int32, timestamp), \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, date64, int64, date64), \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, timestamp, int64, timestamp), \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, int32, date64, date64), \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, int32, timestamp, timestamp), \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, int64, date64, date64), \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, int64, timestamp, timestamp) -#define DATE_DIFF_FNS(name) \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, int32, date64, date64), \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, int32, timestamp, date64), \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, int64, date64, date64), \ - BINARY_GENERIC_SAFE_NULL_IF_NULL(name, int64, timestamp, date64) +#define DATE_DIFF_FNS(name, ALIASES) \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, int32, date64, date64), \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, int32, timestamp, date64), \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, int64, date64, date64), \ + BINARY_GENERIC_SAFE_NULL_IF_NULL(name, ALIASES, int64, timestamp, date64) std::vector GetDateTimeArithmeticFunctionRegistry() { static std::vector datetime_fn_registry_ = { - BINARY_GENERIC_SAFE_NULL_IF_NULL(months_between, date64, date64, float64), - BINARY_GENERIC_SAFE_NULL_IF_NULL(months_between, timestamp, timestamp, float64), + BINARY_GENERIC_SAFE_NULL_IF_NULL(months_between, {}, date64, date64, float64), + BINARY_GENERIC_SAFE_NULL_IF_NULL(months_between, {}, timestamp, timestamp, float64), - TIMESTAMP_DIFF_FN(timestampdiffSecond), - TIMESTAMP_DIFF_FN(timestampdiffMinute), - TIMESTAMP_DIFF_FN(timestampdiffHour), - TIMESTAMP_DIFF_FN(timestampdiffDay), - TIMESTAMP_DIFF_FN(timestampdiffWeek), - TIMESTAMP_DIFF_FN(timestampdiffMonth), - TIMESTAMP_DIFF_FN(timestampdiffQuarter), - TIMESTAMP_DIFF_FN(timestampdiffYear), + TIMESTAMP_DIFF_FN(timestampdiffSecond, {}), + TIMESTAMP_DIFF_FN(timestampdiffMinute, {}), + TIMESTAMP_DIFF_FN(timestampdiffHour, {}), + TIMESTAMP_DIFF_FN(timestampdiffDay, {}), + TIMESTAMP_DIFF_FN(timestampdiffWeek, {}), + TIMESTAMP_DIFF_FN(timestampdiffMonth, {}), + TIMESTAMP_DIFF_FN(timestampdiffQuarter, {}), + TIMESTAMP_DIFF_FN(timestampdiffYear, {}), - TIMESTAMP_ADD_FNS(timestampaddSecond), - TIMESTAMP_ADD_FNS(timestampaddMinute), - TIMESTAMP_ADD_FNS(timestampaddHour), - TIMESTAMP_ADD_FNS(timestampaddDay), - TIMESTAMP_ADD_FNS(timestampaddWeek), - TIMESTAMP_ADD_FNS(timestampaddMonth), - TIMESTAMP_ADD_FNS(timestampaddQuarter), - TIMESTAMP_ADD_FNS(timestampaddYear), + TIMESTAMP_ADD_FNS(timestampaddSecond, {}), + TIMESTAMP_ADD_FNS(timestampaddMinute, {}), + TIMESTAMP_ADD_FNS(timestampaddHour, {}), + TIMESTAMP_ADD_FNS(timestampaddDay, {}), + TIMESTAMP_ADD_FNS(timestampaddWeek, {}), + TIMESTAMP_ADD_FNS(timestampaddMonth, {}), + TIMESTAMP_ADD_FNS(timestampaddQuarter, {}), + TIMESTAMP_ADD_FNS(timestampaddYear, {}), - DATE_ADD_FNS(date_add), - DATE_ADD_FNS(add), + DATE_ADD_FNS(date_add, {}), + DATE_ADD_FNS(add, {}), - DATE_DIFF_FNS(date_sub), - DATE_DIFF_FNS(subtract), - DATE_DIFF_FNS(date_diff)}; + DATE_DIFF_FNS(date_sub, {}), + DATE_DIFF_FNS(subtract, {}), + DATE_DIFF_FNS(date_diff, {})}; return datetime_fn_registry_; } diff --git a/cpp/src/gandiva/native_function.h b/cpp/src/gandiva/native_function.h index 82714c7de9f..5975a01d943 100644 --- a/cpp/src/gandiva/native_function.h +++ b/cpp/src/gandiva/native_function.h @@ -45,7 +45,7 @@ class GANDIVA_EXPORT NativeFunction { static constexpr int32_t kNeedsFunctionHolder = (1 << 2); static constexpr int32_t kCanReturnErrors = (1 << 3); - const FunctionSignature& signature() const { return signature_; } + const std::vector& signatures() const { return signatures_; } std::string pc_name() const { return pc_name_; } ResultNullableType result_nullable_type() const { return result_nullable_type_; } @@ -53,16 +53,22 @@ class GANDIVA_EXPORT NativeFunction { bool NeedsFunctionHolder() const { return (flags_ & kNeedsFunctionHolder) != 0; } bool CanReturnErrors() const { return (flags_ & kCanReturnErrors) != 0; } - NativeFunction(const std::string& base_name, const DataTypeVector& param_types, - DataTypePtr ret_type, const ResultNullableType& result_nullable_type, + NativeFunction(const std::string& base_name, std::vector aliases, + const DataTypeVector& param_types, DataTypePtr ret_type, + const ResultNullableType& result_nullable_type, const std::string& pc_name, int32_t flags = 0) - : signature_(base_name, param_types, ret_type), + : signatures_(), flags_(flags), result_nullable_type_(result_nullable_type), - pc_name_(pc_name) {} + pc_name_(pc_name) { + aliases.push_back(base_name); + for (auto& func_name : aliases) { + signatures_.push_back(FunctionSignature(func_name, param_types, ret_type)); + } + } private: - FunctionSignature signature_; + std::vector signatures_; /// attributes int32_t flags_; From 61c29a214788dc8e5096926900e38f56e8d2faea Mon Sep 17 00:00:00 2001 From: Prudhvi Porandla Date: Tue, 9 Jul 2019 17:58:00 +0530 Subject: [PATCH 02/11] add aliases to truncate, divide, mod --- cpp/src/gandiva/function_registry_arithmetic.cc | 8 ++++---- cpp/src/gandiva/function_registry_math_ops.cc | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cpp/src/gandiva/function_registry_arithmetic.cc b/cpp/src/gandiva/function_registry_arithmetic.cc index e919d0b5e9f..1160d100406 100644 --- a/cpp/src/gandiva/function_registry_arithmetic.cc +++ b/cpp/src/gandiva/function_registry_arithmetic.cc @@ -60,13 +60,13 @@ std::vector GetArithmeticFunctionRegistry() { BINARY_SYMMETRIC_FN(add, {}), BINARY_SYMMETRIC_FN(subtract, {}), BINARY_SYMMETRIC_FN(multiply, {}), NUMERIC_TYPES(BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL, divide, {"div"}), - BINARY_GENERIC_SAFE_NULL_IF_NULL(mod, {}, int64, int32, int32), - BINARY_GENERIC_SAFE_NULL_IF_NULL(mod, {}, int64, int64, int64), + BINARY_GENERIC_SAFE_NULL_IF_NULL(mod, {"modulo"}, int64, int32, int32), + BINARY_GENERIC_SAFE_NULL_IF_NULL(mod, {"modulo"}, int64, int64, int64), BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(add, {}, decimal128), BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(subtract, {}, decimal128), BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(multiply, {}, decimal128), - BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(divide, {}, decimal128), - BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(mod, {}, decimal128), + BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(divide, {"div"}, decimal128), + BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(mod, {"modulo"}, decimal128), // compare functions BINARY_RELATIONAL_SAFE_NULL_IF_NULL(equal, {}, decimal128), diff --git a/cpp/src/gandiva/function_registry_math_ops.cc b/cpp/src/gandiva/function_registry_math_ops.cc index 9c4079d4626..046556b4088 100644 --- a/cpp/src/gandiva/function_registry_math_ops.cc +++ b/cpp/src/gandiva/function_registry_math_ops.cc @@ -51,7 +51,7 @@ std::vector GetMathOpsFunctionRegistry() { MATH_BINARY_UNSAFE(log, {}), - BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(power, {}, float64), + BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(power, {"pow"}, float64), UNARY_SAFE_NULL_NEVER_BOOL_FN(isnull, {}), UNARY_SAFE_NULL_NEVER_BOOL_FN(isnotnull, {}), @@ -66,9 +66,10 @@ std::vector GetMathOpsFunctionRegistry() { UNARY_SAFE_NULL_IF_NULL(ceil, {}, decimal128, decimal128), UNARY_SAFE_NULL_IF_NULL(floor, {}, decimal128, decimal128), UNARY_SAFE_NULL_IF_NULL(round, {}, decimal128, decimal128), - UNARY_SAFE_NULL_IF_NULL(truncate, {}, decimal128, decimal128), + UNARY_SAFE_NULL_IF_NULL(truncate, {"trunc"}, decimal128, decimal128), BINARY_GENERIC_SAFE_NULL_IF_NULL(round, {}, decimal128, int32, decimal128), - BINARY_GENERIC_SAFE_NULL_IF_NULL(truncate, {}, decimal128, int32, decimal128), + BINARY_GENERIC_SAFE_NULL_IF_NULL(truncate, {"trunc"}, decimal128, int32, + decimal128), }; return math_fn_registry_; From ee2ef21e0f190b2e7eae009af840306af896d6a3 Mon Sep 17 00:00:00 2001 From: Prudhvi Porandla Date: Tue, 9 Jul 2019 22:52:42 +0530 Subject: [PATCH 03/11] refactor: descriptive member names in func_registry --- cpp/src/gandiva/expression_registry.cc | 35 +++++++++++++++----------- cpp/src/gandiva/expression_registry.h | 6 ++--- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/cpp/src/gandiva/expression_registry.cc b/cpp/src/gandiva/expression_registry.cc index ffdb67041f4..0c91ebd92a6 100644 --- a/cpp/src/gandiva/expression_registry.cc +++ b/cpp/src/gandiva/expression_registry.cc @@ -30,46 +30,51 @@ ExpressionRegistry::ExpressionRegistry() { ExpressionRegistry::~ExpressionRegistry() {} +// to be used only to create function_signature_start ExpressionRegistry::FunctionSignatureIterator::FunctionSignatureIterator( nf_iterator nf_it, nf_iterator nf_it_end) - : nf_it_(nf_it), nf_it_end_(nf_it_end), fs_it_(&(nf_it->signatures().front())) {} + : native_func_it_{nf_it}, + native_func_it_end_{nf_it_end}, + func_sig_it_{&(nf_it->signatures().front())} {} + +// to be used only to create function_signature_end ExpressionRegistry::FunctionSignatureIterator::FunctionSignatureIterator( fs_iterator fs_it) - : fs_it_(fs_it) {} + : native_func_it_{NULLPTR}, native_func_it_end_{NULLPTR}, func_sig_it_{fs_it} {} const ExpressionRegistry::FunctionSignatureIterator ExpressionRegistry::function_signature_begin() { return FunctionSignatureIterator(function_registry_->begin(), - function_registry_->end()); // nf_it ctr + function_registry_->end()); } const ExpressionRegistry::FunctionSignatureIterator ExpressionRegistry::function_signature_end() const { - return FunctionSignatureIterator( - &(*(function_registry_->back()->signatures().end()))); // fs_it ctr + return FunctionSignatureIterator(&(*(function_registry_->back()->signatures().end()))); } bool ExpressionRegistry::FunctionSignatureIterator::operator!=( const FunctionSignatureIterator& func_sign_it) { - return func_sign_it.fs_it_ != this->fs_it_; + return func_sign_it.func_sig_it_ != this->func_sig_it_; } FunctionSignature ExpressionRegistry::FunctionSignatureIterator::operator*() { - return *fs_it_; + return *func_sig_it_; } ExpressionRegistry::fs_iterator ExpressionRegistry::FunctionSignatureIterator::operator++( int increment) { - ++fs_it_; - // point fs_it_ to first signature of next nativefunction if fs_it_ is pointing to end - if (fs_it_ == &(*nf_it_->signatures().end())) { - ++nf_it_; - if (nf_it_ == nf_it_end_) { // last native function - return fs_it_; + ++func_sig_it_; + // point func_sig_it_ to first signature of next nativefunction if func_sig_it_ is + // pointing to end + if (func_sig_it_ == &(*native_func_it_->signatures().end())) { + ++native_func_it_; + if (native_func_it_ == native_func_it_end_) { // last native function + return func_sig_it_; } - fs_it_ = &(nf_it_->signatures().front()); + func_sig_it_ = &(native_func_it_->signatures().front()); } - return fs_it_; + return func_sig_it_; } DataTypeVector ExpressionRegistry::supported_types_ = diff --git a/cpp/src/gandiva/expression_registry.h b/cpp/src/gandiva/expression_registry.h index 3bf0f84cf2c..c83f3a2d4fe 100644 --- a/cpp/src/gandiva/expression_registry.h +++ b/cpp/src/gandiva/expression_registry.h @@ -53,9 +53,9 @@ class GANDIVA_EXPORT ExpressionRegistry { fs_iterator operator++(int); private: - nf_iterator nf_it_; - nf_iterator nf_it_end_; - fs_iterator fs_it_; + nf_iterator native_func_it_; + const nf_iterator native_func_it_end_; + fs_iterator func_sig_it_; }; const FunctionSignatureIterator function_signature_begin(); const FunctionSignatureIterator function_signature_end() const; From 35407031f33fae3d075131ccd03c634f900f9a62 Mon Sep 17 00:00:00 2001 From: Prudhvi Porandla Date: Wed, 10 Jul 2019 12:52:09 +0530 Subject: [PATCH 04/11] use native funciton's last func signature in glib --- c_glib/gandiva-glib/native-function.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c_glib/gandiva-glib/native-function.cpp b/c_glib/gandiva-glib/native-function.cpp index d0691471bca..46ffc4cc272 100644 --- a/c_glib/gandiva-glib/native-function.cpp +++ b/c_glib/gandiva-glib/native-function.cpp @@ -106,7 +106,7 @@ ggandiva_native_function_get_signature(GGandivaNativeFunction *native_function) { auto gandiva_native_function = ggandiva_native_function_get_raw(native_function); - auto &gandiva_function_signature = gandiva_native_function->signature(); + auto &gandiva_function_signature = gandiva_native_function->signatures().back(); return ggandiva_function_signature_new_raw(&gandiva_function_signature); } @@ -145,7 +145,7 @@ ggandiva_native_function_to_string(GGandivaNativeFunction *native_function) { auto gandiva_native_function = ggandiva_native_function_get_raw(native_function); - auto gandiva_function_signature = gandiva_native_function->signature(); + auto gandiva_function_signature = gandiva_native_function->signatures().back(); return g_strdup(gandiva_function_signature.ToString().c_str()); } From e0d02b1a0e38bde0521014d94d05e0683f997bce Mon Sep 17 00:00:00 2001 From: Prudhvi Porandla Date: Wed, 10 Jul 2019 14:10:56 +0530 Subject: [PATCH 05/11] use nullptr instead of NULLPTR --- cpp/src/gandiva/expression_registry.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/gandiva/expression_registry.cc b/cpp/src/gandiva/expression_registry.cc index 0c91ebd92a6..26618ab9e23 100644 --- a/cpp/src/gandiva/expression_registry.cc +++ b/cpp/src/gandiva/expression_registry.cc @@ -40,7 +40,7 @@ ExpressionRegistry::FunctionSignatureIterator::FunctionSignatureIterator( // to be used only to create function_signature_end ExpressionRegistry::FunctionSignatureIterator::FunctionSignatureIterator( fs_iterator fs_it) - : native_func_it_{NULLPTR}, native_func_it_end_{NULLPTR}, func_sig_it_{fs_it} {} + : native_func_it_{nullptr}, native_func_it_end_{nullptr}, func_sig_it_{fs_it} {} const ExpressionRegistry::FunctionSignatureIterator ExpressionRegistry::function_signature_begin() { From 0376231ed63b3c7a2710502455c7b548e219c60e Mon Sep 17 00:00:00 2001 From: Prudhvi Porandla Date: Wed, 10 Jul 2019 14:40:36 +0530 Subject: [PATCH 06/11] add java test, rename iterator pointer names --- cpp/src/gandiva/expression_registry.cc | 8 ++++---- cpp/src/gandiva/expression_registry.h | 17 +++++++++-------- .../evaluator/ExpressionRegistryTest.java | 10 ++++++++++ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/cpp/src/gandiva/expression_registry.cc b/cpp/src/gandiva/expression_registry.cc index 26618ab9e23..b884bf6eb30 100644 --- a/cpp/src/gandiva/expression_registry.cc +++ b/cpp/src/gandiva/expression_registry.cc @@ -32,14 +32,14 @@ ExpressionRegistry::~ExpressionRegistry() {} // to be used only to create function_signature_start ExpressionRegistry::FunctionSignatureIterator::FunctionSignatureIterator( - nf_iterator nf_it, nf_iterator nf_it_end) + native_func_iterator_type nf_it, native_func_iterator_type nf_it_end) : native_func_it_{nf_it}, native_func_it_end_{nf_it_end}, func_sig_it_{&(nf_it->signatures().front())} {} // to be used only to create function_signature_end ExpressionRegistry::FunctionSignatureIterator::FunctionSignatureIterator( - fs_iterator fs_it) + func_sig_iterator_type fs_it) : native_func_it_{nullptr}, native_func_it_end_{nullptr}, func_sig_it_{fs_it} {} const ExpressionRegistry::FunctionSignatureIterator @@ -62,8 +62,8 @@ FunctionSignature ExpressionRegistry::FunctionSignatureIterator::operator*() { return *func_sig_it_; } -ExpressionRegistry::fs_iterator ExpressionRegistry::FunctionSignatureIterator::operator++( - int increment) { +ExpressionRegistry::func_sig_iterator_type ExpressionRegistry::FunctionSignatureIterator:: +operator++(int increment) { ++func_sig_it_; // point func_sig_it_ to first signature of next nativefunction if func_sig_it_ is // pointing to end diff --git a/cpp/src/gandiva/expression_registry.h b/cpp/src/gandiva/expression_registry.h index c83f3a2d4fe..bcebbe674f3 100644 --- a/cpp/src/gandiva/expression_registry.h +++ b/cpp/src/gandiva/expression_registry.h @@ -36,26 +36,27 @@ class FunctionRegistry; /// data types and functions supported by Gandiva. class GANDIVA_EXPORT ExpressionRegistry { public: - using nf_iterator = const NativeFunction*; - using fs_iterator = const FunctionSignature*; + using native_func_iterator_type = const NativeFunction*; + using func_sig_iterator_type = const FunctionSignature*; ExpressionRegistry(); ~ExpressionRegistry(); static DataTypeVector supported_types() { return supported_types_; } class GANDIVA_EXPORT FunctionSignatureIterator { public: - explicit FunctionSignatureIterator(nf_iterator nf_it, nf_iterator nf_it_end_); - explicit FunctionSignatureIterator(fs_iterator fs_it); + explicit FunctionSignatureIterator(native_func_iterator_type nf_it, + native_func_iterator_type nf_it_end_); + explicit FunctionSignatureIterator(func_sig_iterator_type fs_it); bool operator!=(const FunctionSignatureIterator& func_sign_it); FunctionSignature operator*(); - fs_iterator operator++(int); + func_sig_iterator_type operator++(int); private: - nf_iterator native_func_it_; - const nf_iterator native_func_it_end_; - fs_iterator func_sig_it_; + native_func_iterator_type native_func_it_; + const native_func_iterator_type native_func_it_end_; + func_sig_iterator_type func_sig_it_; }; const FunctionSignatureIterator function_signature_begin(); const FunctionSignatureIterator function_signature_end() const; diff --git a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ExpressionRegistryTest.java b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ExpressionRegistryTest.java index 63a7536bce0..99ae5e466d4 100644 --- a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ExpressionRegistryTest.java +++ b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ExpressionRegistryTest.java @@ -43,4 +43,14 @@ public void testFunctions() throws GandivaException { Set functions = ExpressionRegistry.getInstance().getSupportedFunctions(); Assert.assertTrue(functions.contains(signature)); } + + @Test + public void testFunctionAliases() throws GandivaException { + ArrowType.Int int64 = new ArrowType.Int(64, true); + FunctionSignature signature = + new FunctionSignature("modulo", int64, Lists.newArrayList(int64, int64)); + Set functions = ExpressionRegistry.getInstance().getSupportedFunctions(); + Assert.assertTrue(functions.contains(signature)); + } + } From 0610288cdbb16c272ce067c20d709d638db81dbf Mon Sep 17 00:00:00 2001 From: Prudhvi Porandla Date: Wed, 10 Jul 2019 17:30:11 +0530 Subject: [PATCH 07/11] add base name at front. add get_all_signatures method in glib --- c_glib/gandiva-glib/native-function.cpp | 29 +++++++++++++++++++++++-- cpp/src/gandiva/native_function.h | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/c_glib/gandiva-glib/native-function.cpp b/c_glib/gandiva-glib/native-function.cpp index 46ffc4cc272..f2f15ac785d 100644 --- a/c_glib/gandiva-glib/native-function.cpp +++ b/c_glib/gandiva-glib/native-function.cpp @@ -106,10 +106,35 @@ ggandiva_native_function_get_signature(GGandivaNativeFunction *native_function) { auto gandiva_native_function = ggandiva_native_function_get_raw(native_function); - auto &gandiva_function_signature = gandiva_native_function->signatures().back(); + auto &gandiva_function_signature = gandiva_native_function->signatures().front(); return ggandiva_function_signature_new_raw(&gandiva_function_signature); } +/** + * ggandiva_native_function_get_all_signatures: + * @native_function: A #GGandivaNativeFunction. + * + * Returns: (transfer full): A List of #GGandivaFunctionSignature supported by + * the native function. + * + * Since: ?? + */ +GList * +ggandiva_native_function_get_all_signatures(GGandivaNativeFunction *native_function) +{ + auto gandiva_native_function = + ggandiva_native_function_get_raw(native_function); + + GList *function_signatures = nullptr; + for (auto& function_sig_raw : gandiva_native_function->signatures()) { + auto function_sig = ggandiva_function_signature_new_raw(&function_sig_raw); + function_signatures = g_list_prepend(function_signatures, function_sig); + } + function_signatures = g_list_reverse(function_signatures); + + return function_signatures; +} + /** * ggandiva_native_function_equal: * @native_function: A #GGandivaNativeFunction. @@ -145,7 +170,7 @@ ggandiva_native_function_to_string(GGandivaNativeFunction *native_function) { auto gandiva_native_function = ggandiva_native_function_get_raw(native_function); - auto gandiva_function_signature = gandiva_native_function->signatures().back(); + auto gandiva_function_signature = gandiva_native_function->signatures().front(); return g_strdup(gandiva_function_signature.ToString().c_str()); } diff --git a/cpp/src/gandiva/native_function.h b/cpp/src/gandiva/native_function.h index 5975a01d943..06fd03a9c8a 100644 --- a/cpp/src/gandiva/native_function.h +++ b/cpp/src/gandiva/native_function.h @@ -61,7 +61,7 @@ class GANDIVA_EXPORT NativeFunction { flags_(flags), result_nullable_type_(result_nullable_type), pc_name_(pc_name) { - aliases.push_back(base_name); + aliases.insert(aliases.begin(), base_name); for (auto& func_name : aliases) { signatures_.push_back(FunctionSignature(func_name, param_types, ret_type)); } From 430b97fcc788a2fd0b79a802466751d991b2160a Mon Sep 17 00:00:00 2001 From: Prudhvi Porandla Date: Thu, 11 Jul 2019 11:35:07 +0530 Subject: [PATCH 08/11] refactor: make aliases const-ref, use gmock matcher --- cpp/src/gandiva/function_registry_test.cc | 4 ++-- cpp/src/gandiva/native_function.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/src/gandiva/function_registry_test.cc b/cpp/src/gandiva/function_registry_test.cc index cb08aea7a2e..6d96d795087 100644 --- a/cpp/src/gandiva/function_registry_test.cc +++ b/cpp/src/gandiva/function_registry_test.cc @@ -17,6 +17,7 @@ #include "gandiva/function_registry.h" +#include #include namespace gandiva { @@ -31,8 +32,7 @@ TEST_F(TestFunctionRegistry, TestFound) { const NativeFunction* function = registry_.LookupSignature(add_i32_i32); EXPECT_NE(function, nullptr); - EXPECT_TRUE(std::find(function->signatures().begin(), function->signatures().end(), - add_i32_i32) != function->signatures().end()); + EXPECT_THAT(function->signatures(), testing::Contains(add_i32_i32)); EXPECT_EQ(function->pc_name(), "add_int32_int32"); } diff --git a/cpp/src/gandiva/native_function.h b/cpp/src/gandiva/native_function.h index 06fd03a9c8a..540e07bde4c 100644 --- a/cpp/src/gandiva/native_function.h +++ b/cpp/src/gandiva/native_function.h @@ -53,7 +53,7 @@ class GANDIVA_EXPORT NativeFunction { bool NeedsFunctionHolder() const { return (flags_ & kNeedsFunctionHolder) != 0; } bool CanReturnErrors() const { return (flags_ & kCanReturnErrors) != 0; } - NativeFunction(const std::string& base_name, std::vector aliases, + NativeFunction(const std::string& base_name, const std::vector& aliases, const DataTypeVector& param_types, DataTypePtr ret_type, const ResultNullableType& result_nullable_type, const std::string& pc_name, int32_t flags = 0) @@ -61,7 +61,7 @@ class GANDIVA_EXPORT NativeFunction { flags_(flags), result_nullable_type_(result_nullable_type), pc_name_(pc_name) { - aliases.insert(aliases.begin(), base_name); + signatures_.push_back(FunctionSignature(base_name, param_types, ret_type)); for (auto& func_name : aliases) { signatures_.push_back(FunctionSignature(func_name, param_types, ret_type)); } From 8eb9cc19ae17529f5b759c64eefde0b1adfce56e Mon Sep 17 00:00:00 2001 From: Prudhvi Porandla Date: Thu, 11 Jul 2019 23:43:37 +0530 Subject: [PATCH 09/11] do not pass initializer list through macros directly --- .../gandiva/function_registry_arithmetic.cc | 63 +++++++------- cpp/src/gandiva/function_registry_common.h | 86 ++++++++++--------- cpp/src/gandiva/function_registry_datetime.cc | 38 ++++---- cpp/src/gandiva/function_registry_hash.cc | 18 ++-- cpp/src/gandiva/function_registry_math_ops.cc | 30 +++---- cpp/src/gandiva/function_registry_string.cc | 30 +++---- .../function_registry_timestamp_arithmetic.cc | 47 +++++----- 7 files changed, 162 insertions(+), 150 deletions(-) diff --git a/cpp/src/gandiva/function_registry_arithmetic.cc b/cpp/src/gandiva/function_registry_arithmetic.cc index 0576efb0876..35de4a65441 100644 --- a/cpp/src/gandiva/function_registry_arithmetic.cc +++ b/cpp/src/gandiva/function_registry_arithmetic.cc @@ -29,15 +29,17 @@ namespace gandiva { #define BINARY_RELATIONAL_BOOL_DATE_FN(name, ALIASES) \ NUMERIC_DATE_TYPES(BINARY_RELATIONAL_SAFE_NULL_IF_NULL, name, ALIASES) -#define UNARY_CAST_TO_FLOAT64(name) UNARY_SAFE_NULL_IF_NULL(castFLOAT8, {}, name, float64) +#define UNARY_CAST_TO_FLOAT64(name) \ + UNARY_SAFE_NULL_IF_NULL(castFLOAT8, ({}), name, float64) -#define UNARY_CAST_TO_FLOAT32(name) UNARY_SAFE_NULL_IF_NULL(castFLOAT4, {}, name, float32) +#define UNARY_CAST_TO_FLOAT32(name) \ + UNARY_SAFE_NULL_IF_NULL(castFLOAT4, ({}), name, float32) std::vector GetArithmeticFunctionRegistry() { static std::vector arithmetic_fn_registry_ = { - UNARY_SAFE_NULL_IF_NULL(not, {}, boolean, boolean), - UNARY_SAFE_NULL_IF_NULL(castBIGINT, {}, int32, int64), - UNARY_SAFE_NULL_IF_NULL(castBIGINT, {}, decimal128, int64), + UNARY_SAFE_NULL_IF_NULL(not, ({}), boolean, boolean), + UNARY_SAFE_NULL_IF_NULL(castBIGINT, ({}), int32, int64), + UNARY_SAFE_NULL_IF_NULL(castBIGINT, ({}), decimal128, int64), // cast to float32 UNARY_CAST_TO_FLOAT32(int32), UNARY_CAST_TO_FLOAT32(int64), @@ -47,40 +49,41 @@ std::vector GetArithmeticFunctionRegistry() { UNARY_CAST_TO_FLOAT64(float32), UNARY_CAST_TO_FLOAT64(decimal128), // cast to decimal - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, int32, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, int64, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, float32, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, float64, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, decimal128, decimal128), - UNARY_UNSAFE_NULL_IF_NULL(castDECIMAL, {}, utf8, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, ({}), int32, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, ({}), int64, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, ({}), float32, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, ({}), float64, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, ({}), decimal128, decimal128), + UNARY_UNSAFE_NULL_IF_NULL(castDECIMAL, ({}), utf8, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDATE, {}, int64, date64), + UNARY_SAFE_NULL_IF_NULL(castDATE, ({}), int64, date64), // add/sub/multiply/divide/mod - BINARY_SYMMETRIC_FN(add, {}), BINARY_SYMMETRIC_FN(subtract, {}), - BINARY_SYMMETRIC_FN(multiply, {}), + BINARY_SYMMETRIC_FN(add, ({})), BINARY_SYMMETRIC_FN(subtract, ({})), + BINARY_SYMMETRIC_FN(multiply, ({})), NUMERIC_TYPES(BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL, divide, {"div"}), BINARY_GENERIC_SAFE_NULL_IF_NULL(mod, {"modulo"}, int64, int32, int32), BINARY_GENERIC_SAFE_NULL_IF_NULL(mod, {"modulo"}, int64, int64, int64), - BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(add, {}, decimal128), - BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(subtract, {}, decimal128), - BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(multiply, {}, decimal128), - BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(divide, {"div"}, decimal128), - BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(mod, {"modulo"}, decimal128), + BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(add, ({}), decimal128), + BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(subtract, ({}), decimal128), + BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(multiply, ({}), decimal128), + BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(divide, ({"div"}), decimal128), + BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(mod, ({"modulo"}), decimal128), BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(mod, {"modulo"}, float64), // compare functions - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(equal, {}, decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(not_equal, {}, decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(less_than, {}, decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(less_than_or_equal_to, {}, decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(greater_than, {}, decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(greater_than_or_equal_to, {}, decimal128), - BINARY_RELATIONAL_BOOL_FN(equal, {}), BINARY_RELATIONAL_BOOL_FN(not_equal, {}), - BINARY_RELATIONAL_BOOL_DATE_FN(less_than, {}), - BINARY_RELATIONAL_BOOL_DATE_FN(less_than_or_equal_to, {}), - BINARY_RELATIONAL_BOOL_DATE_FN(greater_than, {}), - BINARY_RELATIONAL_BOOL_DATE_FN(greater_than_or_equal_to, {})}; + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(equal, ({}), decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(not_equal, ({}), decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(less_than, ({}), decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(less_than_or_equal_to, ({}), decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(greater_than, ({}), decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(greater_than_or_equal_to, ({}), decimal128), + BINARY_RELATIONAL_BOOL_FN(equal, ({"eq", "same"})), + BINARY_RELATIONAL_BOOL_FN(not_equal, ({})), + BINARY_RELATIONAL_BOOL_DATE_FN(less_than, ({})), + BINARY_RELATIONAL_BOOL_DATE_FN(less_than_or_equal_to, ({})), + BINARY_RELATIONAL_BOOL_DATE_FN(greater_than, ({})), + BINARY_RELATIONAL_BOOL_DATE_FN(greater_than_or_equal_to, ({}))}; return arithmetic_fn_registry_; } diff --git a/cpp/src/gandiva/function_registry_common.h b/cpp/src/gandiva/function_registry_common.h index c0eaa8dc3b5..b3edae9e0d0 100644 --- a/cpp/src/gandiva/function_registry_common.h +++ b/cpp/src/gandiva/function_registry_common.h @@ -18,6 +18,7 @@ #ifndef GANDIVA_FUNCTION_REGISTRY_COMMON_H #define GANDIVA_FUNCTION_REGISTRY_COMMON_H +#include #include #include #include @@ -74,9 +75,10 @@ typedef std::unordered_map ALIASES, \ + DataTypeVector{TYPE(), TYPE()}, TYPE(), kResultNullIfNull, \ + ARROW_STRINGIFY(NAME##_##TYPE##_##TYPE)) // Binary functions that : // - have the same input type for both params @@ -84,9 +86,10 @@ typedef std::unordered_map ALIASES, \ + DataTypeVector{IN_TYPE(), IN_TYPE()}, OUT_TYPE(), kResultNullIfNull, \ + ARROW_STRINGIFY(NAME##_##IN_TYPE##_##IN_TYPE), \ NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors) #define BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(NAME, ALIASES, TYPE) \ @@ -97,9 +100,10 @@ typedef std::unordered_map ALIASES, \ + DataTypeVector{IN_TYPE1(), IN_TYPE2()}, OUT_TYPE(), kResultNullIfNull, \ + ARROW_STRINGIFY(NAME##_##IN_TYPE1##_##IN_TYPE2)) // Binary functions that : // - have the same input type @@ -108,33 +112,34 @@ typedef std::unordered_map ALIASES, \ + DataTypeVector{TYPE(), TYPE()}, boolean(), kResultNullIfNull, \ + ARROW_STRINGIFY(NAME##_##TYPE##_##TYPE)) // Unary functions that : // - NULL handling is of type NULL_IF_NULL // // The pre-compiled fn name includes the base name & input type name. eg. castFloat_int32 -#define UNARY_SAFE_NULL_IF_NULL(NAME, ALIASES, IN_TYPE, OUT_TYPE) \ - NativeFunction(#NAME, ALIASES, DataTypeVector{IN_TYPE()}, OUT_TYPE(), \ - kResultNullIfNull, ARROW_STRINGIFY(NAME##_##IN_TYPE)) +#define UNARY_SAFE_NULL_IF_NULL(NAME, ALIASES, IN_TYPE, OUT_TYPE) \ + NativeFunction(#NAME, std::vector ALIASES, DataTypeVector{IN_TYPE()}, \ + OUT_TYPE(), kResultNullIfNull, ARROW_STRINGIFY(NAME##_##IN_TYPE)) // Unary functions that : // - NULL handling is of type NULL_NEVER // // The pre-compiled fn name includes the base name & input type name. eg. isnull_int32 -#define UNARY_SAFE_NULL_NEVER_BOOL(NAME, ALIASES, TYPE) \ - NativeFunction(#NAME, ALIASES, DataTypeVector{TYPE()}, boolean(), kResultNullNever, \ - ARROW_STRINGIFY(NAME##_##TYPE)) +#define UNARY_SAFE_NULL_NEVER_BOOL(NAME, ALIASES, TYPE) \ + NativeFunction(#NAME, std::vector ALIASES, DataTypeVector{TYPE()}, \ + boolean(), kResultNullNever, ARROW_STRINGIFY(NAME##_##TYPE)) // Unary functions that : // - NULL handling is of type NULL_INTERNAL // // The pre-compiled fn name includes the base name & input type name. eg. castFloat_int32 -#define UNARY_UNSAFE_NULL_IF_NULL(NAME, ALIASES, IN_TYPE, OUT_TYPE) \ - NativeFunction(#NAME, ALIASES, DataTypeVector{IN_TYPE()}, OUT_TYPE(), \ - kResultNullIfNull, ARROW_STRINGIFY(NAME##_##IN_TYPE), \ +#define UNARY_UNSAFE_NULL_IF_NULL(NAME, ALIASES, IN_TYPE, OUT_TYPE) \ + NativeFunction(#NAME, std::vector ALIASES, DataTypeVector{IN_TYPE()}, \ + OUT_TYPE(), kResultNullIfNull, ARROW_STRINGIFY(NAME##_##IN_TYPE), \ NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors) // Binary functions that : @@ -142,49 +147,52 @@ typedef std::unordered_map ALIASES, \ + DataTypeVector{TYPE(), TYPE()}, boolean(), kResultNullNever, \ + ARROW_STRINGIFY(NAME##_##TYPE##_##TYPE)) // Extract functions (used with data/time types) that : // - NULL handling is of type NULL_IF_NULL // // The pre-compiled fn name includes the base name & input type name. eg. extractYear_date -#define EXTRACT_SAFE_NULL_IF_NULL(NAME, ALIASES, TYPE) \ - NativeFunction(#NAME, ALIASES, DataTypeVector{TYPE()}, int64(), kResultNullIfNull, \ - ARROW_STRINGIFY(NAME##_##TYPE)) +#define EXTRACT_SAFE_NULL_IF_NULL(NAME, ALIASES, TYPE) \ + NativeFunction(#NAME, std::vector ALIASES, DataTypeVector{TYPE()}, \ + int64(), kResultNullIfNull, ARROW_STRINGIFY(NAME##_##TYPE)) // Hash32 functions that : // - NULL handling is of type NULL_NEVER // // The pre-compiled fn name includes the base name & input type name. hash32_int8 -#define HASH32_SAFE_NULL_NEVER(NAME, ALIASES, TYPE) \ - NativeFunction(#NAME, ALIASES, DataTypeVector{TYPE()}, int32(), kResultNullNever, \ - ARROW_STRINGIFY(NAME##_##TYPE)) +#define HASH32_SAFE_NULL_NEVER(NAME, ALIASES, TYPE) \ + NativeFunction(#NAME, std::vector ALIASES, DataTypeVector{TYPE()}, \ + int32(), kResultNullNever, ARROW_STRINGIFY(NAME##_##TYPE)) // Hash32 functions that : // - NULL handling is of type NULL_NEVER // // The pre-compiled fn name includes the base name & input type name. hash32_int8 -#define HASH64_SAFE_NULL_NEVER(NAME, ALIASES, TYPE) \ - NativeFunction(#NAME, ALIASES, DataTypeVector{TYPE()}, int64(), kResultNullNever, \ - ARROW_STRINGIFY(NAME##_##TYPE)) +#define HASH64_SAFE_NULL_NEVER(NAME, ALIASES, TYPE) \ + NativeFunction(#NAME, std::vector ALIASES, DataTypeVector{TYPE()}, \ + int64(), kResultNullNever, ARROW_STRINGIFY(NAME##_##TYPE)) // Hash32 functions with seed that : // - NULL handling is of type NULL_NEVER // // The pre-compiled fn name includes the base name & input type name. hash32WithSeed_int8 -#define HASH32_SEED_SAFE_NULL_NEVER(NAME, ALIASES, TYPE) \ - NativeFunction(#NAME, ALIASES, DataTypeVector{TYPE(), int32()}, int32(), \ - kResultNullNever, ARROW_STRINGIFY(NAME##WithSeed_##TYPE)) +#define HASH32_SEED_SAFE_NULL_NEVER(NAME, ALIASES, TYPE) \ + NativeFunction(#NAME, std::vector ALIASES, \ + DataTypeVector{TYPE(), int32()}, int32(), kResultNullNever, \ + ARROW_STRINGIFY(NAME##WithSeed_##TYPE)) // Hash64 functions with seed that : // - NULL handling is of type NULL_NEVER // // The pre-compiled fn name includes the base name & input type name. hash32WithSeed_int8 -#define HASH64_SEED_SAFE_NULL_NEVER(NAME, ALIASES, TYPE) \ - NativeFunction(#NAME, ALIASES, DataTypeVector{TYPE(), int64()}, int64(), \ - kResultNullNever, ARROW_STRINGIFY(NAME##WithSeed_##TYPE)) +#define HASH64_SEED_SAFE_NULL_NEVER(NAME, ALIASES, TYPE) \ + NativeFunction(#NAME, std::vector ALIASES, \ + DataTypeVector{TYPE(), int64()}, int64(), kResultNullNever, \ + ARROW_STRINGIFY(NAME##WithSeed_##TYPE)) // Iterate the inner macro over all numeric types #define NUMERIC_TYPES(INNER, NAME, ALIASES) \ diff --git a/cpp/src/gandiva/function_registry_datetime.cc b/cpp/src/gandiva/function_registry_datetime.cc index 2f52b74ba25..f943b6b993b 100644 --- a/cpp/src/gandiva/function_registry_datetime.cc +++ b/cpp/src/gandiva/function_registry_datetime.cc @@ -20,32 +20,32 @@ namespace gandiva { -#define DATE_EXTRACTION_FNS(name) \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Millennium, {}), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Century, {}), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Decade, {}), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Year, {}), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Quarter, {}), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Month, {}), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Week, {}), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Day, {}), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Hour, {}), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Minute, {}), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Second, {}) +#define DATE_EXTRACTION_FNS(name) \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Millennium, ({})), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Century, ({})), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Decade, ({})), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Year, ({})), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Quarter, ({})), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Month, ({})), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Week, ({})), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Day, ({})), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Hour, ({})), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Minute, ({})), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Second, ({})) -#define TIME_EXTRACTION_FNS(name) \ - TIME_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Hour, {}), \ - TIME_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Minute, {}), \ - TIME_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Second, {}) +#define TIME_EXTRACTION_FNS(name) \ + TIME_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Hour, ({})), \ + TIME_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Minute, ({})), \ + TIME_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Second, ({})) std::vector GetDateTimeFunctionRegistry() { static std::vector date_time_fn_registry_ = { DATE_EXTRACTION_FNS(extract), DATE_EXTRACTION_FNS(date_trunc_), - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractDoy, {}), - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractDow, {}), - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractEpoch, {}), + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractDoy, ({})), + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractDow, ({})), + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractEpoch, ({})), TIME_EXTRACTION_FNS(extract), diff --git a/cpp/src/gandiva/function_registry_hash.cc b/cpp/src/gandiva/function_registry_hash.cc index 4184f50ba81..a7bb4ae3750 100644 --- a/cpp/src/gandiva/function_registry_hash.cc +++ b/cpp/src/gandiva/function_registry_hash.cc @@ -34,18 +34,18 @@ namespace gandiva { std::vector GetHashFunctionRegistry() { static std::vector hash_fn_registry_ = { - HASH32_SAFE_NULL_NEVER_FN(hash, {}), - HASH32_SAFE_NULL_NEVER_FN(hash32, {}), - HASH32_SAFE_NULL_NEVER_FN(hash32AsDouble, {}), + HASH32_SAFE_NULL_NEVER_FN(hash, ({})), + HASH32_SAFE_NULL_NEVER_FN(hash32, ({})), + HASH32_SAFE_NULL_NEVER_FN(hash32AsDouble, ({})), - HASH32_SEED_SAFE_NULL_NEVER_FN(hash32, {}), - HASH32_SEED_SAFE_NULL_NEVER_FN(hash32AsDouble, {}), + HASH32_SEED_SAFE_NULL_NEVER_FN(hash32, ({})), + HASH32_SEED_SAFE_NULL_NEVER_FN(hash32AsDouble, ({})), - HASH64_SAFE_NULL_NEVER_FN(hash64, {}), - HASH64_SAFE_NULL_NEVER_FN(hash64AsDouble, {}), + HASH64_SAFE_NULL_NEVER_FN(hash64, ({})), + HASH64_SAFE_NULL_NEVER_FN(hash64AsDouble, ({})), - HASH64_SEED_SAFE_NULL_NEVER_FN(hash64, {}), - HASH64_SEED_SAFE_NULL_NEVER_FN(hash64AsDouble, {})}; + HASH64_SEED_SAFE_NULL_NEVER_FN(hash64, ({})), + HASH64_SEED_SAFE_NULL_NEVER_FN(hash64AsDouble, ({}))}; return hash_fn_registry_; } diff --git a/cpp/src/gandiva/function_registry_math_ops.cc b/cpp/src/gandiva/function_registry_math_ops.cc index 046556b4088..af90b50dfe5 100644 --- a/cpp/src/gandiva/function_registry_math_ops.cc +++ b/cpp/src/gandiva/function_registry_math_ops.cc @@ -44,30 +44,30 @@ namespace gandiva { std::vector GetMathOpsFunctionRegistry() { static std::vector math_fn_registry_ = { - MATH_UNARY_OPS(cbrt, {}), - MATH_UNARY_OPS(exp, {}), - MATH_UNARY_OPS(log, {}), - MATH_UNARY_OPS(log10, {}), + MATH_UNARY_OPS(cbrt, ({})), + MATH_UNARY_OPS(exp, ({})), + MATH_UNARY_OPS(log, ({})), + MATH_UNARY_OPS(log10, ({})), - MATH_BINARY_UNSAFE(log, {}), + MATH_BINARY_UNSAFE(log, ({})), BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(power, {"pow"}, float64), - UNARY_SAFE_NULL_NEVER_BOOL_FN(isnull, {}), - UNARY_SAFE_NULL_NEVER_BOOL_FN(isnotnull, {}), + UNARY_SAFE_NULL_NEVER_BOOL_FN(isnull, ({})), + UNARY_SAFE_NULL_NEVER_BOOL_FN(isnotnull, ({})), - NUMERIC_TYPES(UNARY_SAFE_NULL_NEVER_BOOL, isnumeric, {}), + NUMERIC_TYPES(UNARY_SAFE_NULL_NEVER_BOOL, isnumeric, ({})), - BINARY_SAFE_NULL_NEVER_BOOL_FN(is_distinct_from, {}), - BINARY_SAFE_NULL_NEVER_BOOL_FN(is_not_distinct_from, {}), + BINARY_SAFE_NULL_NEVER_BOOL_FN(is_distinct_from, ({})), + BINARY_SAFE_NULL_NEVER_BOOL_FN(is_not_distinct_from, ({})), // decimal functions - UNARY_SAFE_NULL_IF_NULL(abs, {}, decimal128, decimal128), - UNARY_SAFE_NULL_IF_NULL(ceil, {}, decimal128, decimal128), - UNARY_SAFE_NULL_IF_NULL(floor, {}, decimal128, decimal128), - UNARY_SAFE_NULL_IF_NULL(round, {}, decimal128, decimal128), + UNARY_SAFE_NULL_IF_NULL(abs, ({}), decimal128, decimal128), + UNARY_SAFE_NULL_IF_NULL(ceil, ({}), decimal128, decimal128), + UNARY_SAFE_NULL_IF_NULL(floor, ({}), decimal128, decimal128), + UNARY_SAFE_NULL_IF_NULL(round, ({}), decimal128, decimal128), UNARY_SAFE_NULL_IF_NULL(truncate, {"trunc"}, decimal128, decimal128), - BINARY_GENERIC_SAFE_NULL_IF_NULL(round, {}, decimal128, int32, decimal128), + BINARY_GENERIC_SAFE_NULL_IF_NULL(round, ({}), decimal128, int32, decimal128), BINARY_GENERIC_SAFE_NULL_IF_NULL(truncate, {"trunc"}, decimal128, int32, decimal128), }; diff --git a/cpp/src/gandiva/function_registry_string.cc b/cpp/src/gandiva/function_registry_string.cc index bd2fe18ccc5..5860a5c529c 100644 --- a/cpp/src/gandiva/function_registry_string.cc +++ b/cpp/src/gandiva/function_registry_string.cc @@ -35,25 +35,25 @@ namespace gandiva { std::vector GetStringFunctionRegistry() { static std::vector string_fn_registry_ = { - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(equal, {}), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(not_equal, {}), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(less_than, {}), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(less_than_or_equal_to, {}), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(greater_than, {}), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(greater_than_or_equal_to, {}), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(equal, ({})), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(not_equal, ({})), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(less_than, ({})), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(less_than_or_equal_to, ({})), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(greater_than, ({})), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(greater_than_or_equal_to, ({})), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_UTF8_FN(starts_with, {}), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_UTF8_FN(ends_with, {}), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_UTF8_FN(starts_with, ({})), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_UTF8_FN(ends_with, ({})), - UNARY_OCTET_LEN_FN(octet_length, {}), - UNARY_OCTET_LEN_FN(bit_length, {}), + UNARY_OCTET_LEN_FN(octet_length, ({})), + UNARY_OCTET_LEN_FN(bit_length, ({})), - UNARY_UNSAFE_NULL_IF_NULL(char_length, {}, utf8, int32), - UNARY_UNSAFE_NULL_IF_NULL(length, {}, utf8, int32), - UNARY_UNSAFE_NULL_IF_NULL(lengthUtf8, {}, binary, int32), + UNARY_UNSAFE_NULL_IF_NULL(char_length, ({}), utf8, int32), + UNARY_UNSAFE_NULL_IF_NULL(length, ({}), utf8, int32), + UNARY_UNSAFE_NULL_IF_NULL(lengthUtf8, ({}), binary, int32), - UNARY_SAFE_NULL_NEVER_BOOL_FN(isnull, {}), - UNARY_SAFE_NULL_NEVER_BOOL_FN(isnotnull, {}), + UNARY_SAFE_NULL_NEVER_BOOL_FN(isnull, ({})), + UNARY_SAFE_NULL_NEVER_BOOL_FN(isnotnull, ({})), NativeFunction("upper", {}, DataTypeVector{utf8()}, utf8(), kResultNullIfNull, "upper_utf8", NativeFunction::kNeedsContext), diff --git a/cpp/src/gandiva/function_registry_timestamp_arithmetic.cc b/cpp/src/gandiva/function_registry_timestamp_arithmetic.cc index b9d41eaa7d9..a7a19afd3db 100644 --- a/cpp/src/gandiva/function_registry_timestamp_arithmetic.cc +++ b/cpp/src/gandiva/function_registry_timestamp_arithmetic.cc @@ -47,33 +47,34 @@ namespace gandiva { std::vector GetDateTimeArithmeticFunctionRegistry() { static std::vector datetime_fn_registry_ = { - BINARY_GENERIC_SAFE_NULL_IF_NULL(months_between, {}, date64, date64, float64), - BINARY_GENERIC_SAFE_NULL_IF_NULL(months_between, {}, timestamp, timestamp, float64), + BINARY_GENERIC_SAFE_NULL_IF_NULL(months_between, ({}), date64, date64, float64), + BINARY_GENERIC_SAFE_NULL_IF_NULL(months_between, ({}), timestamp, timestamp, + float64), - TIMESTAMP_DIFF_FN(timestampdiffSecond, {}), - TIMESTAMP_DIFF_FN(timestampdiffMinute, {}), - TIMESTAMP_DIFF_FN(timestampdiffHour, {}), - TIMESTAMP_DIFF_FN(timestampdiffDay, {}), - TIMESTAMP_DIFF_FN(timestampdiffWeek, {}), - TIMESTAMP_DIFF_FN(timestampdiffMonth, {}), - TIMESTAMP_DIFF_FN(timestampdiffQuarter, {}), - TIMESTAMP_DIFF_FN(timestampdiffYear, {}), + TIMESTAMP_DIFF_FN(timestampdiffSecond, ({})), + TIMESTAMP_DIFF_FN(timestampdiffMinute, ({})), + TIMESTAMP_DIFF_FN(timestampdiffHour, ({})), + TIMESTAMP_DIFF_FN(timestampdiffDay, ({})), + TIMESTAMP_DIFF_FN(timestampdiffWeek, ({})), + TIMESTAMP_DIFF_FN(timestampdiffMonth, ({})), + TIMESTAMP_DIFF_FN(timestampdiffQuarter, ({})), + TIMESTAMP_DIFF_FN(timestampdiffYear, ({})), - TIMESTAMP_ADD_FNS(timestampaddSecond, {}), - TIMESTAMP_ADD_FNS(timestampaddMinute, {}), - TIMESTAMP_ADD_FNS(timestampaddHour, {}), - TIMESTAMP_ADD_FNS(timestampaddDay, {}), - TIMESTAMP_ADD_FNS(timestampaddWeek, {}), - TIMESTAMP_ADD_FNS(timestampaddMonth, {}), - TIMESTAMP_ADD_FNS(timestampaddQuarter, {}), - TIMESTAMP_ADD_FNS(timestampaddYear, {}), + TIMESTAMP_ADD_FNS(timestampaddSecond, ({})), + TIMESTAMP_ADD_FNS(timestampaddMinute, ({})), + TIMESTAMP_ADD_FNS(timestampaddHour, ({})), + TIMESTAMP_ADD_FNS(timestampaddDay, ({})), + TIMESTAMP_ADD_FNS(timestampaddWeek, ({})), + TIMESTAMP_ADD_FNS(timestampaddMonth, ({})), + TIMESTAMP_ADD_FNS(timestampaddQuarter, ({})), + TIMESTAMP_ADD_FNS(timestampaddYear, ({})), - DATE_ADD_FNS(date_add, {}), - DATE_ADD_FNS(add, {}), + DATE_ADD_FNS(date_add, ({})), + DATE_ADD_FNS(add, ({})), - DATE_DIFF_FNS(date_sub, {}), - DATE_DIFF_FNS(subtract, {}), - DATE_DIFF_FNS(date_diff, {})}; + DATE_DIFF_FNS(date_sub, ({})), + DATE_DIFF_FNS(subtract, ({})), + DATE_DIFF_FNS(date_diff, ({}))}; return datetime_fn_registry_; } From a5ad80efaf59bc3c680339566cfd75959fbe82df Mon Sep 17 00:00:00 2001 From: Prudhvi Porandla Date: Fri, 12 Jul 2019 10:18:09 +0530 Subject: [PATCH 10/11] lint --- cpp/src/gandiva/function_registry_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/gandiva/function_registry_common.h b/cpp/src/gandiva/function_registry_common.h index b3edae9e0d0..b6119f84e63 100644 --- a/cpp/src/gandiva/function_registry_common.h +++ b/cpp/src/gandiva/function_registry_common.h @@ -18,8 +18,8 @@ #ifndef GANDIVA_FUNCTION_REGISTRY_COMMON_H #define GANDIVA_FUNCTION_REGISTRY_COMMON_H -#include #include +#include #include #include From 39bc74f94ed79c25ff75ae2fdd6f1942721bb7b3 Mon Sep 17 00:00:00 2001 From: Prudhvi Porandla Date: Fri, 12 Jul 2019 11:34:47 +0530 Subject: [PATCH 11/11] enclose in parens only when required --- .../gandiva/function_registry_arithmetic.cc | 62 +++++++++---------- cpp/src/gandiva/function_registry_datetime.cc | 38 ++++++------ cpp/src/gandiva/function_registry_hash.cc | 18 +++--- cpp/src/gandiva/function_registry_math_ops.cc | 30 ++++----- cpp/src/gandiva/function_registry_string.cc | 30 ++++----- .../function_registry_timestamp_arithmetic.cc | 47 +++++++------- 6 files changed, 111 insertions(+), 114 deletions(-) diff --git a/cpp/src/gandiva/function_registry_arithmetic.cc b/cpp/src/gandiva/function_registry_arithmetic.cc index 35de4a65441..8cbfdaff8b9 100644 --- a/cpp/src/gandiva/function_registry_arithmetic.cc +++ b/cpp/src/gandiva/function_registry_arithmetic.cc @@ -29,17 +29,15 @@ namespace gandiva { #define BINARY_RELATIONAL_BOOL_DATE_FN(name, ALIASES) \ NUMERIC_DATE_TYPES(BINARY_RELATIONAL_SAFE_NULL_IF_NULL, name, ALIASES) -#define UNARY_CAST_TO_FLOAT64(name) \ - UNARY_SAFE_NULL_IF_NULL(castFLOAT8, ({}), name, float64) +#define UNARY_CAST_TO_FLOAT64(name) UNARY_SAFE_NULL_IF_NULL(castFLOAT8, {}, name, float64) -#define UNARY_CAST_TO_FLOAT32(name) \ - UNARY_SAFE_NULL_IF_NULL(castFLOAT4, ({}), name, float32) +#define UNARY_CAST_TO_FLOAT32(name) UNARY_SAFE_NULL_IF_NULL(castFLOAT4, {}, name, float32) std::vector GetArithmeticFunctionRegistry() { static std::vector arithmetic_fn_registry_ = { - UNARY_SAFE_NULL_IF_NULL(not, ({}), boolean, boolean), - UNARY_SAFE_NULL_IF_NULL(castBIGINT, ({}), int32, int64), - UNARY_SAFE_NULL_IF_NULL(castBIGINT, ({}), decimal128, int64), + UNARY_SAFE_NULL_IF_NULL(not, {}, boolean, boolean), + UNARY_SAFE_NULL_IF_NULL(castBIGINT, {}, int32, int64), + UNARY_SAFE_NULL_IF_NULL(castBIGINT, {}, decimal128, int64), // cast to float32 UNARY_CAST_TO_FLOAT32(int32), UNARY_CAST_TO_FLOAT32(int64), @@ -49,41 +47,41 @@ std::vector GetArithmeticFunctionRegistry() { UNARY_CAST_TO_FLOAT64(float32), UNARY_CAST_TO_FLOAT64(decimal128), // cast to decimal - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, ({}), int32, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, ({}), int64, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, ({}), float32, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, ({}), float64, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDECIMAL, ({}), decimal128, decimal128), - UNARY_UNSAFE_NULL_IF_NULL(castDECIMAL, ({}), utf8, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, int32, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, int64, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, float32, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, float64, decimal128), + UNARY_SAFE_NULL_IF_NULL(castDECIMAL, {}, decimal128, decimal128), + UNARY_UNSAFE_NULL_IF_NULL(castDECIMAL, {}, utf8, decimal128), - UNARY_SAFE_NULL_IF_NULL(castDATE, ({}), int64, date64), + UNARY_SAFE_NULL_IF_NULL(castDATE, {}, int64, date64), // add/sub/multiply/divide/mod - BINARY_SYMMETRIC_FN(add, ({})), BINARY_SYMMETRIC_FN(subtract, ({})), - BINARY_SYMMETRIC_FN(multiply, ({})), + BINARY_SYMMETRIC_FN(add, {}), BINARY_SYMMETRIC_FN(subtract, {}), + BINARY_SYMMETRIC_FN(multiply, {}), NUMERIC_TYPES(BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL, divide, {"div"}), BINARY_GENERIC_SAFE_NULL_IF_NULL(mod, {"modulo"}, int64, int32, int32), BINARY_GENERIC_SAFE_NULL_IF_NULL(mod, {"modulo"}, int64, int64, int64), - BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(add, ({}), decimal128), - BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(subtract, ({}), decimal128), - BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(multiply, ({}), decimal128), - BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(divide, ({"div"}), decimal128), - BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(mod, ({"modulo"}), decimal128), + BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(add, {}, decimal128), + BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(subtract, {}, decimal128), + BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(multiply, {}, decimal128), + BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(divide, {"div"}, decimal128), + BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(mod, {"modulo"}, decimal128), BINARY_SYMMETRIC_UNSAFE_NULL_IF_NULL(mod, {"modulo"}, float64), // compare functions - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(equal, ({}), decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(not_equal, ({}), decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(less_than, ({}), decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(less_than_or_equal_to, ({}), decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(greater_than, ({}), decimal128), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL(greater_than_or_equal_to, ({}), decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(equal, {}, decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(not_equal, {}, decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(less_than, {}, decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(less_than_or_equal_to, {}, decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(greater_than, {}, decimal128), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL(greater_than_or_equal_to, {}, decimal128), BINARY_RELATIONAL_BOOL_FN(equal, ({"eq", "same"})), - BINARY_RELATIONAL_BOOL_FN(not_equal, ({})), - BINARY_RELATIONAL_BOOL_DATE_FN(less_than, ({})), - BINARY_RELATIONAL_BOOL_DATE_FN(less_than_or_equal_to, ({})), - BINARY_RELATIONAL_BOOL_DATE_FN(greater_than, ({})), - BINARY_RELATIONAL_BOOL_DATE_FN(greater_than_or_equal_to, ({}))}; + BINARY_RELATIONAL_BOOL_FN(not_equal, {}), + BINARY_RELATIONAL_BOOL_DATE_FN(less_than, {}), + BINARY_RELATIONAL_BOOL_DATE_FN(less_than_or_equal_to, {}), + BINARY_RELATIONAL_BOOL_DATE_FN(greater_than, {}), + BINARY_RELATIONAL_BOOL_DATE_FN(greater_than_or_equal_to, {})}; return arithmetic_fn_registry_; } diff --git a/cpp/src/gandiva/function_registry_datetime.cc b/cpp/src/gandiva/function_registry_datetime.cc index f943b6b993b..2f52b74ba25 100644 --- a/cpp/src/gandiva/function_registry_datetime.cc +++ b/cpp/src/gandiva/function_registry_datetime.cc @@ -20,32 +20,32 @@ namespace gandiva { -#define DATE_EXTRACTION_FNS(name) \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Millennium, ({})), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Century, ({})), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Decade, ({})), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Year, ({})), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Quarter, ({})), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Month, ({})), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Week, ({})), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Day, ({})), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Hour, ({})), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Minute, ({})), \ - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Second, ({})) +#define DATE_EXTRACTION_FNS(name) \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Millennium, {}), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Century, {}), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Decade, {}), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Year, {}), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Quarter, {}), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Month, {}), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Week, {}), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Day, {}), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Hour, {}), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Minute, {}), \ + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Second, {}) -#define TIME_EXTRACTION_FNS(name) \ - TIME_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Hour, ({})), \ - TIME_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Minute, ({})), \ - TIME_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Second, ({})) +#define TIME_EXTRACTION_FNS(name) \ + TIME_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Hour, {}), \ + TIME_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Minute, {}), \ + TIME_TYPES(EXTRACT_SAFE_NULL_IF_NULL, name##Second, {}) std::vector GetDateTimeFunctionRegistry() { static std::vector date_time_fn_registry_ = { DATE_EXTRACTION_FNS(extract), DATE_EXTRACTION_FNS(date_trunc_), - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractDoy, ({})), - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractDow, ({})), - DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractEpoch, ({})), + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractDoy, {}), + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractDow, {}), + DATE_TYPES(EXTRACT_SAFE_NULL_IF_NULL, extractEpoch, {}), TIME_EXTRACTION_FNS(extract), diff --git a/cpp/src/gandiva/function_registry_hash.cc b/cpp/src/gandiva/function_registry_hash.cc index a7bb4ae3750..4184f50ba81 100644 --- a/cpp/src/gandiva/function_registry_hash.cc +++ b/cpp/src/gandiva/function_registry_hash.cc @@ -34,18 +34,18 @@ namespace gandiva { std::vector GetHashFunctionRegistry() { static std::vector hash_fn_registry_ = { - HASH32_SAFE_NULL_NEVER_FN(hash, ({})), - HASH32_SAFE_NULL_NEVER_FN(hash32, ({})), - HASH32_SAFE_NULL_NEVER_FN(hash32AsDouble, ({})), + HASH32_SAFE_NULL_NEVER_FN(hash, {}), + HASH32_SAFE_NULL_NEVER_FN(hash32, {}), + HASH32_SAFE_NULL_NEVER_FN(hash32AsDouble, {}), - HASH32_SEED_SAFE_NULL_NEVER_FN(hash32, ({})), - HASH32_SEED_SAFE_NULL_NEVER_FN(hash32AsDouble, ({})), + HASH32_SEED_SAFE_NULL_NEVER_FN(hash32, {}), + HASH32_SEED_SAFE_NULL_NEVER_FN(hash32AsDouble, {}), - HASH64_SAFE_NULL_NEVER_FN(hash64, ({})), - HASH64_SAFE_NULL_NEVER_FN(hash64AsDouble, ({})), + HASH64_SAFE_NULL_NEVER_FN(hash64, {}), + HASH64_SAFE_NULL_NEVER_FN(hash64AsDouble, {}), - HASH64_SEED_SAFE_NULL_NEVER_FN(hash64, ({})), - HASH64_SEED_SAFE_NULL_NEVER_FN(hash64AsDouble, ({}))}; + HASH64_SEED_SAFE_NULL_NEVER_FN(hash64, {}), + HASH64_SEED_SAFE_NULL_NEVER_FN(hash64AsDouble, {})}; return hash_fn_registry_; } diff --git a/cpp/src/gandiva/function_registry_math_ops.cc b/cpp/src/gandiva/function_registry_math_ops.cc index af90b50dfe5..046556b4088 100644 --- a/cpp/src/gandiva/function_registry_math_ops.cc +++ b/cpp/src/gandiva/function_registry_math_ops.cc @@ -44,30 +44,30 @@ namespace gandiva { std::vector GetMathOpsFunctionRegistry() { static std::vector math_fn_registry_ = { - MATH_UNARY_OPS(cbrt, ({})), - MATH_UNARY_OPS(exp, ({})), - MATH_UNARY_OPS(log, ({})), - MATH_UNARY_OPS(log10, ({})), + MATH_UNARY_OPS(cbrt, {}), + MATH_UNARY_OPS(exp, {}), + MATH_UNARY_OPS(log, {}), + MATH_UNARY_OPS(log10, {}), - MATH_BINARY_UNSAFE(log, ({})), + MATH_BINARY_UNSAFE(log, {}), BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(power, {"pow"}, float64), - UNARY_SAFE_NULL_NEVER_BOOL_FN(isnull, ({})), - UNARY_SAFE_NULL_NEVER_BOOL_FN(isnotnull, ({})), + UNARY_SAFE_NULL_NEVER_BOOL_FN(isnull, {}), + UNARY_SAFE_NULL_NEVER_BOOL_FN(isnotnull, {}), - NUMERIC_TYPES(UNARY_SAFE_NULL_NEVER_BOOL, isnumeric, ({})), + NUMERIC_TYPES(UNARY_SAFE_NULL_NEVER_BOOL, isnumeric, {}), - BINARY_SAFE_NULL_NEVER_BOOL_FN(is_distinct_from, ({})), - BINARY_SAFE_NULL_NEVER_BOOL_FN(is_not_distinct_from, ({})), + BINARY_SAFE_NULL_NEVER_BOOL_FN(is_distinct_from, {}), + BINARY_SAFE_NULL_NEVER_BOOL_FN(is_not_distinct_from, {}), // decimal functions - UNARY_SAFE_NULL_IF_NULL(abs, ({}), decimal128, decimal128), - UNARY_SAFE_NULL_IF_NULL(ceil, ({}), decimal128, decimal128), - UNARY_SAFE_NULL_IF_NULL(floor, ({}), decimal128, decimal128), - UNARY_SAFE_NULL_IF_NULL(round, ({}), decimal128, decimal128), + UNARY_SAFE_NULL_IF_NULL(abs, {}, decimal128, decimal128), + UNARY_SAFE_NULL_IF_NULL(ceil, {}, decimal128, decimal128), + UNARY_SAFE_NULL_IF_NULL(floor, {}, decimal128, decimal128), + UNARY_SAFE_NULL_IF_NULL(round, {}, decimal128, decimal128), UNARY_SAFE_NULL_IF_NULL(truncate, {"trunc"}, decimal128, decimal128), - BINARY_GENERIC_SAFE_NULL_IF_NULL(round, ({}), decimal128, int32, decimal128), + BINARY_GENERIC_SAFE_NULL_IF_NULL(round, {}, decimal128, int32, decimal128), BINARY_GENERIC_SAFE_NULL_IF_NULL(truncate, {"trunc"}, decimal128, int32, decimal128), }; diff --git a/cpp/src/gandiva/function_registry_string.cc b/cpp/src/gandiva/function_registry_string.cc index 5860a5c529c..bd2fe18ccc5 100644 --- a/cpp/src/gandiva/function_registry_string.cc +++ b/cpp/src/gandiva/function_registry_string.cc @@ -35,25 +35,25 @@ namespace gandiva { std::vector GetStringFunctionRegistry() { static std::vector string_fn_registry_ = { - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(equal, ({})), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(not_equal, ({})), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(less_than, ({})), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(less_than_or_equal_to, ({})), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(greater_than, ({})), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(greater_than_or_equal_to, ({})), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(equal, {}), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(not_equal, {}), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(less_than, {}), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(less_than_or_equal_to, {}), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(greater_than, {}), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_FN(greater_than_or_equal_to, {}), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_UTF8_FN(starts_with, ({})), - BINARY_RELATIONAL_SAFE_NULL_IF_NULL_UTF8_FN(ends_with, ({})), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_UTF8_FN(starts_with, {}), + BINARY_RELATIONAL_SAFE_NULL_IF_NULL_UTF8_FN(ends_with, {}), - UNARY_OCTET_LEN_FN(octet_length, ({})), - UNARY_OCTET_LEN_FN(bit_length, ({})), + UNARY_OCTET_LEN_FN(octet_length, {}), + UNARY_OCTET_LEN_FN(bit_length, {}), - UNARY_UNSAFE_NULL_IF_NULL(char_length, ({}), utf8, int32), - UNARY_UNSAFE_NULL_IF_NULL(length, ({}), utf8, int32), - UNARY_UNSAFE_NULL_IF_NULL(lengthUtf8, ({}), binary, int32), + UNARY_UNSAFE_NULL_IF_NULL(char_length, {}, utf8, int32), + UNARY_UNSAFE_NULL_IF_NULL(length, {}, utf8, int32), + UNARY_UNSAFE_NULL_IF_NULL(lengthUtf8, {}, binary, int32), - UNARY_SAFE_NULL_NEVER_BOOL_FN(isnull, ({})), - UNARY_SAFE_NULL_NEVER_BOOL_FN(isnotnull, ({})), + UNARY_SAFE_NULL_NEVER_BOOL_FN(isnull, {}), + UNARY_SAFE_NULL_NEVER_BOOL_FN(isnotnull, {}), NativeFunction("upper", {}, DataTypeVector{utf8()}, utf8(), kResultNullIfNull, "upper_utf8", NativeFunction::kNeedsContext), diff --git a/cpp/src/gandiva/function_registry_timestamp_arithmetic.cc b/cpp/src/gandiva/function_registry_timestamp_arithmetic.cc index a7a19afd3db..b9d41eaa7d9 100644 --- a/cpp/src/gandiva/function_registry_timestamp_arithmetic.cc +++ b/cpp/src/gandiva/function_registry_timestamp_arithmetic.cc @@ -47,34 +47,33 @@ namespace gandiva { std::vector GetDateTimeArithmeticFunctionRegistry() { static std::vector datetime_fn_registry_ = { - BINARY_GENERIC_SAFE_NULL_IF_NULL(months_between, ({}), date64, date64, float64), - BINARY_GENERIC_SAFE_NULL_IF_NULL(months_between, ({}), timestamp, timestamp, - float64), + BINARY_GENERIC_SAFE_NULL_IF_NULL(months_between, {}, date64, date64, float64), + BINARY_GENERIC_SAFE_NULL_IF_NULL(months_between, {}, timestamp, timestamp, float64), - TIMESTAMP_DIFF_FN(timestampdiffSecond, ({})), - TIMESTAMP_DIFF_FN(timestampdiffMinute, ({})), - TIMESTAMP_DIFF_FN(timestampdiffHour, ({})), - TIMESTAMP_DIFF_FN(timestampdiffDay, ({})), - TIMESTAMP_DIFF_FN(timestampdiffWeek, ({})), - TIMESTAMP_DIFF_FN(timestampdiffMonth, ({})), - TIMESTAMP_DIFF_FN(timestampdiffQuarter, ({})), - TIMESTAMP_DIFF_FN(timestampdiffYear, ({})), + TIMESTAMP_DIFF_FN(timestampdiffSecond, {}), + TIMESTAMP_DIFF_FN(timestampdiffMinute, {}), + TIMESTAMP_DIFF_FN(timestampdiffHour, {}), + TIMESTAMP_DIFF_FN(timestampdiffDay, {}), + TIMESTAMP_DIFF_FN(timestampdiffWeek, {}), + TIMESTAMP_DIFF_FN(timestampdiffMonth, {}), + TIMESTAMP_DIFF_FN(timestampdiffQuarter, {}), + TIMESTAMP_DIFF_FN(timestampdiffYear, {}), - TIMESTAMP_ADD_FNS(timestampaddSecond, ({})), - TIMESTAMP_ADD_FNS(timestampaddMinute, ({})), - TIMESTAMP_ADD_FNS(timestampaddHour, ({})), - TIMESTAMP_ADD_FNS(timestampaddDay, ({})), - TIMESTAMP_ADD_FNS(timestampaddWeek, ({})), - TIMESTAMP_ADD_FNS(timestampaddMonth, ({})), - TIMESTAMP_ADD_FNS(timestampaddQuarter, ({})), - TIMESTAMP_ADD_FNS(timestampaddYear, ({})), + TIMESTAMP_ADD_FNS(timestampaddSecond, {}), + TIMESTAMP_ADD_FNS(timestampaddMinute, {}), + TIMESTAMP_ADD_FNS(timestampaddHour, {}), + TIMESTAMP_ADD_FNS(timestampaddDay, {}), + TIMESTAMP_ADD_FNS(timestampaddWeek, {}), + TIMESTAMP_ADD_FNS(timestampaddMonth, {}), + TIMESTAMP_ADD_FNS(timestampaddQuarter, {}), + TIMESTAMP_ADD_FNS(timestampaddYear, {}), - DATE_ADD_FNS(date_add, ({})), - DATE_ADD_FNS(add, ({})), + DATE_ADD_FNS(date_add, {}), + DATE_ADD_FNS(add, {}), - DATE_DIFF_FNS(date_sub, ({})), - DATE_DIFF_FNS(subtract, ({})), - DATE_DIFF_FNS(date_diff, ({}))}; + DATE_DIFF_FNS(date_sub, {}), + DATE_DIFF_FNS(subtract, {}), + DATE_DIFF_FNS(date_diff, {})}; return datetime_fn_registry_; }