Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wangpatrick57 committed Feb 11, 2024
1 parent e422666 commit 5c2fd60
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion optd-adaptive-demo/src/bin/optd-adaptive-three-join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion optd-core/src/cascades/memo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl<T: RelNodeTyp> Memo<T> {
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(
Expand Down
4 changes: 2 additions & 2 deletions optd-core/src/cascades/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ impl<T: RelNodeTyp> CascadesOptimizer<T> {
group_id: GroupId,
mut on_produce: impl FnMut(RelNodeRef<T>, GroupId) -> RelNodeRef<T>,
) -> Result<RelNodeRef<T>> {
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<()> {
Expand Down
6 changes: 3 additions & 3 deletions optd-core/src/cascades/tasks/optimize_inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl<T: RelNodeTyp> Task<T> 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],
Expand All @@ -177,7 +177,7 @@ impl<T: RelNodeTyp> Task<T> for OptimizeInputsTask {
&expr.typ,
&expr.data,
&input_cost,
Some(context.clone()),
Some(context),
),
&input_cost,
)
Expand Down Expand Up @@ -248,7 +248,7 @@ impl<T: RelNodeTyp> Task<T> for OptimizeInputsTask {
&expr.typ,
&expr.data,
&input_cost,
Some(context.clone()),
Some(context),
),
&input_cost,
),
Expand Down
4 changes: 2 additions & 2 deletions optd-core/src/heuristics/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn match_node<T: RelNodeTyp>(
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;
Expand Down Expand Up @@ -124,7 +124,7 @@ impl<T: RelNodeTyp> HeuristicsOptimizer<T> {
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();
}
Expand Down
4 changes: 2 additions & 2 deletions optd-datafusion-bridge/src/from_optd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -108,7 +108,7 @@ impl OptdPlanContext<'_> {
false,
&args,
&[],
&context,
context,
"<agg_func>",
)?)
}
Expand Down
14 changes: 7 additions & 7 deletions optd-datafusion-bridge/src/into_optd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(
Expand Down Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion optd-datafusion-repr/src/plan_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl PlanNode {
}

pub fn from_group(rel_node: OptRelNodeRef) -> Self {
return Self(rel_node);
Self(rel_node)
}
}

Expand Down
6 changes: 3 additions & 3 deletions optd-datafusion-repr/src/rules/joins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,16 @@ 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,
data: expr.data.clone(),
}
.into(),
)
.unwrap();
expr
.unwrap()
}

let left = Arc::new(left.clone());
Expand Down
2 changes: 1 addition & 1 deletion optd-sqlplannertest/src/bin/planner_test_apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
4 changes: 2 additions & 2 deletions optd-sqlplannertest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand All @@ -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!(
Expand Down
2 changes: 1 addition & 1 deletion optd-sqlplannertest/tests/planner_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

0 comments on commit 5c2fd60

Please sign in to comment.