You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/07/30 11:18:01 UTC

[doris] branch dev-1.1.2 updated (ee83ab908e -> 9d65a64a02)

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

yiguolei pushed a change to branch dev-1.1.2
in repository https://gitbox.apache.org/repos/asf/doris.git


    from ee83ab908e [fix](be): fix stack overflow in unhex function (#11204) (#11291)
     new bf77148b4d [fix] the nullable info is lost in ifnull expr (#11212)
     new 9d65a64a02 [Bug][Function] core dump on sum(distinct) (#11308)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../aggregate_function_distinct.h                  |  8 ++++++--
 be/src/vec/functions/function_ifnull.h             | 24 ++++++++++++++++++----
 be/src/vec/functions/if.cpp                        |  3 +++
 3 files changed, 29 insertions(+), 6 deletions(-)


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


[doris] 01/02: [fix] the nullable info is lost in ifnull expr (#11212)

Posted by yi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch dev-1.1.2
in repository https://gitbox.apache.org/repos/asf/doris.git

commit bf77148b4d8863272553a4888cf4eb619334cc91
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Fri Jul 29 21:33:58 2022 +0800

    [fix] the nullable info is lost in ifnull expr (#11212)
    
    ifnull function has defect when processing nullable column or const column in some case
---
 be/src/vec/functions/function_ifnull.h | 24 ++++++++++++++++++++----
 be/src/vec/functions/if.cpp            |  3 +++
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/be/src/vec/functions/function_ifnull.h b/be/src/vec/functions/function_ifnull.h
index b6627641c0..1a83785c48 100644
--- a/be/src/vec/functions/function_ifnull.h
+++ b/be/src/vec/functions/function_ifnull.h
@@ -40,11 +40,21 @@ public:
 
     bool use_default_implementation_for_constants() const override { return false; }
 
+    // be compatible with fe code
+    /* 
+        if (fn.functionName().equalsIgnoreCase("ifnull") || fn.functionName().equalsIgnoreCase("nvl")) {
+            Preconditions.checkState(children.size() == 2);
+            if (children.get(0).isNullable()) {
+                return children.get(1).isNullable();
+            }
+            return false;
+        }
+    */
     DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
-        if (!arguments[0]->is_nullable() && arguments[1]->is_nullable()) {
-            return reinterpret_cast<const DataTypeNullable*>(arguments[1].get())->get_nested_type();
+        if (arguments[0]->is_nullable()) {
+            return arguments[1];
         }
-        return arguments[1];
+        return arguments[0];
     }
 
     bool use_default_implementation_for_nulls() const override { return false; }
@@ -75,10 +85,16 @@ public:
         const ColumnsWithTypeAndName if_columns {
                 null_column_arg0, block.get_by_position(arguments[1]), nested_column_arg0};
 
+        // see get_return_type_impl
+        // if result is nullable, means both then and else column are nullable, we use original col_left to keep nullable info
+        // if result is not nullable, means both then and else column are not nullable, we use nested_column_arg0 to remove nullable info
+        bool result_nullable = block.get_by_position(result).type->is_nullable();
         Block temporary_block({
                 null_column_arg0,
                 block.get_by_position(arguments[1]),
-                nested_column_arg0,
+                result_nullable
+                        ? col_left
+                        : nested_column_arg0, // if result is nullable, we need pass the original col_left else pass nested_column_arg0
                 block.get_by_position(result),
         });
 
diff --git a/be/src/vec/functions/if.cpp b/be/src/vec/functions/if.cpp
index 714203f492..40132b8dec 100644
--- a/be/src/vec/functions/if.cpp
+++ b/be/src/vec/functions/if.cpp
@@ -139,6 +139,9 @@ public:
     static ColumnPtr get_nested_column(const ColumnPtr& column) {
         if (auto* nullable = check_and_get_column<ColumnNullable>(*column))
             return nullable->get_nested_column_ptr();
+        else if (const auto* column_const = check_and_get_column<ColumnConst>(*column))
+            return ColumnConst::create(get_nested_column(column_const->get_data_column_ptr()),
+                                       column->size());
 
         return column;
     }


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


[doris] 02/02: [Bug][Function] core dump on sum(distinct) (#11308)

Posted by yi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch dev-1.1.2
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 9d65a64a02e40cdf4267693e534d2751cbafca7f
Author: Pxl <95...@qq.com>
AuthorDate: Sat Jul 30 10:24:48 2022 +0800

    [Bug][Function] core dump on sum(distinct) (#11308)
    
    * fix align size calculate for distinct combinator
---
 be/src/vec/aggregate_functions/aggregate_function_distinct.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/be/src/vec/aggregate_functions/aggregate_function_distinct.h b/be/src/vec/aggregate_functions/aggregate_function_distinct.h
index 820759a7ff..f37f3f3efa 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_distinct.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_distinct.h
@@ -154,7 +154,7 @@ template <typename Data>
 class AggregateFunctionDistinct
         : public IAggregateFunctionDataHelper<Data, AggregateFunctionDistinct<Data>> {
 private:
-    static constexpr auto prefix_size = sizeof(Data);
+    size_t prefix_size;
     AggregateFunctionPtr nested_func;
     size_t arguments_num;
 
@@ -171,7 +171,11 @@ public:
             : IAggregateFunctionDataHelper<Data, AggregateFunctionDistinct>(
                       arguments, nested_func_->get_parameters()),
               nested_func(nested_func_),
-              arguments_num(arguments.size()) {}
+              arguments_num(arguments.size()) {
+        size_t nested_size = nested_func->align_of_data();
+        CHECK_GT(nested_size, 0);
+        prefix_size = (sizeof(Data) + nested_size - 1) / nested_size * nested_size;
+    }
 
     void add(AggregateDataPtr __restrict place, const IColumn** columns, size_t row_num,
              Arena* arena) const override {


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