table::arrow
On this page
Arrow IPC: the file format (.arrow, Feather v2) and the streaming
format, read and written without an Arrow library. Columns map to
Arrow types one to one (i64 int64, f64 float64, bool, str
utf8, cat a utf8 dictionary with int32 indices, date date32,
datetime timestamp[ns]); reading also widens the narrower integer
and float types, date64, any timestamp unit and large_utf8, and
decompresses ZSTD and LZ4 frame bodies. Nested, decimal, binary,
time, duration and view types are an error naming the column, unless
columns leaves them out.
Structs
ArrowSource
pub struct ArrowHow to read or write Arrow IPC data. Start from Arrow::new().
use table::Arrow;
let t = table::table!{ "id": [1, 2, 3], "name": ["a", none, "c"] };
let bytes = Arrow::new().write_bytes(t);
let back = try Arrow::new().read_bytes(bytes);
assert(back == t);
let ids = try Arrow::new().columns(["id"]).read_bytes(bytes);
assert(ids.names() == ["id"]);
Read every column; write the file format in one record batch.
Read only these columns, in this order; the others are skipped without decoding.
Write record batches of at most
nrows.nabilet t = table::table!{ "x": [1, 2, 3, 4, 5] }; let b = table::Arrow::new().batch_rows(2).write_bytes(t); assert(try table::Arrow::new().read_bytes(b) == t);Write the streaming format (no footer; what a socket or pipe carries) instead of the file format. Reading tells them apart by themselves.
nabilet t = table::table!{ "x": [1.5, 2.5] }; let b = table::Arrow::new().stream(true).write_bytes(t); assert(try table::Arrow::new().read_bytes(b) == t);
Sourcepub fn read_bytes(§self, b: List<u8>) throws (TableError) -> Table The table in
b, file or stream format.
Sourcepub fn read_file(§self, path: str) throws (TableError) -> Table The table in the file at
path.tas Arrow IPC bytes.
Sourcepub fn write_file(§self, t: Table, path: str) throws (TableError) Write
ttopath, replacing it.
Functions
read_arrowSource
pub fn read_arrow(path: str) throws (TableError) -> Table The Arrow file (or stream) at path: Arrow::new().read_file(path).
let t = try "trips.arrow" |> table::read_arrow;
write_arrowSource
pub fn write_arrow(t: Table, path: str) throws (TableError) Write t to path in the Arrow file format.
try t |> table::write_arrow("trips.arrow");
arrow_schemaSource
pub fn arrow_schema(b: List<u8>) throws (TableError) -> Schema The schema of the Arrow data in b, without reading its rows.
let t = table::table!{ "d": [date"2024-01-02"] };
let s = try table::arrow_schema(table::Arrow::new().write_bytes(t));
assert(s.dtype("d") == table::DType::Date);