apache / apache/datafusion

No way to get the schema for sliding accumulator state

オープン
#14,701 コメント 1 件 リアクション 2 件 担当者 0 名 GitHub で見る
主要言語
Rust
スター
9.3k
フォーク
2.4k
平均マージ
3日 11時間
マージ済み PR(30日)
360

説明

The AggregateUDF trait includes a function `fn state_fields(&self, args: StateFieldsArgs) -> Result>` to get the types for the intermediate state of the aggregate. This is useful if we need to store the states, for example for multi-level aggregation.

For our use-case we also need to store the accumulator states as part of our checkpointing system. This works so long as we're using the standard accumulators, but breaks down if you want to use sliding accumulators. This is because some aggregates (for example, sum) have different state fields in sliding mode (for sum, this is additional "count" field, used to determine when we've retracted all of the data).

But there doesn't seem to be any way to determine what the state fields will be for a sliding accumulator. A couple of possible options here:

* Follow the pattern of is_distinct, which also can produce different accumulators. This is passed in to the state_fields function as a field on the StateFieldsArgs struct; we could add a similar one for is_sliding
* It seems like state_fields is really a property of the accumulator, not of the aggregate (as various aggregates may produce different accumulators depending on the options and which accumulator function is called), so it might be better to have the state_fields function on the accumulator instead of the aggregate.

We've gone ahead and implemented the first approach in our fork, but would be nice to get something in upstream that addresses this.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず AggregateUDF::state_fields 関数と StateFieldsArgs を読み、次に sum などの標準アキュムレーターとスライディングアキュムレーターについて生成される状態フィールドを比較します。完了条件は、upstream API がチェックポイント用にスライディングアキュムレーターの正しい状態フィールドスキーマを公開でき、関連する動作がカバレッジされていることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
rust
領域
backend-api-design
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。