apache / apache/datafusion

Decimal division compatibility mode with spark

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

Description

### Is your feature request related to a problem or challenge?

As described in detail by @liukun4515 and @tustvold and @viirya on https://github.com/apache/arrow-datafusion/pull/6832, DataFusion's decimal devision semantics.

@liukun4515 notes https://github.com/apache/arrow-datafusion/pull/6832#issuecomment-1680098056 that spark has the config to control the precision loss : https://github.com/apache/spark/blob/2be20e54a2222f6cdf64e8486d1910133b43665f/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala#L246

And @tustvold notes For people looking to emulate spark which only supports precision up to 38, casting to Decimal256 and then truncating down to Decimal128 will be equivalent, and is what a precision loss arithmetic kernel would do

### Describe the solution you'd like

If anyone needs spark compatible decimal division rules, I suggest:

1. Add a new config option
2. Apply the rewrite suggested by @tustvold (cast to Decimal256, divide, and then cast to Decimal128) as an [AnalyzerRule](https://docs.rs/datafusion/latest/datafusion/optimizer/analyzer/trait.AnalyzerRule.html#)

### Describe alternatives you've considered

See ticket -- we discussed at length changing the semantics of division in arrow-rs and concluded there was no one agreed upon ideal behavior

### Additional context

_No response_

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par la discussion dans la pull request 6832 et par la documentation de AnalyzerRule liée dans l’issue. Suivez la manière dont la division décimale est analysée, puis déterminez où doivent être placées une nouvelle option de configuration et la réécriture de Decimal256 vers Decimal128. Le travail est considéré comme terminé lorsque le comportement compatible avec Spark de la division décimale est couvert par des tests, même si aucun fichier de test n’est nommé dans l’issue.

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

Évaluation

Stack technique
rust, spark, sql
Domaine
backend, databases
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
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.