Skip to content

[SPARK-55818][PS] Decimal-float mixed arithmetic should always raise TypeError#54599

Open
devin-petersohn wants to merge 1 commit intoapache:masterfrom
devin-petersohn:devin/fix-decimal-float-mixed
Open

[SPARK-55818][PS] Decimal-float mixed arithmetic should always raise TypeError#54599
devin-petersohn wants to merge 1 commit intoapache:masterfrom
devin-petersohn:devin/fix-decimal-float-mixed

Conversation

@devin-petersohn
Copy link
Contributor

What changes were proposed in this pull request?

Remove the is_ansi_mode_enabled guard from _is_decimal_float_mixed checks in FractionalOps so that mixing decimal.Decimal with float Series always raises TypeError, 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 raises TypeError. The correct behavior (raising TypeError) was only triggered when spark.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

…TypeError

Co-authored-by: Devin Petersohn <devin.petersohn@snowflake.com>
Signed-off-by: Devin Petersohn <devin.petersohn@gmail.com>
Copy link
Contributor Author

@devin-petersohn devin-petersohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@devin-petersohn
Copy link
Contributor Author

cc @ueshin @HyukjinKwon @holdenk @gaogaotiantian - flagging for discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant