Skip to content

Prevent silent column type coercion#14

Merged
VLCDaniel merged 1 commit intomainfrom
fix-update-type-coercion
Apr 9, 2026
Merged

Prevent silent column type coercion#14
VLCDaniel merged 1 commit intomainfrom
fix-update-type-coercion

Conversation

@VLCDaniel
Copy link
Copy Markdown
Collaborator

@VLCDaniel VLCDaniel commented Apr 7, 2026

Without this, updates/merges would silently corrupt your table:
table.update().with_update("age", lit("hello")).await // age is Int32
DataFusion would quietly change the age column type from Int32 to Utf8 in the written parquet file, while the Delta log still said it was Int32.

// silently widen the column (e.g. Int32 → Utf8), and
// (b) incompatible assignments (e.g. a non-numeric string into an Int32
// column) are caught during plan optimisation via constant folding.
let typed_expr = cast(expr.to_owned(), field.data_type().clone());
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataFusion silently coerces incompatible types in CASE expressions (e.g. promoting Int32 to Utf8 when a string expression is assigned to an integer column) instead of erroring. Without an explicit check, a type-mismatched update would succeed and write a parquet file with the wrong column type

test_expected_failures exposed this, this is how it fails now:

  Optimizer rule 'simplify_expressions' failed
  caused by
  Arrow error: Cast error: Cannot cast string 'a string' to value of Int32 type

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

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.

@VLCDaniel VLCDaniel force-pushed the fix-update-type-coercion branch from 1fd71c5 to 66d15d2 Compare April 9, 2026 09:31
@VLCDaniel VLCDaniel merged commit 3fa7f35 into main Apr 9, 2026
3 of 23 checks passed
@VLCDaniel VLCDaniel deleted the fix-update-type-coercion branch April 9, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants