@@ -446,59 +446,60 @@ lazyframe__profile <- function(
446446# ' lazy_query <- lazy_frame$sort("Species")$filter(pl$col("Species") != "setosa")
447447# '
448448# ' # This is the query that was written by the user, without any optimizations
449- # ' # (use cat () for better printing)
450- # ' lazy_query$explain(optimized = FALSE) |> cat ()
449+ # ' # (use writeLines () for better printing)
450+ # ' lazy_query$explain(optimized = FALSE) |> writeLines ()
451451# '
452452# ' # This is the query after `polars` optimizes it: instead of sorting first and
453453# ' # then filtering, it is faster to filter first and then sort the rest.
454- # ' lazy_query$explain() |> cat()
454+ # ' lazy_query$explain() |> writeLines()
455+ # '
456+ # ' # You can disable specific optimizations.
457+ # ' lazy_query$explain(
458+ # ' optimizations = pl$QueryOptFlags(predicate_pushdown = FALSE)
459+ # ' ) |>
460+ # ' writeLines()
455461# '
456462# ' # Also possible to see this as tree format
457- # ' lazy_query$explain(format = "tree") |> cat ()
463+ # ' lazy_query$explain(format = "tree") |> writeLines ()
458464lazyframe__explain <- function (
459465 ... ,
460466 format = c(" plain" , " tree" ),
467+ engine = c(" auto" , " in-memory" , " streaming" ),
461468 optimized = TRUE ,
462- type_coercion = TRUE ,
463- `_type_check` = TRUE ,
464- predicate_pushdown = TRUE ,
465- projection_pushdown = TRUE ,
466- simplify_expression = TRUE ,
467- slice_pushdown = TRUE ,
468- comm_subplan_elim = TRUE ,
469- comm_subexpr_elim = TRUE ,
470- cluster_with_columns = TRUE ,
471- collapse_joins = deprecated(),
472- `_check_order` = TRUE
469+ optimizations = QueryOptFlags(),
470+ type_coercion = deprecated(),
471+ predicate_pushdown = deprecated(),
472+ projection_pushdown = deprecated(),
473+ simplify_expression = deprecated(),
474+ slice_pushdown = deprecated(),
475+ comm_subplan_elim = deprecated(),
476+ comm_subexpr_elim = deprecated(),
477+ cluster_with_columns = deprecated(),
478+ collapse_joins = deprecated()
473479) {
474480 wrap({
475481 check_dots_empty0(... )
476482
477483 format <- arg_match0(format , c(" plain" , " tree" ))
484+ engine <- arg_match0(engine , c(" auto" , " in-memory" , " streaming" ))
485+ check_is_S7(optimizations , QueryOptFlags )
478486
479- if (is_present(collapse_joins )) {
480- deprecate_warn(
481- c(
482- `!` = sprintf(" %s is deprecated." , format_arg(" collapse_joins" )),
483- `i` = sprintf(" Use %s instead." , format_arg(" predicate_pushdown" ))
484- )
485- )
486- }
487+ optimizations <- forward_old_opt_flags(
488+ optimizations ,
489+ type_coercion = type_coercion ,
490+ predicate_pushdown = predicate_pushdown ,
491+ projection_pushdown = projection_pushdown ,
492+ simplify_expression = simplify_expression ,
493+ slice_pushdown = slice_pushdown ,
494+ comm_subplan_elim = comm_subplan_elim ,
495+ comm_subexpr_elim = comm_subexpr_elim ,
496+ cluster_with_columns = cluster_with_columns ,
497+ collapse_joins = collapse_joins
498+ )
487499
488500 if (isTRUE(optimized )) {
489- ldf <- self $ `_ldf` $ optimization_toggle(
490- type_coercion = type_coercion ,
491- `_type_check` = `_type_check` ,
492- predicate_pushdown = predicate_pushdown ,
493- projection_pushdown = projection_pushdown ,
494- simplify_expression = simplify_expression ,
495- slice_pushdown = slice_pushdown ,
496- comm_subplan_elim = comm_subplan_elim ,
497- comm_subexpr_elim = comm_subexpr_elim ,
498- cluster_with_columns = cluster_with_columns ,
499- `_check_order` = `_check_order` ,
500- `_eager` = FALSE
501- )
501+ prop(optimizations , " streaming" , check = FALSE ) <- engine == " streaming"
502+ ldf <- self $ `_ldf` $ with_optimizations(optimizations )
502503
503504 if (format == " tree" ) {
504505 ldf $ describe_optimized_plan_tree()
0 commit comments