PromQL support: Add functions for working with tags#93234
Merged
vitlibar merged 8 commits intoClickHouse:masterfrom Jan 16, 2026
Merged
PromQL support: Add functions for working with tags#93234vitlibar merged 8 commits intoClickHouse:masterfrom
vitlibar merged 8 commits intoClickHouse:masterfrom
Conversation
Contributor
|
Workflow [PR], commit [2feef4e] Summary: ❌
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive support for working with time series tags in PromQL by introducing new functions and refactoring existing ones. The changes include:
- Adding new tag manipulation functions:
timeSeriesTagsToGroup(),timeSeriesExtractTag(),timeSeriesCopyTag(),timeSeriesCopyTags(),timeSeriesRemoveTags(),timeSeriesJoinTags(),timeSeriesReplaceTag(),timeSeriesRemoveTag(),timeSeriesRemoveAllTagsExcept() - Renaming functions for consistency:
timeSeriesTagsGroupToTags()→timeSeriesGroupToTags(),timeSeriesIdToTagsGroup()→timeSeriesIdToGroup() - Refactoring the
ContextTimeSeriesTagsCollectorclass to support group-based operations - Extracting common helper functions into
TimeSeriesTagsFunctionHelpers
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
tests/queries/0_stateless/03709_time_series_tags_functions.sql |
Test file exercising all new time series tag manipulation functions |
tests/queries/0_stateless/03709_time_series_tags_functions.reference |
Expected output for the test cases |
src/Interpreters/ContextTimeSeriesTagsCollector.h |
Major refactoring: introduced Group type, renamed functions, added new tag manipulation methods |
src/Interpreters/ContextTimeSeriesTagsCollector.cpp |
Implementation of tag manipulation logic including remove, copy, join, and replace operations |
src/Interpreters/Context.h |
Changed return type from reference to shared_ptr for thread safety |
src/Interpreters/Context.cpp |
Updated implementation to match new return type |
src/Functions/TimeSeries/timeSeriesTagsToGroup.cpp |
New function to convert tags to a group identifier |
src/Functions/TimeSeries/timeSeriesStoreTags.cpp |
Refactored to use helper functions and support nullable IDs |
src/Functions/TimeSeries/timeSeriesReplaceTag.cpp |
New function implementing PromQL label_replace() logic |
src/Functions/TimeSeries/timeSeriesRemoveTags.cpp |
New function to remove multiple tags from a group |
src/Functions/TimeSeries/timeSeriesRemoveTag.cpp |
New function to remove a single tag from a group |
src/Functions/TimeSeries/timeSeriesRemoveAllTagsExcept.cpp |
New function to keep only specified tags |
src/Functions/TimeSeries/timeSeriesJoinTags.cpp |
New function implementing PromQL label_join() logic |
src/Functions/TimeSeries/timeSeriesIdToTags.cpp |
Refactored to use helper functions and new collector API |
src/Functions/TimeSeries/timeSeriesIdToGroup.cpp |
New function replacing timeSeriesIdToTagsGroup with alias for backward compatibility |
src/Functions/TimeSeries/timeSeriesGroupToTags.cpp |
New function replacing timeSeriesTagsGroupToTags with alias for backward compatibility |
src/Functions/TimeSeries/timeSeriesExtractTag.cpp |
New function to extract a single tag value from a group |
src/Functions/TimeSeries/timeSeriesCopyTags.cpp |
New function to copy multiple tags between groups |
src/Functions/TimeSeries/timeSeriesCopyTag.cpp |
New function to copy a single tag between groups |
src/Functions/TimeSeries/TimeSeriesTagsFunctionHelpers.h |
Header for common helper functions used across time series functions |
src/Functions/TimeSeries/TimeSeriesTagsFunctionHelpers.cpp |
Implementation of argument validation, extraction, and column creation helpers |
Comments suppressed due to low confidence (1)
src/Interpreters/ContextTimeSeriesTagsCollector.cpp:1
- The logic is inverted. When
null_map[i]is true (indicating a NULL value), the ID should be reset toIDType{}. The condition should beif (null_map[i]).
#include <Interpreters/ContextTimeSeriesTagsCollector.h>
1 task
3fcac07 to
634313c
Compare
634313c to
d194b80
Compare
95a64ad to
d9561bc
Compare
d9561bc to
239bca3
Compare
Member
Author
|
@GrigoryPervakov please take a look at this PR, it improves the functions for working with time series tags added in #75036 |
…imeSeriesIdToTagsGroup -> timeSeriesIdToGroup.
…eriesExtractTag, timeSeriesCopyTags, timeSeriesRemoveTags, timeSeriesJoinTags, timeSeriesReplaceTag.
239bca3 to
2ef66ce
Compare
GrigoryPervakov
approved these changes
Jan 13, 2026
Member
GrigoryPervakov
left a comment
There was a problem hiding this comment.
LGTM, we also agreed that some new functions, like timeSeriesReplaceTag, need a link to the Prometheus docs
GrigoryPervakov
approved these changes
Jan 16, 2026
Merged
via the queue into
ClickHouse:master
with commit Jan 16, 2026
98416ad
257 of 260 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 support: Add functions for working with tags (labels):
timeSeriesTagsToGroup(),timeSeriesExtractTag(),timeSeriesCopyTags(),timeSeriesRemoveTags(),timeSeriesJoinTags(),timeSeriesReplaceTag()timeSeriesTagsGroupToTags()totimeSeriesGroupToTags(),timeSeriesIdToTagsGroup()totimeSeriesIdToGroup()Part of #89356