Skip to main content

DataBackendSession

Struct DataBackendSession 

Source
pub struct DataBackendSession {
    pub chunk_size: usize,
    pub runtime: Handle,
    /* private fields */
}
Expand description

Provides a DataFusion session and registers DataFusion queries.

The session is used to register data sources and make queries on them. A query returns a Chunk of Arrow records. It is decoded and converted into a Vec of data by types that implement DecodeDataFromRecordBatch.

Fields§

§chunk_size: usize§runtime: Handle

Implementations§

Source§

impl DataBackendSession

Source

pub fn new(chunk_size: usize) -> Self

Creates a new DataBackendSession instance.

Source

pub fn register_object_store( &mut self, url: &Url, object_store: Arc<dyn ObjectStore>, )

Register an object store with the session context

Source

pub fn register_object_store_from_uri( &mut self, uri: &str, storage_options: Option<AHashMap<String, String>>, ) -> Result<()>

Register an object store with the session context from a URI with optional storage options.

§Errors

Returns an error if the object store URI cannot be normalized or the backend cannot be created.

Source

pub fn write_data<T: EncodeToRecordBatch>( data: &[T], metadata: &AHashMap<String, String>, stream: &mut dyn WriteStream, ) -> Result<(), DataStreamingError>

Writes encoded data to a streaming sink.

§Errors

Returns an error if Arrow encoding or stream writing fails.

Source

pub fn add_file<T>( &mut self, table_name: &str, file_path: &str, sql_query: Option<&str>, custom_type_name: Option<&str>, ) -> Result<()>

Registers a Parquet file and adds a batch stream for decoding.

The caller must specify T to indicate the kind of data expected. table_name is the logical name for queries; file_path is the Parquet path; sql_query defaults to SELECT * FROM {table_name} ORDER BY ts_init if None.

When custom_type_name is Some, it is merged into each batch’s schema metadata before decoding (as type_name). Use this for custom data when Parquet/DataFusion does not preserve schema metadata so the decoder can look up the type in the registry.

The file data must be ordered by the ts_init in ascending order for this to work correctly.

§Errors

Returns an error if parquet registration, SQL planning, stream execution, or data decoding setup fails.

Source

pub fn collect_query_batches( &mut self, table_name: &str, file_path: &str, sql_query: Option<&str>, ) -> Result<Vec<RecordBatch>>

Registers a Parquet file and executes a query, returning the raw record batches.

§Errors

Returns an error if parquet registration, SQL planning, stream execution, or batch collection fails.

Source

pub fn get_query_result(&mut self) -> QueryResult

Source

pub fn clear_registered_tables(&mut self)

Clears all registered tables and batch streams.

This is useful when the underlying files have changed and we need to re-register tables with updated data.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more