Repository navigation
Use an inverted text index for TimeSeries tags - #120083
Conversation
|
Workflow [PR], commit [4960f3f] Summary: ❌
AI ReviewSummaryThis PR bumps Findings❌ Blockers
|
| Metric | Baseline | Current | Δ |
|---|---|---|---|
| Lines | 88.40% | 88.40% | +0.00% |
| Functions | 91.80% | 91.80% | +0.00% |
| Branches | 80.60% | 80.60% | +0.00% |
Changed lines: Changed C/C++ lines covered: 151/152 (99.34%) · Uncovered code
Expect the default `tags_idx` text index in the copied table definition. CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120083&sha=4616dd76665308fa6d66d488afcde17fd64e10ca&name_0=PR&name_1=Fast%20test Related: #120083
| ASTPtr inner_columns; | ||
| if (ParserToken(TokenType::OpeningRoundBracket).ignore(pos, expected) | ||
| && ParserColumnDeclarationList{}.parse(pos, col_list, expected) | ||
| && ParserTablePropertiesDeclarationList{}.parse(pos, inner_columns, expected) |
There was a problem hiding this comment.
Allowing ParserTablePropertiesDeclarationList here makes INDEX ... legal in INNER COLUMNS for every TimeSeries schema version. The only later gate is around the auto-generated tags_idx, so CREATE TABLE ... ENGINE = TimeSeries SETTINGS version = 3 TAGS INNER COLUMNS (INDEX custom_tags tags TYPE text(tokenizer = 'keyValuePairs')) is now accepted and stored as a version = 3 table. A pre-v4 server that still supports version 3 cannot parse that metadata on ATTACH / DDL replay because its ParserViewTargets only accepted column declarations. That breaks the versioning contract that an explicit older version keeps the definition readable/replayable by servers supporting that version. Please reject inner indexes when version < 4 or bump the table version when one is present.
| auto & indices = inner_columns.indices->children; | ||
| auto is_generated = [&](const ASTPtr & index) | ||
| { | ||
| return index->formatWithSecretsOneLine() == default_index; |
There was a problem hiding this comment.
Matching on formatWithSecretsOneLine() makes every INDEX tags_idx tags TYPE text(tokenizer = 'keyValuePairs') look generated, even when the user spelled it explicitly. In CREATE TABLE ... AS ... that silently drops such an index whenever the destination will not regenerate it, for example TAGS INNER ENGINE = Memory. The PR body/docs promise that custom indexes are preserved, but this path turns an explicit schema choice into a no-op. We need a way to distinguish the auto-generated tags_idx from a user-declared one, or at least fail instead of stripping the ambiguous case.
The new default tags index advances the schema version. Expect version 4 in metadata after `DETACH`/`ATTACH` and after changing another setting. CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120083&sha=1761e4134b4e1f6cdc5b57a5e73c24d40f5fdbc1&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29 Related: #120083
Build profile diff (arm_release)Comparing commit See the job log for details. |
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
Include the merged upstream revert for the `NOT_FOUND_COLUMN_IN_BLOCK` exception in `03710_analyzer_limit_by_aggregate_validation` when `optimize_injective_functions_in_group_by` is disabled. Preserve the complete `TimeSeries` tags-index diff and all existing PR commits. CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120083&sha=26c00521dd478c40580fdc59b77ddf46d937d8e6&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29 Related: #120118 Related: #120083
| auto inner_columns = make_intrusive<ASTColumns>(); | ||
| inner_columns->set(inner_columns->columns, col_list); | ||
| const auto & columns = inner_columns->as<ASTColumns &>(); | ||
| if (columns.constraints || columns.projections || columns.primary_key || columns.primary_key_from_columns) |
There was a problem hiding this comment.
ParserTablePropertiesDeclarationList does not just add INDEX support here: it also parses FOREIGN KEY ... and then drops ASTForeignKeyDeclaration on the floor in ParserTablePropertiesDeclarationList. Because this check only rejects constraints / projections / primary keys, ... INNER COLUMNS (FOREIGN KEY (...) REFERENCES ...) now succeeds and the foreign-key clause disappears from the stored definition instead of being rejected.
INNER COLUMNS should reject every non-column / non-index table property at this boundary, not silently turn unsupported syntax into a no-op.
| SELECT value FROM prometheusQuery(ts_text, 'test_metric{job="worker"}', 1000) | ||
| SETTINGS log_comment = 'timeseries_tags_text_index_promql'; | ||
| SYSTEM FLUSH LOGS query_log; | ||
| SELECT count() = 2 AND min(ProfileEvents['TextIndexUsedEmbeddedPostings'] + ProfileEvents['TextIndexReadPostings'] > 0) |
There was a problem hiding this comment.
This proves that the planner can hit the text index, but it still does not establish the contract claimed by the PR metadata/docs (Performance Improvement, "It accelerates ...").
Because this change also bumps the stored TimeSeries schema version for every new table, we still need a small before/after measurement on representative exact-label selectors, for example elapsed, read_rows, or read_bytes with and without the index, to show that the new default index is worth the version bump.
| return false; | ||
|
|
||
| auto indices = make_intrusive<ASTExpressionList>(); | ||
| indices->children.push_back(makeDefaultTagsIndex()); |
There was a problem hiding this comment.
No TimeSeries setting is used, so we won't be able to turn it off
Use `keyValuePairs` to index label pairs in the `tags` map for new schema version 4 tables. Preserve explicit indexes and earlier schema versions, and carry index declarations through inner-table creation and attachment. Related: #115579
Expect the default `tags_idx` text index in the copied table definition. CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120083&sha=4616dd76665308fa6d66d488afcde17fd64e10ca&name_0=PR&name_1=Fast%20test Related: #120083
3181c8d to
9747926
Compare
| /// every version in [MIN_SUPPORTED, LATEST] must stay supported, so either make the schema generation | ||
| /// version-aware or bump MIN_SUPPORTED too. | ||
| constexpr UInt64 LATEST = 4; | ||
| constexpr UInt64 LATEST = 5; |
There was a problem hiding this comment.
I rebased this PR to fix conflict, so version is 5 now
… `TimeSeries` version The tests `05213_timeseries_metric_families_target` and `05214_timeseries_backup_restore` printed the version pinned into a new table, which is now 5 because of the default text index on `tags`. The latest version is covered by `04612_timeseries_version_setting`, so these tests check only the keyword, the inner table names, and that the restored definition keeps the version. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120083&sha=9747926c14e6d3f65bb0369fa2496c2b6e56fc9a&name_0=PR&name_1=Fast%20test PR: #120083
PromQL Compliance ReportBaseline: S3 master
Note: score is unchanged vs baseline. |
Add a
keyValuePairstext index to newly createdTimeSeriestags tables (schema version 4), preserving older schemas and custom indexes.Validated with 5 functional tests, 20 normalization tests, and all 15 style checks.
Related: #115579
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Accelerate exact PromQL label matching on new
TimeSeriestables using a text index on thetagsmap.Workflow [PR]
Sync PR [sync-upstream/pr/120083]
Version info
26.10.1.29(included in26.10and later)