Repository navigation
Text index postprocessor resubmit - #108606
Conversation
This reverts commit 208ee06.
1. Add hasPhrase to needApplyPostprocessor 2. Process haystack by postprocessing and rejoining. 3. Add postprocess code to has_positions branch in condition 4. Use a counter to set positions when addDocumentsFromArray.
|
Workflow [PR], commit [e674dce] Summary: ✅
AI ReviewSummaryThis PR adds a Missing context / blind spots
Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block Minimum required actions: fix the |
|
@ahmadov Please check if the |
| MutableColumnConstPtr separator_column = separator_type->createColumnConst(0, Field(String(" "))); | ||
| const ActionsDAG::Node & separator = actions_dag.addColumn(std::move(separator_column), separator_type, "' '"); | ||
| FunctionOverloadResolverPtr concat = FunctionFactory::instance().get("arrayStringConcat", context); | ||
| new_children[0] = &actions_dag.addFunction(concat, {new_children[0], &separator}, ""); |
There was a problem hiding this comment.
The fallback expression here is not equivalent to the positional index once the hasPhrase postprocessor changes token lengths. The indexed path stores and matches the postprocessed token sequence directly, but unmaterialized parts, query_plan_direct_read_from_text_index = 0, and the text-index reader's high-cardinality fallback all run this rewritten expression, which joins those tokens and calls hasPhrase with the original tokenizer again. For example, with tokenizer = ngrams(3), postprocessor = substring(message, 1, 1), and positions = 1, a row abc stores token a and the exact index matches hasPhrase(message, 'abc'); the fallback rewrites both sides to a, then hasPhrase('a', 'a', 'ngrams(3)') has no phrase tokens and returns 0. That makes results depend on materialization/direct-read/fallback choice. Please either evaluate hasPhrase over the postprocessed token array directly, or disable this exact/fallback normalization when re-tokenizing transformed tokens is not proven equivalent, and add a direct-read on/off regression for this case.
| ASTPtr tokens_ast = make_intrusive<ASTIdentifier>(col_name); | ||
| if (isArray(col_type)) | ||
| { | ||
| tokens_ast = makeASTFunction("arrayFlatten", | ||
| makeASTFunction("arrayMap", | ||
| makeASTLambda({postprocessor_element_arg}, | ||
| makeASTFunction("tokens", | ||
| make_intrusive<ASTIdentifier>(postprocessor_element_arg), | ||
| make_intrusive<ASTLiteral>(Field(tokenizer_description)))), | ||
| std::move(tokens_ast))); | ||
| } | ||
| else | ||
| { | ||
| tokens_ast = makeASTFunction("tokens", std::move(tokens_ast), make_intrusive<ASTLiteral>(Field(tokenizer_description))); |
There was a problem hiding this comment.
The fallback/default-expression path has to accept the same column types that the index builder accepts. Here it feeds the original column, or each array element, directly into tokens, but tokens only type-checks String/FixedString; it does not accept Nullable(String) or LowCardinality(String). As a result, a postprocessed text index on a supported type such as Nullable(String) or Array(Nullable(String)) fails while building this DAG for hasToken/hasAnyTokens/hasAllTokens/hasPhrase (this is built before exact direct-read replacement too, and it is also the expression needed for unmaterialized parts). Please unwrap/skip nullable values before calling tokens (for arrays, e.g. guard null elements and tokenize assumeNotNull(x)) and add a direct-read-off or partially materialized regression for a nullable postprocessed index.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 514/530 (96.98%) · Uncovered code |
|
The private tests failing are unrelated and known issues |
|
Hi @Ergus @rschu1ze — while reviewing this PR I found the following:
Could you review the test PR and add the |
Cherry pick #108606 to 26.6: Text index postprocessor resubmit
Backport #108606 to 26.6: Text index postprocessor resubmit
…sor_resubmit Text index postprocessor resubmit
Related: #98939
Related: #108432
Related: #103172
Related: #108456
Parameters:
Example use:
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added a postprocessor to the text index which transforms the tokens after tokenization.
Version info
26.7.1.283(included in26.7and later)26.6.2.33