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: HandleImplementations§
Source§impl DataBackendSession
impl DataBackendSession
Sourcepub fn new(chunk_size: usize) -> Self
pub fn new(chunk_size: usize) -> Self
Creates a new DataBackendSession instance.
Sourcepub fn register_object_store(
&mut self,
url: &Url,
object_store: Arc<dyn ObjectStore>,
)
pub fn register_object_store( &mut self, url: &Url, object_store: Arc<dyn ObjectStore>, )
Register an object store with the session context
Sourcepub fn register_object_store_from_uri(
&mut self,
uri: &str,
storage_options: Option<AHashMap<String, String>>,
) -> Result<()>
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.
Sourcepub fn write_data<T: EncodeToRecordBatch>(
data: &[T],
metadata: &AHashMap<String, String>,
stream: &mut dyn WriteStream,
) -> Result<(), DataStreamingError>
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.
Sourcepub fn add_file<T>(
&mut self,
table_name: &str,
file_path: &str,
sql_query: Option<&str>,
custom_type_name: Option<&str>,
) -> Result<()>where
T: DecodeDataFromRecordBatch,
pub fn add_file<T>(
&mut self,
table_name: &str,
file_path: &str,
sql_query: Option<&str>,
custom_type_name: Option<&str>,
) -> Result<()>where
T: DecodeDataFromRecordBatch,
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.
Sourcepub fn collect_query_batches(
&mut self,
table_name: &str,
file_path: &str,
sql_query: Option<&str>,
) -> Result<Vec<RecordBatch>>
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.
pub fn get_query_result(&mut self) -> QueryResult ⓘ
Sourcepub fn clear_registered_tables(&mut self)
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§
impl !RefUnwindSafe for DataBackendSession
impl !UnwindSafe for DataBackendSession
impl Freeze for DataBackendSession
impl Send for DataBackendSession
impl Sync for DataBackendSession
impl Unpin for DataBackendSession
impl UnsafeUnpin for DataBackendSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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