Repository navigation
Add tokensForLikePattern function - #97872
Conversation
|
Workflow [PR], commit [710e282] Summary: ❌
AI Review1) SummaryThis PR adds 2) Missing context (if any)
3) Findings (by severity)No Blockers or Majors found. 4) Tests & Evidence
5) ClickHouse Compliance Checklist (Yes/No + short note)
6) Performance & Safety Notes
7) User-Lens Review
8) Final Verdict
|
|
Could it be used as tokenizer function for bf indexes lookup? |
It's likely irrelevant. I’m not clear on the motivation TBH. |
Introduce tokensForLikePattern SQL function that tokenizes LIKE patterns while respecting wildcard semantics: - % and _ are treated as wildcards - Escaped wildcards (\%, \_) are treated as literals - Tokens adjacent to unescaped wildcards are discarded The function is primarily intended for debugging and testing tokenization behavior for LIKE patterns.
2962aac to
e5fbdfd
Compare
|
@george-larionov may want to check (he's out at the moment). |
TLDR, current tokenizer used for BF index lookup is too aggressive and it remove tokens even if they have escaped %, _ characters. |
But this PR doesn't provide a tokenizer. It just exports the existing |
I see, but as i see you did implemented fix proposed in #68985, which should cover this particular issue? |
|
That said, the original report in #68985 (unescaped More broadly, this PR doesn't introduce a new tokenizer — it just exposes the existing |
This is expected and fine.
Good, this is what was need. |
|
@george-larionov Could you help take another look? |
There was a problem hiding this comment.
Pull request overview
This PR introduces a new SQL function tokensForLikePattern to tokenize LIKE pattern strings while respecting wildcard/escape semantics, primarily for debugging/testing tokenization behavior, and adds a stateless test to validate expected outputs across tokenizers.
Changes:
- Add
tokensForLikePatternalongsidetokens, including validation that the chosen tokenizer supports LIKE-pattern tokenization. - Extend
ITokenizerwith accessors for internal/external tokenizer names, and adjust LIKE tokenization behavior inSplitByNonAlphaTokenizer. - Add a stateless SQL test + reference output for
tokensForLikePattern.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/Functions/tokens.cpp |
Implements and registers tokensForLikePattern, adds support-check/error for unsupported tokenizers, and adds function documentation. |
src/Interpreters/ITokenizer.h |
Extends tokenizer interface with name accessors and implements them via ITokenizerHelper. |
src/Interpreters/ITokenizer.cpp |
Fixes SplitByNonAlphaTokenizer::nextInStringLike to advance past delimiters when returning a token. |
tests/queries/0_stateless/03814_tokens_for_like_pattern.sql |
Adds stateless coverage for LIKE-pattern tokenization across default + ngrams tokenizers and unsupported-tokenizer errors. |
tests/queries/0_stateless/03814_tokens_for_like_pattern.reference |
Adds expected output for the new stateless test. |
There was a problem hiding this comment.
LGTM, but I want to give @ahmadov a chance to take a look since he is working in the same area. Also, you will need to pull in the latest changes from your other PR.
…attern # Conflicts: # src/Functions/tokens.cpp
|
@george-larionov "CH Inc sync — tests failed" Is this relevant? |
Only some fuzzer tests failed, which are unrelated to your changes, if you can address @ahmadov's comments I will merge. |
tokensForLikePattern function
…nd unify tests Replace template<bool for_like_pattern> with TokensTraits structs (PlainTokensTraits, LikePatternTokensTraits) following the pattern from hasAnyAllTokens.h. Rename test from 03814_tokens_for_like_pattern to 03403_function_tokens_for_like_pattern to match the existing 03403_function_tokens numbering. Unify test inputs so both tokens() and tokensForLikePattern() receive the same string, making it easy to compare how each function tokenizes the same input differently.
…ttern in text index docs
|
Thanks @george-larionov, @ahmadov, and @rschu1ze for the reviews! I've addressed all the feedback. |
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 98.95% (94/95) |
dd054d4

Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Introduce tokensForLikePattern SQL function that tokenizes LIKE patterns while respecting wildcard semantics:
The function is primarily intended for debugging and testing tokenization behavior for LIKE patterns. Part of #90268.
Documentation entry for user-facing changes
Note
Medium Risk
Adds a new SQL function and execution path for LIKE-aware tokenization, plus tweaks tokenizer behavior around separators/wildcards, which could affect pattern token extraction and related debugging workflows.
Overview
Introduces a new SQL function,
tokensForLikePattern, that tokenizes LIKE pattern strings while respecting wildcard/escape semantics, primarily for debugging/testing tokenization behavior.Refactors the existing
tokensimplementation to share a templated execution pipeline with the new mode, and enforces that only tokenizers advertisingsupportsStringLike()can be used (otherwiseBAD_ARGUMENTS). UpdatesSplitByNonAlphaTokenizer::nextInStringLiketo more clearly discard tokens adjacent to unescaped wildcards and to consume separators consistently. Adds docs and stateless tests covering behavior across tokenizers and unsupported cases, and updates the aspell ignore list.Written by Cursor Bugbot for commit 710e282. This will update automatically on new commits. Configure here.
Version info
26.3.1.618