PromQL: Simplify using decimals in PrometheusQueryTree#95223
Merged
nikitamikhaylov merged 4 commits intoClickHouse:masterfrom Jan 30, 2026
Merged
PromQL: Simplify using decimals in PrometheusQueryTree#95223nikitamikhaylov merged 4 commits intoClickHouse:masterfrom
nikitamikhaylov merged 4 commits intoClickHouse:masterfrom
Conversation
Contributor
|
Workflow [PR], commit [e48a4a3] Summary: ❌
|
1 task
Contributor
There was a problem hiding this comment.
Pull request overview
This PR simplifies the handling of ranges and offsets in the Prometheus query parser by replacing DecimalField<DateTime64> and DecimalField<Decimal64> wrapper types with direct DateTime64 and Decimal64 primitive types throughout PrometheusQueryTree.
Changes:
- Replaced
ScalarLiteralandIntervalLiteralnodes with a singleScalarnode type - Removed
DecimalFieldwrappers in favor of storingDateTime64andDecimal64values directly - Updated parsing utilities to work with the new type system and take a
timestamp_scaleparameter
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/TableFunctions/TableFunctionPrometheusQuery.cpp | Retrieves timestamp scale from storage metadata and passes it to the query parser |
| src/Storages/TimeSeries/PrometheusQueryToSQL.cpp | Refactored to use primitive decimal types instead of DecimalField wrappers, simplified arithmetic operations |
| src/Storages/StoragePrometheusQuery.cpp | Added whitespace formatting |
| src/Parsers/Prometheus/tests/gtest_PrometheusQueryTree.cpp | Updated test expectations to reflect renamed node types and simplified output format |
| src/Parsers/Prometheus/PrometheusQueryTree.h | Modified node structure to store primitive types and added timestamp_scale field to the tree |
| src/Parsers/Prometheus/PrometheusQueryTree.cpp | Updated node implementations to use primitive types and pass tree context for dumping |
| src/Parsers/Prometheus/PrometheusQueryParsingUtil.h | Restructured parsing API to separate scalar, timestamp, and duration parsing with explicit scale parameters |
| src/Parsers/Prometheus/PrometheusQueryParsingUtil.cpp | Implemented new parsing functions with proper overflow checking and scale handling |
| src/Parsers/Prometheus/PrometheusQueryParsingUtil-antlr.cpp | Updated ANTLR-based parser to use new parsing utilities and store values directly in nodes |
| src/Core/DecimalFunctions.h | Added tryMultiplyAdd helper function for overflow-safe decimal arithmetic |
…<DateTime64> to simplify calculations.
…ifferent data types).
1af45ba to
e48a4a3
Compare
Member
Author
|
Ready for review |
nikitamikhaylov
approved these changes
Jan 29, 2026
Merged
via the queue into
ClickHouse:master
with commit Jan 30, 2026
8af83c4
128 of 134 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
PromQL: Simplify storing ranges and offsets in
PrometheusQueryTree,use
DateTime64instead ofDecimalField<DateTime64>.Part of #89356