Struct polars_sql::SQLContext
source · 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 !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