{{ message }}
Aggregation function lastChangeAt#103458
Open
KirIgor wants to merge 1 commit intoClickHouse:masterfrom
Open
Conversation
Returns the `calculated_at` timestamp of the most recent actual change in `value` across a time-ordered sequence. A change is counted only when the value genuinely differs between consecutive observations. If the value never changes, the first `calculated_at` is returned. Supported value types: `(U)Int*`, `Float*`, `Decimal*`, `Date`, `DateTime`, `DateTime64`, and `AggregateFunction(groupBitmap, UInt*)`. Supported timestamp types: `(U)Int*`, `Float*`, `Date`, `DateTime`, `DateTime64`. Designed for `AggregatingMergeTree` to maintain a `changed_at` column without storing full history. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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: New Feature
Changelog entry:
Added aggregate function
lastChangeAt(value, calculated_at)that returns the time of the most recent actual change invalueacross a time-ordered sequence. Supports numeric, Decimal, Date, DateTime, DateTime64, and BitmapData value types. Designed for use with AggregatingMergeTree to maintain achanged_atcolumn without storing full history.Documentation entry:
Motivation:
In AggregatingMergeTree tables it is sometimes necessary to track when a metric last changed its value. Storing the full history is expensive, and without lastChangeAt there is no way to answer "when did this value last change?" across incremental merges while keeping only a fixed-size state.
Parameters:
value— the metric to observe. Supported types:(U)Int*,Float*,Decimal*,Date,DateTime,DateTime64,AggregateFunction(groupBitmap, UInt*). For bitmaps, equality is tested viabitmapXorCardinality.calculated_at— timestamp of each observation (rows must be ordered by this column). Supported types:(U)Int*,Float*,Date,DateTime,DateTime64.Example: