- カテゴリ:
集計関数 (Percentile Estimation) , ウィンドウ関数の構文と使用法
APPROX_PERCENTILE_ACCUMULATE¶
集計の終了時にt-Digest状態の内部表現を( JSON オブジェクトとして)返します。(t-Digestの詳細については、 パーセンタイル値の推定 をご参照ください)
The function APPROX_PERCENTILE discards this internal, intermediate state when the final percentile estimate is returned. However, in certain advanced use cases, such as estimating incremental percentile during bulk loading, you may wish to keep the intermediate state, in which case you would use APPROX_PERCENTILE_ACCUMULATE instead of APPROX_PERCENTILE.
APPROX_PERCENTILE_ACCUMULATE does not return a percentile value. Instead, it returns the algorithm state itself. The intermediate state can later be:
別々ではあるが関連するデータのバッチからのその他中間状態と結合(つまりマージ)されます。
中間状態で直接動作する他の関数によって処理されます。例: APPROX_PERCENTILE_ESTIMATE (例については、以下の「例」セクションをご参照ください。)
外部ツールにエクスポートされます。
- こちらもご参照ください。
構文¶
引数¶
expr数値に評価される列名などの、有効な式。
使用上の注意¶
パーセンタイルは数値でのみ機能するため、
exprは数値または数値にキャストできる値を生成する必要があります。
10進浮動小数点( DECFLOAT )の値はサポートされていません。
例¶
Store the t-Digest state of the testtable.c1 column in a table and then use the state to compute percentiles:
Here is a more extensive example that shows the usage of all three related functions: APPROX_PERCENTILE_ACCUMULATE, APPROX_PERCENTILE_ESTIMATE, and APPROX_PERCENTILE_COMBINE.
簡単なテーブルとデータを作成します。
Create a table that contains the "state" that represents the current
approximate percentile information for the table named test_table1:
その状態情報を使用して、中央値の現在の推定値を表示します(0.5は、50番目のパーセンタイルの値が必要であることを意味します)。
次に、2番目のテーブルを作成してデータを追加します。(より現実的な状況では、ユーザーは最初のテーブルにより多くのデータを読み込み、データが読み込まれた時間に基づいてデータを重複しないセットに分割できます)
新しいデータのみの「状態」情報を取得します。
行の2つのバッチの「状態」情報を結合します。
行の結合セットのおおよその中央値を取得します。