pub struct ArrowTable { /* private fields */ }Expand description
Arrow record batches shown as one table: rows run through the batches in order.
Formatting is chosen per column from its data type when a batch is added, so writing a cell is a lookup and a format into a stack buffer, without allocating. Batches can be appended while the table is shown (a stream); their arrays are shared, not copied.
Formatted types: booleans, integers, floats, Decimal128, strings (Utf8, LargeUtf8,
Utf8View), dictionaries of those, dates, times, timestamps (with a time zone: in UTC,
marked Z) and durations. Other types (lists, structs, maps, binary, intervals) show
?.
A batch is accepted when its columns have the table’s data types in order; field names, nullability and metadata may differ. A timestamp’s time zone is part of its data type.
Implementations§
Source§impl ArrowTable
impl ArrowTable
Sourcepub fn new(schema: SchemaRef) -> Self
pub fn new(schema: SchemaRef) -> Self
An empty table for batches with schema; columns are sized by their titles until
the first rows arrive.
Sourcepub fn from_batches(
batches: impl IntoIterator<Item = RecordBatch>,
) -> Result<Self, TableError>
pub fn from_batches( batches: impl IntoIterator<Item = RecordBatch>, ) -> Result<Self, TableError>
A table of batches, with the first batch’s schema.
§Errors
TableError::NoBatches for none; a column error if a batch’s schema differs.
Sourcepub fn push(&mut self, batch: RecordBatch) -> Result<(), TableError>
pub fn push(&mut self, batch: RecordBatch) -> Result<(), TableError>
Appends batch’s rows. The first rows to arrive size the columns (their titles and
up to the first 1,000 values, at most 40 characters); later rows widen a number or time
column whose values no longer fit (measuring some rows of each batch, the last among
them), never narrowing it. Columns sized with
set_column_chars keep their width.
§Errors
A column error if batch has other columns or data types; the table is unchanged.
Sourcepub fn columns(&self) -> Vec<Column>
pub fn columns(&self) -> Vec<Column>
Grid columns: titled by field name, sized by content, numbers and times aligned right.
Sourcepub fn set_decimals(
&mut self,
column: usize,
decimals: Option<usize>,
) -> Result<(), TableError>
pub fn set_decimals( &mut self, column: usize, decimals: Option<usize>, ) -> Result<(), TableError>
Prints floating-point values of column with decimals fixed decimal places
(None: the shortest exact form). A column sized by the first rows is sized again
from them, as now printed.
§Errors
TableError::NoSuchColumn if there is no such column.
Sourcepub fn set_column_chars(
&mut self,
column: usize,
chars: usize,
) -> Result<(), TableError>
pub fn set_column_chars( &mut self, column: usize, chars: usize, ) -> Result<(), TableError>
Sets column to chars characters wide (1 to CELL_BYTES, the most a cell can
hold): columns reports it, longer text is cut to fit ending in
…, and the first rows to arrive no longer size it.
§Errors
TableError::NoSuchColumn if there is no such column.