diff --git a/optd-adaptive-demo/src/bin/optd-adaptive-three-join.rs b/optd-adaptive-demo/src/bin/optd-adaptive-three-join.rs index 3217b890..9d17ba7d 100644 --- a/optd-adaptive-demo/src/bin/optd-adaptive-three-join.rs +++ b/optd-adaptive-demo/src/bin/optd-adaptive-three-join.rs @@ -84,7 +84,7 @@ async fn main() -> Result<()> { ) .await; - let mut data_progress = vec![5; 3]; + let mut data_progress = [5; 3]; let mut iter = 0; fn do_insert(table: usize, begin: usize, end: usize, repeat: usize) -> String { diff --git a/optd-core/src/cascades/memo.rs b/optd-core/src/cascades/memo.rs index 44289589..3f406f42 100644 --- a/optd-core/src/cascades/memo.rs +++ b/optd-core/src/cascades/memo.rs @@ -167,7 +167,7 @@ impl Memo { unreachable!("not found {}", memo_node) }; let group_id = self.get_group_id_of_expr_id(expr_id); - return (group_id, expr_id); + (group_id, expr_id) } fn infer_properties( diff --git a/optd-core/src/cascades/optimizer.rs b/optd-core/src/cascades/optimizer.rs index 6cee8223..c3871cdd 100644 --- a/optd-core/src/cascades/optimizer.rs +++ b/optd-core/src/cascades/optimizer.rs @@ -214,9 +214,9 @@ impl CascadesOptimizer { group_id: GroupId, mut on_produce: impl FnMut(RelNodeRef, GroupId) -> RelNodeRef, ) -> Result> { - Ok(self + self .memo - .get_best_group_binding(group_id, &mut on_produce)?) + .get_best_group_binding(group_id, &mut on_produce) } fn fire_optimize_tasks(&mut self, group_id: GroupId) -> Result<()> { diff --git a/optd-core/src/cascades/tasks/optimize_inputs.rs b/optd-core/src/cascades/tasks/optimize_inputs.rs index fa260db5..2a3368f6 100644 --- a/optd-core/src/cascades/tasks/optimize_inputs.rs +++ b/optd-core/src/cascades/tasks/optimize_inputs.rs @@ -153,7 +153,7 @@ impl Task for OptimizeInputsTask { }; if self.should_terminate( cost.sum( - &cost.compute_cost(&expr.typ, &expr.data, &input_cost, Some(context.clone())), + &cost.compute_cost(&expr.typ, &expr.data, &input_cost, Some(context)), &input_cost, ) .0[0], @@ -177,7 +177,7 @@ impl Task for OptimizeInputsTask { &expr.typ, &expr.data, &input_cost, - Some(context.clone()), + Some(context), ), &input_cost, ) @@ -248,7 +248,7 @@ impl Task for OptimizeInputsTask { &expr.typ, &expr.data, &input_cost, - Some(context.clone()), + Some(context), ), &input_cost, ), diff --git a/optd-core/src/heuristics/optimizer.rs b/optd-core/src/heuristics/optimizer.rs index 7886f5ae..4a081a0d 100644 --- a/optd-core/src/heuristics/optimizer.rs +++ b/optd-core/src/heuristics/optimizer.rs @@ -51,7 +51,7 @@ fn match_node( RuleMatcher::PickMany { pick_to } => { let res = pick.insert( *pick_to, - RelNode::new_list(node.children[idx..].to_vec()).into(), + RelNode::new_list(node.children[idx..].to_vec()), ); assert!(res.is_none(), "dup pick"); should_end = true; @@ -124,7 +124,7 @@ impl HeuristicsOptimizer { for rule in self.rules.as_ref() { let matcher = rule.matcher(); if let Some(picks) = match_and_pick(matcher, root_rel.clone()) { - let mut results = rule.apply(&self, picks); + let mut results = rule.apply(self, picks); assert_eq!(results.len(), 1); root_rel = results.remove(0).into(); } diff --git a/optd-datafusion-bridge/src/from_optd.rs b/optd-datafusion-bridge/src/from_optd.rs index eb259496..1feb614c 100644 --- a/optd-datafusion-bridge/src/from_optd.rs +++ b/optd-datafusion-bridge/src/from_optd.rs @@ -49,7 +49,7 @@ fn from_optd_schema(optd_schema: &OptdSchema) -> Schema { .0 .iter() .enumerate() - .map(|(i, typ)| Field::new(&format!("c{}", i), match_type(typ), false)) + .map(|(i, typ)| Field::new(format!("c{}", i), match_type(typ), false)) .collect(); Schema::new(fields) } @@ -108,7 +108,7 @@ impl OptdPlanContext<'_> { false, &args, &[], - &context, + context, "", )?) } diff --git a/optd-datafusion-bridge/src/into_optd.rs b/optd-datafusion-bridge/src/into_optd.rs index 1b0b6f80..2de6c0ce 100644 --- a/optd-datafusion-bridge/src/into_optd.rs +++ b/optd-datafusion-bridge/src/into_optd.rs @@ -72,7 +72,7 @@ impl OptdPlanContext<'_> { } ScalarValue::Int64(x) => { let x = x.as_ref().unwrap(); - Ok(ConstantExpr::int(*x as i64).into_expr()) + Ok(ConstantExpr::int(*x).into_expr()) } ScalarValue::Date32(x) => { let x = x.as_ref().unwrap(); @@ -97,8 +97,8 @@ impl OptdPlanContext<'_> { let when_then_expr = &x.when_then_expr; assert_eq!(when_then_expr.len(), 1); let (when_expr, then_expr) = &when_then_expr[0]; - let when_expr = self.into_optd_expr(&when_expr, context)?; - let then_expr = self.into_optd_expr(&then_expr, context)?; + let when_expr = self.into_optd_expr(when_expr, context)?; + let then_expr = self.into_optd_expr(then_expr, context)?; let else_expr = self.into_optd_expr(x.else_expr.as_ref().unwrap(), context)?; assert!(x.expr.is_none()); Ok(FuncExpr::new( @@ -226,20 +226,20 @@ impl OptdPlanContext<'_> { match node.filter { Some(DFExpr::Literal(ScalarValue::Boolean(Some(val)))) => { - return Ok(LogicalJoin::new( + Ok(LogicalJoin::new( left, right, ConstantExpr::bool(val).into_expr(), join_type, - )); + )) } None => { - return Ok(LogicalJoin::new( + Ok(LogicalJoin::new( left, right, ConstantExpr::bool(true).into_expr(), join_type, - )); + )) } _ => bail!("unsupported join filter: {:?}", node.filter), } diff --git a/optd-datafusion-repr/src/plan_nodes.rs b/optd-datafusion-repr/src/plan_nodes.rs index 37860d39..f47fe342 100644 --- a/optd-datafusion-repr/src/plan_nodes.rs +++ b/optd-datafusion-repr/src/plan_nodes.rs @@ -207,7 +207,7 @@ impl PlanNode { } pub fn from_group(rel_node: OptRelNodeRef) -> Self { - return Self(rel_node); + Self(rel_node) } } diff --git a/optd-datafusion-repr/src/rules/joins.rs b/optd-datafusion-repr/src/rules/joins.rs index 09591b62..a0314140 100644 --- a/optd-datafusion-repr/src/rules/joins.rs +++ b/optd-datafusion-repr/src/rules/joins.rs @@ -342,7 +342,8 @@ fn apply_projection_pull_up_join( .into_rel_node(), ); } - let expr = Expr::from_rel_node( + + Expr::from_rel_node( RelNode { typ: expr.typ.clone(), children, @@ -350,8 +351,7 @@ fn apply_projection_pull_up_join( } .into(), ) - .unwrap(); - expr + .unwrap() } let left = Arc::new(left.clone()); diff --git a/optd-sqlplannertest/src/bin/planner_test_apply.rs b/optd-sqlplannertest/src/bin/planner_test_apply.rs index f1436d70..50608bf4 100644 --- a/optd-sqlplannertest/src/bin/planner_test_apply.rs +++ b/optd-sqlplannertest/src/bin/planner_test_apply.rs @@ -6,7 +6,7 @@ use anyhow::Result; async fn main() -> Result<()> { sqlplannertest::planner_test_apply( Path::new(env!("CARGO_MANIFEST_DIR")).join("tests"), - || async { Ok(optd_sqlplannertest::DatafusionDb::new().await?) }, + || async { optd_sqlplannertest::DatafusionDb::new().await }, ) .await?; Ok(()) diff --git a/optd-sqlplannertest/src/lib.rs b/optd-sqlplannertest/src/lib.rs index 470c6625..a7cbff9d 100644 --- a/optd-sqlplannertest/src/lib.rs +++ b/optd-sqlplannertest/src/lib.rs @@ -108,7 +108,7 @@ impl DatafusionDb { /// Executes the `execute` task. async fn task_execute(&mut self, r: &mut String, sql: &str, with_logical: bool) -> Result<()> { use std::fmt::Write; - let result = self.execute(&sql, with_logical).await?; + let result = self.execute(sql, with_logical).await?; writeln!(r, "{}", result.into_iter().map(|x| x.join(" ")).join("\n"))?; writeln!(r)?; Ok(()) @@ -132,7 +132,7 @@ impl DatafusionDb { } else { "explain:".len() }; - for subtask in task[subtask_start_pos..].split(",") { + for subtask in task[subtask_start_pos..].split(',') { let subtask = subtask.trim(); if subtask == "logical_datafusion" { writeln!( diff --git a/optd-sqlplannertest/tests/planner_test.rs b/optd-sqlplannertest/tests/planner_test.rs index 806b6f0d..f870ce7c 100644 --- a/optd-sqlplannertest/tests/planner_test.rs +++ b/optd-sqlplannertest/tests/planner_test.rs @@ -5,7 +5,7 @@ use anyhow::Result; fn main() -> Result<()> { sqlplannertest::planner_test_runner( Path::new(env!("CARGO_MANIFEST_DIR")).join("tests"), - || async { Ok(optd_sqlplannertest::DatafusionDb::new().await?) }, + || async { optd_sqlplannertest::DatafusionDb::new().await }, )?; Ok(()) }