github-actions[bot] commented on code in PR #69347:
URL: https://github.com/apache/doris/pull/69347#discussion_r4332154939
##########
be/src/exprs/vsearch.cpp:
##########
@@ -59,6 +61,61 @@ void add_search_binding_diagnostic(const IndexExecContext*
index_context,
}
}
+// A missing iterator is not evidence of a missing value: doc/sparse paths and
+// old rowsets may contain values without an executable SEARCH index.
+Status verify_missing_variant_path(const TSearchFieldBinding& binding, int
column_index,
+ IndexExecContext* index_context) {
+ auto* segment = index_context->segment();
+ if (segment == nullptr || !binding.__isset.parent_field_name ||
+ !binding.__isset.subcolumn_path) {
+ return Status::Error<ErrorCode::INVERTED_INDEX_NOT_SUPPORTED>(
+ "SEARCH cannot establish missing path '{}'",
binding.field_name);
+ }
+ const auto& read_schema = index_context->read_schema();
+ DORIS_CHECK_GE(column_index, 0);
+ DORIS_CHECK_LT(static_cast<size_t>(column_index),
read_schema->num_read_columns());
+ const auto& column = *read_schema->column(column_index);
+ const auto& opts = index_context->column_iter_opts();
+ DORIS_CHECK(opts.stats != nullptr);
+ StorageReadOptions read_options(*opts.stats);
+ read_options.io_ctx = opts.io_ctx;
+ std::shared_ptr<VariantColumnReader> reader;
+ Status st = segment->get_variant_root_reader(column, read_options,
&reader);
+ if (st.is<ErrorCode::NOT_FOUND>()) {
+ // After DROP v(uid=1), ADD v(uid=2), an old segment cannot contain
this scan's root.
+ // Resolve by the current uid so historical values of the same name
cannot match.
+ return Status::OK();
+ }
+ RETURN_IF_ERROR(st);
+ DORIS_CHECK(reader != nullptr);
+ RETURN_IF_ERROR(reader->load_external_meta_once(opts.stats, &opts.io_ctx));
+ const PathInData path(binding.subcolumn_path);
+ const auto* stats = reader->get_stats();
+ // Doc statistics enumerate stored paths without the sparse statistics
limit. For example,
+ // a segment containing only `string4` can prove `string5` absent even in
doc mode.
+ // An opaque root/ancestor value may contain the requested path, so it
remains unavailable.
+ bool in_doc = stats->existed_in_doc_value_column("") ||
+ stats->has_prefix_path_in_doc_value_column(path.get_path() +
".");
+ std::string ancestor = path.get_path();
+ while (!in_doc) {
+ in_doc = stats->existed_in_doc_value_column(ancestor);
+ const auto dot = ancestor.rfind('.');
+ if (dot == std::string::npos) {
+ break;
+ }
+ ancestor.resize(dot);
+ }
+ // Truncated sparse statistics cannot prove absence, nor can an existing
unindexed path.
+ if (reader->get_subcolumn_meta_by_path(path) != nullptr ||
+ reader->has_prefix_path(path, opts.stats, &opts.io_ctx) ||
+ reader->exist_in_sparse_column(path) ||
reader->is_exceeded_sparse_column_limit() ||
+ in_doc || stats->has_nested_group) {
Review Comment:
[P2] Preserve empty results for absent NestedGroups
`has_nested_group` describes the entire VARIANT root, so it is also true
when the requested group is absent. With NestedGroup storage enabled, write
separate rowsets containing `{"other":[{"msg":"x"}]}` and
`{"items":[{"msg":"hit"}]}`, then run `SEARCH('NESTED(v.items, msg:hit)')`. The
first segment has no `v.items.msg` iterator, and this check raises `SEARCH
index unavailable` before `VariantNestedSearchEvaluator::evaluate()` can take
its existing `!found || group_chain.empty()` empty-result branch. A valid query
over heterogeneous rowsets therefore aborts instead of returning the second
rowset's match. Resolve the requested path against NestedGroup metadata, or let
the nested evaluator handle a missing group, and cover this mixed-group case
through `VSearchExpr`.
--
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]