Skip to main content

Documentation Index

Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-replace-private-preview-badge-man.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

timeSeriesGroupArray

Introduced in: v25.8.0 Sorts time series data by timestamp in ascending order.
This function is experimental, enable it by setting allow_experimental_ts_to_grid_aggregate_function=true.
Syntax
timeSeriesGroupArray(timestamp, value)
Arguments Returned value Returns an array of tuples (timestamp, value) sorted by timestamp in ascending order. If there are multiple values for the same timestamp then the function chooses the greatest of these values. Array(Tuple(T1, T2)) Examples Basic usage with individual values
Query
WITH
    [110, 120, 130, 140, 140, 100]::Array(UInt32) AS timestamps,
    [1, 6, 8, 17, 19, 5]::Array(Float32) AS values
SELECT timeSeriesGroupArray(timestamp, value)
FROM
(
    SELECT
        arrayJoin(arrayZip(timestamps, values)) AS ts_and_val,
        ts_and_val.1 AS timestamp,
        ts_and_val.2 AS value
);
Response
┌─timeSeriesGroupArray(timestamp, value)───────────────┐
│ [(100, 5), (110, 1), (120, 6), (130, 8), (140, 19)]  │
└──────────────────────────────────────────────────────┘
Passing multiple samples of timestamps and values as arrays of equal size
Query
WITH
    [110, 120, 130, 140, 140, 100]::Array(UInt32) AS timestamps,
    [1, 6, 8, 17, 19, 5]::Array(Float32) AS values
SELECT timeSeriesGroupArray(timestamps, values);
Response
┌─timeSeriesGroupArray(timestamps, values)──────────────┐
│ [(100, 5), (110, 1), (120, 6), (130, 8), (140, 19)]   │
└───────────────────────────────────────────────────────┘