[SPARK-55818][PS] Decimal-float mixed arithmetic should always raise TypeError#54599
Open
devin-petersohn wants to merge 1 commit intoapache:masterfrom
Open
[SPARK-55818][PS] Decimal-float mixed arithmetic should always raise TypeError#54599devin-petersohn wants to merge 1 commit intoapache:masterfrom
devin-petersohn wants to merge 1 commit intoapache:masterfrom
Conversation
…TypeError Co-authored-by: Devin Petersohn <devin.petersohn@snowflake.com> Signed-off-by: Devin Petersohn <devin.petersohn@gmail.com>
devin-petersohn
commented
Mar 3, 2026
Contributor
Author
devin-petersohn
left a comment
There was a problem hiding this comment.
This is one of those cases where ansi mode flag intetionally had different behavior in pandas depending on if it was on or off, so I'm opening this to start a discussion around whether we should take a different approach and always stay consistent with pandas.
Contributor
Author
|
cc @ueshin @HyukjinKwon @holdenk @gaogaotiantian - flagging for discussion. |
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.
What changes were proposed in this pull request?
Remove the
is_ansi_mode_enabledguard from_is_decimal_float_mixedchecks inFractionalOpsso that mixingdecimal.Decimalwith float Series always raisesTypeError, regardless of ANSI mode.Why are the changes needed?
It is a bug. With ANSI mode off,
ps.Series([1.0, 2.0, 3.0]) * decimal.Decimal("1.5")silently computes a result, while pandas raisesTypeError. The correct behavior (raisingTypeError) was only triggered whenspark.sql.ansi.enabled=true.Does this PR introduce any user-facing change?
Yes, decimal-float mixed arithmetic now always raises
TypeError(matching pandas), even with ANSI mode disabled.How was this patch tested?
CI
Was this patch authored or co-authored using generative AI tooling?
Co-authored-by: Claude Opus 4