From 23ec7bce4618c7538f205a29d2c25761c6a97767 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 9e303e957507e..217cd9500ab55 100644 --- a/cpp/src/gandiva/function_registry_math_ops.cc +++ b/cpp/src/gandiva/function_registry_math_ops.cc @@ -79,9 +79,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 162421090de7d..7ef542201d182 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 #include "./types.h" @@ -96,23 +95,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 254fb385de56b..6e59f684f6214 100644 --- a/cpp/src/gandiva/precompiled/extended_math_ops_test.cc +++ b/cpp/src/gandiva/precompiled/extended_math_ops_test.cc @@ -273,10 +273,4 @@ TEST(TestExtendedMathOps, TestTrigonometricFunctions) { VerifyFuzzyEquals(cot_float64(M_PI / 2), tan(M_PI / 2 - M_PI / 2)); } -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 3aef8b19a1e8e..63eada5c4f300 100644 --- a/cpp/src/gandiva/precompiled/types.h +++ b/cpp/src/gandiva/precompiled/types.h @@ -234,9 +234,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);