Explain multiple LazyFrames as if passed to pl$collect_all()
Description
Common Subplan Elimination is applied on the combined plan, meaning that diverging queries will run only once.
Usage
pl$explain_all(lazy_frames, ..., optimizations = pl\$QueryOptFlags())
Arguments
Value
A character value containing the query plan.
Examples
library("polars")
lf <- as_polars_lf(mtcars)$with_columns(sqrt_mpg = pl$col("mpg")$sqrt())
cyl_4 <- lf$filter(pl$col("cyl") == 4)
cyl_6 <- lf$filter(pl$col("cyl") == 6)
# Note that `sqrt_mpg` is present in the plans for `cyl_4` and `cyl_6` but
# only once in the plan produced by `pl$explain_all()`. This is because
# `pl$explain_all()` eliminates parts of the queries that are shared across
# multiple plans.
pl$explain_all(list(cyl_4, cyl_6)) |>
writeLines()
#> SINK_MULTIPLE
#> PLAN 0:
#> WITH_COLUMNS:
#> [col("mpg").sqrt().alias("sqrt_mpg")]
#> FILTER [(col("cyl")) == (4.0)]
#> FROM
#> DF ["mpg", "cyl", "disp", "hp", ...]; PROJECT */11 COLUMNS
#> PLAN 1:
#> WITH_COLUMNS:
#> [col("mpg").sqrt().alias("sqrt_mpg")]
#> FILTER [(col("cyl")) == (6.0)]
#> FROM
#> DF ["mpg", "cyl", "disp", "hp", ...]; PROJECT */11 COLUMNS
#> END SINK_MULTIPLE