Skip to content

TimeSeries: Rename inner column metric_family_name to metric_family - #119226

Merged
vitlibar merged 1 commit into
ClickHouse:masterfrom
vitlibar:timeseries-metric-family-column-rename
Sep 22, 2026
Merged

vitlibar merged 1 commit into
ClickHouse:masterfrom
vitlibar:timeseries-metric-family-column-rename

Conversation

@vitlibar

@vitlibar vitlibar commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Experimental Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

There is an outer column of TimeSeries table engine called metric_family, but the matching column of the inner tables was called metric_family_name. This PR renames the inner column to match the outer column: metric_family_name -> metric_family.


Workflow [PR]
Sync PR [sync-upstream/pr/119226]

Version info

  • Merged into: 26.10.1.452-master (included in 26.10 and later)

@vitlibar vitlibar added do not test disable testing on pull request comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... labels Sep 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a78d687]

Summary: ✅


AI Review

Summary

This PR bumps TimeSeries to schema version 6 and renames the metric-families inner column from metric_family_name to metric_family, while keeping older table versions readable and writable. The common read/write paths look updated, but the version-crossing CREATE TABLE ... AS path still mishandles user customizations around that renamed identifier, and the new-table validator still misses one legacy INNER ENGINE spelling, so I would not merge this as-is.

Missing context / blind spots
  • ⚠️ I did not run the test suite locally in this workspace; the verdict is based on code tracing and the tests added in the diff.
Findings

⚠️ Majors

  • [src/Storages/TimeSeries/normalizeTimeSeriesDefinitionImpl.cpp:1097-1109,1610-1613] The direct version-6 INNER ENGINE path still accepts the legacy key spelling when INNER COLUMNS is omitted. normalizeInnerColumns only rejects metric_family_name when it appears in the explicit column list, and normalizeInnerEngine only regenerates a sort key when it is missing, so CREATE TABLE ... ENGINE = TimeSeries METRIC FAMILIES ENGINE = ReplacingMergeTree ORDER BY metric_family_name still carries a dead identifier into inner-table creation instead of renaming or rejecting it at the TimeSeries layer. Suggested fix: reject or rewrite metric_family_name everywhere inside the metric-families engine AST, not just in INNER COLUMNS.
  • [dismissed by author -- https://github.com/TimeSeries: Rename inner column metric_family_name to metric_family #119226#discussion_r4008153215] [src/Storages/TimeSeries/normalizeTimeSeriesDefinitionImpl.cpp:557-562,1097-1112,1942-1949,1965-1970] CREATE TABLE new AS existing_table ENGINE = TimeSeries no longer preserves customized metric-families columns and key layout across the version-5 -> 6 rename. The copy path deletes the old metric_family_name column outright and regenerates the default metric_family String, so a source table customized as LowCardinality(String) or with a sort key like (metric_family_name, type) is copied with different deduplication and layout semantics. I still consider this real because the docs promise that customized INNER COLUMNS / INNER ENGINE parts are kept and adjusted, and this path instead silently discards them.
  • [dismissed by author -- https://github.com/TimeSeries: Rename inner column metric_family_name to metric_family #119226#discussion_r4008647720] [src/Storages/TimeSeries/normalizeTimeSeriesDefinitionImpl.cpp:796-817,1967-1970] The CREATE TABLE ... AS rewrite only strips order_by, primary_key, and partition_by when they reference the pre-6 metric-family name. Other engine expressions such as sample_by or ttl_table are left untouched, so a copied table can still retain metric_family_name inside the inner engine AST even after the new version renamed the column to metric_family. I still consider this real because those expressions then point at a column that no longer exists, turning a version-crossing copy into an invalid or behavior-changing definition.
Final Verdict

Request changes. The rename itself is mostly wired through, but the compatibility story is still incomplete around CREATE TABLE ... AS and legacy INNER ENGINE clauses, which are both part of the versioned-schema contract this PR is changing.

LLVM Coverage Report

Measured on commit a78d687.

Metric Baseline Current Δ
Lines 88.10% 88.10% +0.00%
Functions 91.70% 91.70% +0.00%
Branches 79.30% 79.40% +0.10%

Changed lines: Changed C/C++ lines covered: 240/245 (97.96%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-experimental Experimental Feature label Sep 10, 2026
@vitlibar vitlibar changed the title [WIP] TimeSeries: rename inner column metric_family_name to metric_family [WIP] TimeSeries: Rename inner column metric_family_name to metric_family Sep 10, 2026
@vitlibar
vitlibar force-pushed the timeseries-metric-family-column-rename branch from 19f46dd to 3cd65c4 Compare September 14, 2026 17:42
@vitlibar vitlibar removed the do not test disable testing on pull request label Sep 14, 2026
case ViewTarget::Metrics:
{
add_column_if_missing(TimeSeriesColumnNames::MetricFamilyName, makeASTDataType("String"));
add_column_if_missing(TimeSeriesColumnNames::getInnerMetricFamily(time_series_settings[TimeSeriesSetting::version]), makeASTDataType("String"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only adds the version-4 spelling. If a user writes the legacy spelling directly in a new definition, for example

CREATE TABLE ts ENGINE = TimeSeries
METRICS INNER COLUMNS (metric_family_name LowCardinality(String))
METRICS ENGINE = ReplacingMergeTree ORDER BY metric_family_name

normalizeInnerColumns leaves metric_family_name as an extra column, adds a fresh metric_family String here, and the read/write paths still use only metric_family. So the requested customization silently lands on a dead column, and the sort key can stay attached to that dead column too. The external-table path throws a targeted exception for the same mismatch; this direct INNER COLUMNS / INNER ENGINE path should either rename the legacy spelling or reject it as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only fixed for the INNER COLUMNS half. The legacy spelling is rejected only when it appears in the explicit inner column list (normalizeTimeSeriesDefinitionImpl.cpp:1104). If a new definition omits METRIC FAMILIES INNER COLUMNS and only says METRIC FAMILIES ENGINE = ReplacingMergeTree ORDER BY metric_family_name, normalizeInnerEngine keeps that explicit ORDER BY unchanged and only synthesizes a key when it is missing (normalizeTimeSeriesDefinitionImpl.cpp:1612). So the direct INNER ENGINE path still carries the stale identifier instead of renaming or rejecting it.

@vitlibar
vitlibar force-pushed the timeseries-metric-family-column-rename branch from 3cd65c4 to 7ea894e Compare September 14, 2026 18:46
@vitlibar vitlibar changed the title [WIP] TimeSeries: Rename inner column metric_family_name to metric_family TimeSeries: Rename inner column metric_family_name to metric_family Sep 14, 2026
Comment on lines 30 to +35
CREATE TABLE ts_metrics (
metric_family_name String,
metric_family String,
type String,
unit String,
help String)
ENGINE = ReplacingMergeTree ORDER BY metric_family_name;
ENGINE = ReplacingMergeTree ORDER BY metric_family;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The column of the inner table was named metric_family_name before, and now it's named metric_family.

@vitlibar
vitlibar marked this pull request as ready for review September 14, 2026 18:50
@clickhouse-gh

clickhouse-gh Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit a78d6875fd80342721a912766da26d529bd3e4bc was not compared: the CI logs cluster did not answer (every POST attempt failed with an exception).

See the job log for details.

@vitlibar
vitlibar force-pushed the timeseries-metric-family-column-rename branch 4 times, most recently from cc5c4a1 to dc04d0f Compare September 22, 2026 10:00
@vitlibar
vitlibar force-pushed the timeseries-metric-family-column-rename branch from dc04d0f to a78d687 Compare September 22, 2026 13:54
@clickhouse-gh

clickhouse-gh Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

PromQL Compliance Report

Baseline: S3 master 7b3eac99f

Metric Baseline Current Δ
Score 96.47% 96.47% +0.00%
Passed 520 520 +0
Failed 3 3 +0
Unsupported 16 16 +0

Note: score is unchanged vs baseline.

Uploaded compliance JSON for this PR commit

@vitlibar
vitlibar added this pull request to the merge queue Sep 22, 2026
Merged via the queue into ClickHouse:master with commit 6ca4ef4 Sep 22, 2026
176 checks passed
@vitlibar
vitlibar deleted the timeseries-metric-family-column-rename branch September 22, 2026 20:31
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 22, 2026
valerypetrov added a commit to valerypetrov/ClickHouse that referenced this pull request Sep 23, 2026
The precision test only writes external samples and tags. Let `TimeSeries`
generate its unused metric-families target instead of defining an external
table with the pre-version-6 `metric_family_name` column. This keeps the
fixture compatible with both the PR base and current master without changing
the evaluation-time assertions.

Related: ClickHouse#120942 (comment)
Related: ClickHouse#119226
CI: https://github.com/ClickHouse/ClickHouse/actions/runs/35799204924
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-ClickHouse__ClickHouse that referenced this pull request Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... pr-experimental Experimental Feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants