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

gabriellee pushed a commit to branch branch-1.1-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.1-lts by this push:
     new 05ce6f3b97 [Bug](function) fix bug of if function of nullable column 
process (#13852)
05ce6f3b97 is described below

commit 05ce6f3b97f84605e97de49b7cd3c0e52506dbcf
Author: HappenLee <[email protected]>
AuthorDate: Tue Nov 1 14:07:20 2022 +0800

    [Bug](function) fix bug of if function of nullable column process (#13852)
---
 be/src/vec/functions/if.cpp | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/be/src/vec/functions/if.cpp b/be/src/vec/functions/if.cpp
index 40132b8dec..45202f181c 100644
--- a/be/src/vec/functions/if.cpp
+++ b/be/src/vec/functions/if.cpp
@@ -405,23 +405,33 @@ public:
         bool cond_is_null = arg_cond.column->only_null();
 
         if (cond_is_null) {
-            block.replace_by_position(result, 
arg_else.column->clone_resized(arg_cond.column->size()));
+            block.replace_by_position(result,
+                                      
arg_else.column->clone_resized(arg_cond.column->size()));
             return true;
         }
 
-        if (auto * nullable = 
check_and_get_column<ColumnNullable>(*arg_cond.column)) {
-               DCHECK(remove_nullable(arg_cond.type)->get_type_id() == 
TypeIndex::UInt8);
-               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)
-            };
+        if (auto* nullable = 
check_and_get_column<ColumnNullable>(*arg_cond.column)) {
+            DCHECK(remove_nullable(arg_cond.type)->get_type_id() == 
TypeIndex::UInt8);
 
-            execute_impl(context, temporary_block, {0, 1, 2}, 3, 
temporary_block.rows());
+            // 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)};
 
-            block.get_by_position(result).column = 
std::move(temporary_block.get_by_position(3).column);
+            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);
             return true;
         }
         return false;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to