fix(substrait): reject incompatible decimal output types - #25087
Draft
Satyr09 wants to merge 2 commits into
Draft
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #25087 +/- ##
==========================================
+ Coverage 81.72% 81.75% +0.02%
==========================================
Files 1127 1129 +2
Lines 416519 417375 +856
Branches 416519 417375 +856
==========================================
+ Hits 340401 341208 +807
+ Misses 56115 56025 -90
- Partials 20003 20142 +139 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
[ This causes a lot of previously passing queries to potentially fail - and as such may not be the best option - keeping this in draft while I work on a better fix ]
The Substrait consumer can accept decimal arithmetic while silently changing its declared result precision and scale. For example, division declared as decimal(21,8) becomes a native DataFusion expression returning decimal(15,6).
This PR rejects conversions that cannot preserve the declared result type. Casting the result alone would not recover fractional digits already lost during calculation or prevent intermediate overflow.
What changes are included in this PR?
Plans with matching result types retain their existing behavior. Plans omitting output_type remain accepted for compatibility. Implementing Substrait-specific decimal arithmetic is outside this change’s scope.
What is the testing strategy for this PR?
Added consumer tests covering the issue’s five examples, matching declarations, malformed types, decimal-width differences, missing declarations, and nested mismatches.
An integration test executes native decimal arithmetic through producer/consumer round trips, checks result types and values, and verifies acceptance or rejection after changing the declared output types.
Local validation:
Are there any user-facing changes?
Yes. Imported plans whose declared decimal arithmetic result types differ from DataFusion’s native result types now fail during conversion instead of silently producing a different type. Native SQL arithmetic is unchanged.