From 682150995af7fc420fd2de52be1501aa85d88037 Mon Sep 17 00:00:00 2001 From: Yuan Zhou Date: Thu, 4 Feb 2021 11:57:49 +0800 Subject: [PATCH] Revert "[oap-native-sql] adding round support" This reverts commit e551b63e54ae26c3ca261a6148d8555d7aaf8a24. --- cpp/src/gandiva/function_registry_math_ops.cc | 3 --- .../gandiva/precompiled/extended_math_ops.cc | 18 ------------------ .../precompiled/extended_math_ops_test.cc | 6 ------ cpp/src/gandiva/precompiled/types.h | 3 --- 4 files changed, 30 deletions(-) diff --git a/cpp/src/gandiva/function_registry_math_ops.cc b/cpp/src/gandiva/function_registry_math_ops.cc index 968d04bfbd925..f3d80110152d5 100644 --- a/cpp/src/gandiva/function_registry_math_ops.cc +++ b/cpp/src/gandiva/function_registry_math_ops.cc @@ -91,9 +91,6 @@ std::vector GetMathOpsFunctionRegistry() { UNARY_SAFE_NULL_IF_NULL(abs, {}, float32, float32), UNARY_SAFE_NULL_IF_NULL(abs, {}, float64, float64), - BINARY_GENERIC_SAFE_NULL_IF_NULL(round, {}, float64, int32, float64), - BINARY_GENERIC_SAFE_NULL_IF_NULL(round, {}, float64, int64, float64), - // decimal functions UNARY_SAFE_NULL_IF_NULL(abs, {}, decimal128, decimal128), UNARY_SAFE_NULL_IF_NULL(ceil, {}, decimal128, decimal128), diff --git a/cpp/src/gandiva/precompiled/extended_math_ops.cc b/cpp/src/gandiva/precompiled/extended_math_ops.cc index 696fb4fd012e9..1ec80c195771a 100644 --- a/cpp/src/gandiva/precompiled/extended_math_ops.cc +++ b/cpp/src/gandiva/precompiled/extended_math_ops.cc @@ -26,7 +26,6 @@ extern "C" { #include #include -#include #include #include @@ -97,23 +96,6 @@ ABS_TYPES_UNARY(int64, uint64) ABS_FTYPES_UNARY(float32, float32) ABS_FTYPES_UNARY(float64, float64) -// round -#define ROUND_TYPES_UNARY(IN_TYPE1, IN_TYPE2, OUT_TYPE) \ - FORCE_INLINE \ - gdv_##OUT_TYPE round_##IN_TYPE1##_##IN_TYPE2(gdv_##IN_TYPE1 val, gdv_##IN_TYPE2 dp) { \ - int charsNeeded = 1 + snprintf(NULL, 0, "%.*f", (int) dp, val); \ - char* buffer = reinterpret_cast(malloc(charsNeeded)); \ - snprintf(buffer, charsNeeded, "%.*f", (int) dp, nextafter(val, val*2)); \ - double result = atof(buffer); \ - free(buffer); \ - return static_cast(result); \ - } - -ROUND_TYPES_UNARY(float64, int32, float64) -ROUND_TYPES_UNARY(float64, int64, float64) - -#undef ROUND_TYPES_UNARY - FORCE_INLINE void set_error_for_logbase(int64_t execution_context, double base) { char const* prefix = "divide by zero error with log of base"; diff --git a/cpp/src/gandiva/precompiled/extended_math_ops_test.cc b/cpp/src/gandiva/precompiled/extended_math_ops_test.cc index e8f24d9d139f5..3e9d8a5d2cd44 100644 --- a/cpp/src/gandiva/precompiled/extended_math_ops_test.cc +++ b/cpp/src/gandiva/precompiled/extended_math_ops_test.cc @@ -407,10 +407,4 @@ TEST(TestExtendedMathOps, TestBinRepresentation) { "1000000000000000000000000000000000000000000000000000000000000000"); EXPECT_FALSE(ctx.has_error()); } -TEST(TestExtendedMathOps, TestRound) { - EXPECT_EQ(round_float64_int32(1234.56789, 4), 1234.5679); - EXPECT_EQ(round_float64_int64(1234.56789, 4), 1234.5679); - EXPECT_EQ(round_float64_int32(-1234.56789, 4), -1234.5679); - EXPECT_EQ(round_float64_int64(-1234.56789, 4), -1234.5679); -} } // namespace gandiva diff --git a/cpp/src/gandiva/precompiled/types.h b/cpp/src/gandiva/precompiled/types.h index e4e9ee0de313b..01c8cd6e67a7d 100644 --- a/cpp/src/gandiva/precompiled/types.h +++ b/cpp/src/gandiva/precompiled/types.h @@ -297,9 +297,6 @@ gdv_float64 degrees_int64(gdv_int64); gdv_float64 degrees_float32(gdv_float32); gdv_float64 degrees_float64(gdv_float64); -gdv_float64 round_float64_int32(gdv_float64 in1, gdv_int32 in2); -gdv_float64 round_float64_int64(gdv_float64 in1, gdv_int64 in2); - gdv_int32 bitwise_and_int32_int32(gdv_int32 in1, gdv_int32 in2); gdv_int64 bitwise_and_int64_int64(gdv_int64 in1, gdv_int64 in2); gdv_int32 bitwise_or_int32_int32(gdv_int32 in1, gdv_int32 in2);