dr/src/sql.rs
Guillem Borrell 3af97c71f0
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
Fixed compile time issue
2022-12-25 09:22:24 +00:00

16 lines
433 B
Rust

use polars::sql::SQLContext;
use polars_lazy::frame::LazyFrame;
pub fn execute(ldf: LazyFrame, statement: &String) -> LazyFrame {
let mut context = SQLContext::try_new().expect("Could not create context");
context.register("this", ldf);
match context.execute(statement) {
Ok(res) => res,
Err(e) => {
eprintln!("Query execution error {e}");
LazyFrame::default()
}
}
}