Skip to content

Use Delta, T64, and ZSTD(3) for TimeSeries timestamps - #120589

Closed
nikitamikhaylov wants to merge 5 commits into
masterfrom
timeseries-t64-defaults
Closed

nikitamikhaylov wants to merge 5 commits into
masterfrom
timeseries-t64-defaults

Conversation

@nikitamikhaylov

@nikitamikhaylov nikitamikhaylov commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

These changes are now included in the combined timestamp and value codec update.

Related: #120454

Use CODEC(Delta, T64, ZSTD(3)) for generated timestamp columns in the samples and recent samples tables of TimeSeries. Preserve explicit codecs and recognize historical and current defaults in CREATE TABLE AS.

Changelog category (leave one):

  • Experimental Feature

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

Use Delta, T64, and ZSTD(3) as the default timestamp codec in the samples and recent samples tables of the TimeSeries engine.


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

Apply the codec to generated timestamps in both sample targets. Recognize
historical and current generated codecs when copying table definitions.
@clickhouse-gh

clickhouse-gh Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f734927]


AI Review

Summary

This PR switches the auto-generated timestamp codec in TimeSeries samples and recent-samples tables from CODEC(DoubleDelta, ZSTD(1)) to CODEC(Delta, T64, ZSTD(3)), updates the user-facing documentation, and teaches CREATE TABLE AS to treat both codec stacks as generated defaults. The codec choice itself looks coherent, but the implementation breaks the TimeSeries versioning contract, so the change is not ready to merge as-is.

Findings

❌ Blockers

  • [src/Storages/TimeSeries/TimeSeriesVersion.h:33-36], [src/Storages/TimeSeries/normalizeTimeSeriesDefinitionImpl.cpp:968-976], [src/Storages/TimeSeries/tests/gtest_normalize_time_series_definition.cpp:723-728] TimeSeries versions are supposed to freeze generated target-table schemas, but this PR changes the generated timestamp codec for every supported version and even updates the version = 1 expectation accordingly. After this lands, the meaning of CREATE TABLE ... SETTINGS version = 1 depends on which server version normalized it, which is exactly what the pinned version setting is meant to prevent.
  • Suggested fix: introduce a new TimeSeriesVersion for the CODEC(Delta, T64, ZSTD(3)) default and gate both generation and generated-column recognition on that version, while keeping CODEC(DoubleDelta, ZSTD(1)) for older versions.
Final Verdict

Changes requested.

@clickhouse-gh clickhouse-gh Bot added the pr-experimental Experimental Feature label Sep 17, 2026
@nikitamikhaylov nikitamikhaylov changed the title Use T64 and ZSTD(3) for TimeSeries timestamps Use T64 and ZSTD(3) for TimeSeries timestamps Sep 17, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... label Sep 17, 2026
if (auto * timestamp_decl = add_column_if_missing(TimeSeriesColumnNames::Timestamp, dataTypeToAST(resolved_types.timestamp_type)))
timestamp_decl->setCodec(makeASTFunction(
"CODEC", make_intrusive<ASTIdentifier>("DoubleDelta"), makeASTFunction("ZSTD", make_intrusive<ASTLiteral>(UInt64{1}))));
"CODEC", make_intrusive<ASTIdentifier>("T64"), makeASTFunction("ZSTD", make_intrusive<ASTLiteral>(UInt64{3}))));

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.

TimeSeries versions are supposed to freeze the generated target-table schema, but this codec switch is unconditional. TimeSeriesVersion.h:33-35 explicitly says schema changes need either a new version or version-aware generation, yet normalizeInnerColumns will now emit CODEC(T64, ZSTD(3)) even for SETTINGS version = 1..5 (the updated gtest_normalize_time_series_definition.cpp:723-728 expectation already shows version = 1 being rewritten this way).

Can we gate the new codec behind a new TimeSeriesVersion and keep CODEC(DoubleDelta, ZSTD(1)) for the older versions, with the same version check in the generated-column detection for CREATE TABLE AS?

@clickhouse-gh

clickhouse-gh Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 10f1e6706 with master ec5bf8bf3 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

8 translation units recompiled, 18 s compile time in total, 8 of them have a recent master baseline.

Job report

@nikitamikhaylov
nikitamikhaylov marked this pull request as ready for review September 17, 2026 23:24
@nikitamikhaylov nikitamikhaylov changed the title Use T64 and ZSTD(3) for TimeSeries timestamps Use Delta, T64, and ZSTD(3) for TimeSeries timestamps Sep 17, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

PromQL Compliance Report

Baseline: S3 master ec5bf8bf3

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

nikitamikhaylov added a commit that referenced this pull request Sep 18, 2026
Move the `Delta`, `T64`, and `ZSTD(3)` timestamp defaults into
the `ALP` value codec change for both sample targets.
Preserve both functional tests and combine overlapping expectations.

Related: #120589
Related: #120454
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants