hello-stephen commented on code in PR #71215:
URL: https://github.com/apache/doris/pull/71215#discussion_r4750849256
##########
be/src/exprs/vmatch_predicate.cpp:
##########
@@ -247,8 +251,19 @@ Status VMatchPredicate::execute_column_impl(VExprContext*
context, const Block*
// prepare a column to save result
temp_block.insert({nullptr, _data_type, _expr_name});
- RETURN_IF_ERROR(_function->execute(context->fn_context(_fn_context_index),
temp_block,
- arguments, num_columns_without_result,
temp_block.rows()));
+ // Rows of a segment must match as that segment's index would. The format
is known only in
+ // the storage layer; elsewhere the rows keep the CLucene element spacing.
+ auto* fn_context = context->fn_context(_fn_context_index);
+ const auto index_context = context->get_index_context();
+ const bool snii_segment =
+ index_context != nullptr && index_context->segment() != nullptr &&
+
index_context->segment()->tablet_schema()->get_inverted_index_storage_format()
==
+ InvertedIndexStorageFormatPB::SNII;
+
fn_context->set_function_state(FunctionContext::FunctionStateScope::THREAD_LOCAL,
+ snii_segment ? _snii_analyzer_ctx :
_analyzer_ctx);
Review Comment:
[P2] Keep phrase spacing consistent above and inside the segment
With `enable_match_without_inverted_index=true` and
`enable_inverted_index_query=false`, consider an SNII DUPLICATE KEY table with
an English phrase index and a non-NULL `arr=['hello','world']`:
```sql
SELECT arr MATCH_PHRASE 'hello world' AS m,
NOT(arr MATCH_PHRASE 'hello world') AS n
FROM t;
```
`PushDownMatchProjectionAsVirtualColumn.unwrapMatch()` virtualizes only the
direct MATCH alias, leaving the nested MATCH in the ordinary projection. The
resulting source-derived shape is:
```text
Project[m=virtual_m, n=NOT(MATCH(arr, 'hello world'))]
OlapScan[virtual_m=MATCH(arr, 'hello world')]
```
The virtual expression has a segment context, so this selection gives it gap
1 and `m=false`. The nested MATCH executes in the scanner/operator projection
without that context, gets gap 0 and returns true, making `n=false` too. Both
run by rows because index querying is disabled; at the base both used gap 0 and
returned `(true,false)`. Physical CSE cannot reconcile them after the direct
MATCH has become a virtual slot.
Please carry a consistent positional policy to every evaluation of the bound
MATCH, including wrapped projections, and add a SQL regression for this case.
The new fixture always injects a segment context and misses this path.
--
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]