From d0e92d1c0bd3fbad1b90dfef1c32a9508675c632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogumi=C5=82=20Kami=C5=84ski?= Date: Sat, 17 Sep 2022 17:18:03 +0200 Subject: [PATCH] Fix allocatecolumn (#298) * Fix allocatecolumn * Update src/fallbacks.jl * Update src/fallbacks.jl --- src/fallbacks.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/fallbacks.jl b/src/fallbacks.jl index d2ce02b..c560889 100644 --- a/src/fallbacks.jl +++ b/src/fallbacks.jl @@ -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