apache / apache/datafusion

No way to get the schema for sliding accumulator state

Ouverte
#14,701 1 commentaire 2 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Rust
Étoiles
9.3k
Forks
2.4k
Merge moyen
3 j 11 h
PR mergées (30 j)
360

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par lire la fonction AggregateUDF::state_fields et StateFieldsArgs, puis comparez les champs d’état produits pour les accumulateurs standard et glissants tels que sum. Le travail est terminé lorsque l’API upstream peut exposer le schéma correct des champs d’état de l’accumulateur glissant pour le checkpointing, avec une couverture du comportement concerné.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
rust
Domaine
backend-api-design
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.