Skip to content

fix: update stats serialization logic for scale-0 decimals#3916

Merged
rtyler merged 1 commit intodelta-io:mainfrom
DrakeLin:drake-lin_data/decimal
Nov 5, 2025
Merged

fix: update stats serialization logic for scale-0 decimals#3916
rtyler merged 1 commit intodelta-io:mainfrom
DrakeLin:drake-lin_data/decimal

Conversation

@DrakeLin
Copy link
Copy Markdown
Contributor

@DrakeLin DrakeLin commented Nov 4, 2025

Description

Creating Delta tables with Decimal(precision, scale=0) columns fails since in stats code, we store decimals as f64. serde_json converts f64 values like 1234.0 to 1234.0 for scale=0. Arrow Parser then rejects it since it expects 1234.

Modified StatsScalar enum to preserve scale information:

  • Changed from Decimal(f64) to Decimal { value: f64, scale: i32 }
  • Updated serialization logic to output integers for scale=0 decimal

Tested by building delta-rs and running the example script linked in the issue.

Related Issue(s)

delta-io/delta-kernel-rs#1431

Documentation

@github-actions github-actions bot added the binding/rust Issues for the Rust crate label Nov 4, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 4, 2025

ACTION NEEDED

delta-rs follows the Conventional Commits specification for release automation.

The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification.

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.89%. Comparing base (2e5f7b0) to head (9814ab2).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3916   +/-   ##
=======================================
  Coverage   73.88%   73.89%           
=======================================
  Files         152      152           
  Lines       39426    39443   +17     
  Branches    39426    39443   +17     
=======================================
+ Hits        29131    29147   +16     
- Misses       8971     8973    +2     
+ Partials     1324     1323    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: DrakeLin <drakelin18@gmail.com>
@DrakeLin DrakeLin force-pushed the drake-lin_data/decimal branch from c045d52 to 9814ab2 Compare November 4, 2025 00:49
@DrakeLin DrakeLin changed the title [WIP] decimal fix: Change Nov 4, 2025
@DrakeLin DrakeLin changed the title fix: Change fix: update serialization logic for scale-0 decimals Nov 4, 2025
@DrakeLin DrakeLin changed the title fix: update serialization logic for scale-0 decimals fix: update stats serialization logic for scale-0 decimals Nov 4, 2025
@rtyler
Copy link
Copy Markdown
Member

rtyler commented Nov 4, 2025

@DrakeLin is this independent of any kernel changes, or is this pending something in kernel to be released?

@DrakeLin
Copy link
Copy Markdown
Contributor Author

DrakeLin commented Nov 4, 2025

@rtyler This is independent of any kernel changes. The bug seen in delta-io/delta-kernel-rs#1431 didn't turn out to be a kernel issue (delta-rs doesn't use kernel for writes), so putting up a quick fix in delta-rs. The bug, as the original author pointed out, is due to an issue in serde_json.

This bug caused delta-rs to write stats with scale 0 out as 1234.0. The kernel issue we saw was due to kernel trying to read this and failing. I think there is a kernel fix we can push out as well to relax our constraints on read, but that's independent of this change.

@rtyler rtyler merged commit 16621c4 into delta-io:main Nov 5, 2025
47 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

binding/rust Issues for the Rust crate

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants