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/10/31 00:38:59 UTC

[doris] branch master updated: [Bug](function) fix bug of if function of nullable column process (#13779)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new b15e0a9fb5 [Bug](function) fix bug of if function of nullable column process (#13779)
b15e0a9fb5 is described below

commit b15e0a9fb592402824662123c2a4c5620f86bb45
Author: HappenLee <ha...@hotmail.com>
AuthorDate: Mon Oct 31 08:38:53 2022 +0800

    [Bug](function) fix bug of if function of nullable column process (#13779)
---
 be/src/vec/functions/if.cpp                            | 12 +++++++++++-
 .../conditional_functions/test_nullif.out              | 18 ++++++++++++++++++
 .../conditional_functions/test_nullif.groovy           |  1 +
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/be/src/vec/functions/if.cpp b/be/src/vec/functions/if.cpp
index 0308acc36a..d839142db3 100644
--- a/be/src/vec/functions/if.cpp
+++ b/be/src/vec/functions/if.cpp
@@ -414,13 +414,23 @@ public:
 
         if (auto* nullable = check_and_get_column<ColumnNullable>(*arg_cond.column)) {
             DCHECK(remove_nullable(arg_cond.type)->get_type_id() == TypeIndex::UInt8);
+
+            // update neseted column by nullmap
+            auto* __restrict null_map = nullable->get_null_map_data().data();
+            auto* __restrict nested_bool_data =
+                    ((ColumnVector<UInt8>&)(nullable->get_nested_column())).get_data().data();
+            auto rows = nullable->size();
+            for (size_t i = 0; i < rows; i++) {
+                nested_bool_data[i] = null_map[i] ? false : nested_bool_data[i];
+            }
+
             Block temporary_block {{nullable->get_nested_column_ptr(),
                                     remove_nullable(arg_cond.type), arg_cond.name},
                                    arg_then,
                                    arg_else,
                                    block.get_by_position(result)};
 
-            execute_impl(context, temporary_block, {0, 1, 2}, 3, temporary_block.rows());
+            execute_impl(context, temporary_block, {0, 1, 2}, 3, rows);
 
             block.get_by_position(result).column =
                     std::move(temporary_block.get_by_position(3).column);
diff --git a/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out b/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out
index 436797c791..397283ef01 100644
--- a/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out
+++ b/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out
@@ -13,6 +13,24 @@ true
 -- !select --
 2010-01-02T04:03:06
 
+-- !select --
+\N
+1999-01-08T02:05:06
+1989-01-08T04:05:06
+2010-01-02T02:05:06
+2010-01-02T05:09:06
+2010-01-02T04:03:06
+2002-01-07T01:05:06
+2005-01-09T04:05:06
+2010-01-02T04:03:06
+2010-01-02T04:03:06
+2010-01-02T04:03:06
+2010-01-02T04:03:06
+2010-01-02T04:03:06
+2010-01-02T04:03:06
+\N
+2010-01-02T04:03:06
+
 -- !select --
 2010-01-02T04:03:06
 
diff --git a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy
index 722525a802..16b6864809 100644
--- a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy
+++ b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy
@@ -80,6 +80,7 @@ suite("test_nullif") {
 
     qt_select "select nullif(k6, \"false\") k from test_query_db.test order by k1"
     qt_select "select if(c_date is null,c_timestamp,c_date) from ${tableName} where c_date is null and c_timestamp is not null"
+    qt_select "select if(c_bigint > 10,c_timestamp,c_date) from ${tableName}"
     qt_select "select if(c_date_1 is null,c_timestamp_1,c_date_1) from ${tableName} where c_date_1 is null and c_timestamp_1 is not null"
     qt_select "select if(c_date_1 is null,c_timestamp_2,c_date_1) from ${tableName} where c_date_1 is null and c_timestamp_2 is not null"
     qt_select "select if(c_date_1 is null,c_timestamp_3,c_date_1) from ${tableName} where c_date_1 is null and c_timestamp_3 is not null"


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