Skip to content

Plot the query plan

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,
  `_type_check` = 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,
  collapse_joins = TRUE,
  streaming = FALSE,
  `_check_order` = TRUE
)

Arguments

Not used..
optimized Optimize the query plan.
type_coercion A logical, indicats type coercion optimization.
predicate_pushdown A logical, indicats predicate pushdown optimization.
projection_pushdown A logical, indicats projection pushdown optimization.
simplify_expression A logical, indicats simplify expression optimization.
slice_pushdown A logical, indicats slice pushdown optimization.
comm_subplan_elim A logical, indicats tring to cache branching subplans that occur on self-joins or unions.
comm_subexpr_elim A logical, indicats tring to cache common subexpressions.
cluster_with_columns A logical, indicats to combine sequential independent calls to with_columns.
collapse_joins Collapse a join and filters into a faster join.
streaming [Deprecated] A logical. If TRUE, process the query in batches to handle larger-than-memory data. If FALSE (default), the entire query is processed in a single batch. Note that streaming mode is considered unstable. It may be changed at any point without it being considered a breaking change.
\_check_order, \_type_check For internal use only.

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"]
#>   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().