Path: blob/main/crates/polars-sql/tests/functions_meta.rs
6939 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) FROM df"#;16let res = context.execute(sql).unwrap();17let df = res.collect().unwrap();18let lf = lf.select([col("year"), col("country"), col("year").max()]);19let expected = lf.describe_optimized_plan().unwrap();2021let expected = expected.split('\n').map(Some).collect::<Vec<_>>();22let actual = df23.column("Logical Plan")24.unwrap()25.str()26.unwrap()27.into_iter()28.collect::<Vec<_>>();2930assert_eq!(actual, expected);31}323334