Repository navigation
Support ALIAS columns in text index preprocessor and postprocessor - #110014
Conversation
|
Workflow [PR], commit [b38e421] Summary: ✅
AI ReviewSummaryThis PR fixes the main Findings
Final Verdict
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 64/64 (100.00%) · Uncovered code |
|
@ahmadov I faced the issue myself and didn't know that there was an open issue related and you implement a fix. |
| /// upper(col), or upperUTF8(col), where col is the index column itself. | ||
| /// upper(col), or upperUTF8(col), where col is the index column itself. The argument is | ||
| /// compared by column name so that an ALIAS index column (expanded to its expression) is | ||
| /// still recognized, matching the physical-column case. |
There was a problem hiding this comment.
matching the physical-column case --> matching the non-ALIAS column handling
| DROP TABLE tab; | ||
|
|
||
| SELECT '-- Preprocessor referencing an ALIAS column'; | ||
| -- https://github.com/ClickHouse/ClickHouse/issues/95944 |
There was a problem hiding this comment.
I suppose the general practice is moving such tests into its own file with the issue number in the name e.g. 02346_text_index_bug95944.sql. What do you think about moving to a new test file?
I don't have a strong opinion on that, it's up to tou.
There was a problem hiding this comment.
I tend to agree, I put them here because if I run all preprocessor and postprocessor tests I won't forget to run also these... maybe calling them like 02346_text_index_preprocessor_bug95944.sql...
There was a problem hiding this comment.
yes, that could be one option 👍
There was a problem hiding this comment.
Yes, let's move all new tests into 02346_text_index_bug95944.sql. You will still be able to run clickhouse-test 02346_text_index and it will execute this test.
There was a problem hiding this comment.
Well, thinking again - the preprocessor tests also kind of fit. Still consider moving if CI is red and another iteration is needed.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 62/62 (100.00%) · Uncovered code |
| if (data.private_aliases.contains(column_name)) | ||
| return; | ||
|
|
||
| if (data.columns.hasAlias(column_name)) |
There was a problem hiding this comment.
This still only expands exact identifier names. For a transform that references a subcolumn of an ALIAS-typed tuple/map/etc., the AST identifier is compound (a.v), so column.name() is a.v and columns.hasAlias(column_name) is false. The visitor leaves the transform untouched, and validation later analyzes it against the physical source columns only, so definitions like
CREATE TABLE t
(
raw Tuple(v String),
a Tuple(v String) ALIAS raw,
INDEX idx(raw.v) TYPE text(tokenizer = 'splitByNonAlpha', preprocessor = lower(a.v))
) ENGINE = MergeTree ORDER BY tuple();still fail even though they are logically the same as lower(raw.v). The same gap exists for postprocessor. Can we expand compound identifiers whose root name is an ALIAS (or explicitly reject/document that surface) instead of only matching whole-name aliases?
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes11 object files changed (+83.23 KiB total), 0 added.
737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units9 translation units recompiled, 22 s compile time in total, 9 of them have a recent master baseline. |
|
Hi @Ergus @rschu1ze @ahmadov — a couple of suggestions to make this PR easier for reviewers and the changelog reader. Description (currently
Ignore this if the current title/body is intentional. |
`02346_text_index_functions_select_expression` fails at query 54 on
this branch:
Code: 47. DB::Exception: Missing columns: 'alias' while processing:
'lower(alias)', required columns: 'alias', available columns:
'__text_index_token': When validating secondary index `idx_alias`.
(UNKNOWN_IDENTIFIER)
Using an `ALIAS` column inside a text index `preprocessor` /
`postprocessor` needs `expandTextIndexTransformAliases` in
`IndexDescription::getIndexFromAST`, which rewrites the argument's
`alias` into `ifNull(str, 'default')` before
`MergeTreeIndexTextPostprocessor` looks for the index column name.
That comes from #110014, which is not in this branch: here the
postprocessor stays `lower(alias)`, nothing matches the single source
column `__text_index_token`, and the `CREATE TABLE` is rejected.
#110014 is not folded in: besides that helper it also rewrites
`ReplaceAliasByExpressionVisitor`, which every skip index goes
through, and that is too wide a change to carry inside a bug-fix
backport of an unrelated pull request. If the `ALIAS` support is
wanted on 26.6 it should be backported on its own merit - it is
labelled `pr-bugfix`.
Everything the backported pull request is actually about - injecting
the tokenizer into supported functions outside `WHERE` / `PREWHERE` -
is covered by the rest of the test, which passes.
Closes: #95944
Related: #103626
The text index
preprocessorandpostprocessorarguments only accepted physicalcolumns. Fixing that
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Allow the
preprocessorandpostprocessorexpressions of a text index to referenceALIAScolumns.