Skip to content

Plot the query plan

Source code

Description

This only returns the "dot" output that can be passed to other packages, such as DiagrammeR::grViz().

Usage

<LazyFrame>$to_dot(
  ...,
  optimized = TRUE,
  type_coercion = TRUE,
  predicate_pushdown = TRUE,
  projection_pushdown = TRUE,
  simplify_expression = TRUE,
  slice_pushdown = TRUE,
  comm_subplan_elim = TRUE,
  comm_subexpr_elim = TRUE,
  cluster_with_columns = TRUE,
  streaming = FALSE
)

Arguments

Not used..
optimized Optimize the query plan.
type_coercion Logical. Coerce types such that operations succeed and run on minimal required memory.
predicate_pushdown Logical. Applies filters as early as possible at scan level.
projection_pushdown Logical. Select only the columns that are needed at the scan level.
simplify_expression Logical. Various optimizations, such as constant folding and replacing expensive operations with faster alternatives.
slice_pushdown Logical. Only load the required slice from the scan level. Don’t materialize sliced outputs (e.g. join$head(10)).
comm_subplan_elim Logical. Will try to cache branching subplans that occur on self-joins or unions.
comm_subexpr_elim Logical. Common subexpressions will be cached and reused.
cluster_with_columns Combine sequential independent calls to with_columns().
streaming Logical. Run parts of the query in a streaming fashion (this is in an alpha state).

Value

A character vector

Examples

library("polars")

lf = pl$LazyFrame(
  a = c("a", "b", "a", "b", "b", "c"),
  b = 1:6,
  c = 6:1
)

query = lf$group_by("a", maintain_order = TRUE)$agg(
  pl$all()$sum()
)$sort(
  "a"
)

query$to_dot() |> cat()
#> graph  polars_query {
#>   p1 -- p2
#>   p2 -- p3
#>   p3[label="TABLE\nπ 3/3;\nσ None"]
#>   p2[label="AGG [col(\"b\").sum(), col(\"c\").sum()]\nBY\n[col(\"a\")]"]
#>   p1[label="SORT BY [col(\"a\")]"]
#> }
# You could print the graph by using DiagrammeR for example, with
# query$to_dot() |> DiagrammeR::grViz().