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

eldenmoon pushed a commit to branch cs_opt_version-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/cs_opt_version-3.1 by this 
push:
     new 644b0d62dd6 [enhance](variant) use read type to insert default (#55978)
644b0d62dd6 is described below

commit 644b0d62dd65a97e173c6037dc496d96bf84307d
Author: Sun Chenyang <[email protected]>
AuthorDate: Mon Sep 15 19:44:13 2025 +0800

    [enhance](variant) use read type to insert default (#55978)
    
    cherry-pick https://github.com/apache/doris/pull/56066
---
 be/src/olap/rowset/segment_v2/segment.cpp | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/be/src/olap/rowset/segment_v2/segment.cpp 
b/be/src/olap/rowset/segment_v2/segment.cpp
index 548ac7935ea..4fd5f2755f9 100644
--- a/be/src/olap/rowset/segment_v2/segment.cpp
+++ b/be/src/olap/rowset/segment_v2/segment.cpp
@@ -604,15 +604,24 @@ vectorized::DataTypePtr Segment::get_data_type_of(const 
TabletColumn& column,
     // Case 1: Node not found for the given path within the variant reader.
     // If relative_path is empty, it means the original path pointed to the 
root
     // of the variant column itself. We should return the Variant type.
+    // If node is nullptr, it means the path is not exist in the variant sub 
columns.
     if (node == nullptr || relative_path.empty()) {
-        if (column.is_nested_subcolumn()) {
+        // when the path is in the sparse column or exceeded the limit, return 
the variant type.
+        if (variant_reader->exist_in_sparse_column(relative_path) ||
+            variant_reader->is_exceeded_sparse_column_limit()) {
+            if (column.is_nested_subcolumn()) {
+                return 
vectorized::DataTypeFactory::instance().create_data_type(column);
+            }
+            return column.is_nullable()
+                           ? 
vectorized::make_nullable(std::make_shared<vectorized::DataTypeObject>(
+                                     column.variant_max_subcolumns_count()))
+                           : std::make_shared<vectorized::DataTypeObject>(
+                                     column.variant_max_subcolumns_count());
+        }
+        // now, path is not in this segment, return the default type from 
column.
+        else {
             return 
vectorized::DataTypeFactory::instance().create_data_type(column);
         }
-        return column.is_nullable()
-                       ? 
vectorized::make_nullable(std::make_shared<vectorized::DataTypeObject>(
-                                 column.variant_max_subcolumns_count()))
-                       : std::make_shared<vectorized::DataTypeObject>(
-                                 column.variant_max_subcolumns_count());
     }
 
     bool exist_in_sparse = 
variant_reader->exist_in_sparse_column(relative_path);
@@ -630,11 +639,9 @@ vectorized::DataTypePtr Segment::get_data_type_of(const 
TabletColumn& column,
                              
!variant_reader->is_exceeded_sparse_column_limit())) {
         return node->data.file_column_type;
     }
-    return column.is_nullable()
-                   ? 
vectorized::make_nullable(std::make_shared<vectorized::DataTypeObject>(
-                             column.variant_max_subcolumns_count()))
-                   : std::make_shared<vectorized::DataTypeObject>(
-                             column.variant_max_subcolumns_count());
+
+    // not the compaction read, return the default type from column.
+    return vectorized::DataTypeFactory::instance().create_data_type(column);
 }
 
 Status Segment::_create_column_meta_once(OlapReaderStatistics* stats) {


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

Reply via email to