You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "aprimadi (via GitHub)" <gi...@apache.org> on 2023/05/02 03:21:26 UTC

[GitHub] [arrow-datafusion] aprimadi commented on issue #6179: Implement expression simplification for filtering (vs generically)

aprimadi commented on issue #6179:
URL: https://github.com/apache/arrow-datafusion/issues/6179#issuecomment-1530815784

   # Background
   
   AFAIK, currently filter expressions can occur in three types of LogicalPlan: TableScan, Filter, and Join. In Join LogicalPlan, expressions can occur in either ON clause or optional FILTER clause but the current expr simplifier rule doesn't have any context of where the expression occurs, i.e. we want to optimize `FILTER` expr in Join logical plan but not in `ON` clause. So I propose to add ExprContext that can be passed to the expr simplifier.
   
   # Proposed API Change
   
   I think this requires adding an ExprContext struct which has the following fields:
   ```rust
   pub struct ExprContext {
       in_filter: bool,
   }
   ```
   
   And also change `LogicalPlan::inspect_expressions` to take a function as an argument that has the following signature:
   
   ```rust
   F: FnMut(&Expr, ExprContext) -> Result<(), E>
   ```
   
   And add another public API to LogicalPlan with the following function signature:
   
   ```rust
   pub fn expressions_with_context(self: &LogicalPlan) -> Vec<(Expr, ExprContext)>
   ```
   
   # Alternative
   
   Since OptimizerRule takes LogicalPlan as input, perhaps we don't need to modify/add public LogicalPlan API and keeps the implementation detail encapsulated in `SimplifyExpressions`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org