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

> 시계열 작업을 위한 함수 문서

# 시계열 작업을 위한 함수

아래 함수는 [`timeSeriesInstantRateToGrid`](/ko/reference/functions/aggregate-functions/timeSeriesInstantRateToGrid),
[`timeSeriesLastToGrid`](/ko/reference/functions/aggregate-functions/timeSeriesResampleToGridWithStaleness) 등의
`timeSeries*()` 집계 함수와 함께 사용하도록 설계되었습니다.

{/*AUTOGENERATED_START*/}

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

도입된 버전: v24.1.0

STL [(Seasonal-Trend Decomposition Procedure Based on Loess)](https://www.wessa.net/download/stl.pdf)을 사용해 시계열 데이터를 계절성, 추세, 잔차 요소로 분해합니다.

**구문**

```sql theme={null}
seriesDecomposeSTL(series, period)
```

**인수**

* `series` — 숫자 값으로 이루어진 배열 [`Array((U)Int8/16/32/64)`](/ko/reference/data-types/array) 또는 [`Array(Float*)`](/ko/reference/data-types/array)
* `period` — 양의 정수 [`UInt8/16/32/64`](/ko/reference/data-types/int-uint)

**반환 값**

4개의 배열로 구성된 배열을 반환합니다. 첫 번째 배열에는 계절 성분, 두 번째 배열에는 추세, 세 번째 배열에는 잔차 성분, 네 번째 배열에는 베이스라인(계절 + 추세) 성분이 포함됩니다. [`Array(Array(Float32), Array(Float32), Array(Float32), Array(Float32))`](/ko/reference/data-types/array)

**예시**

**STL을 사용한 시계열 데이터 분해**

```sql title=Query theme={null}
SELECT seriesDecomposeSTL([10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34], 3) AS print_0
```

```response title=Response theme={null}
┌───────────print_0──────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ [[
        -13.529999, -3.1799996, 16.71,      -13.53,     -3.1799996, 16.71,      -13.53,     -3.1799996,
        16.71,      -13.530001, -3.18,      16.710001,  -13.530001, -3.1800003, 16.710001,  -13.530001,
        -3.1800003, 16.710001,  -13.530001, -3.1799994, 16.71,      -13.529999, -3.1799994, 16.709997
    ],
    [
        23.63,     23.63,     23.630003, 23.630001, 23.630001, 23.630001, 23.630001, 23.630001,
        23.630001, 23.630001, 23.630001, 23.63,     23.630001, 23.630001, 23.63,     23.630001,
        23.630001, 23.63,     23.630001, 23.630001, 23.630001, 23.630001, 23.630001, 23.630003
    ],
    [
        0, 0.0000019073486, -0.0000019073486, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.0000019073486, 0,
        0
    ],
    [
        10.1, 20.449999, 40.340004, 10.100001, 20.45, 40.34, 10.100001, 20.45, 40.34, 10.1, 20.45, 40.34,
        10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.100002, 20.45, 40.34
    ]]                                                                                                                   │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```

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

도입 버전: v24.2.0

[Tukey Fences](https://en.wikipedia.org/wiki/Outlier#Tukey%27s_fences)를 사용해 시계열 데이터의 이상치를 감지합니다.

**구문**

```sql theme={null}
seriesOutliersDetectTukey(series[, min_percentile, max_percentile, K])
```

**인수**

* `series` — 숫자 값으로 이루어진 배열입니다. [`Array((UInt8/16/32/64))`](/ko/reference/data-types/array) 또는 [`Array(Float*)`](/ko/reference/data-types/array)
* `min_percentile` — 선택 사항입니다. 사분위 범위[(IQR)](https://en.wikipedia.org/wiki/Interquartile_range)를 계산할 때 사용할 최소 분위수입니다. 값은 \[0.02,0.98] 범위에 있어야 합니다. 기본값은 0.25입니다. [`Float*`](/ko/reference/data-types/float)
* `max_percentile` — 선택 사항입니다. 사분위 범위(IQR)를 계산할 때 사용할 최대 분위수입니다. 값은 \[0.02,0.98] 범위에 있어야 합니다. 기본값은 0.75입니다. [`Float*`](/ko/reference/data-types/float)
* `K` — 선택 사항입니다. 약한 이상치 또는 그보다 더 뚜렷한 이상치를 탐지하기 위한 음이 아닌 상수 값입니다. 기본값은 1.5입니다. [`Float*`](/ko/reference/data-types/float)

**반환 값**

입력 배열과 길이가 같은 배열을 반환합니다. 이 배열의 각 값은 `series`에서 해당 요소의 잠재적인 이상치 점수를 나타냅니다. 점수가 0이 아니면 이상치일 가능성이 있음을 의미합니다. [`Array(Float32)`](/ko/reference/data-types/array)

**예시**

**기본 이상치 탐지**

```sql title=Query theme={null}
SELECT seriesOutliersDetectTukey([-3, 2, 15, 3, 5, 6, 4, 5, 12, 45, 12, 3, 3, 4, 5, 6]) AS print_0
```

```response title=Response theme={null}
┌───────────print_0─────────────────┐
│[0,0,0,0,0,0,0,0,0,27,0,0,0,0,0,0] │
└───────────────────────────────────┘
```

**사용자 지정 매개변수를 이용한 이상값 탐지**

```sql title=Query theme={null}
SELECT seriesOutliersDetectTukey([-3, 2, 15, 3, 5, 6, 4.50, 5, 12, 45, 12, 3.40, 3, 4, 5, 6], 0.2, 0.8, 1.5) AS print_0
```

```response title=Response theme={null}
┌─print_0──────────────────────────────┐
│ [0,0,0,0,0,0,0,0,0,19.5,0,0,0,0,0,0] │
└──────────────────────────────────────┘
```

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

도입 버전: v23.12.0

FFT를 사용해 주어진 시계열 데이터의 주기를 찾습니다 - [고속 푸리에 변환](https://en.wikipedia.org/wiki/Fast_Fourier_transform)

**구문**

```sql theme={null}
seriesPeriodDetectFFT(series)
```

**인수**

* `series` — 숫자 값으로 이루어진 배열입니다. [`Array((U)Int8/16/32/64)`](/ko/reference/data-types/array) 또는 [`Array(Float*)`](/ko/reference/data-types/array)

**반환 값**

시계열 데이터의 주기와 동일한 실수 값을 반환합니다. 데이터 포인트 수가 4개 미만이면 NaN을 반환합니다. [`Float64`](/ko/reference/data-types/float)

**예시**

**단순 패턴을 사용한 주기 감지**

```sql title=Query theme={null}
SELECT seriesPeriodDetectFFT([1, 4, 6, 1, 4, 6, 1, 4, 6, 1, 4, 6, 1, 4, 6, 1, 4, 6, 1, 4, 6]) AS print_0
```

```response title=Response theme={null}
┌───────────print_0──────┐
│                      3 │
└────────────────────────┘
```

**복잡한 패턴을 사용한 주기 감지**

```sql title=Query theme={null}
SELECT seriesPeriodDetectFFT(arrayMap(x -> abs((x % 6) - 3), range(1000))) AS print_0
```

```response title=Response theme={null}
┌─print_0─┐
│       6 │
└─────────┘
```

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

도입 버전: v26.1.0

지정한 태그를 한 태그 그룹(`src_group`)에서 다른 태그 그룹(`dest_group`)으로 복사합니다.
이 함수는 `dest_group`에 있는 해당 태그의 기존 값을 모두 대체합니다.
복사할 태그가 `src_group`에 없으면 `dest_group`에서도 해당 태그를 제거합니다.
이 함수는 Prometheus의
[group left/group right](https://prometheus.io/docs/prometheus/latest/querying/operators/#group-modifiers) 수정자에서 사용하는 복사 로직을 따릅니다.

**구문**

```sql theme={null}
timeSeriesCopyTag(dest_group, src_group, tag_to_copy)
```

**인수**

* `dest_group` — 대상 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)
* `src_group` — 소스 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)
* `tag_to_copy` — 복사할 태그의 이름입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`dest_group`의 태그와 `src_group`에서 복사한 태그를 함께 포함하는 태그 그룹을 반환합니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**예시**

```sql title=Query theme={null}
SELECT timeSeriesTagsToGroup([('region', 'eu'), ('env', 'dev')], '__name__', 'http_requests_count') AS dest_group,
       timeSeriesTagsToGroup([('code', '404'), ('message', 'Page not found')], '__name__', 'http_codes') AS src_group,
       timeSeriesCopyTag(dest_group, src_group, '__name__') AS result_group,
       timeSeriesGroupToTags(result_group)
```

```response title=Response theme={null}
┌─dest_group─┬─src_group─┬─result_group─┬─timeSeriesGroupToTags(result_group)────────────────────────┐
│          1 │         2 │            3 │ [('__name__','http_codes'),('code','404'),('region','eu')] │
└────────────┴───────────┴──────────────┴────────────────────────────────────────────────────────────┘
```

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

도입 버전: v26.1.0

지정된 태그를 한 태그 그룹(`src_group`)에서 다른 태그 그룹(`dest_group`)으로 복사합니다.
이 함수는 `dest_group`에 있는 복사 대상 태그의 기존 값을 모두 대체합니다.
복사 대상 태그 중 일부가 `src_group`에 없으면 `dest_group`에서도 해당 태그를 제거합니다.
이 함수는 Prometheus의
[group left/group right](https://prometheus.io/docs/prometheus/latest/querying/operators/#group-modifiers) 수정자의 복사 로직을 따릅니다.

**구문**

```sql theme={null}
timeSeriesCopyTags(dest_group, src_group, tags_to_copy)
```

**인수**

* `dest_group` — 대상 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)
* `src_group` — 소스 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)
* `tags_to_copy` — 복사할 태그 이름입니다. [`Array(String)`](/ko/reference/data-types/array)

**반환 값**

`dest_group`의 태그와 `src_group`에서 복사한 태그를 함께 포함하는 태그 그룹을 반환합니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**예시**

```sql title=Query theme={null}
SELECT timeSeriesTagsToGroup([('region', 'eu'), ('env', 'dev')], '__name__', 'http_requests_count') AS dest_group,
       timeSeriesTagsToGroup([('code', '404'), ('message', 'Page not found')], '__name__', 'http_codes') AS src_group,
       timeSeriesCopyTags(dest_group, src_group, ['__name__', 'code', 'env']) AS result_group,
       timeSeriesGroupToTags(result_group)
```

```response title=Response theme={null}
┌─dest_group─┬─src_group─┬─result_group─┬─timeSeriesGroupToTags(result_group)────────────────────────┐
│          1 │         2 │            3 │ [('__name__','http_codes'),('code','404'),('region','eu')] │
└────────────┴───────────┴──────────────┴────────────────────────────────────────────────────────────┘
```

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

도입 버전: v26.1.0

그룹에서 지정한 태그의 값을 추출합니다. 찾을 수 없으면 NULL을 반환합니다.
관련 항목: 함수 [timeSeriesGroupToTags()](/ko/reference/functions/regular-functions/time-series-functions#timeSeriesGroupToTags).

**구문**

```sql theme={null}
timeSeriesExtractTag(group)
```

**인수**

* `group` — 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)
* `tag_to_extract` — 그룹에서 추출할 태그 이름입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

지정한 태그의 값을 반환합니다. [`Nullable(String)`](/ko/reference/data-types/nullable)

**예시**

**예시**

```sql title=Query theme={null}
SELECT timeSeriesTagsToGroup([('region', 'eu'), ('env', 'dev')], '__name__', 'http_requests_count') AS group,
       timeSeriesExtractTag(group, '__name__'),
       timeSeriesExtractTag(group, 'env'),
       timeSeriesExtractTag(group, 'instance')
```

```response title=Response theme={null}
┌─group─┬─timeSeriesExtractTag(group, '__name__')─┬─timeSeriesExtractTag(group, 'env')─┬─timeSeriesExtractTag(group, 'instance')─┐
│     1 │ http_requests_count                     │ dev                                │ ᴺᵁᴸᴸ                                    │
└───────┴─────────────────────────────────────────┴────────────────────────────────────┴─────────────────────────────────────────┘
```

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

도입 버전: v25.8.0

값 배열 `[x1, x2, x3, ...]`을 튜플 배열
`[(start_timestamp, x1), (start_timestamp + step, x2), (start_timestamp + 2 * step, x3), ...]`로 변환합니다.

현재 타임스탬프는 `end_timestamp`를 초과할 때까지 `step`만큼 증가합니다.
값의 개수가 타임스탬프의 개수와 일치하지 않으면 예외를 발생시킵니다.

`[x1, x2, x3, ...]`의 NULL 값은 건너뛰지만 현재 타임스탬프는 계속 증가합니다.
예를 들어 `[value1, NULL, x2]`의 경우 함수는 `[(start_timestamp, x1), (start_timestamp + 2 * step, x2)]`를 반환합니다.

**구문**

```sql theme={null}
timeSeriesFromGrid(start_timestamp, end_timestamp, step, values)
```

**인수**

* `start_timestamp` — 그리드의 시작입니다. [`DateTime64`](/ko/reference/data-types/datetime64) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UInt32`](/ko/reference/data-types/int-uint)
* `end_timestamp` — 그리드의 끝입니다. [`DateTime64`](/ko/reference/data-types/datetime64) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UInt32`](/ko/reference/data-types/int-uint)
* `step` — 초 단위 그리드의 간격입니다. [`Decimal64`](/ko/reference/data-types/decimal) 또는 [`Decimal32`](/ko/reference/data-types/decimal) 또는 [`UInt32/64`](/ko/reference/data-types/int-uint)
* `values` — 값 배열입니다. [`Array(Float*)`](/ko/reference/data-types/array) 또는 [`Array(Nullable(Float*))`](/ko/reference/data-types/array)

**반환 값**

`start_timestamp`와 `step`으로 정의된 일정한 시간 그리드에서 타임스탬프와 결합된 소스 배열의 값을 반환합니다. [`Array(Tuple(DateTime64, Float64))`](/ko/reference/data-types/array)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT timeSeriesFromGrid('2025-06-01 00:00:00'::DateTime64(3), '2025-06-01 00:01:30.000'::DateTime64(3), 30, [10, 20, NULL, 30]) AS result;
```

```response title=Response theme={null}
┌─────────────────────────────────────────────result─────────────────────────────────────────────┐
│ [('2025-06-01 00:00:00.000',10),('2025-06-01 00:00:30.000',20),('2025-06-01 00:01:30.000',30)] │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
```

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

도입 버전: v26.4.0

지정된 그룹의 태그로부터 파생된 일관된 `UInt64` 샘플링 키를 반환합니다.

이 값은 결정적입니다. 즉, 동일한 입력 태그는 항상 동일한 키를 생성합니다.
`limitk`, `limit_ratio`와 같은 샘플링 연산자의 정렬 키로 사용하도록 설계되었습니다.

**구문**

```sql theme={null}
timeSeriesGroupToSamplingKey(group)
```

**인수**

* `group` — 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)

**반환 값**

그룹에 연결된 태그로부터 계산된 안정적인 `UInt64` 해시입니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**예시**

```sql title=Query theme={null}
SELECT timeSeriesTagsToGroup([('region', 'eu'), ('env', 'dev')], '__name__', 'http_requests_count') AS group,
       timeSeriesGroupToSamplingKey(group) AS sampling_key
```

```response title=Response theme={null}
┌─group─┬─────────sampling_key─┐
│     1 │ 12876543210987654321 │
└───────┴──────────────────────┘
```

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

도입 버전: v26.1.0

지정한 그룹에 연결된 태그의 이름과 값을 반환합니다.
관련 항목: [timeSeriesTagsToGroup()](/ko/reference/functions/regular-functions/time-series-functions#timeSeriesTagsToGroup) 함수를 참조하십시오.

**구문**

```sql theme={null}
timeSeriesGroupToTags(group)
```

**별칭**: `timeSeriesTagsGroupToTags`

**인수**

* `group` — 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)

**반환 값**

`(tag_name, tag_value)` 쌍으로 이루어진 배열을 반환합니다.
반환된 배열은 항상 `tag_name`으로 정렬되며, 동일한 `tag_name`은 두 번 이상 포함하지 않습니다.
[`Array(Tuple(String, String))`](/ko/reference/data-types/array)

**예시**

**예시**

```sql title=Query theme={null}
SELECT timeSeriesTagsToGroup([('region', 'eu'), ('env', 'dev')], '__name__', 'http_requests_count') AS group,
       timeSeriesGroupToTags(group) AS sorted_tags,
       timeSeriesTagsToGroup(sorted_tags) AS same_group,
       throwIf(same_group != group)
```

```response title=Response theme={null}
┌─group─┬─sorted_tags────────────────────────────────────────────────────────┬─same_group─┬─throwIf(notE⋯up, group))─┐
│     1 │ [('__name__','http_requests_count'),('env','dev'),('region','eu')] │          1 │                        0 │
└───────┴────────────────────────────────────────────────────────────────────┴────────────┴──────────────────────────┘
```

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

도입 버전: v26.1.0

지정된 시계열(time series) 식별자에 연결된 태그의 이름과 값을 반환합니다.
관련 항목: 함수 [timeSeriesStoreTags()](/ko/reference/functions/regular-functions/time-series-functions#timeSeriesStoreTags)을 참조하십시오.

**구문**

```sql theme={null}
timeSeriesIdToGroup(id)
```

**별칭**: `timeSeriesIdToTagsGroup`

**인수**

* `id` — 시계열 식별자입니다. [`UInt64`](/ko/reference/data-types/int-uint) 또는 [`UInt128`](/ko/reference/data-types/int-uint) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`FixedString(16)`](/ko/reference/data-types/fixedstring)

**반환 값**

시계열의 식별자 `id`에 연결된 태그 그룹을 반환합니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**예시**

```sql title=Query theme={null}
SELECT 8374283493092 AS id,
       timeSeriesStoreTags(id, [('region', 'eu'), ('env', 'dev')], '__name__', 'http_requests_count') AS same_id,
       throwIf(same_id != id),
       timeSeriesIdToGroup(same_id) AS group,
       timeSeriesGroupToTags(group)
```

```response title=Response theme={null}
┌────────────id─┬───────same_id─┬─throwIf(notE⋯me_id, id))─┬─group─┬─timeSeriesGroupToTags(group)───────────────────────────────────────┐
│ 8374283493092 │ 8374283493092 │                        0 │     1 │ [('__name__','http_requests_count'),('env','dev'),('region','eu')] │
└───────────────┴───────────────┴──────────────────────────┴───────┴────────────────────────────────────────────────────────────────────┘
```

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

도입 버전: v25.8.0

지정한 시계열(시계열) 식별자에 연결된 태그를 반환합니다.
관련 항목: 함수 [timeSeriesStoreTags()](/ko/reference/functions/regular-functions/time-series-functions#timeSeriesStoreTags).

**구문**

```sql theme={null}
timeSeriesIdToTags(id)
```

**인수**

* `id` — 시계열의 식별자입니다. [`UInt64`](/ko/reference/data-types/int-uint) 또는 [`UInt128`](/ko/reference/data-types/int-uint) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`FixedString(16)`](/ko/reference/data-types/fixedstring)

**반환 값**

`(tag_name, tag_value)` 쌍으로 이루어진 배열을 반환합니다.
반환되는 배열은 항상 `tag_name` 기준으로 정렬되며, 같은 `tag_name`은 두 번 이상 포함되지 않습니다.
[`Array(Tuple(String, String))`](/ko/reference/data-types/array)

**예시**

**예시**

```sql title=Query theme={null}
SELECT 8374283493092 AS id,
       timeSeriesStoreTags(id, [('region', 'eu'), ('env', 'dev')], '__name__', 'http_requests_count') AS same_id,
       throwIf(same_id != id),
       timeSeriesIdToTags(same_id)
```

```response title=Response theme={null}
┌────────────id─┬───────same_id─┬─throwIf(notE⋯me_id, id))─┬─timeSeriesIdToTags(same_id)────────────────────────────────────────┐
│ 8374283493092 │ 8374283493092 │                        0 │ [('__name__','http_requests_count'),('env','dev'),('region','eu')] │
└───────────────┴───────────────┴──────────────────────────┴────────────────────────────────────────────────────────────────────┘
```

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

도입 버전: v26.1.0

태그 그룹에서 추출한 지정된 태그의 값을 조인합니다.
이 함수는 조인된 값 사이에 구분자를 삽입하고, `dest_tag` 태그가 조인된 값으로 설정된 새로운 태그 그룹을 반환합니다.
이 함수는 Prometheus 함수
[label\_join()](https://prometheus.io/docs/prometheus/latest/querying/functions/#label_join)의 로직을 모방합니다.

**구문**

```sql theme={null}
timeSeriesJoinTags(group, dest_tag, separator, src_tags)
```

**인수**

* `group` — 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)
* `dest_tag` — 결합 결과를 담아 `group`에 추가할 태그 이름입니다. [`String`](/ko/reference/data-types/string)
* `separator` — 결합된 값 사이에 삽입할 구분자입니다. [`String`](/ko/reference/data-types/string)
* `src_tags` — 결합할 값이 들어 있는 원본 태그 이름입니다. [`Array(String)`](/ko/reference/data-types/array)

**반환 값**

`dest_tag` 태그가 결합 결과로 설정된 새 태그 그룹을 반환합니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**예시**

```sql title=Query theme={null}
SELECT timeSeriesTagsToGroup([('__name__', 'up'), ('job', 'api-server'), ('src1', 'a'), ('src2', 'b'), ('src3', 'c')]) AS group,
       timeSeriesJoinTags(group, 'foo', ',', ['src1', 'src2', 'src3']) AS result_group,
       timeSeriesGroupToTags(result_group)
```

```response title=Response theme={null}
┌─group─┬─result_group─┬─timeSeriesGroupToTags(result_group)─────────────────────────────────────────────────────────────┐
│     1 │            2 │ [('__name__','up'),('foo','a,b,c'),('job','api-server'),('src1','a'),('src2','b'),('src3','c')] │
└───────┴──────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────┘
```

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

v25.8.0에서 도입

타임스탬프 범위 `[start&#95;timestamp, start&#95;timestamp + step, start&#95;timestamp + 2 * step, ..., end&#95;timestamp]`를 생성합니다.

`start_timestamp`와 `end_timestamp`가 같으면, 함수는 `[start_timestamp]`를 포함하는 단일 요소 배열을 반환합니다.

함수 `timeSeriesRange()`는 [range](/ko/reference/functions/regular-functions/array-functions#range) 함수와 유사합니다.

**구문**

```sql theme={null}
timeSeriesRange(start_timestamp, end_timestamp, step)
```

**인수**

* `start_timestamp` — 범위의 시작 시점입니다. [`DateTime64`](/ko/reference/data-types/datetime64) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UInt32`](/ko/reference/data-types/int-uint)
* `end_timestamp` — 범위의 끝 시점입니다. [`DateTime64`](/ko/reference/data-types/datetime64) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UInt32`](/ko/reference/data-types/int-uint)
* `step` — 범위의 초 단위 간격입니다. [`UInt32/64`](/ko/reference/data-types/int-uint) 또는 [`Decimal32/64`](/ko/reference/data-types/decimal)

**반환 값**

타임스탬프 범위를 반환합니다. [`Array(DateTime64)`](/ko/reference/data-types/array)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT timeSeriesRange('2025-06-01 00:00:00'::DateTime64(3), '2025-06-01 00:01:00'::DateTime64(3), 30)
```

```response title=Response theme={null}
┌────────────────────────────────────result─────────────────────────────────────────┐
│ ['2025-06-01 00:00:00.000', '2025-06-01 00:00:30.000', '2025-06-01 00:01:00.000'] │
└───────────────────────────────────────────────────────────────────────────────────┘
```

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

도입 버전: v26.1.0

태그 그룹에서 지정한 태그만 남기고 나머지 모든 태그를 제거합니다.
관련 항목: 함수 [timeSeriesRemoveTag()](/ko/reference/functions/regular-functions/time-series-functions#timeSeriesRemoveTag),
[timeSeriesRemoveTags()](/ko/reference/functions/regular-functions/time-series-functions#timeSeriesRemoveTags).

**구문**

```sql theme={null}
timeSeriesRemoveAllTagsExcept(group, tags_to_keep)
```

**인수**

* `group` — 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)
* `tags_to_keep` — 그룹에 남겨둘 태그 이름입니다. [`Array(String)`](/ko/reference/data-types/array)

**반환 값**

지정한 태그만 남긴 새 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**예시**

```sql title=Query theme={null}
SELECT timeSeriesTagsToGroup([('region', 'eu'), ('env', 'dev')], '__name__', 'http_requests_count') AS group,
       timeSeriesRemoveAllTagsExcept(group, ['env']) AS result_group,
       timeSeriesGroupToTags(result_group)
```

```response title=Response theme={null}
┌─group─┬─result_group─┬─timeSeriesGroupToTags(result_group)─┐
│     1 │            2 │ [('env','dev')]                     │
└───────┴──────────────┴─────────────────────────────────────┘
```

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

도입 버전: v26.1.0

태그 그룹에서 지정된 태그를 제거합니다.
그룹에 해당 태그가 없으면 변경 없이 그대로 반환됩니다.
관련 항목: [timeSeriesRemoveTags()](/ko/reference/functions/regular-functions/time-series-functions#timeSeriesRemoveTags),
[timeSeriesRemoveAllTagsExcept()](/ko/reference/functions/regular-functions/time-series-functions#timeSeriesRemoveAllTagsExcept) 함수를 참조하십시오.

**구문**

```sql theme={null}
timeSeriesRemoveTag(group, tag_to_remove)
```

**인수**

* `group` — 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)
* `tag_to_remove` — 그룹에서 제거할 태그 이름입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

지정된 태그를 제외한 새 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**예시**

```sql title=Query theme={null}
SELECT timeSeriesTagsToGroup([('region', 'eu'), ('env', 'dev')], '__name__', 'http_requests_count') AS group_of_3,
       timeSeriesRemoveTag(group_of_3, '__name__') AS group_of_2,
       timeSeriesGroupToTags(group_of_2),
       timeSeriesRemoveTag(group_of_2, 'env') AS group_of_1,
       timeSeriesGroupToTags(group_of_1),
       timeSeriesRemoveTag(group_of_1, 'region') AS empty_group,
       timeSeriesGroupToTags(empty_group)
```

```response title=Response theme={null}
┌─group_of_3─┬─group_of_2─┬─timeSeriesGroupToTags(group_of_2)─┬─group_of_1─┬─timeSeriesGroupToTags(group_of_1)─┬─empty_group─┬─timeSeriesGroupToTags(empty_group)─┐
│          1 │          2 │ [('env','dev'),('region','eu')]   │          3 │ [('region','eu')]                 │           0 │ []                                 │
└────────────┴────────────┴───────────────────────────────────┴────────────┴───────────────────────────────────┴─────────────┴────────────────────────────────────┘
```

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

도입 버전: v26.1.0

태그 그룹에서 지정한 태그를 제거합니다.
지정한 태그 중 일부가 태그 그룹에 없으면 함수는 해당 태그를 무시합니다.
관련 항목: 함수 [timeSeriesRemoveTag()](/ko/reference/functions/regular-functions/time-series-functions#timeSeriesRemoveTag),
[timeSeriesRemoveAllTagsExcept()](/ko/reference/functions/regular-functions/time-series-functions#timeSeriesRemoveAllTagsExcept).

**구문**

```sql theme={null}
timeSeriesRemoveTags(group, tags_to_remove)
```

**인수**

* `group` — 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)
* `tags_to_remove` — 그룹에서 제거할 태그 이름입니다. [`Array(String)`](/ko/reference/data-types/array)

**반환 값**

지정된 태그가 제거된 새 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**예시**

```sql title=Query theme={null}
SELECT timeSeriesTagsToGroup([('region', 'eu'), ('env', 'dev')], '__name__', 'http_requests_count') AS group_of_3,
       timeSeriesRemoveTags(group_of_3, ['env', 'region']) AS group_of_1,
       timeSeriesGroupToTags(group_of_1),
       timeSeriesRemoveTags(group_of_1, ['__name__', 'nonexistent']) AS empty_group,
       timeSeriesGroupToTags(empty_group)
```

```response title=Response theme={null}
┌─group_of_3─┬─group_of_1─┬─timeSeriesGroupToTags(group_of_1)────┬─empty_group─┬─timeSeriesGroupToTags(empty_group)─┐
│          1 │          2 │ [('__name__','http_requests_count')] │           0 │ []                                 │
└────────────┴────────────┴──────────────────────────────────────┴─────────────┴────────────────────────────────────┘
```

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

도입 버전: v26.1.0

태그 `src_tag`의 값이 정규식 `regex`와 일치하는지 검사합니다.
일치하는 경우 반환되는 그룹에서 태그 `dest_tag`의 값은 `replacement`를 확장한 결과가 되며,
입력에 있던 원래 태그와 함께 반환됩니다.
이 함수는 Prometheus 함수
[label\_replace()](https://prometheus.io/docs/prometheus/latest/querying/functions/#label_replace)의 로직을 모방합니다.

**구문**

```sql theme={null}
timeSeriesReplaceTag(group, dest_tag, replacement, src_tag, regex)
```

**인수**

* `group` — 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)
* `dest_tag` — 결과 그룹을 얻을 대상 태그의 이름입니다. [`String`](/ko/reference/data-types/string)
* `replacement` — 대체 패턴입니다. 정규식 'regex'의 캡처 그룹을 참조하는 $1, $2 또는 \$name을 포함할 수 있습니다. [`String`](/ko/reference/data-types/string)
* `src_tag` — 값이 정규식 'regex'와 매칭되는 데 사용되는 태그의 이름입니다. [`String`](/ko/reference/data-types/string)
* `regex` — 정규식입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`dest_tag`가 추가될 수 있는 새 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**예시**

```sql title=Query theme={null}
SELECT timeSeriesTagsToGroup([('__name__', 'up'), ('job', 'api-server'), ('service', 'a:c')]) AS group,
       timeSeriesReplaceTag(group, 'foo', '$1', 'service', '(.*):.*') AS result_group,
       timeSeriesGroupToTags(result_group)
```

```response title=Response theme={null}
┌─group─┬─result_group─┬─timeSeriesGroupToTags(result_group)────────────────────────────────────┐
│     1 │            2 │ [('__name__','up'),('foo','a'),('job','api-server'),('service','a:c')] │
└───────┴──────────────┴────────────────────────────────────────────────────────────────────────┘
```

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

도입 버전: v25.8.0

쿼리 Context에 지정된 시계열 식별자와 태그 집합 사이의 매핑을 저장합니다.
이후 쿼리 실행 중 함수 [timeSeriesIdToTags()](/ko/reference/functions/regular-functions/time-series-functions#timeSeriesIdToTags)
및 [timeSeriesIdToGroup()](/ko/reference/functions/regular-functions/time-series-functions#timeSeriesIdToGroup)
를 사용해 이 매핑에 접근할 수 있습니다.

**구문**

```sql theme={null}
timeSeriesStoreTags(id, tags_array, separate_tag_name_1, separate_tag_value_1, ...)
```

**인수**

* `id` — 시계열 식별자입니다. [`UInt64`](/ko/reference/data-types/int-uint) 또는 [`UInt128`](/ko/reference/data-types/int-uint) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`FixedString(16)`](/ko/reference/data-types/fixedstring)
* `tags_array` — (tag\_name, tag\_value) 쌍으로 이루어진 배열입니다. [`Array(Tuple(String, String))`](/ko/reference/data-types/array) 또는 [`NULL`](/ko/reference/syntax#null)
* `separate_tag_name_i` — 태그 이름입니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)
* `separate_tag_value_i` — 태그 값입니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring) 또는 [`Nullable(String)`](/ko/reference/data-types/nullable)

**반환 값**

시계열 식별자, 즉 첫 번째 인수를 반환합니다.

**예시**

**예시**

```sql title=Query theme={null}
SELECT 8374283493092 AS id,
       timeSeriesStoreTags(id, [('region', 'eu'), ('env', 'dev')], '__name__', 'http_requests_count') AS same_id,
       throwIf(same_id != id),
       timeSeriesIdToTags(same_id),
       timeSeriesGroupToTags(timeSeriesIdToGroup(same_id))
```

```response title=Response theme={null}
┌────────────id─┬───────same_id─┬─throwIf(notEquals(same_id, id))─┬─timeSeriesIdToTags(same_id)────────────────────────────────────────┬─timeSeriesGroupToTags(timeSeriesIdToGroup(same_id))────────────────┐
│ 8374283493092 │ 8374283493092 │                               0 │ [('__name__','http_requests_count'),('env','dev'),('region','eu')] │ [('__name__','http_requests_count'),('env','dev'),('region','eu')] │
└───────────────┴───────────────┴─────────────────────────────────┴────────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────┘
```

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

도입 버전: v26.1.0

지정된 태그에 해당하는 태그 그룹을 반환합니다.
쿼리 실행 중 동일한 태그 그룹이 여러 번 발견되면 함수는 동일한 그룹을 반환합니다.
빈 태그 집합에 대해서는 함수가 항상 0을 반환합니다.
관련 항목: [timeSeriesGroupToTags()](/ko/reference/functions/regular-functions/time-series-functions#timeSeriesGroupToTags) 함수.

**구문**

```sql theme={null}
timeSeriesTagsToGroup(tags_array, tag_name_1, tag_value_1, tag_name2, tag_value2, ...)
```

**인수**

* `tags_array` — (tag\_name, tag\_value) 쌍의 배열입니다. [`Array(Tuple(String, String))`](/ko/reference/data-types/array) 또는 [`NULL`](/ko/reference/syntax#null)
* `tag_name_i` — 태그 이름입니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)
* `tag_value_i` — 태그 값입니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring) 또는 [`Nullable(String)`](/ko/reference/data-types/nullable)

**반환 값**

지정된 태그와 연관된 태그 그룹을 반환합니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**예시**

```sql title=Query theme={null}
SELECT timeSeriesTagsToGroup([('region', 'eu'), ('env', 'dev')], '__name__', 'http_requests_count') AS group1,
       timeSeriesTagsToGroup([], '__name__', 'http_failures') AS group2,
       timeSeriesTagsToGroup([]) AS empty_group,
       timeSeriesTagsToGroup([], '__name__', 'http_failures') AS same_group2,
       throwIf(same_group2 != group2),
       timeSeriesGroupToTags(group2)
```

```response title=Response theme={null}
┌─group1─┬─group2─┬─empty_group─┬─same_group2─┬─throwIf(notEquals(same_group2, group2))─┬─timeSeriesGroupToTags(group2)──┐
│      1 │      2 │           0 │           2 │                                       0 │ [('__name__','http_failures')] │
└────────┴────────┴─────────────┴─────────────┴─────────────────────────────────────────┴────────────────────────────────┘
```

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

도입 버전: v26.2.0

`condition`을 검사하여 참이면 다음 메시지와 함께 예외를 발생시킵니다.
`Multiple series have the same tags <tags>, duplicate series in the same result set are not allowed`.
`condition`이 거짓이면 이 함수는 `0`을 반환합니다.
이 함수는 [throwIf()](/ko/reference/functions/regular-functions/other-functions#throwIf)와 유사하지만,
서로 다른 오류 코드를 사용하며 오류 메시지 포맷도 다르게 지정됩니다.

**구문**

```sql theme={null}
timeSeriesThrowDuplicateSeriesIf(condition, group)
```

**인수**

* `condition` — 확인할 조건입니다. 일반적으로 [count()](/ko/reference/functions/aggregate-functions/count#count) 함수를 포함하는 [`UInt8`](/ko/reference/data-types/int-uint)입니다.
* `group` — 태그 그룹입니다. [`UInt64`](/ko/reference/data-types/int-uint)

**반환 값**

`0`을 반환합니다. [`UInt8`](/ko/reference/data-types/int-uint)

**예시**

**예시**

```sql title=Query theme={null}
CREATE TABLE test(tags Array(Tuple(String, String))) engine=Memory;

INSERT INTO test VALUES ([('__name__', 'up')]);

SELECT timeSeriesTagsToGroup(tags) AS group
FROM test
GROUP BY group
HAVING timeSeriesThrowDuplicateSeriesIf(count() > 1, group) = 0;  -- 정상

INSERT INTO test VALUES ([('__name__', 'up')]);

SELECT timeSeriesTagsToGroup(tags) AS group
FROM test
GROUP BY group
HAVING timeSeriesThrowDuplicateSeriesIf(count() > 1, group) = 0;  -- 예외 발생 "Multiple series have the same tags {'__name__': 'up'}"
```

```response title=Response theme={null}
```
