This is an automated email from the ASF dual-hosted git repository.

lihaopeng pushed a commit to branch vectorized
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git

commit a33b2ac2d1027e7c3c00c2a0d36276dd1b54df33
Author: HappenLee <happen...@hotmail.com>
AuthorDate: Fri Dec 31 00:37:54 2021 -0600

    [Bug] Fix negative function error result and sort node eos (#7555)
    
    Co-authored-by: lihaopeng <lihaop...@baidu.com>
---
 be/src/vec/exec/vsort_node.cpp              | 1 +
 be/src/vec/functions/math.cpp               | 9 +--------
 be/test/vec/function/function_math_test.cpp | 2 +-
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/be/src/vec/exec/vsort_node.cpp b/be/src/vec/exec/vsort_node.cpp
index 79af7c8..734af91 100644
--- a/be/src/vec/exec/vsort_node.cpp
+++ b/be/src/vec/exec/vsort_node.cpp
@@ -84,6 +84,7 @@ Status VSortNode::get_next(RuntimeState* state, Block* block, 
bool* eos) {
             _sorted_blocks[0].skip_num_rows(_offset);
         }
         block->swap(_sorted_blocks[0]);
+        *eos = true;
     } else {
         RETURN_IF_ERROR(merge_sort_read(state, block, eos));
     }
diff --git a/be/src/vec/functions/math.cpp b/be/src/vec/functions/math.cpp
index af48277..57d6c48 100644
--- a/be/src/vec/functions/math.cpp
+++ b/be/src/vec/functions/math.cpp
@@ -258,14 +258,7 @@ struct NegativeImpl {
     using ResultType = A;
 
     static inline ResultType apply(A a) {
-        if constexpr (IsDecimalNumber<A>)
-            return a > 0 ? A(-a) : a;
-        else if constexpr (std::is_integral_v<A> && std::is_signed_v<A>)
-            return a > 0 ? static_cast<ResultType>(~a) + 1 : a;
-        else if constexpr (std::is_integral_v<A> && std::is_unsigned_v<A>)
-            return static_cast<ResultType>(-a);
-        else if constexpr (std::is_floating_point_v<A>)
-            return static_cast<ResultType>(-std::abs(a));
+        return -a;
     }
 };
 
diff --git a/be/test/vec/function/function_math_test.cpp 
b/be/test/vec/function/function_math_test.cpp
index f56ab7d..0413abd 100644
--- a/be/test/vec/function/function_math_test.cpp
+++ b/be/test/vec/function/function_math_test.cpp
@@ -296,7 +296,7 @@ TEST(MathFunctionTest, negative_test) {
     {
         std::vector<std::any> input_types = {vectorized::TypeIndex::Float64};
 
-        DataSet data_set = {{{0.0123}, -0.0123}, {{90.45}, -90.45}, {{0.0}, 
0.0}, {{-60.0}, -60.0}};
+        DataSet data_set = {{{0.0123}, -0.0123}, {{90.45}, -90.45}, {{0.0}, 
0.0}, {{-60.0}, 60.0}};
 
         vectorized::check_function<vectorized::DataTypeFloat64, 
true>(func_name, input_types,
                                                                       
data_set);

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to