> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-vortex-format.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> 일정한 시간 그리드(regular time grid)에서 PromQL과 유사한 `ts_of_min_over_time`을 계산합니다.

# timeSeriesTimestampOfMinToGrid

<h2 id="timeSeriesTimestampOfMinToGrid">
  timeSeriesTimestampOfMinToGrid
</h2>

도입 버전: v26.9.0

타임스탬프와 값의 쌍으로 이루어진 시계열 데이터를 입력받아, 시작 타임스탬프, 종료 타임스탬프, 간격으로 정의되는 일정한 시간 그리드에서 [PromQL과 유사한 ts\_of\_min\_over\_time](https://prometheus.io/docs/prometheus/latest/querying/functions/#aggregation_over_time)을 계산하는 집계 함수입니다. 그리드의 각 지점에서 결과는 지정된 시간 윈도우 내에서 최솟값을 가진 가장 최근 샘플의 타임스탬프(초 단위)입니다.

샘플은 다음 세 가지 형식 중 하나로 전달할 수 있습니다.

* 두 개의 인수 `timestamp`와 `value`로 전달합니다. 이 경우 각 행에는 샘플 하나가 담깁니다.
* 타임스탬프 배열과 값 배열 두 개로 전달합니다. 이 경우 각 행에는 시계열 전체가 담깁니다.
* `(timestamp, value)` 튜플로 구성된 단일 배열로 전달합니다. 이 경우 각 행에는 시계열 전체가 담깁니다.

값이 NaN인 샘플은 무시됩니다. 단, 윈도우 내의 모든 샘플이 NaN이면 무시되지 않습니다.

여러 샘플의 타임스탬프가 같으면 그중 값이 가장 큰 샘플 하나만 사용됩니다. NaN 값은 다른 어떤 값보다도 우선순위가 낮으므로, 해당 타임스탬프의 모든 샘플이 NaN일 때만 NaN 값이 사용됩니다.

<Note>
  이 함수는 비공개 프리뷰 단계입니다. `enable_time_series_aggregate_functions=true`로 설정하면 활성화할 수 있습니다.
</Note>

**구문**

```sql theme={null}
timeSeriesTimestampOfMinToGrid(start_timestamp, end_timestamp, grid_step, staleness)(timestamp, value)
timeSeriesTimestampOfMinToGrid(start_timestamp, end_timestamp, grid_step, staleness)(samples)
```

**매개변수**

* `start_timestamp` — 그리드의 시작을 지정합니다. 소수, 또는 숫자나 날짜-시간 텍스트를 담은 문자열로도 지정할 수 있습니다. [`UInt32`](/ko/reference/data-types/int-uint) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`DateTime64`](/ko/reference/data-types/datetime64) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Decimal*`](/ko/reference/data-types/decimal) 또는 [`String`](/ko/reference/data-types/string)
* `end_timestamp` — 그리드의 끝을 지정합니다. 소수, 또는 숫자나 날짜-시간 텍스트를 담은 문자열로도 지정할 수 있습니다. [`UInt32`](/ko/reference/data-types/int-uint) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`DateTime64`](/ko/reference/data-types/datetime64) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Decimal*`](/ko/reference/data-types/decimal) 또는 [`String`](/ko/reference/data-types/string)
* `grid_step` — 그리드의 간격을 초 단위로 지정합니다. 소수, 또는 숫자나 '15s', '1m'과 같은 기간을 담은 문자열로도 지정할 수 있습니다. [`UInt32`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Decimal*`](/ko/reference/data-types/decimal) 또는 [`String`](/ko/reference/data-types/string)
* `staleness` — 고려 대상 샘플의 최대 "staleness"를 초 단위로 지정합니다. staleness 윈도우는 왼쪽이 열리고 오른쪽이 닫힌 인터벌입니다. 소수, 또는 숫자나 '15s', '1m'과 같은 기간을 담은 문자열로도 지정할 수 있습니다. [`UInt32`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Decimal*`](/ko/reference/data-types/decimal) 또는 [`String`](/ko/reference/data-types/string)

**인수**

* `timestamp` — 샘플의 타임스탬프입니다. 개별 값 또는 배열을 사용할 수 있습니다. [`UInt32`](/ko/reference/data-types/int-uint) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`DateTime64`](/ko/reference/data-types/datetime64) 또는 [`Array(UInt32)`](/ko/reference/data-types/array) 또는 [`Array(DateTime)`](/ko/reference/data-types/array) 또는 [`Array(DateTime64)`](/ko/reference/data-types/array)
* `value` — 타임스탬프에 대응하는 시계열 값입니다. 개별 값 또는 배열을 사용할 수 있습니다. [`Float*`](/ko/reference/data-types/float) 또는 [`Array(Float*)`](/ko/reference/data-types/array)
* `samples` — `(timestamp, value)` 튜플의 배열 형태로 전달하는 시계열 샘플입니다. 각 튜플 원소의 타입은 위에 나열된 타임스탬프 및 값 타입과 같습니다. 타임스탬프와 값을 두 개의 인수로 따로 전달하는 대신 사용할 수 있습니다. [`Array(Tuple(T1, T2))`](/ko/reference/data-types/array)

**반환 값**

지정된 그리드에서의 `ts_of_min_over_time` 값으로, 최솟값이 나타난 타임스탬프이며 `timestamp`와 동일한 타입입니다. 반환되는 배열에는 시간 그리드 지점마다 하나의 값이 포함됩니다. 특정 그리드 지점의 윈도우 내에 샘플이 없으면 해당 값은 NULL입니다. [`Array(Nullable(UInt32))`](/ko/reference/data-types/array) 또는 [`Array(Nullable(DateTime))`](/ko/reference/data-types/array) 또는 [`Array(Nullable(DateTime64))`](/ko/reference/data-types/array)

**예시**

**그리드 \[90, 105, 120, 135, 150, 165, 180, 195, 210, 225]에서 ts\_of\_min\_over\_time 값 계산**

```sql title=Query theme={null}
SET enable_time_series_aggregate_functions = 1;
WITH
    -- NOTE: the gap between 130 and 190 is to show how values are filled for ts = 180 according to window parameter
    [110, 120, 130, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps,
    [1, 3, 2, 6, 6, 4, 2, 0]::Array(Float32) AS values, -- array of values corresponding to timestamps above
    90 AS start_ts,       -- start of timestamp grid
    90 + 135 AS end_ts,   -- end of timestamp grid
    15 AS step_seconds,   -- step of timestamp grid
    45 AS window_seconds  -- "staleness" window
SELECT timeSeriesTimestampOfMinToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value)
FROM
(
    -- This subquery converts arrays of timestamps and values into rows of `timestamp`, `value`
    SELECT
        arrayJoin(arrayZip(timestamps, values)) AS ts_and_val,
        ts_and_val.1 AS timestamp,
        ts_and_val.2 AS value
);
```

```response title=Response theme={null}
┌─timeSeriesTimestampOfMinToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value)───────────────────────────────────────────────────────────────────────────┐
│ [NULL,NULL,'1970-01-01 00:01:50','1970-01-01 00:01:50','1970-01-01 00:01:50','1970-01-01 00:02:10',NULL,'1970-01-01 00:03:10','1970-01-01 00:03:30','1970-01-01 00:03:40'] │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```

**배열 인수를 사용한 동일한 쿼리**

```sql title=Query theme={null}
SET enable_time_series_aggregate_functions = 1;
WITH
    [110, 120, 130, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps,
    [1, 3, 2, 6, 6, 4, 2, 0]::Array(Float32) AS values,
    90 AS start_ts,
    90 + 135 AS end_ts,
    15 AS step_seconds,
    45 AS window_seconds
SELECT timeSeriesTimestampOfMinToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values);
```

```response title=Response theme={null}
┌─timeSeriesTimestampOfMinToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values)─────────────────────────────────────────────────────────────────────────┐
│ [NULL,NULL,'1970-01-01 00:01:50','1970-01-01 00:01:50','1970-01-01 00:01:50','1970-01-01 00:02:10',NULL,'1970-01-01 00:03:10','1970-01-01 00:03:30','1970-01-01 00:03:40'] │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```
