TypedTables.jl icon indicating copy to clipboard operation
TypedTables.jl copied to clipboard

Differences from StructArrays

Open aplavin opened this issue 3 years ago • 3 comments

The interface seems very similar to a StructArray, so I wonder what are the main differences. Are they highlighted somewhere? A cursory look suggests that a Table and a StructArray are basically drop-in replacements for each other.

aplavin avatar Nov 24 '22 19:11 aplavin

I'm asking myself the same question. StructArray also has a richer functionality, since it can wrap not only NamedTuples but custom structs as well.

sairus7 avatar Jan 20 '23 15:01 sairus7

Historically, TypedTables came just before StructArrays, and they have a lot in common. I'd say TypedTables comes from "dataframes in Julia should just be a strongly typed AbstractVector" and StructArrays implements a struct-of-arrays (SoA) to array-of-structs (AoS) wrapper type, which end up being somewhat equivalent ideas.

StructArray also has a richer functionality, since it can wrap not only NamedTuples but custom structs as well.

One difference that manifests from this viewpoint is in data systems (like, say, SQL) a row (element in a relation) is just a named tuple (and is structurally typed), whereas the SoA-AoS transformation naturally is useful for arbitrary Julia structs (which are nominally typed), which explains this distinction.

andyferris avatar Jan 21 '23 10:01 andyferris

@andyferris is there any functionality in TypedTables.Table not provided by StructArrays? Ie in what circumstances one should use the former?

aplavin avatar Jan 23 '23 23:01 aplavin

TypedTables, IndexedTables, and StructArrays seem to have overlap in functionality for the end user. Note IndexedTables stores its data in a StructArray.

kpa28-git avatar Jan 27 '23 23:01 kpa28-git