PromQL: Add set binary operators by vitlibar · Pull Request #105000 · ClickHouse/ClickHouse · GitHub
Skip to content

PromQL: Add set binary operators#105000

Merged
nikitamikhaylov merged 1 commit into
ClickHouse:masterfrom
vitlibar:promql-set-operators
May 19, 2026
Merged

PromQL: Add set binary operators#105000
nikitamikhaylov merged 1 commit into
ClickHouse:masterfrom
vitlibar:promql-set-operators

Conversation

@vitlibar

@vitlibar vitlibar commented May 15, 2026

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

PromQL: Add set binary operators and, or, unless

This was a part of #98948 (0c63be2) which wasn't merged

Version info

  • Merged into: 26.5.1.810

@clickhouse-gh

clickhouse-gh Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label May 15, 2026
@vitlibar vitlibar requested a review from Copilot May 15, 2026 07:35

Copilot AI left a comment

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.

Pull request overview

Adds support for the PromQL set binary operators and, or, and unless to the PrometheusQueryToSQL converter. Each operator is translated into a multi-step SQL pipeline that joins the left/right vector grids on the appropriate group keys (respecting on(...)/ignoring(...)) and combines per-timestamp samples accordingly. Note that group_left/group_right modifiers are explicitly rejected for set operators, matching Prometheus semantics.

Changes:

  • New files applyBinaryOperatorAnd.{h,cpp}, applyBinaryOperatorOr.{h,cpp}, applyBinaryOperatorUnless.{h,cpp} implementing the three set operators, including a shared checkArgumentTypesForSetBinaryOperator helper.
  • Dispatch wiring in applyBinaryOperator.cpp for the three new operator names; introduces a new JoinCounts column-name constant in TimeSeriesColumnNames.h.
  • Integration tests in test_evaluation.py::test_set_binary_operators covering basic operators, on(...)/ignoring(...) matching, and group_left/group_right rejection.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Storages/TimeSeries/TimeSeriesColumnNames.h Adds JoinCounts column constant used by set-operator subqueries.
src/Storages/TimeSeries/PrometheusQueryToSQL/applyBinaryOperator.cpp Dispatches and/or/unless to the new implementations.
src/Storages/TimeSeries/PrometheusQueryToSQL/applyBinaryOperatorAnd.{h,cpp} Implements and (LEFT SEMI join on grouping keys) and the shared argument-type check.
src/Storages/TimeSeries/PrometheusQueryToSQL/applyBinaryOperatorUnless.{h,cpp} Implements unless (LEFT ANY join, NULL-out matched timestamps).
src/Storages/TimeSeries/PrometheusQueryToSQL/applyBinaryOperatorOr.{h,cpp} Implements or via 4-step pipeline combining left-priority samples with right-only samples via UNION ALL.
tests/integration/test_prometheus_protocols/test_evaluation.py Adds test_set_binary_operators covering all three operators, matching modifiers, and grouping-modifier errors.

Comment thread src/Storages/TimeSeries/PrometheusQueryToSQL/applyBinaryOperatorOr.cpp Outdated

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Comment thread src/Storages/TimeSeries/PrometheusQueryToSQL/applyBinaryOperatorOr.cpp Outdated
@vitlibar vitlibar force-pushed the promql-set-operators branch 2 times, most recently from 038efb5 to 4729ffa Compare May 15, 2026 10:54
@vitlibar vitlibar requested a review from Copilot May 15, 2026 10:54

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Comment thread src/Storages/TimeSeries/PrometheusQueryToSQL/applyBinaryOperatorOr.cpp Outdated

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@clickhouse-gh

clickhouse-gh Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 90.90% 90.90% +0.00%
Branches 76.60% 76.60% +0.00%

Changed lines: 92.75% (256/276) · Uncovered code

Full report · Diff report

@leshikus leshikus left a comment

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.

Generally look good, though this is not my area of expertise. It seems checkArgumentTypesForSetBinaryOperator can be moved to setBinaryOperator.{h,cpp} instead of being at applyBinaryOperatorAnd.h

@nikitamikhaylov nikitamikhaylov added this pull request to the merge queue May 19, 2026
Merged via the queue into ClickHouse:master with commit 7e8e36e May 19, 2026
171 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog 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.

5 participants