Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-lazy/src/tests/schema.rs
6939 views
1
use super::*;
2
3
#[test]
4
fn test_schema_update_after_projection_pd() -> PolarsResult<()> {
5
let df = df![
6
"a" => [1],
7
"b" => [1],
8
"c" => [1],
9
]?;
10
11
let q = df
12
.lazy()
13
.with_column(col("a").implode())
14
.explode(by_name(["a"], true))
15
.select([cols(["a", "b"]).as_expr()]);
16
17
// run optimizations
18
// Get the explode node
19
let IRPlan {
20
lp_top,
21
lp_arena,
22
expr_arena: _,
23
} = q.to_alp_optimized()?;
24
25
// assert the schema has been corrected with the projection pushdown run
26
let lp = lp_arena.get(lp_top);
27
assert!(matches!(
28
lp,
29
IR::MapFunction {
30
function: FunctionIR::Explode { .. },
31
..
32
}
33
));
34
35
let schema = lp.schema(&lp_arena).into_owned();
36
let mut expected = Schema::default();
37
expected.with_column("a".into(), DataType::Int32);
38
expected.with_column("b".into(), DataType::Int32);
39
assert_eq!(schema.as_ref(), &expected);
40
41
Ok(())
42
}
43
44