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 2023/02/03 12:49:53 UTC

[doris] branch master updated: [Fix](topn) fix wrong nullable cast for RowId column and use heapsorter for two phase read (#16399)

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 f94a78ab4a [Fix](topn) fix wrong nullable cast for RowId column and use heapsorter for two phase read (#16399)
f94a78ab4a is described below

commit f94a78ab4ac7bf52c08f0ae368325c15f576964b
Author: lihangyu <15...@163.com>
AuthorDate: Fri Feb 3 20:49:45 2023 +0800

    [Fix](topn) fix wrong nullable cast for RowId column and use heapsorter for two phase read (#16399)
    
    convert_nullable_flags does not contain nullable info for RowID column, but valid_column_ids contain RowID column, nullable falg will be undefined for RowID column
---
 be/src/vec/common/sort/heap_sorter.cpp | 2 +-
 be/src/vec/common/sort/sorter.cpp      | 2 +-
 be/src/vec/exec/vsort_node.cpp         | 3 ++-
 be/src/vec/utils/util.hpp              | 4 ++--
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/be/src/vec/common/sort/heap_sorter.cpp b/be/src/vec/common/sort/heap_sorter.cpp
index 18bddaaf7a..de36223915 100644
--- a/be/src/vec/common/sort/heap_sorter.cpp
+++ b/be/src/vec/common/sort/heap_sorter.cpp
@@ -48,7 +48,7 @@ Status HeapSorter::append_block(Block* block) {
                 if (column_id < 0) {
                     continue;
                 }
-                if (convert_nullable_flags[i]) {
+                if (i < convert_nullable_flags.size() && convert_nullable_flags[i]) {
                     auto column_ptr = make_nullable(block->get_by_position(column_id).column);
                     new_block.insert({column_ptr,
                                       make_nullable(block->get_by_position(column_id).type), ""});
diff --git a/be/src/vec/common/sort/sorter.cpp b/be/src/vec/common/sort/sorter.cpp
index 6bfff5da1d..3fa7b9e06f 100644
--- a/be/src/vec/common/sort/sorter.cpp
+++ b/be/src/vec/common/sort/sorter.cpp
@@ -250,7 +250,7 @@ Status Sorter::partial_sort(Block& src_block, Block& dest_block) {
             if (column_id < 0) {
                 continue;
             }
-            if (convert_nullable_flags[i]) {
+            if (i < convert_nullable_flags.size() && convert_nullable_flags[i]) {
                 auto column_ptr = make_nullable(src_block.get_by_position(column_id).column);
                 new_block.insert(
                         {column_ptr, make_nullable(src_block.get_by_position(column_id).type), ""});
diff --git a/be/src/vec/exec/vsort_node.cpp b/be/src/vec/exec/vsort_node.cpp
index 3744c349c6..d9adfe1ac8 100644
--- a/be/src/vec/exec/vsort_node.cpp
+++ b/be/src/vec/exec/vsort_node.cpp
@@ -44,7 +44,8 @@ Status VSortNode::init(const TPlanNode& tnode, RuntimeState* state) {
     // exclude cases which incoming blocks has string column which is sensitive to operations like
     // `filter` and `memcpy`
     if (_limit > 0 && _limit + _offset < HeapSorter::HEAP_SORT_THRESHOLD &&
-        (tnode.sort_node.use_topn_opt || !row_desc.has_varlen_slots())) {
+        (tnode.sort_node.sort_info.use_two_phase_read || tnode.sort_node.use_topn_opt ||
+         !row_desc.has_varlen_slots())) {
         _sorter.reset(new HeapSorter(_vsort_exec_exprs, _limit, _offset, _pool, _is_asc_order,
                                      _nulls_first, row_desc));
         _reuse_mem = false;
diff --git a/be/src/vec/utils/util.hpp b/be/src/vec/utils/util.hpp
index 22f1d5d362..67a7489d2f 100644
--- a/be/src/vec/utils/util.hpp
+++ b/be/src/vec/utils/util.hpp
@@ -35,7 +35,7 @@ public:
     }
 
     static ColumnsWithTypeAndName create_columns_with_type_and_name(
-            const RowDescriptor& row_desc, bool ignore_trivial_slot = false) {
+            const RowDescriptor& row_desc, bool ignore_trivial_slot = true) {
         ColumnsWithTypeAndName columns_with_type_and_name;
         for (const auto& tuple_desc : row_desc.tuple_descriptors()) {
             for (const auto& slot_desc : tuple_desc->slots()) {
@@ -50,7 +50,7 @@ public:
     }
 
     static ColumnsWithTypeAndName create_empty_block(const RowDescriptor& row_desc,
-                                                     bool ignore_trivial_slot = false) {
+                                                     bool ignore_trivial_slot = true) {
         ColumnsWithTypeAndName columns_with_type_and_name;
         for (const auto& tuple_desc : row_desc.tuple_descriptors()) {
             for (const auto& slot_desc : tuple_desc->slots()) {


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