table::parquet
On this page
Parquet files, read and written without a Parquet library. Writing:
flat optional columns (i64 INT64, f64 DOUBLE, bool BOOLEAN,
str and cat BYTE_ARRAY strings, dictionary-encoded for cat and
for str with few distinct values, date DATE, datetime
TIMESTAMP(NANOS)), data pages v1, min / max statistics, Snappy or no
compression, and the Arrow schema in the metadata. Reading: data
pages v1 and v2; PLAIN, dictionary, RLE, DELTA_BINARY_PACKED,
DELTA_LENGTH_BYTE_ARRAY, DELTA_BYTE_ARRAY and BYTE_STREAM_SPLIT
encodings; Snappy, Zstandard or no compression; INT32 / INT64 of any
integer logical type, INT96 and every timestamp unit, FLOAT, DOUBLE,
FLOAT16, strings. Nested, decimal, time and fixed-length binary
columns are an error naming the column, unless columns leaves them
out; gzip, Brotli and LZ4 pages are an error.
Structs
ParquetSource
pub struct ParquetHow to read or write Parquet. Start from Parquet::new().
use table::Parquet;
let t = table::table!{ "city": ["Seoul", "Busan", none], "temp": [21.5, 24.0, 19.0] };
let b = Parquet::new().write_bytes(t);
assert(try Parquet::new().read_bytes(b) == t);
let temps = try Parquet::new().columns(["temp"]).read_bytes(b);
assert(temps.names() == ["temp"]);
Every column; row groups of 1048576 rows, pages of 65536 rows, Snappy, dictionaries where they pay.
Read only these columns, in this order; the other column chunks are not read at all.
Write row groups of at most
nrows: smaller groups let a filtered scan skip more by their statistics.nabilet t = table::table!{ "x": [1, 2, 3, 4, 5] }; let b = table::Parquet::new().row_group_rows(2).write_bytes(t); assert(try table::Parquet::new().read_bytes(b) == t);Write data pages of at most
nrows.
Sourcepub fn compression(§self, c: Compression) -> Parquet The page compression to write (reading takes any it supports).
Whether to write dictionary pages (
catcolumns, andstrcolumns with few distinct values);falsewrites every value PLAIN (acatcolumn still reads back ascat, through the Arrow schema the file carries).
Sourcepub fn read_bytes(§self, b: List<u8>) throws (TableError) -> Table The table in
b.
Sourcepub fn read_file(§self, path: str) throws (TableError) -> Table The table in the file at
path.tas Parquet bytes.
Sourcepub fn write_file(§self, t: Table, path: str) throws (TableError) Write
ttopath, replacing it.
Enums
CompressionSource
pub enum CompressionThe page compression a written file uses.
use table::{Compression, Parquet};
let t = table::table!{ "x": [1, 2, 3] };
let b = Parquet::new().compression(Compression::None).write_bytes(t);
assert(try Parquet::new().read_bytes(b) == t);
Snappy: fast, about 2x on typical tables; the default, as in pyarrow and Polars.
Functions
read_parquetSource
pub fn read_parquet(path: str) throws (TableError) -> Table The Parquet file at path: Parquet::new().read_file(path).
let t = try "trips.parquet" |> table::read_parquet;
write_parquetSource
pub fn write_parquet(t: Table, path: str) throws (TableError) Write t to path as Parquet with the defaults of Parquet::new().
try t |> table::write_parquet("trips.parquet");
parquet_schemaSource
pub fn parquet_schema(b: List<u8>) throws (TableError) -> Schema The schema of the Parquet data in b (its readable columns), from
the footer alone.
let t = table::table!{ "n": [1, 2], "s": ["a", "b"] };
let s = try table::parquet_schema(table::Parquet::new().write_bytes(t));
assert(s.dtype("s") == table::DType::Str);