hello-stephen commented on code in PR #71231:
URL: https://github.com/apache/doris/pull/71231#discussion_r4798712863


##########
be/src/storage/segment/variant/variant_column_reader.cpp:
##########
@@ -219,6 +220,34 @@ bool VariantColumnReader::exist_in_sparse_column(const 
PathInData& relative_path
     return existed_in_sparse_column || prefix_existed_in_sparse_column;
 }
 
+bool VariantColumnReader::sparse_stats_may_hide_path(const PathInData& path,
+                                                     bool use_rowset_template) 
const {
+    if (!is_exceeded_sparse_column_limit()) {
+        return false;
+    }
+    const auto& name = path.get_path();
+    if (!use_rowset_template || path.get_parts().size() != 1 ||
+        name.find_first_of("./") != std::string::npos) {
+        return true;
+    }
+    const auto& root = _tablet_schema->column_by_uid(_root_unique_id);
+    if (root.variant_enable_typed_paths_to_sparse() || 
root.variant_enable_doc_mode() ||
+        root.variant_enable_nested_group()) {
+        return true;
+    }
+    // A literal prefix followed by '*' (e.g. string_*) pins the field and its 
dotted
+    // descendants for slash-free keys. The writer's fnmatch(FNM_PATHNAME) 
stops at '/'.
+    return std::ranges::none_of(root.get_sub_columns(), [&](const auto& field) 
{

Review Comment:
   [P2] Keep materialized Variant keys visible to the absence check
   
   Use the regression’s indexed `label_*` template and one-entry limits for 
dynamic subcolumns and sparse statistics, with `storage_format=V2`. Insert a 
row with `label_left__D0_ng__right` equal to `hit` in a segment whose unrelated 
keys fill the sparse statistics. The writer materializes and indexes that 
ordinary key, but the inline footer loader at lines 1381–1387 drops any path 
containing `__D0_ng__`, even with nested groups disabled. The index iterator is 
unavailable and the metadata checks miss the stored key. This shortcut then 
changes the previous index-unavailable error into an empty SEARCH result or a 
negated result that includes the matching row. Restrict the footer filter to 
actual nested-group columns, or retain the absence guard when those skipped 
entries could be ordinary materialized paths.



##########
regression-test/suites/variant_p0/test_variant_search_vertical_compaction.groovy:
##########
@@ -0,0 +1,71 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+suite("test_variant_search_vertical_compaction", "p0,nonConcurrent") {
+    if (getFeConfig("enable_debug_points").toBoolean()) {
+        sql "SET debug_variant_enable_doc_mode = false"
+    }
+    sql "SET enable_sql_cache = false"
+    sql "SET enable_query_cache = false"
+    sql "SET enable_inverted_index_query_cache = false"
+    sql "DROP TABLE IF EXISTS test_variant_search_vertical_compaction"
+    sql """CREATE TABLE test_variant_search_vertical_compaction (
+        id INT NOT NULL,
+        v VARIANT<'label_*':TEXT, PROPERTIES(
+            "variant_enable_nested_group"="false",
+            "variant_enable_typed_paths_to_sparse"="false",
+            "variant_max_subcolumns_count"="1",
+            "variant_max_sparse_column_statistics_size"="1",
+            "variant_sparse_hash_shard_count"="1")>,
+        INDEX idx(v) USING INVERTED 
PROPERTIES("field_pattern"="label_*","parser"="english")
+    ) DUPLICATE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 1
+    PROPERTIES("replication_num"="1","inverted_index_storage_format"="V3",
+               "disable_auto_compaction"="true")"""
+
+    sql """INSERT INTO test_variant_search_vertical_compaction VALUES
+        (1, 
parse_to_variant('{"hot":1,"noise_a":1,"noise_b":2,"label_other":"hit"}')),
+        (2, 
parse_to_variant('{"hot":2,"noise_a":1,"noise_c":3,"label_other":"other"}'))"""
+    sql """INSERT INTO test_variant_search_vertical_compaction VALUES
+        (3, 
parse_to_variant('{"hot":3,"noise_a":1,"noise_b":2,"label_other":"hit"}')),
+        (4, 
parse_to_variant('{"hot":4,"noise_a":1,"noise_c":3,"label_other":"other"}'))"""
+
+    def tablet = sql_return_maparray("SHOW TABLETS FROM 
test_variant_search_vertical_compaction")[0].TabletId
+    def rowsets = """SELECT count(*), sum(ROWSET_NUM_ROWS) FROM 
information_schema.rowsets
+        WHERE TABLET_ID=${tablet} AND NUM_SEGMENTS>0"""

Review Comment:
   [P3] Keep the Cloud regression on the backend that compacts the tablet
   
   With two Cloud BEs and `enable_cloud_multi_replica=true`, the before queries 
can warm both BEs. `information_schema.rowsets` visits both local tablet 
caches, so after compaction it can count one new output plus two old input 
rowsets on the other BE. A post-compaction SEARCH routed to that other BE can 
also bypass the live output Rowset this test is meant to exercise. Run this 
fixture on a single-BE Cloud compute group or explicitly scope it to 
shared-nothing mode, where the single replica keeps the counts and queries tied 
to the compaction backend.



-- 
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