Skip to content

Fall back to floats for out-of-range decimal literals - #55

Merged
osipovartem merged 1 commit into
expr-planner-aggregate-schemafrom
fix-decimal-literal-float-fallback
Sep 2, 2026
Merged

Fall back to floats for out-of-range decimal literals#55
osipovartem merged 1 commit into
expr-planner-aggregate-schemafrom
fix-decimal-literal-float-fallback

Conversation

@osipovartem

Copy link
Copy Markdown
Collaborator

Summary

  • keep planning representable numeric literals as Decimal when parse_float_as_decimal is enabled
  • fall back to Float64 when a fractional or scientific literal exceeds Arrow Decimal precision/scale limits
  • preserve the existing error for out-of-range integer literals, avoiding silent precision loss for integer syntax
  • share the existing float parsing/error path between normal and fallback planning

Motivation

Snowflake accepts values such as 1.7976931348623157e+308 and 2.2250738585072014e-308 as DOUBLE. With decimal-literal parsing enabled, DataFusion previously rejected them before target-type coercion because their Decimal scale or precision cannot be represented by Arrow.

This prevented otherwise valid inserts into FLOAT columns. The fallback is limited to syntax that already denotes a fractional/scientific numeric value and only runs after Decimal planning reports an unsupported representation.

Validation

  • cargo +1.97.0 test -p datafusion-sql --test sql_integration parse_decimal
  • cargo +1.97.0 test -p datafusion-sql test_parse_decimal
  • cargo +1.97.0 clippy -p datafusion-sql --all-targets -- -D warnings
  • cargo +1.97.0 fmt --all --check
  • downstream Rustice data-types/float.slt: 18/19 -> 19/19

@github-actions github-actions Bot added the sql label Sep 2, 2026
@osipovartem
osipovartem merged commit e017e21 into expr-planner-aggregate-schema Sep 2, 2026
47 of 51 checks passed
@osipovartem
osipovartem deleted the fix-decimal-literal-float-fallback branch September 2, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant