-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improved support for struct columns with missing values #498
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #498 +/- ##
==========================================
+ Coverage 87.34% 87.36% +0.01%
==========================================
Files 26 26
Lines 3288 3292 +4
==========================================
+ Hits 2872 2876 +4
Misses 416 416 ☔ View full report in Codecov by Sentry. |
0fa25e5
to
78e22be
Compare
@quinnj / @ericphanson - Any questions/comments/concerns here? If not I'd like to merge and release. Thanks. |
ToStruct(x::A, j::Integer) where {A} = | ||
ToStruct{fieldtype(Base.nonmissingtype(eltype(A)), j),j,A}(x) | ||
function ToStruct(x::A, j::Integer, hasmissing::Bool=false) where {A} | ||
AT = fieldtype(eltype(A), j) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we still want Base.nonmissingtype(eltype(A))
inside the field type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. My change makes it so missing types are properly supported.
I don't really know this code well enough to be confident here. But one thing I can say is it's probably good if the PR adds a test that is failing on main, to show precisely what has been fixed (and prevent regressions) |
The current implementation depends on
Arrow.default
returning a sentinel object when the value is missing. This usually works, but occasionally has problems. This PR simplifies the implementation and solves some of the problematic corner-cases.One example of a problematic corner-case is a column of lists of structs:
It's possible that users may wrap this Vector in a
SubArray
. In this caseArrow.default(::Type{<:SubArray })
actually usesArrow.default(::Type{<:AbstractVector})
which enforces that the parent-type is aVector
- this is not always the case. For example, the parent may well be of typeArrow.Struct
if the data being written was also read from an Arrow file. Certainly we could enhanceArrow.default
to return a proper type for SubArray but simpler is to remove the dependency onArrow.default
fromToStruct
.