Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimal division compatibility mode with spark #7301

Open
alamb opened this issue Aug 16, 2023 · 1 comment
Open

Decimal division compatibility mode with spark #7301

alamb opened this issue Aug 16, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@alamb
Copy link
Contributor

alamb commented Aug 16, 2023

Is your feature request related to a problem or challenge?

As described in detail by @liukun4515 and @tustvold and @viirya on #6832, DataFusion's decimal devision semantics.

@liukun4515 notes #6832 (comment) 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

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

@alamb alamb added the enhancement New feature or request label Aug 16, 2023
@alamb
Copy link
Contributor Author

alamb commented Aug 16, 2023

I don't think we should implement this unless a user actually needs it, but I wanted to summarize the conversation on #6832

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant