fix: Raise on missing struct fields when casting with strict=True - #28631
Open
MatteoPossamai wants to merge 1 commit into
Open
fix: Raise on missing struct fields when casting with strict=True#28631MatteoPossamai wants to merge 1 commit into
MatteoPossamai wants to merge 1 commit into
Conversation
MatteoPossamai
requested review from
MarcoGorelli,
alexander-beedie,
c-peters,
orlp and
ritchie46
as code owners
July 31, 2026 15:01
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #28631 +/- ##
==========================================
- Coverage 81.33% 76.46% -4.88%
==========================================
Files 1870 1870
Lines 263034 263039 +5
Branches 3217 3217
==========================================
- Hits 213950 201144 -12806
- Misses 48253 61064 +12811
Partials 831 831 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #28587.
Problem
Struct casts map fields by name and unconditionally fill unmatched target
fields with nulls. Under
strict=Truethis never raised:Changes
source struct, raise a SchemaError if the cast is strict. The error
message names the missing field and lists the available source fields.
Non-strict casts keep the existing null-filling behavior
null-filling missing fields, which remains supported for non-strict casts
(per the expected behavior in
cast(Struct{...}, strict=True)to renamed fields silently nulls every value #28587).raises for both zero-overlap and partial-overlap field names, and
non-strict cast still null-fills.
Local test