Path: blob/main/docs/source/src/python/user-guide/concepts/streaming.py
7890 views
import base6412# --8<-- [start:import]3import polars as pl4# --8<-- [end:import]56# --8<-- [start:streaming]7q1 = (8pl.scan_csv("docs/assets/data/iris.csv")9.filter(pl.col("sepal_length") > 5)10.group_by("species")11.agg(pl.col("sepal_width").mean())12)13df = q1.collect(engine="streaming")14# --8<-- [end:streaming]1516"""17# --8<-- [start:createplan_query]18q1 = (19pl.scan_csv("docs/assets/data/iris.csv")20.filter(pl.col("sepal_length") > 5)21.group_by("species")22.agg(23mean_width=pl.col("sepal_width").mean(),24mean_width2=pl.col("sepal_width").sum() / pl.col("sepal_length").count(),25)26.show_graph(plan_stage="physical", engine="streaming")27)28# --8<-- [end:createplan_query]29"""3031# --8<-- [start:createplan]32import base6433import polars as pl3435q1 = (36pl.scan_csv("docs/assets/data/iris.csv")37.filter(pl.col("sepal_length") > 5)38.group_by("species")39.agg(40mean_width=pl.col("sepal_width").mean(),41mean_width2=pl.col("sepal_width").sum() / pl.col("sepal_length").count(),42)43)4445q1.show_graph(46plan_stage="physical",47engine="streaming",48show=False,49output_path="docs/assets/images/query_plan.png",50)51with open("docs/assets/images/query_plan.png", "rb") as f:52png = base64.b64encode(f.read()).decode()53print(f'<img src="data:image/png;base64, {png}"/>')54# --8<-- [end:createplan]555657