From d74a6c6bcdf74f6f0492b7a4635595133e6b6522 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Sat, 13 Mar 2021 07:25:06 -0500 Subject: [PATCH 1/3] ARROW-11790: [Rust][DataFusion] RFC: Change builder signatures to take Vec rather than &[Expr] --- rust/datafusion/examples/simple_udf.rs | 2 +- rust/datafusion/src/dataframe.rs | 6 +-- rust/datafusion/src/execution/context.rs | 10 ++--- .../src/execution/dataframe_impl.rs | 8 ++-- rust/datafusion/src/logical_plan/builder.rs | 25 +++++++----- rust/datafusion/src/logical_plan/plan.rs | 4 +- .../src/optimizer/constant_folding.rs | 14 +++---- .../src/optimizer/filter_push_down.rs | 40 +++++++++---------- .../src/optimizer/limit_push_down.rs | 2 +- .../src/optimizer/projection_push_down.rs | 16 ++++---- rust/datafusion/src/physical_plan/planner.rs | 8 ++-- rust/datafusion/src/sql/planner.rs | 4 +- rust/datafusion/tests/custom_sources.rs | 2 +- 13 files changed, 72 insertions(+), 69 deletions(-) diff --git a/rust/datafusion/examples/simple_udf.rs b/rust/datafusion/examples/simple_udf.rs index d49aac48527..a9584bc9eb3 100644 --- a/rust/datafusion/examples/simple_udf.rs +++ b/rust/datafusion/examples/simple_udf.rs @@ -133,7 +133,7 @@ async fn main() -> Result<()> { let expr1 = pow.call(vec![col("a"), col("b")]); // equivalent to `'SELECT pow(a, b), pow(a, b) AS pow1 FROM t'` - let df = df.select(&[ + let df = df.select(vec![ expr, // alias so that they have different column names expr1.alias("pow1"), diff --git a/rust/datafusion/src/dataframe.rs b/rust/datafusion/src/dataframe.rs index ceb5ca65f5e..b1de04f80f1 100644 --- a/rust/datafusion/src/dataframe.rs +++ b/rust/datafusion/src/dataframe.rs @@ -75,11 +75,11 @@ pub trait DataFrame: Send + Sync { /// # fn main() -> Result<()> { /// let mut ctx = ExecutionContext::new(); /// let df = ctx.read_csv("tests/example.csv", CsvReadOptions::new())?; - /// let df = df.select(&[col("a") * col("b"), col("c")])?; + /// let df = df.select(vec![col("a") * col("b"), col("c")])?; /// # Ok(()) /// # } /// ``` - fn select(&self, expr: &[Expr]) -> Result>; + fn select(&self, expr: Vec) -> Result>; /// Filter a DataFrame to only include rows that match the specified filter expression. /// @@ -157,7 +157,7 @@ pub trait DataFrame: Send + Sync { /// let mut ctx = ExecutionContext::new(); /// let left = ctx.read_csv("tests/example.csv", CsvReadOptions::new())?; /// let right = ctx.read_csv("tests/example.csv", CsvReadOptions::new())? - /// .select(&[ + /// .select(vec![ /// col("a").alias("a2"), /// col("b").alias("b2"), /// col("c").alias("c2")])?; diff --git a/rust/datafusion/src/execution/context.rs b/rust/datafusion/src/execution/context.rs index caf09be708d..60e3624b678 100644 --- a/rust/datafusion/src/execution/context.rs +++ b/rust/datafusion/src/execution/context.rs @@ -834,7 +834,7 @@ mod tests { let table = ctx.table("test")?; let logical_plan = LogicalPlanBuilder::from(&table.to_logical_plan()) - .project(&[col("c2")])? + .project(vec![col("c2")])? .build()?; let optimized_plan = ctx.optimize(&logical_plan)?; @@ -886,7 +886,7 @@ mod tests { assert_eq!(schema.field_with_name("c1")?.is_nullable(), false); let plan = LogicalPlanBuilder::scan_empty("", schema.as_ref(), None)? - .project(&[col("c1")])? + .project(vec![col("c1")])? .build()?; let plan = ctx.optimize(&plan)?; @@ -917,7 +917,7 @@ mod tests { )?]]; let plan = LogicalPlanBuilder::scan_memory(partitions, schema, None)? - .project(&[col("b")])? + .project(vec![col("b")])? .build()?; assert_fields_eq(&plan, vec!["b"]); @@ -1548,7 +1548,7 @@ mod tests { let plan = LogicalPlanBuilder::scan_empty("", schema.as_ref(), None)? .aggregate(&[col("c1")], &[sum(col("c2"))])? - .project(&[col("c1"), col("SUM(c2)").alias("total_salary")])? + .project(vec![col("c1"), col("SUM(c2)").alias("total_salary")])? .build()?; let plan = ctx.optimize(&plan)?; @@ -1773,7 +1773,7 @@ mod tests { let t = ctx.table("t")?; let plan = LogicalPlanBuilder::from(&t.to_logical_plan()) - .project(&[ + .project(vec![ col("a"), col("b"), ctx.udf("my_add")?.call(vec![col("a"), col("b")]), diff --git a/rust/datafusion/src/execution/dataframe_impl.rs b/rust/datafusion/src/execution/dataframe_impl.rs index 3a0931d8ccc..97201c5a2d2 100644 --- a/rust/datafusion/src/execution/dataframe_impl.rs +++ b/rust/datafusion/src/execution/dataframe_impl.rs @@ -58,11 +58,11 @@ impl DataFrame for DataFrameImpl { .map(|name| self.plan.schema().field_with_unqualified_name(name)) .collect::>>()?; let expr: Vec = fields.iter().map(|f| col(f.name())).collect(); - self.select(&expr) + self.select(expr) } /// Create a projection based on arbitrary expressions - fn select(&self, expr_list: &[Expr]) -> Result> { + fn select(&self, expr_list: Vec) -> Result> { let plan = LogicalPlanBuilder::from(&self.plan) .project(expr_list)? .build()?; @@ -197,7 +197,7 @@ mod tests { fn select_expr() -> Result<()> { // build plan using Table API let t = test_table()?; - let t2 = t.select(&[col("c1"), col("c2"), col("c11")])?; + let t2 = t.select(vec![col("c1"), col("c2"), col("c11")])?; let plan = t2.to_logical_plan(); // build query using SQL @@ -315,7 +315,7 @@ mod tests { let f = df.registry(); - let df = df.select(&[f.udf("my_fn")?.call(vec![col("c12")])])?; + let df = df.select(vec![f.udf("my_fn")?.call(vec![col("c12")])])?; let plan = df.to_logical_plan(); // build query using SQL diff --git a/rust/datafusion/src/logical_plan/builder.rs b/rust/datafusion/src/logical_plan/builder.rs index 1f017b6f3c8..8ae80c3abf3 100644 --- a/rust/datafusion/src/logical_plan/builder.rs +++ b/rust/datafusion/src/logical_plan/builder.rs @@ -132,16 +132,19 @@ impl LogicalPlanBuilder { /// This function errors under any of the following conditions: /// * Two or more expressions have the same name /// * An invalid expression is used (e.g. a `sort` expression) - pub fn project(&self, expr: &[Expr]) -> Result { + pub fn project(&self, expr: Vec) -> Result { let input_schema = self.plan.schema(); let mut projected_expr = vec![]; - (0..expr.len()).for_each(|i| match &expr[i] { - Expr::Wildcard => { - (0..input_schema.fields().len()) - .for_each(|i| projected_expr.push(col(input_schema.field(i).name()))); - } - _ => projected_expr.push(expr[i].clone()), - }); + for e in expr { + match e { + Expr::Wildcard => { + (0..input_schema.fields().len()).for_each(|i| { + projected_expr.push(col(input_schema.field(i).name())) + }); + } + _ => projected_expr.push(e), + }; + } validate_unique_names("Projections", &projected_expr, input_schema)?; @@ -352,7 +355,7 @@ mod tests { Some(vec![0, 3]), )? .filter(col("state").eq(lit("CO")))? - .project(&[col("id")])? + .project(vec![col("id")])? .build()?; let expected = "Projection: #id\ @@ -372,7 +375,7 @@ mod tests { Some(vec![3, 4]), )? .aggregate(&[col("state")], &[sum(col("salary")).alias("total_salary")])? - .project(&[col("state"), col("total_salary")])? + .project(vec![col("state"), col("total_salary")])? .build()?; let expected = "Projection: #state, #total_salary\ @@ -421,7 +424,7 @@ mod tests { Some(vec![0, 3]), )? // two columns with the same name => error - .project(&[col("id"), col("first_name").alias("id")]); + .project(vec![col("id"), col("first_name").alias("id")]); match plan { Err(DataFusionError::Plan(e)) => { diff --git a/rust/datafusion/src/logical_plan/plan.rs b/rust/datafusion/src/logical_plan/plan.rs index 8aec9e668a3..c9c483a042c 100644 --- a/rust/datafusion/src/logical_plan/plan.rs +++ b/rust/datafusion/src/logical_plan/plan.rs @@ -762,7 +762,7 @@ mod tests { .unwrap() .filter(col("state").eq(lit("CO"))) .unwrap() - .project(&[col("id")]) + .project(vec![col("id")]) .unwrap() .build() .unwrap() @@ -1063,7 +1063,7 @@ mod tests { .unwrap() .filter(col("state").eq(lit("CO"))) .unwrap() - .project(&[col("id")]) + .project(vec![col("id")]) .unwrap() .build() .unwrap() diff --git a/rust/datafusion/src/optimizer/constant_folding.rs b/rust/datafusion/src/optimizer/constant_folding.rs index ab39daee276..c1f96a16956 100644 --- a/rust/datafusion/src/optimizer/constant_folding.rs +++ b/rust/datafusion/src/optimizer/constant_folding.rs @@ -468,7 +468,7 @@ mod tests { let plan = LogicalPlanBuilder::from(&table_scan) .filter(col("b").eq(lit(true)))? .filter(col("c").eq(lit(false)))? - .project(&[col("a")])? + .project(vec![col("a")])? .build()?; let expected = "\ @@ -488,7 +488,7 @@ mod tests { .filter(col("b").not_eq(lit(true)))? .filter(col("c").not_eq(lit(false)))? .limit(1)? - .project(&[col("a")])? + .project(vec![col("a")])? .build()?; let expected = "\ @@ -507,7 +507,7 @@ mod tests { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) .filter(col("b").not_eq(lit(true)).and(col("c").eq(lit(true))))? - .project(&[col("a")])? + .project(vec![col("a")])? .build()?; let expected = "\ @@ -524,7 +524,7 @@ mod tests { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) .filter(col("b").not_eq(lit(true)).or(col("c").eq(lit(false))))? - .project(&[col("a")])? + .project(vec![col("a")])? .build()?; let expected = "\ @@ -541,7 +541,7 @@ mod tests { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) .filter(col("b").eq(lit(false)).not())? - .project(&[col("a")])? + .project(vec![col("a")])? .build()?; let expected = "\ @@ -557,7 +557,7 @@ mod tests { fn optimize_plan_support_projection() -> Result<()> { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a"), col("d"), col("b").eq(lit(false))])? + .project(vec![col("a"), col("d"), col("b").eq(lit(false))])? .build()?; let expected = "\ @@ -572,7 +572,7 @@ mod tests { fn optimize_plan_support_aggregate() -> Result<()> { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a"), col("c"), col("b")])? + .project(vec![col("a"), col("c"), col("b")])? .aggregate( &[col("a"), col("c")], &[max(col("b").eq(lit(true))), min(col("b"))], diff --git a/rust/datafusion/src/optimizer/filter_push_down.rs b/rust/datafusion/src/optimizer/filter_push_down.rs index 0ae8e06015d..5013e83baf8 100644 --- a/rust/datafusion/src/optimizer/filter_push_down.rs +++ b/rust/datafusion/src/optimizer/filter_push_down.rs @@ -451,7 +451,7 @@ mod tests { fn filter_before_projection() -> Result<()> { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a"), col("b")])? + .project(vec![col("a"), col("b")])? .filter(col("a").eq(lit(1i64)))? .build()?; // filter is before projection @@ -467,7 +467,7 @@ mod tests { fn filter_after_limit() -> Result<()> { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a"), col("b")])? + .project(vec![col("a"), col("b")])? .limit(10)? .filter(col("a").eq(lit(1i64)))? .build()?; @@ -485,8 +485,8 @@ mod tests { fn filter_jump_2_plans() -> Result<()> { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a"), col("b"), col("c")])? - .project(&[col("c"), col("b")])? + .project(vec![col("a"), col("b"), col("c")])? + .project(vec![col("c"), col("b")])? .filter(col("a").eq(lit(1i64)))? .build()?; // filter is before double projection @@ -536,7 +536,7 @@ mod tests { fn alias() -> Result<()> { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a").alias("b"), col("c")])? + .project(vec![col("a").alias("b"), col("c")])? .filter(col("b").eq(lit(1i64)))? .build()?; // filter is before projection @@ -569,7 +569,7 @@ mod tests { fn complex_expression() -> Result<()> { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[ + .project(vec![ add(multiply(col("a"), lit(2)), col("c")).alias("b"), col("c"), ])? @@ -599,12 +599,12 @@ mod tests { fn complex_plan() -> Result<()> { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[ + .project(vec![ add(multiply(col("a"), lit(2)), col("c")).alias("b"), col("c"), ])? // second projection where we rename columns, just to make it difficult - .project(&[multiply(col("b"), lit(3)).alias("a"), col("c")])? + .project(vec![multiply(col("b"), lit(3)).alias("a"), col("c")])? .filter(col("a").eq(lit(1i64)))? .build()?; @@ -635,7 +635,7 @@ mod tests { // the aggregation allows one filter to pass (b), and the other one to not pass (SUM(c)) let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a").alias("b"), col("c")])? + .project(vec![col("a").alias("b"), col("c")])? .aggregate(&[col("b")], &[sum(col("c"))])? .filter(col("b").gt(lit(10i64)))? .filter(col("SUM(c)").gt(lit(10i64)))? @@ -671,7 +671,7 @@ mod tests { // the aggregation allows one filter to pass (b), and the other one to not pass (SUM(c)) let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a").alias("b"), col("c")])? + .project(vec![col("a").alias("b"), col("c")])? .aggregate(&[col("b")], &[sum(col("c"))])? .filter(and( col("SUM(c)").gt(lit(10i64)), @@ -706,10 +706,10 @@ mod tests { fn double_limit() -> Result<()> { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a"), col("b")])? + .project(vec![col("a"), col("b")])? .limit(20)? .limit(10)? - .project(&[col("a"), col("b")])? + .project(vec![col("a"), col("b")])? .filter(col("a").eq(lit(1i64)))? .build()?; // filter does not just any of the limits @@ -729,10 +729,10 @@ mod tests { fn filter_2_breaks_limits() -> Result<()> { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a")])? + .project(vec![col("a")])? .filter(col("a").lt_eq(lit(1i64)))? .limit(1)? - .project(&[col("a")])? + .project(vec![col("a")])? .filter(col("a").gt_eq(lit(1i64)))? .build()?; // Should be able to move both filters below the projections @@ -768,7 +768,7 @@ mod tests { .limit(1)? .filter(col("a").lt_eq(lit(1i64)))? .filter(col("a").gt_eq(lit(1i64)))? - .project(&[col("a")])? + .project(vec![col("a")])? .build()?; // not part of the test @@ -820,7 +820,7 @@ mod tests { let table_scan = test_table_scan()?; let left = LogicalPlanBuilder::from(&table_scan).build()?; let right = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a")])? + .project(vec![col("a")])? .build()?; let plan = LogicalPlanBuilder::from(&left) .join(&right, JoinType::Inner, &["a"], &["a"])? @@ -855,10 +855,10 @@ mod tests { fn filter_join_on_common_dependent() -> Result<()> { let table_scan = test_table_scan()?; let left = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a"), col("c")])? + .project(vec![col("a"), col("c")])? .build()?; let right = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a"), col("b")])? + .project(vec![col("a"), col("b")])? .build()?; let plan = LogicalPlanBuilder::from(&left) .join(&right, JoinType::Inner, &["a"], &["a"])? @@ -889,10 +889,10 @@ mod tests { fn filter_join_on_one_side() -> Result<()> { let table_scan = test_table_scan()?; let left = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a"), col("b")])? + .project(vec![col("a"), col("b")])? .build()?; let right = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a"), col("c")])? + .project(vec![col("a"), col("c")])? .build()?; let plan = LogicalPlanBuilder::from(&left) .join(&right, JoinType::Inner, &["a"], &["a"])? diff --git a/rust/datafusion/src/optimizer/limit_push_down.rs b/rust/datafusion/src/optimizer/limit_push_down.rs index 67af69bc6b4..20adff0287e 100644 --- a/rust/datafusion/src/optimizer/limit_push_down.rs +++ b/rust/datafusion/src/optimizer/limit_push_down.rs @@ -127,7 +127,7 @@ mod test { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a")])? + .project(vec![col("a")])? .limit(1000)? .build()?; diff --git a/rust/datafusion/src/optimizer/projection_push_down.rs b/rust/datafusion/src/optimizer/projection_push_down.rs index 59c7b10d15e..48965362eee 100644 --- a/rust/datafusion/src/optimizer/projection_push_down.rs +++ b/rust/datafusion/src/optimizer/projection_push_down.rs @@ -352,7 +352,7 @@ mod tests { let table_scan = test_table_scan()?; let projection = LogicalPlanBuilder::from(&table_scan) - .project(&[Expr::Cast { + .project(vec![Expr::Cast { expr: Box::new(col("c")), data_type: DataType::Float64, }])? @@ -373,7 +373,7 @@ mod tests { assert_fields_eq(&table_scan, vec!["a", "b", "c"]); let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("a"), col("b")])? + .project(vec![col("a"), col("b")])? .build()?; assert_fields_eq(&plan, vec!["a", "b"]); @@ -393,7 +393,7 @@ mod tests { assert_fields_eq(&table_scan, vec!["a", "b", "c"]); let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("c"), col("a")])? + .project(vec![col("c"), col("a")])? .limit(5)? .build()?; @@ -422,7 +422,7 @@ mod tests { fn table_scan_with_literal_projection() -> Result<()> { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[lit(1_i64), lit(2_i64)])? + .project(vec![lit(1_i64), lit(2_i64)])? .build()?; let expected = "Projection: Int64(1), Int64(2)\ \n TableScan: test projection=Some([0])"; @@ -439,7 +439,7 @@ mod tests { // we never use "b" in the first projection => remove it let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("c"), col("a"), col("b")])? + .project(vec![col("c"), col("a"), col("b")])? .filter(col("c").gt(lit(1)))? .aggregate(&[col("c")], &[max(col("a"))])? .build()?; @@ -466,8 +466,8 @@ mod tests { // there is no need for the first projection let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("b")])? - .project(&[lit(1).alias("a")])? + .project(vec![col("b")])? + .project(vec![lit(1).alias("a")])? .build()?; assert_fields_eq(&plan, vec!["a"]); @@ -512,7 +512,7 @@ mod tests { let plan = LogicalPlanBuilder::from(&table_scan) .aggregate(&[col("a"), col("c")], &[max(col("b")), min(col("b"))])? .filter(col("c").gt(lit(1)))? - .project(&[col("c"), col("a"), col("MAX(b)")])? + .project(vec![col("c"), col("a"), col("MAX(b)")])? .build()?; assert_fields_eq(&plan, vec!["c", "a", "MAX(b)"]); diff --git a/rust/datafusion/src/physical_plan/planner.rs b/rust/datafusion/src/physical_plan/planner.rs index ef1cb1160a8..05505a8c74c 100644 --- a/rust/datafusion/src/physical_plan/planner.rs +++ b/rust/datafusion/src/physical_plan/planner.rs @@ -778,7 +778,7 @@ mod tests { let logical_plan = LogicalPlanBuilder::scan_csv(&path, options, None)? // filter clause needs the type coercion rule applied .filter(col("c7").lt(lit(5_u8)))? - .project(&[col("c1"), col("c2")])? + .project(vec![col("c1"), col("c2")])? .aggregate(&[col("c1")], &[sum(col("c2"))])? .sort(&[col("c1").sort(true, true)])? .limit(10)? @@ -851,7 +851,7 @@ mod tests { ]; for case in cases { let logical_plan = LogicalPlanBuilder::scan_csv(&path, options, None)? - .project(&[case.clone()]); + .project(vec![case.clone()]); let message = format!( "Expression {:?} expected to error due to impossible coercion", case @@ -941,7 +941,7 @@ mod tests { let logical_plan = LogicalPlanBuilder::scan_csv(&path, options, None)? // filter clause needs the type coercion rule applied .filter(col("c12").lt(lit(0.05)))? - .project(&[col("c1").in_list(list, false)])? + .project(vec![col("c1").in_list(list, false)])? .build()?; let execution_plan = plan(&logical_plan)?; // verify that the plan correctly adds cast from Int64(1) to Utf8 @@ -956,7 +956,7 @@ mod tests { let logical_plan = LogicalPlanBuilder::scan_csv(&path, options, None)? // filter clause needs the type coercion rule applied .filter(col("c12").lt(lit(0.05)))? - .project(&[col("c12").lt_eq(lit(0.025)).in_list(list, false)])? + .project(vec![col("c12").lt_eq(lit(0.025)).in_list(list, false)])? .build()?; let execution_plan = plan(&logical_plan); diff --git a/rust/datafusion/src/sql/planner.rs b/rust/datafusion/src/sql/planner.rs index f985b506536..a44eeb5c8b9 100644 --- a/rust/datafusion/src/sql/planner.rs +++ b/rust/datafusion/src/sql/planner.rs @@ -501,7 +501,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { plan }; - self.project(&plan, &select_exprs_post_aggr, false) + self.project(&plan, select_exprs_post_aggr, false) } /// Returns the `Expr`'s corresponding to a SQL query's SELECT expressions. @@ -532,7 +532,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { fn project( &self, input: &LogicalPlan, - expr: &[Expr], + expr: Vec, force: bool, ) -> Result { self.validate_schema_satisfies_exprs(&input.schema(), &expr)?; diff --git a/rust/datafusion/tests/custom_sources.rs b/rust/datafusion/tests/custom_sources.rs index 0bc699ceffb..a00dd6ac282 100644 --- a/rust/datafusion/tests/custom_sources.rs +++ b/rust/datafusion/tests/custom_sources.rs @@ -162,7 +162,7 @@ async fn custom_source_dataframe() -> Result<()> { let table = ctx.read_table(Arc::new(CustomTableProvider))?; let logical_plan = LogicalPlanBuilder::from(&table.to_logical_plan()) - .project(&[col("c2")])? + .project(vec![col("c2")])? .build()?; let optimized_plan = ctx.optimize(&logical_plan)?; From fb2dae9d798aa92575e9d7c0c44815e298116fa2 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Sat, 13 Mar 2021 07:35:43 -0500 Subject: [PATCH 2/3] fixup tpch --- rust/benchmarks/src/bin/tpch.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/benchmarks/src/bin/tpch.rs b/rust/benchmarks/src/bin/tpch.rs index b0a6cedd172..3bfba128688 100644 --- a/rust/benchmarks/src/bin/tpch.rs +++ b/rust/benchmarks/src/bin/tpch.rs @@ -1636,7 +1636,7 @@ mod tests { .file_extension(".out"); let df = ctx.read_csv(&format!("{}/answers/q{}.out", path, n), options)?; let df = df.select( - &get_answer_schema(n) + get_answer_schema(n) .fields() .iter() .map(|field| { From deb15be16a631f27dc89ba1b0fcfbf4385fbcc2b Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Tue, 16 Mar 2021 17:14:04 -0400 Subject: [PATCH 3/3] Fixup logical conflict --- rust/datafusion/src/optimizer/projection_push_down.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/datafusion/src/optimizer/projection_push_down.rs b/rust/datafusion/src/optimizer/projection_push_down.rs index 48965362eee..2ce09b18656 100644 --- a/rust/datafusion/src/optimizer/projection_push_down.rs +++ b/rust/datafusion/src/optimizer/projection_push_down.rs @@ -487,8 +487,8 @@ mod tests { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(&table_scan) - .project(&[col("b")])? - .project(&[lit(1).alias("a")])? + .project(vec![col("b")])? + .project(vec![lit(1).alias("a")])? .build()?; let optimized_plan1 = optimize(&plan).expect("failed to optimize plan");