Skip to content

PruningPredicate Use Physical not Logical Predicate #4695

Closed

Description

@tustvold

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

Related to #4693, currently PruningPredicate accepts a logical Expr which it then converts to a PhysicalExpr. The comments appear to indicate this at one point related to serialization. However, looking at the code in datafusion-proto, we appear to be able to serialize physical expressions.

Describe the solution you'd like

I would like PruningPredicate to be created with a PhysicalExpr instead of Expr, this would in turn mean ParquetExec would be created with PhysicalExpr instead of Expr.

Not only would this avoid issues like #4693 but would also be more consistent for the physical plan to contain PhysicalExpr, and not logical Expr

Describe alternatives you've considered

Additional context

This relates to #4629 which tracks making ExecutionProps a trait to ensure all stages of planning/execution take place against the same configuration.

FYI @alamb in case there is something fundamental I have missed here

Activity

  1. alamb commented on Dec 21, 2022

    @alamb
    Contributor

    I think using PhysicalExpr would be fine for pruning predicates.

    If we are going to rewrite pruning anyways, I think we should consider changing the approach -- rather than doing algebriac rewrite I would love to change it to a range analysis -- using the base that @isidentical has created (for predicate selectivity analysis)

  2. tustvold commented on Dec 21, 2022

    @tustvold
    ContributorAuthor

    This wouldn't require a rewrite, it already uses PhysicalExpr internally, it is just its external interface is Expr. This is the cause of the issue 😅

  3. tustvold commented on Dec 22, 2022

    @tustvold
    ContributorAuthor

    I didn't dig deep enough into the code, it is actually performing a rewrite of the Expr which would require a non-trivial rewrite to port to PhysicalExpr

  4. tustvold commented on Feb 22, 2023

    @tustvold
    ContributorAuthor

    I believe @crepererum plans to pick this one up

  5. alamb commented on Feb 23, 2023

    @alamb
    Contributor

    If anyone is going to significantly revamp the pruning predicate logic, I recommend to please coordinate with @mingmwang @ozankabak @metesynnada -- it turns out there is already another range analysis implementation (other than PruningPredicate) and we are in discussions about possibly adding a third: #5322 (comment)

    If possible it would be great to avoid investing a lot of time into PruningPredicate only to then have to do some other major surgery on it to avoid duplication with the range analysis

    The other two range analysis are based on PhysicalExpr

  6. crepererum commented on Feb 23, 2023

    @crepererum
    Contributor

    It's not really a revamp. It's mostly a straight-forward porting of the PruningPredicate and ParquetExec from logical to phys. expressions. I would like to perform this port first before compressing/de-duping the two implementations. I agree that ideally there should be a single way to express ranges etc.

  7. ozankabak commented on Feb 23, 2023

    @ozankabak
    Contributor

    Sounds good, if it is a straightforward porting it makes sense to do it early. We can subsequently merge them in the upcoming weeks as we mature the interval arithmetic library.

  8. added 3 commits that reference this issue on Feb 27, 2023
    c1aedad
    3dae660
    b909edf
  9. added a commit that references this issue on Mar 1, 2023
    03fbf9f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions