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

> 一定間隔の時間グリッド上で PromQL の `quantile_over_time` を計算します。

# timeSeriesQuantileToGrid

<h2 id="timeSeriesQuantileToGrid">
  timeSeriesQuantileToGrid
</h2>

導入バージョン: v26.9.0

タイムスタンプと値のペアとして与えられた時系列データを受け取り、開始タイムスタンプ、終了タイムスタンプ、ステップで定義される一定間隔の時間グリッド上で [PromQL `quantile_over_time`](https://prometheus.io/docs/prometheus/latest/querying/functions/#quantile_over_time) 関数を計算する集約関数です。グリッド上の各ポイントでは、指定された時間ウィンドウ内のサンプルを対象に分位数を計算します。分位数は `quantileExactInclusive` と同様に R-7 (inclusive) 方式で計算されます。ただし、NaN サンプルは `quantileExactInclusive` とは異なりスキップされません。Prometheus と同様に保持され、すべての実数値より前にソートされます。そのため、`[1, NaN, 2]` というウィンドウの中央値は `1` となり、サンプルがすべて NaN のウィンドウでは NaN が返されます。

分位数のレベルは、サンプルの後ろに最後の引数として指定します。すべてのグリッドポイントに共通の単一の数値か、グリッドポイントごとに 1 つずつ数値を持つ配列のいずれかを指定できます。この値はすべての行で同一である必要があります。Prometheus と同様に、レベルが 0 未満の場合は `-Inf`、1 を超える場合は `+Inf` となり、レベルが NaN の場合は、ウィンドウにサンプルが存在するすべてのグリッドポイントで NaN が返されます。

<Note>
  この関数はプライベートプレビュー段階です。使用するには `enable_time_series_aggregate_functions=true` を設定して有効化してください。
</Note>

**構文**

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

**パラメータ**

* `start_timestamp` — グリッドの開始位置を指定します。小数、または数値や日時テキストを含む文字列で指定することもできます。[`UInt32`](/ja/reference/data-types/int-uint) または [`DateTime`](/ja/reference/data-types/datetime) または [`DateTime64`](/ja/reference/data-types/datetime64) または [`Float*`](/ja/reference/data-types/float) または [`Decimal*`](/ja/reference/data-types/decimal) または [`String`](/ja/reference/data-types/string)
* `end_timestamp` — グリッドの終了位置を指定します。小数、または数値や日時テキストを含む文字列で指定することもできます。[`UInt32`](/ja/reference/data-types/int-uint) または [`DateTime`](/ja/reference/data-types/datetime) または [`DateTime64`](/ja/reference/data-types/datetime64) または [`Float*`](/ja/reference/data-types/float) または [`Decimal*`](/ja/reference/data-types/decimal) または [`String`](/ja/reference/data-types/string)
* `grid_step` — グリッドのステップを秒単位で指定します。小数、または数値や '15s'、'1m' のような期間を含む文字列で指定することもできます。[`UInt32`](/ja/reference/data-types/int-uint) または [`Float*`](/ja/reference/data-types/float) または [`Decimal*`](/ja/reference/data-types/decimal) または [`String`](/ja/reference/data-types/string)
* `staleness` — 対象とするサンプルの最大「staleness」を秒単位で指定します。staleness ウィンドウは左開右閉区間です。小数、または数値や '15s'、'1m' のような期間を含む文字列で指定することもできます。[`UInt32`](/ja/reference/data-types/int-uint) または [`Float*`](/ja/reference/data-types/float) または [`Decimal*`](/ja/reference/data-types/decimal) または [`String`](/ja/reference/data-types/string)

**引数**

* `timestamp` — サンプルのタイムスタンプ。単一の値または配列を指定できます。[`UInt32`](/ja/reference/data-types/int-uint) または [`DateTime`](/ja/reference/data-types/datetime) または [`DateTime64`](/ja/reference/data-types/datetime64) または [`Array(UInt32)`](/ja/reference/data-types/array) または [`Array(DateTime)`](/ja/reference/data-types/array) または [`Array(DateTime64)`](/ja/reference/data-types/array)
* `value` — タイムスタンプに対応する時系列の値。単一の値または配列を指定できます。[`Float*`](/ja/reference/data-types/float) または [`Array(Float*)`](/ja/reference/data-types/array)
* `samples` — `(timestamp, value)` のタプルの配列として渡す時系列のサンプル。タプルの各要素の型は、上記のタイムスタンプおよび値の型と同じです。タイムスタンプと値を 2 つの別々の引数として渡す代わりに使用できます。[`Array(Tuple(T1, T2))`](/ja/reference/data-types/array)
* `phi` — 分位数のレベル。通常は \[0, 1] の範囲です。グリッド全体に対して 1 つの数値を指定するか、グリッドポイントごとに 1 つの数値を含む配列を指定します。すべての行で同じ値である必要があります。[`Float*`](/ja/reference/data-types/float) または [`UInt8/16/32/64`](/ja/reference/data-types/int-uint) または [`Int8/16/32/64`](/ja/reference/data-types/int-uint) または [`Array(Float*)`](/ja/reference/data-types/array) または [`Array(UInt8/16/32/64)`](/ja/reference/data-types/array) または [`Array(Int8/16/32/64)`](/ja/reference/data-types/array)

**戻り値**

指定されたグリッド上における値の phi 分位数を返します。返される配列には、時間グリッドのポイントごとに 1 つの値が含まれます。あるグリッドポイントのウィンドウ内にサンプルが存在しない場合、その値は NULL になります。[`Array(Nullable(Float64))`](/ja/reference/data-types/array)

**例**
