Skip to content

refactor: use Arrow cast for decimal rescale check - #5444

Closed
peterxcli wants to merge 1 commit into
apache:mainfrom
peterxcli:refactor/5094-use-arrow-decimal-cast
Closed

refactor: use Arrow cast for decimal rescale check#5444
peterxcli wants to merge 1 commit into
apache:mainfrom
peterxcli:refactor/5094-use-arrow-decimal-cast

Conversation

@peterxcli

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #5094.

Rationale for this change

DecimalRescaleCheckOverflow duplicates Arrow's Decimal128 rescale, HALF_UP rounding, and precision validation. Delegating the fused operation to Arrow removes the sentinel and follow-up null-masking pass while keeping Spark-compatible legacy and ANSI behavior.

What changes are included in this PR?

  • Use ColumnarValue::cast_to with DataFusion's default cast options for the common one-pass decimal rescale path.
  • Preserve Spark semantics for legacy nulls, ANSI NUMERIC_VALUE_OUT_OF_RANGE errors, SQL query context, scalar inputs, and scale deltas outside Arrow's Decimal128 power table.
  • Port Spark DecimalExpressionSuite cases and add boundary coverage for rounding, overflow, null propagation, and extreme scale changes.
  • Update the expression audit documentation.

How are these changes tested?

  • cargo test --manifest-path native/Cargo.toml -p datafusion-comet-spark-expr (647 unit tests and 5 integration tests)
  • cargo test --manifest-path native/Cargo.toml -p datafusion-comet fused_decimal_overflow_keeps_query_context
  • cargo clippy --manifest-path native/Cargo.toml -p datafusion-comet-spark-expr -p datafusion-comet --all-targets -- -D warnings
  • cargo fmt --manifest-path native/Cargo.toml --all -- --check

@peterxcli peterxcli closed this Aug 23, 2026
@peterxcli
peterxcli deleted the refactor/5094-use-arrow-decimal-cast branch August 23, 2026 15:37
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.

decimal_rescale_check: replace fused rescale and precision check with arrow decimal cast

1 participant