Path: blob/main/docs/source/src/rust/user-guide/concepts/streaming.rs
7889 views
use polars::prelude::*;12fn main() -> Result<(), Box<dyn std::error::Error>> {3// --8<-- [start:streaming]4let q1 = LazyCsvReader::new(PlPath::new("docs/assets/data/iris.csv"))5.with_has_header(true)6.finish()?7.filter(col("sepal_length").gt(lit(5)))8.group_by(vec![col("species")])9.agg([col("sepal_width").mean()]);1011let df = q1.clone().with_new_streaming(true).collect()?;12println!("{df}");13// --8<-- [end:streaming]1415// --8<-- [start:example]16let query_plan = q1.with_new_streaming(true).explain(true)?;17println!("{query_plan}");18// --8<-- [end:example]1920// --8<-- [start:example2]21let q2 = LazyCsvReader::new(PlPath::new("docs/assets/data/iris.csv"))22.finish()?23.with_columns(vec![24col("sepal_length")25.mean()26.over(vec![col("species")])27.alias("sepal_length_mean"),28]);2930let query_plan = q2.with_new_streaming(true).explain(true)?;31println!("{query_plan}");32// --8<-- [end:example2]3334Ok(())35}363738