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

> 지정된 그리드에서 시계열 데이터에 대한 PromQL 유사 선형 예측을 계산하는 집계 함수입니다.

# timeSeriesPredictLinearToGrid

<div id="timeSeriesPredictLinearToGrid">
  ## timeSeriesPredictLinearToGrid
</div>

도입 버전: v25.6.0

타임스탬프와 값의 쌍으로 이루어진 시계열 데이터를 입력받아, 시작 타임스탬프, 종료 타임스탬프, 간격으로 정의된 정규 시간 그리드에서 지정된 예측 타임스탬프 오프셋에 대한 [PromQL 유사 선형 예측](https://prometheus.io/docs/prometheus/latest/querying/functions/#predict_linear)을 계산하는 집계 함수입니다. 그리드의 각 지점에서는 지정된 시간 윈도우 내의 샘플을 사용해 `predict_linear`을 계산합니다.

<Note>
  이 함수는 실험적 기능입니다. `allow_experimental_time_series_aggregate_functions=true`를 설정하여 활성화하십시오.
</Note>

**구문**

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

**매개변수**

* `start_timestamp` — 그리드의 시작점을 지정합니다. `DateTime64` 타임스탬프 인수의 경우 소수, 숫자 또는 날짜-시간 텍스트를 포함하는 문자열도 사용할 수 있습니다. [`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` — 그리드의 끝점을 지정합니다. `DateTime64` 타임스탬프 인수의 경우 소수, 숫자 또는 날짜-시간 텍스트를 포함하는 문자열도 사용할 수 있습니다. [`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` — 그리드 간격을 초 단위로 지정합니다. `DateTime64` 타임스탬프 인수의 경우 소수, 숫자 또는 '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 윈도우는 왼쪽이 열린 구간이고 오른쪽이 닫힌 인터벌입니다. `DateTime64` 타임스탬프 인수의 경우 소수, 숫자 또는 '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)
* `predict_offset` — 예측 시간에 추가할 오프셋을 초 단위로 지정합니다. [`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` — 샘플의 타임스탬프입니다. 개별 값 또는 배열일 수 있습니다. - `value` — 타임스탬프에 해당하는 시계열 값입니다. 개별 값 또는 배열일 수 있습니다.

**반환 값**

지정된 그리드의 `predict_linear` 값을 `Array(Nullable(Float64))`로 반환합니다. 반환된 배열에는 각 시간 그리드 지점에 대한 값이 하나씩 포함됩니다. 특정 그리드 지점에서 rate 값을 계산하기에 윈도우 내 샘플이 충분하지 않으면 값은 NULL입니다.

**예시**

**60초 오프셋으로 그리드 \[90, 105, 120, 135, 150, 165, 180, 195, 210]에서 predict\_linear 값 계산**

```sql title=Query theme={null}
SET allow_experimental_time_series_aggregate_functions = 1;
WITH
    -- NOTE: the gap between 140 and 190 is to show how values are filled for ts = 150, 165, 180 according to window parameter
    [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps,
    [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, -- array of values corresponding to timestamps above
    90 AS start_ts,       -- start of timestamp grid
    90 + 120 AS end_ts,   -- end of timestamp grid
    15 AS step_seconds,   -- step of timestamp grid
    45 AS window_seconds, -- "staleness" window
    60 AS predict_offset  -- prediction time offset
SELECT timeSeriesPredictLinearToGrid(start_ts, end_ts, step_seconds, window_seconds, predict_offset)(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}
┌─timeSeriesPredictLinearToGrid(start_ts, end_ts, step_seconds, window_seconds, predict_offset)(timestamp, value)─┐
│ [NULL,NULL,1,9.166667,11.6,16.916666,NULL,NULL,16.5]                                                            │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```

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

```sql title=Query theme={null}
SET allow_experimental_time_series_aggregate_functions = 1;
WITH
    [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps,
    [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values,
    90 AS start_ts,
    90 + 120 AS end_ts,
    15 AS step_seconds,
    45 AS window_seconds,
    60 AS predict_offset
SELECT timeSeriesPredictLinearToGrid(start_ts, end_ts, step_seconds, window_seconds, predict_offset)(timestamps, values);
```

```response title=Response theme={null}
┌─timeSeriesPredictLinearToGrid(start_ts, end_ts, step_seconds, window_seconds, predict_offset)(timestamp, value)─┐
│ [NULL,NULL,1,9.166667,11.6,16.916666,NULL,NULL,16.5]                                                            │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```
