pub struct SQLContext { /* private fields */ }
Expand description
The SQLContext is the main entry point for executing SQL queries.
Implementations§
Source§impl SQLContext
impl SQLContext
Sourcepub fn get_tables(&self) -> Vec<String>
pub fn get_tables(&self) -> Vec<String>
Get the names of all registered tables, in sorted order.
Sourcepub fn register(&mut self, name: &str, lf: LazyFrame)
pub fn register(&mut self, name: &str, lf: LazyFrame)
Register a LazyFrame
as a table in the SQLContext.
let mut ctx = SQLContext::new();
let df = df! {
"a" => [1, 2, 3],
}.unwrap().lazy();
ctx.register("df", df);
Sourcepub fn unregister(&mut self, name: &str)
pub fn unregister(&mut self, name: &str)
Unregister a LazyFrame
table from the SQLContext
.
Sourcepub fn execute(&mut self, query: &str) -> PolarsResult<LazyFrame>
pub fn execute(&mut self, query: &str) -> PolarsResult<LazyFrame>
Execute a SQL query, returning a LazyFrame
.
let mut ctx = SQLContext::new();
let df = df! {
"a" => [1, 2, 3],
}
.unwrap();
ctx.register("df", df.clone().lazy());
let sql_df = ctx.execute("SELECT * FROM df").unwrap().collect().unwrap();
assert!(sql_df.equals(&df));
Sourcepub fn with_function_registry(
self,
function_registry: Arc<dyn FunctionRegistry>,
) -> Self
pub fn with_function_registry( self, function_registry: Arc<dyn FunctionRegistry>, ) -> Self
add a function registry to the SQLContext the registry provides the ability to add custom functions to the SQLContext
Sourcepub fn registry(&self) -> &Arc<dyn FunctionRegistry>
pub fn registry(&self) -> &Arc<dyn FunctionRegistry>
Get the function registry of the SQLContext
Sourcepub fn registry_mut(&mut self) -> &mut dyn FunctionRegistry
pub fn registry_mut(&mut self) -> &mut dyn FunctionRegistry
Get a mutable reference to the function registry of the SQLContext
Source§impl SQLContext
impl SQLContext
Sourcepub fn get_table_map(&self) -> PlHashMap<String, LazyFrame>
pub fn get_table_map(&self) -> PlHashMap<String, LazyFrame>
Get internal table map. For internal use only.
Sourcepub fn new_from_table_map(table_map: PlHashMap<String, LazyFrame>) -> Self
pub fn new_from_table_map(table_map: PlHashMap<String, LazyFrame>) -> Self
Create a new SQLContext from a table map. For internal use only
Trait Implementations§
Source§impl Clone for SQLContext
impl Clone for SQLContext
Source§fn clone(&self) -> SQLContext
fn clone(&self) -> SQLContext
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl !Freeze for SQLContext
impl !RefUnwindSafe for SQLContext
impl Send for SQLContext
impl !Sync for SQLContext
impl Unpin for SQLContext
impl !UnwindSafe for SQLContext
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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