Skip to content

Commit

Permalink
Fix allocatecolumn (#298)
Browse files Browse the repository at this point in the history
* Fix allocatecolumn

* Update src/fallbacks.jl

* Update src/fallbacks.jl
  • Loading branch information
bkamins authored Sep 17, 2022
1 parent 70b5039 commit d0e92d1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/fallbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ end
Custom column types can override with an appropriate "scalar" element type that should dispatch to their column allocator.
Alternatively, and more generally, custom scalars can overload `DataAPI.defaultarray` to signal the default array type.
In this case the signaled array type must support a constructor accepting `undef` for initialization.
"""
allocatecolumn(T, len) = DataAPI.defaultarray(T, 1)(Base.nonmissingtype(T) === T ? undef : missing, len)
function allocatecolumn(T, len)
a = DataAPI.defaultarray(T, 1)(undef, len)
Missing <: T && fill!(a, missing)
return a
end

@inline function _allocatecolumns(::Schema{names, types}, len) where {names, types}
if @generated
Expand Down

0 comments on commit d0e92d1

Please sign in to comment.