Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-9619: [Rust] [DataFusion] Add predicate push-down #7880

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust/datafusion/README.md
Expand Up @@ -42,7 +42,7 @@ DataFusion includes a simple command-line interactive SQL utility. See the [CLI
- [x] SQL Query Planner
- [x] Query Optimizer
- [x] Projection push down
- [ ] Predicate push down
- [x] Predicate push down
- [x] Type coercion
- [x] Parallel query execution

Expand Down
5 changes: 4 additions & 1 deletion rust/datafusion/src/execution/context.rs
Expand Up @@ -45,7 +45,9 @@ use crate::execution::physical_plan::PhysicalPlanner;
use crate::logicalplan::{FunctionMeta, FunctionType, LogicalPlan, LogicalPlanBuilder};
use crate::optimizer::optimizer::OptimizerRule;
use crate::optimizer::projection_push_down::ProjectionPushDown;
use crate::optimizer::type_coercion::TypeCoercionRule;
use crate::optimizer::{
filter_push_down::FilterPushDown, type_coercion::TypeCoercionRule,
};
use crate::sql::{
parser::{DFParser, FileType},
planner::{SchemaProvider, SqlToRel},
Expand Down Expand Up @@ -335,6 +337,7 @@ impl ExecutionContext {
pub fn optimize(&self, plan: &LogicalPlan) -> Result<LogicalPlan> {
let rules: Vec<Box<dyn OptimizerRule>> = vec![
Box::new(ProjectionPushDown::new()),
Box::new(FilterPushDown::new()),
Box::new(TypeCoercionRule::new(
self.state
.lock()
Expand Down
9 changes: 9 additions & 0 deletions rust/datafusion/src/logicalplan.rs
Expand Up @@ -509,6 +509,15 @@ fn binary_expr(l: Expr, op: Operator, r: Expr) -> Expr {
}
}

/// return a new expression with a logical AND
pub fn and(left: &Expr, right: &Expr) -> Expr {
Expr::BinaryExpr {
left: Box::new(left.clone()),
op: Operator::And,
right: Box::new(right.clone()),
}
}

/// Create a column expression based on a column name
pub fn col(name: &str) -> Expr {
Expr::Column(name.to_owned())
Expand Down