Path: blob/main/crates/polars-sql/tests/functions_meta.rs
8420 views
use polars_core::prelude::*;1use polars_lazy::prelude::*;2use polars_sql::*;34#[test]5fn test_describe() {6let lf = df! {7"year"=> [2018],8"country"=> ["US"],9"sales"=> [1000.0]10}11.unwrap()12.lazy();13let mut context = SQLContext::new();14context.register("df", lf.clone());15let sql = r#"EXPLAIN SELECT year, country, MAX(year) as year_max FROM df"#;16let res = context.execute(sql).unwrap();17let df = res.collect().unwrap();18let lf = lf.select([19col("year"),20col("country"),21col("year").max().alias("year_max"),22]);23let expected = lf.describe_optimized_plan().unwrap();2425let expected = expected.split('\n').map(Some).collect::<Vec<_>>();26let actual = df27.column("Logical Plan")28.unwrap()29.str()30.unwrap()31.into_iter()32.collect::<Vec<_>>();3334assert_eq!(actual, expected);35}363738