airborne12 commented on code in PR #62992:
URL: https://github.com/apache/doris/pull/62992#discussion_r3187154193


##########
be/src/storage/segment/variant/variant_column_reader.cpp:
##########
@@ -1325,55 +1325,52 @@ Status VariantColumnReader::load_external_meta_once() {
 
 TabletIndexes VariantColumnReader::find_subcolumn_tablet_indexes(const 
TabletColumn& column,
                                                                  const 
DataTypePtr& data_type) {
-    TabletSchema::SubColumnInfo sub_column_info;
-    const auto& parent_index = 
_tablet_schema->inverted_indexs(column.parent_unique_id());
     auto relative_path = column.path_info_ptr()->copy_pop_front();
-    // if subcolumn has index, add index to _variant_subcolumns_indexes
-    if (variant_util::generate_sub_column_info(*_tablet_schema, 
column.parent_unique_id(),
-                                               relative_path.get_path(), 
&sub_column_info) &&
-        !sub_column_info.indexes.empty()) {
-        return sub_column_info.indexes;
-    }
-
-    // Otherwise, inherit index from the VARIANT parent column.
-    if (!parent_index.empty() && data_type->get_primitive_type() != 
PrimitiveType::TYPE_VARIANT &&
-        data_type->get_primitive_type() != PrimitiveType::TYPE_MAP /*SPARSE 
COLUMN*/) {
-        // type in column maynot be real type, so use data_type to get the 
real type
-        PathInData index_path {*column.path_info_ptr()};
-        DataTypePtr index_data_type = data_type;
-        if (!relative_path.empty()) {
-            auto [nested_reader, _] = 
find_nested_group_for_path(relative_path.get_path());
-            const std::string root_path(kRootNestedGroupPath);
-
-            if (nested_reader != nullptr) {
-                const bool is_root_ng = nested_reader->array_path == root_path;
-                if (!is_root_ng) {
-                    // Named NG — use variant-relative path (consistent with 
write path)
-                    index_path = relative_path;
-                } else {
-                    // $root NG — prefix path with __D0_root__
-                    index_path = PathInData(root_path + "." + 
relative_path.get_path());
-                }
 
-                // Unwrap Nullable(Array(...)) → element type for NG subcolumns
-                if (data_type->is_nullable()) {
-                    auto base = 
variant_util::get_base_type_of_array(remove_nullable(data_type));
-                    index_data_type = base->is_nullable() ? base : 
make_nullable(base);
-                } else {
-                    index_data_type = 
variant_util::get_base_type_of_array(data_type);
-                }
+    // Sparse columns (VARIANT/MAP) only resolve via field_pattern templates;
+    // no parent index inheritance.
+    if (data_type->get_primitive_type() == PrimitiveType::TYPE_VARIANT ||

Review Comment:
   You're right — segment-level resolution stays in 
find_subcolumn_tablet_indexes. Reverted that function to master in a1730c2a54b. 
The collector was crossing the tablet/segment boundary because it reused this 
function's logic via a shared helper, but at collect time we have no segment 
context (no inferred data_type, no _subcolumns_meta_info), so we cannot do 
nested-group inference or inherit_index runtime-type dispatch. Restricted the 
collector fallback in efdde31068b to a schema-only generate_sub_column_info 
call (covers field_pattern templates), then dropped the now-orphan helper in 
3d90512c584. Comprehensive unit tests covering all branches of 
MatchPredicateCollector::collect added in 6c4fff4ac47. Local regression on 
test_bm25_score caught one missing case the simplification dropped: when 
_init_variant_columns materializes a dynamic variant path as the 
OLAP_FIELD_TYPE_VARIANT placeholder and the parent has a plain 
(non-field_pattern) inverted index — added an inline collector
 -side branch in 00738ddf5fd that clones the parent's non-field_pattern indexes 
with the variant path as suffix. Segment-side find_subcolumn_tablet_indexes 
remains exactly as on master.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to