liurenjie1024 opened a new issue, #2633:
URL: https://github.com/apache/arrow-datafusion/issues/2633
There are some discussions about datafusion's optimizer framework in #440
and #1972. And I tried to build a framework based datafusion's expression
system with the following features:
1. Includes a heuristic optimizer that applies rules to plan iteratively in
different ways: top-down or bottom-up. The optimizer stops applying rules to
the plan until reaching a fixpoint or max iteration times.
2. Includes a cascades style cost-based optimizer framework.
3. Pattern matching and binding for rules.
Following is an example of removing limit rule, including patten definition
and rule implementation:
```
pattern(|op| matches!(op, Logical(LogicalLimit(_))))
.leaf(|op| matches!(op, Logical(LogicalProjection(_))))
.finish()
```
```
if let (Logical(LogicalLimit(limit1)), Logical(LogicalLimit(limit2))) =
(input.get_operator(&_ctx)?, input[0].get_operator(&_ctx)?)
{
let new_limit = min(limit1.limit(), limit2.limit());
let ret =
input[0].clone_with_inputs(Logical(LogicalLimit(Limit::new(new_limit))));
result.add(ret);
Ok(())
} else {
bail!("Pattern miss matched")
}
```
And the source code can be found here:
https://github.com/liurenjie1024/rust-opt-framework
Welcome to discuss and share your thoughts.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]