Skip to content

PromQL: Improve parser#94091

Merged
nikitamikhaylov merged 8 commits intoClickHouse:masterfrom
vitlibar:promql-improve-parser
Jan 26, 2026
Merged

PromQL: Improve parser#94091
nikitamikhaylov merged 8 commits intoClickHouse:masterfrom
vitlibar:promql-improve-parser

Conversation

@vitlibar
Copy link
Member

@vitlibar vitlibar commented Jan 13, 2026

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):

Improve PromQL parser:

  • Fix parsing numbers in special cases: hexadecimal, inf/nan, underscore between digits (1_000_000)
  • Fix passing the timestamp scale from Prometheus HTTP API
  • Improve ANTLR4 PromQL grammar
  • Add test to check parsing of prometheus queries

Part of #89356

@clickhouse-gh
Copy link
Contributor

clickhouse-gh bot commented Jan 13, 2026

Workflow [PR], commit [d0739ab]

Summary:

job_name test_name status info comment
AST fuzzer (amd_debug) failure
Logical error: Cannot convert nested result of function A with type B to the expected result type C: D (STID: 4827-671c) FAIL cidb, issue ISSUE EXISTS
BuzzHouse (amd_msan) failure
Logical error: Function writeSlice expects same column types for GenericArraySlice and GenericArraySink. (STID: None) FAIL cidb, issue ISSUE CREATED

@nikitamikhaylov nikitamikhaylov added the comp-promql Issues related to the PromQL support and TimeSeries table engine. label Jan 13, 2026
@vitlibar vitlibar requested a review from Copilot January 13, 2026 17:39
@clickhouse-gh clickhouse-gh bot added pr-not-for-changelog This PR should not be mentioned in the changelog submodule changed At least one submodule changed in this PR. labels Jan 13, 2026
@vitlibar vitlibar added comp-promql Issues related to the PromQL support and TimeSeries table engine. and removed comp-promql Issues related to the PromQL support and TimeSeries table engine. labels Jan 13, 2026

This comment was marked as outdated.

@vitlibar vitlibar changed the title PromQL: More correct parsing for timestamps for durations PromQL: More correct parsing for timestamps and durations Jan 13, 2026
@vitlibar vitlibar changed the title PromQL: More correct parsing for timestamps and durations [WIP] PromQL: More correct parsing for timestamps and durations Jan 13, 2026
@vitlibar vitlibar force-pushed the promql-improve-parser branch 2 times, most recently from c6aedb0 to 2376b56 Compare January 19, 2026 21:24
@vitlibar vitlibar requested a review from Copilot January 19, 2026 21:24
Copy link
Contributor

Copilot AI left a comment

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 28 out of 40 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/Parsers/Prometheus/parseTimeSeriesTimestamp.cpp:1

  • On line 560, milliseconds is being added to scaled_seconds, but milliseconds should be scaled_milliseconds (computed earlier). The current code adds unscaled milliseconds to scaled seconds, producing incorrect results.
#include <Parsers/Prometheus/parseTimeSeriesTimestamp.h>

@vitlibar vitlibar changed the title [WIP] PromQL: More correct parsing for timestamps and durations [WIP] PromQL: More correct parsing and processing of timestamps and durations Jan 19, 2026
@vitlibar vitlibar force-pushed the promql-improve-parser branch 5 times, most recently from 419ce37 to 7ca2d0f Compare January 20, 2026 08:43
@vitlibar vitlibar requested a review from Copilot January 20, 2026 08:43
Copy link
Contributor

Copilot AI left a comment

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 29 out of 41 changed files in this pull request and generated 4 comments.

@vitlibar vitlibar changed the title [WIP] PromQL: More correct parsing and processing of timestamps and durations [WIP] PromQL: Improve parser Jan 20, 2026
@vitlibar vitlibar force-pushed the promql-improve-parser branch from 7ca2d0f to 5478eb1 Compare January 20, 2026 10:28
@vitlibar vitlibar changed the title [WIP] PromQL: Improve parser PromQL: Improve parser Jan 20, 2026
@vitlibar vitlibar marked this pull request as ready for review January 20, 2026 10:30
@vitlibar vitlibar force-pushed the promql-improve-parser branch from 5478eb1 to c66a6bb Compare January 20, 2026 10:35
@vitlibar vitlibar force-pushed the promql-improve-parser branch 2 times, most recently from 8adb206 to c6be808 Compare January 21, 2026 10:03
@vitlibar vitlibar force-pushed the promql-improve-parser branch from c6be808 to 83892f3 Compare January 21, 2026 10:49
@vitlibar
Copy link
Member Author

Ready for review

UnaryOperator(-)
ScalarLiteral(1)
)");

Copy link
Member

Choose a reason for hiding this comment

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

Can you please also add these queries? https://github.com/prometheus/compliance/blob/3de836d255ffc98bbf7d58eb487b7662b496d047/promql/promql-test-queries.yml#L34-L42

Queries .123, 1.23e-3, 0x3d, +Inf, NaN look very interesting.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

I also added most of other queries from https://github.com/prometheus/compliance/blob/main/promql/promql-test-queries.yml to this test.

@vitlibar
Copy link
Member Author

CI failures are unrelated

@nikitamikhaylov nikitamikhaylov added this pull request to the merge queue Jan 26, 2026
Merged via the queue into ClickHouse:master with commit b290c0a Jan 26, 2026
129 of 132 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-promql Issues related to the PromQL support and TimeSeries table engine. 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 submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants