@@ -446,59 +446,54 @@ 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 ()
455455# '
456456# ' # Also possible to see this as tree format
457- # ' lazy_query$explain(format = "tree") |> cat ()
457+ # ' lazy_query$explain(format = "tree") |> writeLines ()
458458lazyframe__explain <- function (
459459 ... ,
460460 format = c(" plain" , " tree" ),
461+ engine = c(" auto" , " in-memory" , " streaming" ),
461462 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
463+ optimizations = QueryOptFlags(),
464+ type_coercion = deprecated(),
465+ predicate_pushdown = deprecated(),
466+ projection_pushdown = deprecated(),
467+ simplify_expression = deprecated(),
468+ slice_pushdown = deprecated(),
469+ comm_subplan_elim = deprecated(),
470+ comm_subexpr_elim = deprecated(),
471+ cluster_with_columns = deprecated(),
472+ collapse_joins = deprecated()
473473) {
474474 wrap({
475475 check_dots_empty0(... )
476476
477477 format <- arg_match0(format , c(" plain" , " tree" ))
478+ engine <- arg_match0(engine , c(" auto" , " in-memory" , " streaming" ))
479+ check_is_S7(optimizations , QueryOptFlags )
478480
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- }
481+ optimizations <- forward_old_opt_flags(
482+ optimizations ,
483+ type_coercion = type_coercion ,
484+ predicate_pushdown = predicate_pushdown ,
485+ projection_pushdown = projection_pushdown ,
486+ simplify_expression = simplify_expression ,
487+ slice_pushdown = slice_pushdown ,
488+ comm_subplan_elim = comm_subplan_elim ,
489+ comm_subexpr_elim = comm_subexpr_elim ,
490+ cluster_with_columns = cluster_with_columns ,
491+ collapse_joins = collapse_joins
492+ )
487493
488494 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- )
495+ prop(optimizations , " streaming" , check = FALSE ) <- engine == " streaming"
496+ ldf <- self $ `_ldf` # TODO: with_optimizations
502497
503498 if (format == " tree" ) {
504499 ldf $ describe_optimized_plan_tree()
0 commit comments