@@ -604,15 +604,24 @@ vectorized::DataTypePtr Segment::get_data_type_of(const TabletColumn& column,
604
604
// Case 1: Node not found for the given path within the variant reader.
605
605
// If relative_path is empty, it means the original path pointed to the root
606
606
// of the variant column itself. We should return the Variant type.
607
+ // If node is nullptr, it means the path is not exist in the variant sub columns.
607
608
if (node == nullptr || relative_path.empty ()) {
608
- if (column.is_nested_subcolumn ()) {
609
+ // when the path is in the sparse column or exceeded the limit, return the variant type.
610
+ if (variant_reader->exist_in_sparse_column (relative_path) ||
611
+ variant_reader->is_exceeded_sparse_column_limit ()) {
612
+ if (column.is_nested_subcolumn ()) {
613
+ return vectorized::DataTypeFactory::instance ().create_data_type (column);
614
+ }
615
+ return column.is_nullable ()
616
+ ? vectorized::make_nullable (std::make_shared<vectorized::DataTypeObject>(
617
+ column.variant_max_subcolumns_count ()))
618
+ : std::make_shared<vectorized::DataTypeObject>(
619
+ column.variant_max_subcolumns_count ());
620
+ }
621
+ // now, path is not in this segment, return the default type from column.
622
+ else {
609
623
return vectorized::DataTypeFactory::instance ().create_data_type (column);
610
624
}
611
- return column.is_nullable ()
612
- ? vectorized::make_nullable (std::make_shared<vectorized::DataTypeObject>(
613
- column.variant_max_subcolumns_count ()))
614
- : std::make_shared<vectorized::DataTypeObject>(
615
- column.variant_max_subcolumns_count ());
616
625
}
617
626
618
627
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,
630
639
!variant_reader->is_exceeded_sparse_column_limit ())) {
631
640
return node->data .file_column_type ;
632
641
}
633
- return column.is_nullable ()
634
- ? vectorized::make_nullable (std::make_shared<vectorized::DataTypeObject>(
635
- column.variant_max_subcolumns_count ()))
636
- : std::make_shared<vectorized::DataTypeObject>(
637
- column.variant_max_subcolumns_count ());
642
+
643
+ // not the compaction read, return the default type from column.
644
+ return vectorized::DataTypeFactory::instance ().create_data_type (column);
638
645
}
639
646
640
647
Status Segment::_create_column_meta_once (OlapReaderStatistics* stats) {
0 commit comments