Skip to content

fix: float <-> decimal coercion should coerce to float#22448

Draft
neilconway wants to merge 2 commits into
apache:mainfrom
neilconway:neilc/fix-decimal-coercion
Draft

fix: float <-> decimal coercion should coerce to float#22448
neilconway wants to merge 2 commits into
apache:mainfrom
neilconway:neilc/fix-decimal-coercion

Conversation

@neilconway
Copy link
Copy Markdown
Contributor

@neilconway neilconway commented May 22, 2026

Which issue does this PR close?

Rationale for this change

Type coercion between a float and a decimal previously resulted in preferring decimal; it should instead prefer float, for several reasons:

  1. DataFusion's decimal implementation cannot represent special values like NaN and +/- infinity
  2. Float64's range is significantly larger than decimal's range
  3. Preferring float matches the behavior of PostgreSQL and DuckDB

What changes are included in this PR?

  • Update decimal_coercion behavior
  • Update SLT expected results for new behavior
  • Add new SLT tests for new behavior

Are these changes tested?

Yes; new tests added.

Are there any user-facing changes?

Yes; changes in type coercion behavior. The migration guide has been updated.

@github-actions github-actions Bot added logical-expr Logical plan and expressions sqllogictest SQL Logic Tests (.slt) labels May 22, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 22, 2026
@neilconway neilconway marked this pull request as draft May 22, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation logical-expr Logical plan and expressions sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coercion between floating point types and exact numeric types should result in floating point type as the common super type

1 participant