polars icon indicating copy to clipboard operation
polars copied to clipboard

describe_optimized_plan

Open braaannigan opened this issue 3 years ago • 6 comments

Having describe_plan and describe_optimized_plan is confusing for newcomers and verbose. Propose to deprecate these and replace them with something like:

def plan(
        optimized:bool = True,
        type_coercion: bool = True,
        predicate_pushdown: bool = True,
        projection_pushdown: bool = True,
        simplify_expression: bool = True,
        slice_pushdown: bool = True
)

braaannigan avatar Jul 05 '22 08:07 braaannigan

If combining the two functions I'd keep the name describe_plan (as it does indeed return a description of the plan, and it's what people are used to), adding the params as suggested (though don't need 'optimized'). Just plan is a bit ambiguous.

alexander-beedie avatar Jul 05 '22 08:07 alexander-beedie

If combining the two functions I'd keep the name describe_plan (as it does indeed return a description of the plan, and it's what people are used to), adding the params as suggested (though don't need 'optimized'). Just plan is a bit ambiguous.

Does it not need the optimized param to allow the non-optimized plan to be returned?

braaannigan avatar Jul 05 '22 09:07 braaannigan

Having describe_plan and describe_optimized_plan is confusing

I don't agree this is confusing. It does exactly what is says. The naming is a bit similar to rust where different functions are preferred over more arguments. Take for instance the is_sorted methods in rusts iterators: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.is_sorted.

Having more explicit function calls make code more readable IMO. You can create the same readability by only allowing keyword arguments/ which I am also in favor of. But either way, it will be a bit more verbose.

Which I think is good. As I like readable code.

ritchie46 avatar Jul 05 '22 10:07 ritchie46

Does it not need the optimized param to allow the non-optimized plan to be returned?

No; I believe it would just need all the other params set to False, as they are the optimizations.

alexander-beedie avatar Jul 05 '22 10:07 alexander-beedie

Having describe_plan and describe_optimized_plan is confusing I'm giving a workshop this week and find I'm having to say "ok, ignore this describe_plan if you want to know what's going to happen because it's not actually the plan"

braaannigan avatar Jul 05 '22 10:07 braaannigan

I'm giving a workshop this week and find I'm having to say "ok, ignore this describe_plan if you want to know what's going to happen because it's not actually the plan"

It does have merit. It is the query plan 'as is'. Comparing the two shows which optimizations polars does. We often have to compare them both.

ritchie46 avatar Jul 05 '22 11:07 ritchie46

This method is now called explain and it has a parameter optimized=True/False defaulting to True.

I believe this issue has been adequately addressed. If not, please open a new issue.

stinodego avatar Aug 02 '23 05:08 stinodego