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.frame_equal(&df));
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 moresource§impl Default for SQLContext
impl Default for SQLContext
source§fn default() -> SQLContext
fn default() -> SQLContext
Returns the “default value” for a type. Read more
Auto 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