feat: include source field context in cast errors - #24920
Open
haohuaijin wants to merge 4 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #24920 +/- ##
==========================================
- Coverage 81.63% 81.63% -0.01%
==========================================
Files 1123 1123
Lines 409963 409990 +27
Branches 409963 409990 +27
==========================================
+ Hits 334684 334704 +20
- Misses 55602 55608 +6
- Partials 19677 19678 +1 ☔ 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.
Which issue does this PR close?
Rationale for this change
Runtime cast errors currently identify the invalid value and target type but not the source field. This makes failures difficult to diagnose when a query contains multiple casts or an application processes many fields.
Including the source field in the error provides actionable context while retaining the original Arrow error as the cause.
What changes are included in this PR?
This PR adds context to errors returned by
CastExpr::evaluate:For example, the error now looks like:
Are these changes tested?
Yes. The existing invalid cast unit test now verifies the complete error, including the source field, source and target data types, and original Arrow error.
The following checks pass:
cargo fmt --all cargo test -p datafusion-physical-expr invalid_cast_with_options_error cargo clippy --all-targets --all-features -- -D warningsThe behavior was also verified end to end with the DataFusion CLI using the reproduction from #24919.
Are there any user-facing changes?
Yes. Runtime cast error messages now include the source field and source and target data types. The original cast error remains available as the cause.
There are no public API changes.