Print the optimized or non-optimized plans of LazyFrame
Description
$describe_plan()
shows the query
in the format that polars
understands.
$describe_optimized_plan()
shows
the optimized query plan that polars
will execute when
$collect()
is called. It is
possible that both plans are identical if polars
doesn’t
find any way to optimize the query.
Usage
<LazyFrame>$describe_optimized_plan()
LazyFrame_describe_plan()
Value
This only prints the plan in the console, it doesn’t return any value.
Examples
library(polars)
lazy_frame = pl$LazyFrame(iris)
# Prepare your query
lazy_query = lazy_frame$sort("Species")$filter(pl$col("Species") != "setosa")
# This is the query as `polars` understands it
lazy_query$describe_plan()
#> FILTER [(col("Species")) != (String(setosa))] FROM
#> SORT BY [col("Species")]
#> DF ["Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"]; PROJECT */5 COLUMNS; SELECTION: None
#> $ok
#> NULL
#>
#> $err
#> NULL
#>
#> attr(,"class")
#> [1] "extendr_result"
# This is the query after `polars` optimizes it: instead of sorting first and
# then filtering, it is faster to filter first and then sort the rest.
lazy_query$describe_optimized_plan()
#> SORT BY [col("Species")]
#> DF ["Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"]; PROJECT */5 COLUMNS; SELECTION: [(col("Species")) != (String(setosa))]