Fix defaults for structs with missing fields + Vararg fieldtypes #465
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.
Fixes #461. The issue here is that in the conversion from a column of a struct that had a field with type
Union{T, Missing}
whereT
was a type that had anyTuple{Vararg}
fieldtypes, then the ArrowTypes.default call blew up (fieldcount not defined). To resolve, we could try to define adefault
forTuple{Vararg}
, but that seemed pretty messy and relying on some pretty deep reflection internals that aren't well-exposed (T.parameters[end] isa Core.TypeofVararg
!), so the alternative proposed here is that to get a struct fields default value, we actually call thedefault
on the entire struct and get the default from that. I think this should be more robust because we have pretty sensibledefault
s (pun intended) on most types, but when it comes to field types specifically, there are a lot of weird edge cases that are just hard to handle, like vararg fields. In this way, we don't try to mess with field type directly and instead rely on being able to get thedefault
of the parent struct on the way down.