Skip to content

Add optional decimal literal normalization - #50

Merged
osipovartem merged 2 commits into
expr-planner-aggregate-schemafrom
snowflake-decimal-literals
Sep 1, 2026
Merged

Add optional decimal literal normalization#50
osipovartem merged 2 commits into
expr-planner-aggregate-schemafrom
snowflake-decimal-literals

Conversation

@osipovartem

Copy link
Copy Markdown
Collaborator

Which issue does this PR close?

Part of Embucket Snowflake query compatibility work.

Rationale for this change

Snowflake removes insignificant trailing zeros when inferring exact numeric literal types: 10.00 is NUMBER(2,0), 10.10 is NUMBER(3,1), and 0.00100 is NUMBER(4,3). DataFusion currently preserves the textual scale. This affects result metadata and decimal rendering in otherwise-correct queries.

What changes are included in this PR?

  • Add opt-in datafusion.sql_parser.trim_decimal_literal_trailing_zeros (default false).
  • Normalize only positive decimal scale; scientific notation that requires negative scale remains intact.
  • Preserve a leading zero in precision for values below one, matching Snowflake exact numeric inference.
  • Add parser and planner coverage and document the option.

The default DataFusion behavior is unchanged. Rustice enables this option explicitly.

Are there any user-facing changes?

Only for applications that enable the new option.

How was this tested?

  • cargo test -p datafusion-sql --lib (92 passed)
  • cargo test -p datafusion-sql --test sql_integration parse_decimals_trim_insignificant_trailing_zeros
  • cargo check -p datafusion
  • cargo clippy -p datafusion-common -p datafusion-sql -p datafusion --all-targets -- -D warnings
  • cargo fmt --all -- --check

@github-actions github-actions Bot added documentation Improvements or additions to documentation core sql common labels Sep 1, 2026
@osipovartem
osipovartem changed the base branch from qualified-wildcard-options to expr-planner-aggregate-schema September 1, 2026 23:58
@osipovartem
osipovartem merged commit a4762a3 into expr-planner-aggregate-schema Sep 1, 2026
33 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common core documentation Improvements or additions to documentation sql

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant