Skip to content

PromQL: check duplicate series of binary operators after the JOIN - #124879

Merged
vitlibar merged 2 commits into
ClickHouse:masterfrom
vitlibar:promql-per-step-duplicate-series-check-2
Oct 13, 2026
Merged

vitlibar merged 2 commits into
ClickHouse:masterfrom
vitlibar:promql-per-step-duplicate-series-check-2

Conversation

@vitlibar

@vitlibar vitlibar commented Oct 9, 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):

PromQL: check duplicate series of binary operators after the JOIN.
Follow-up to #124086.

Before this PR the duplicate series check for binary operators was done before the JOIN: each side which must be unique (both sides of a one-to-one match, the side one of group_left/group_right) was checked across all its series, so a duplicate which the other side does not even match failed the whole query.

Now the check happens after the JOIN, and duplicates are reported only at steps where the matched series of the other side has a value.


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

Version info

  • Merged into: 26.10.1.2268-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 Oct 9, 2026
@vitlibar vitlibar changed the title [WIP] Follow-up to https://github.com/ClickHouse/ClickHouse/pull/124086 [WIP] Follow-up to #124086 Oct 9, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [852b486]

Summary: ✅


AI Review

Summary

This PR refactors PromQL duplicate-series checks for binary operators so they are computed per step after the join, and adds stateless coverage for the new behavior. The refactor removes some false positives, but it also weakens the check on the side Prometheus still treats as uniquely matched: upstream Prometheus still rejects duplicate series on that side before it probes for a match, while this patch now lets those unmatched duplicates pass. Because that changes PromQL semantics and the new tests lock the divergence in, I would not merge it as-is.

Findings

❌ Blockers

  • [src/Storages/TimeSeries/PrometheusQueryToSQL/applySimpleBinaryOperator.cpp:391] [dismissed by author -- https://github.com/ClickHouse/ClickHouse/pull/124879#discussion_r4239579800] The new rule “report duplicates on the side that must be unique only at steps where a matched series of the other side has a value” is not what Prometheus currently does. Upstream promql/engine.go still rejects duplicate series on the indexed one side before it scans the opposite vector, so queries like req{instance="i1"} / on(instance) group_left lim and last_over_time({__name__=~"f|g"}[50s]) + on(dc) last_over_time({__name__=~"a|b"}[50s]) continue to fail there while the new tests here expect success. Suggested fix: restore a pre-probe uniqueness check for the side treated as unique by PromQL matching (the old GROUP BY join_group HAVING ... path, or an equivalent pre-join mask/count), and update the new 05271 / 05320 expectations accordingly.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    • Restore Prometheus-compatible duplicate detection for the uniquely matched one side instead of gating it on opposite-side presence.
    • Drop or rewrite the new stateless expectations that now assert successful evaluation for those duplicate-series cases.

@clickhouse-gh clickhouse-gh Bot added the pr-experimental Experimental Feature label Oct 9, 2026
@vitlibar
vitlibar force-pushed the promql-per-step-duplicate-series-check-2 branch from f14ba51 to 1f7f9cb Compare October 10, 2026 13:10
@vitlibar vitlibar changed the title [WIP] Follow-up to #124086 PromQL: check duplicate series of binary operators after the JOIN Oct 10, 2026
@vitlibar vitlibar removed the do not test disable testing on pull request label Oct 10, 2026
@vitlibar
vitlibar force-pushed the promql-per-step-duplicate-series-check-2 branch from 1f7f9cb to 25af3a6 Compare October 10, 2026 23:02
@clickhouse-gh

clickhouse-gh Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 852b486a5 with master 2079ed3d5 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of dca38d441; 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

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

Job report

Duplicates on the side "one" are reported only at steps where a matched series
of the other side has a value (see `makeNoDuplicatePerStepCheck`), so
`req{instance="i1"} / on(instance) lim` and its `group_left` variant return
a result instead of an error. Dropping the metric name still reports duplicates
in any group.
@vitlibar
vitlibar force-pushed the promql-per-step-duplicate-series-check-2 branch from 25af3a6 to 852b486 Compare October 11, 2026 11:46
@vitlibar
vitlibar marked this pull request as ready for review October 11, 2026 18:03
@clickhouse-gh

clickhouse-gh Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

PromQL Compliance Report

Baseline: S3 master dca38d441

Suite Baseline Current Delta
Prometheus compliance 100.00% 100.00% +0.00%
Extended support (upstream engine tests) 91.12% 91.12% +0.00%
Suite Passed Failed Unsupported
Prometheus compliance 539 -> 539 (+0) 0 -> 0 (+0) 0 -> 0 (+0)
Extended support (upstream engine tests) 667 -> 667 (+0) 62 -> 62 (+0) 3 -> 3 (+0)

Extended support (upstream engine tests): native-histogram exclusions: 149; excluded assertions: 248; upstream 3da2514eff5c.

Note: Prometheus compliance score is unchanged vs baseline.

Uploaded compliance JSON for this PR commit

@vitlibar
vitlibar added this pull request to the merge queue Oct 13, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 13, 2026
@vitlibar
vitlibar added this pull request to the merge queue Oct 13, 2026
Merged via the queue into ClickHouse:master with commit 2393ab2 Oct 13, 2026
326 of 327 checks passed
@vitlibar
vitlibar deleted the promql-per-step-duplicate-series-check-2 branch October 13, 2026 10:45
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 13, 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