From 70bbe64cb1f588bb80f2ca8b432b9966a7bf0d00 Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Fri, 27 Mar 2020 08:03:56 -0600 Subject: [PATCH] Fix inconsistency in LogicalPlanBuilder api --- rust/datafusion/src/execution/context.rs | 2 +- rust/datafusion/src/logicalplan.rs | 8 ++++---- rust/datafusion/src/sql/planner.rs | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rust/datafusion/src/execution/context.rs b/rust/datafusion/src/execution/context.rs index 3ea06480b75..39d3a36139d 100644 --- a/rust/datafusion/src/execution/context.rs +++ b/rust/datafusion/src/execution/context.rs @@ -745,7 +745,7 @@ mod tests { vec![col(0)], vec![aggregate_expr("SUM", col(1), DataType::Int32)], )? - .project(&vec![col(0), col(1).alias("total_salary")])? + .project(vec![col(0), col(1).alias("total_salary")])? .build()?; let physical_plan = ctx.create_physical_plan(&Arc::new(plan), 1024)?; diff --git a/rust/datafusion/src/logicalplan.rs b/rust/datafusion/src/logicalplan.rs index 584165b9c47..be1ca2838ab 100644 --- a/rust/datafusion/src/logicalplan.rs +++ b/rust/datafusion/src/logicalplan.rs @@ -702,7 +702,7 @@ impl LogicalPlanBuilder { } /// Apply a projection - pub fn project(&self, expr: &Vec) -> Result { + pub fn project(&self, expr: Vec) -> Result { let input_schema = self.plan.schema(); let projected_expr = if expr.contains(&Expr::Wildcard) { let mut expr_vec = vec![]; @@ -792,7 +792,7 @@ mod tests { Some(vec![0, 3]), )? .filter(col(1).eq(&lit_str("CO")))? - .project(&vec![col(0)])? + .project(vec![col(0)])? .build()?; // prove that a plan can be passed to a thread @@ -813,7 +813,7 @@ mod tests { Some(vec![0, 3]), )? .filter(col(1).eq(&lit_str("CO")))? - .project(&vec![col(0)])? + .project(vec![col(0)])? .build()?; let expected = "Projection: #0\n \ @@ -837,7 +837,7 @@ mod tests { vec![col(0)], vec![aggregate_expr("SUM", col(1), DataType::Int32)], )? - .project(&vec![col(0), col(1).alias("total_salary")])? + .project(vec![col(0), col(1).alias("total_salary")])? .build()?; let expected = "Projection: #0, #1 AS total_salary\ diff --git a/rust/datafusion/src/sql/planner.rs b/rust/datafusion/src/sql/planner.rs index 709bd08e411..714be1ebd0f 100644 --- a/rust/datafusion/src/sql/planner.rs +++ b/rust/datafusion/src/sql/planner.rs @@ -92,7 +92,7 @@ impl SqlToRel { let plan = if group_by.is_some() || aggr_expr.len() > 0 { self.aggregate(&plan, projection_expr, group_by, aggr_expr)? } else { - self.project(&plan, &projection_expr)? + self.project(&plan, projection_expr)? }; // apply ORDER BY @@ -140,7 +140,7 @@ impl SqlToRel { } /// Wrap a plan in a projection - fn project(&self, input: &LogicalPlan, expr: &Vec) -> Result { + fn project(&self, input: &LogicalPlan, expr: Vec) -> Result { LogicalPlanBuilder::from(input).project(expr)?.build() } @@ -200,7 +200,7 @@ impl SqlToRel { if projection_needed { self.project( &plan, - &projected_fields.iter().map(|i| Expr::Column(*i)).collect(), + projected_fields.iter().map(|i| Expr::Column(*i)).collect(), ) } else { Ok(plan)