in src/write.jl [508:556]
function toarrowtable(
cols,
dictencodings,
largelists,
compress,
denseunions,
dictencode,
dictencodenested,
maxdepth,
meta,
colmeta,
)
@debug "converting input table to arrow formatted columns"
sch = Tables.schema(cols)
types = collect(sch.types)
N = length(types)
newcols = Vector{Any}(undef, N)
newtypes = Vector{Type}(undef, N)
dictencodingdeltas = DictEncoding[]
Tables.eachcolumn(sch, cols) do col, i, nm
oldcolmeta = getmetadata(col)
newcolmeta = isnothing(colmeta) ? oldcolmeta : get(colmeta, nm, oldcolmeta)
newcol = toarrowvector(
col,
i,
dictencodings,
dictencodingdeltas,
newcolmeta;
compression=compress,
largelists=largelists,
denseunions=denseunions,
dictencode=dictencode,
dictencodenested=dictencodenested,
maxdepth=maxdepth,
)
newtypes[i] = eltype(newcol)
newcols[i] = newcol
end
minlen, maxlen = isempty(newcols) ? (0, 0) : extrema(length, newcols)
minlen == maxlen ||
throw(ArgumentError("columns with unequal lengths detected: $minlen < $maxlen"))
meta = _normalizemeta(meta)
return ToArrowTable(
Tables.Schema(sch.names, newtypes),
newcols,
meta,
dictencodingdeltas,
)
end