Decimal division compatibility mode with spark
- Lenguaje dominante
- Rust
- Estrellas
- 9.3k
- Forks
- 2.4k
- Merge medio
- 3 d 11 h
- PR fusionados (30 d)
- 360
Descripción
### 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_
Guía de contribución
Línea de trabajo
Comienza con la discusión en el pull request 6832 y la documentación de AnalyzerRule enlazada en la issue. Rastrea cómo se analiza la división decimal y determina después dónde deben ubicarse una nueva opción de configuración y la reescritura de Decimal256 a Decimal128. Se considera terminado cuando el comportamiento compatible con Spark de la división decimal está cubierto por pruebas, aunque en la issue no se nombra ningún archivo de prueba.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- rust, spark, sql
- Área
- backend, databases
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100