pub struct QueryEngine { /* private fields */ }Expand description
High-performance SQL query engine powered by Apache DataFusion
The QueryEngine manages a DataFusion SessionContext and provides
methods for registering data files and executing SQL queries with
zero-copy streaming.
Implementations§
Source§impl QueryEngine
impl QueryEngine
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new query engine with default configuration
§Errors
Returns an error if the session context cannot be initialized
Sourcepub async fn register_file(
&mut self,
file_path: &str,
table_name: &str,
) -> Result<()>
pub async fn register_file( &mut self, file_path: &str, table_name: &str, ) -> Result<()>
Register a CSV or JSON file as a table in the query engine
The file format is automatically detected from the file extension.
Supported formats: .csv, .json
§Arguments
file_path- Path to the data filetable_name- Name to use for the table in SQL queries
§Errors
Returns an error if:
- The file does not exist
- The file format is unsupported
- Schema inference fails
- Table registration fails
Sourcepub async fn execute_query(&self, sql: &str) -> Result<DataFrame>
pub async fn execute_query(&self, sql: &str) -> Result<DataFrame>
Sourcepub async fn print_results(&self, dataframe: DataFrame) -> Result<()>
pub async fn print_results(&self, dataframe: DataFrame) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QueryEngine
impl !RefUnwindSafe for QueryEngine
impl Send for QueryEngine
impl Sync for QueryEngine
impl Unpin for QueryEngine
impl !UnwindSafe for QueryEngine
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
Mutably borrows from an owned value. Read more
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>
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 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>
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