apache / apache/datafusion

Decimal division compatibility mode with spark

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

説明

### 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_

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

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

調査の方向性

pull request 6832 の議論と、issue にリンクされている AnalyzerRule のドキュメントから始めてください。小数除算がどのように解析されるかを追跡し、その後、新しい設定オプションと Decimal256 から Decimal128 への書き換えをどこに配置すべきかを判断してください。issue ではテストファイルが指定されていませんが、小数除算の Spark 互換の動作がテストでカバーされれば完了です。

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

評価

技術スタック
rust, spark, sql
領域
backend, databases
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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