Skip to content

Commit

Permalink
fix[python]: add missing cse param to LazyFrame "profile" method (#5054)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie committed Oct 1, 2022
1 parent 358cf31 commit b5b7cea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions py-polars/polars/internals/lazyframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ def profile(
simplify_expression: bool = True,
no_optimization: bool = False,
slice_pushdown: bool = True,
common_subplan_elimination: bool = True,
) -> tuple[pli.DataFrame, pli.DataFrame]:
"""
Profile a LazyFrame.
Expand All @@ -779,6 +780,8 @@ def profile(
Turn off (certain) optimizations.
slice_pushdown
Slice pushdown optimization.
common_subplan_elimination
Will try to cache branching subplans that occur on self-joins or unions.
Returns
-------
Expand All @@ -795,6 +798,7 @@ def profile(
projection_pushdown,
simplify_expression,
slice_pushdown,
common_subplan_elimination,
)
df, timings = ldf.profile()
return pli.wrap_df(df), pli.wrap_df(timings)
Expand Down
12 changes: 12 additions & 0 deletions py-polars/tests/unit/test_lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ def test_lazy() -> None:
# test if pl.list is available, this is `to_list` re-exported as list
df.groupby("a").agg(pl.list("b"))

# profile lazyframe operation/plan
df.lazy().groupby("a").agg(pl.list("b")).profile()
# ┌──────────────┬───────┬─────┐
# │ node ┆ start ┆ end │
# │ --- ┆ --- ┆ --- │
# │ str ┆ u64 ┆ u64 │
# ╞══════════════╪═══════╪═════╡
# │ optimization ┆ 0 ┆ 6 │
# ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌┤
# │ groupby(a) ┆ 6 ┆ 230 │
# └──────────────┴───────┴─────┘


def test_lazyframe_membership_operator() -> None:
ldf = pl.DataFrame({"name": ["Jane", "John"], "age": [20, 30]}).lazy()
Expand Down

0 comments on commit b5b7cea

Please sign in to comment.