You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by li...@apache.org on 2021/12/31 06:38:06 UTC

[incubator-doris] branch vectorized updated: [Bug] Fix negative function error result and sort node eos (#7555)

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


The following commit(s) were added to refs/heads/vectorized by this push:
     new ad71c92  [Bug] Fix negative function error result and sort node eos (#7555)
ad71c92 is described below

commit ad71c92fcc18178dd1c9f849e89ad23b3eb2755c
Author: HappenLee <ha...@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 <li...@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-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org