hello-stephen commented on code in PR #71231:
URL: https://github.com/apache/doris/pull/71231#discussion_r4754837579
##########
be/src/storage/segment/variant/variant_column_reader.cpp:
##########
@@ -219,6 +219,23 @@ 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)
const {
+ if (!is_exceeded_sparse_column_limit()) {
+ return false;
+ }
+ const auto& parent = _tablet_schema->column_by_uid(_root_unique_id);
+ // For a top-level prefix match, the writer materializes both the field
and all its
+ // descendants. A nested lookup could still have an opaque ancestor in
sparse storage.
+ if (parent.variant_enable_typed_paths_to_sparse() ||
parent.variant_enable_doc_mode() ||
+ parent.variant_enable_nested_group() || path.get_parts().size() != 1 ||
+ path.get_path().find('.') != std::string::npos) {
+ return true;
+ }
+ return std::ranges::none_of(parent.get_sub_columns(), [&](const auto&
path_template) {
+ return variant_util::matches_variant_literal_prefix(*path_template,
path.get_path());
Review Comment:
[P1] Keep the truncation guard for segments written by the old matcher
Existing segments do not satisfy the new descendant-materialization
guarantee. With the regression's one-subcolumn/one-stat limits, write its final
three rows before this change: `FNM_PATHNAME` leaves `string_Key.leaf/slash`
untyped, `hot` is materialized, and `aaa_noise` consumes the sparse-stat slot,
hiding the descendant. After upgrade this helper returns false for `string_Key`
solely because `string_*` matches. `verify_missing_variant_path` then accepts
the stored parent as absent, so SEARCH/NOT SEARCH uses an empty bitmap or its
complement instead of reporting the unavailable index. Retain conservative
handling unless the segment is known to satisfy the new materialization rule,
and add an old-writer fixture.
##########
be/src/exec/common/variant_util.cpp:
##########
@@ -1538,8 +1548,8 @@ bool generate_sub_column_info(const TabletSchema& schema,
int32_t col_unique_id,
break;
}
case PatternTypePB::MATCH_NAME_GLOB: {
- int result = fnmatch(pattern, path.c_str(), FNM_PATHNAME);
- if (result == 0) {
+ if (matches_variant_literal_prefix(*sub_column, path) ||
Review Comment:
[P1] Reconcile historical slash paths before changing their typed
classification
In an ordinary UNIQUE KEY table with merge-on-write enabled,
`VARIANT<'p*':TEXT>`, one dynamic subcolumn and typed-to-sparse disabled, write
`(1, {"p/x":42})` before this change, then `(2, {"p/x":"42"})` afterward.
Compaction collects the old untyped integer's statistics and the new typed TEXT
path, so `get_extended_compaction_schema` appends both columns for `p/x`. The
later integer target casts the new `"42"` to `42`, then replaces the TEXT
footer node when `VariantColumnReader` builds its tree. `check_path_stats`
skips UNIQUE KEY tables, allowing a committed JSON string to become a number
after compaction. Please normalize/deduplicate the historical and typed
representations and cover mixed-writer compaction.
##########
regression-test/suites/variant_p0/test_variant_search_sparse_stats_and_score.groovy:
##########
@@ -0,0 +1,63 @@
+// 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_sparse_stats_and_score", "p0") {
+ def tbl = "test_variant_search_sparse_stats_and_score"
+ sql "DROP TABLE IF EXISTS ${tbl}"
+ sql """CREATE TABLE ${tbl} (
+ id INT NOT NULL,
+ mixedRoot VARIANT<'string_*':TEXT, PROPERTIES(
+ "variant_max_subcolumns_count"="1",
"variant_max_sparse_column_statistics_size"="1",
Review Comment:
[P2] Pin doc mode off before creating this sparse-storage fixture
Standard p0/cloud_p0 configs enable fuzzy session variables and debug
points, so `debug_variant_enable_doc_mode` can be true and the doc
materialization threshold can exceed two rows. `LogicalPlanBuilder` retains
that omitted doc flag and zeros these explicit sparse settings. The initial
insert then gets no materialized leaf index and the first NOT SEARCH assertion
throws `SEARCH index unavailable`; with a lower threshold the suite can pass
without exercising sparse statistics. Set `debug_variant_enable_doc_mode=false`
before CREATE, as other sparse-specific suites do.
--
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]