Table

Struct Table 

Source
pub struct Table {
    pub(crate) record_batches: Vec<RecordBatch>,
    pub(crate) schema: SchemaRef,
}
Expand description

This is a convenience wrapper around Vec<RecordBatch> that tries to simplify conversion from and to pyarrow.Table.

This could be used in circumstances where you either want to consume a pyarrow.Table directly (although technically, since pyarrow.Table implements the ArrayStreamReader PyCapsule interface, one could also consume a PyArrowType<ArrowArrayStreamReader> instead) or, more importantly, where one wants to export a pyarrow.Table from a Vec<RecordBatch> from the Rust side.

#[pyfunction]
fn return_table(...) -> PyResult<PyArrowType<Table>> {
    let batches: Vec<RecordBatch>;
    let schema: SchemaRef;
    PyArrowType(Table::try_new(batches, schema).map_err(|err| err.into_py_err(py))?)
}

Fields§

§record_batches: Vec<RecordBatch>§schema: SchemaRef

Implementations§

Source§

impl Table

Source

pub fn try_new( record_batches: Vec<RecordBatch>, schema: SchemaRef, ) -> Result<Self, ArrowError>

Source

pub fn record_batches(&self) -> &[RecordBatch]

Source

pub fn schema(&self) -> SchemaRef

Source

pub fn into_inner(self) -> (Vec<RecordBatch>, SchemaRef)

Trait Implementations§

Source§

impl Clone for Table

Source§

fn clone(&self) -> Table

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl FromPyArrow for Table

Convert a pyarrow.Table (or any other ArrowArrayStream compliant object) into Table

Source§

fn from_pyarrow_bound(ob: &Bound<'_, PyAny>) -> PyResult<Self>

Convert a Python object to an arrow-rs type. Read more
Source§

impl IntoPyArrow for Table

Convert a Table into pyarrow.Table.

Source§

fn into_pyarrow(self, py: Python<'_>) -> PyResult<Bound<'_, PyAny>>

Convert the implemented type into a Python object while consuming it.
Source§

impl TryFrom<Box<dyn RecordBatchReader<Item = Result<RecordBatch, ArrowError>>>> for Table

Source§

type Error = ArrowError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Box<dyn RecordBatchReader>) -> Result<Self, ArrowError>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Table

§

impl !RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl !UnwindSafe for Table

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Ungil for T
where T: Send,