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

Commit 45974d2

Browse files
committed
clean and fmt
Signed-off-by: AveryQi115 <[email protected]>
1 parent dce1dca commit 45974d2

File tree

6 files changed

+49
-23
lines changed

6 files changed

+49
-23
lines changed

datafusion-optd-cli/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,10 @@ pub async fn main() -> Result<()> {
158158
};
159159

160160
let mut session_config = SessionConfig::from_env()?.with_information_schema(true);
161-
161+
162162
if !args.enable_logical {
163163
session_config.options_mut().optimizer.max_passes = 0;
164164
}
165-
166165

167166
if let Some(batch_size) = args.batch_size {
168167
session_config = session_config.with_batch_size(batch_size);

optd-datafusion-bridge/src/from_optd.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
1-
use std::{collections::HashMap, fmt::Display, sync::Arc};
1+
use std::{collections::HashMap, sync::Arc};
22

33
use anyhow::{bail, Context, Result};
44
use async_recursion::async_recursion;
55
use datafusion::{
6-
arrow::datatypes::{Schema, SchemaRef}, catalog::schema, common::DFSchema, datasource::source_as_provider, logical_expr::Operator, physical_expr, physical_plan::{
6+
arrow::datatypes::{Schema, SchemaRef},
7+
datasource::source_as_provider,
8+
logical_expr::Operator,
9+
physical_expr,
10+
physical_plan::{
711
self,
812
aggregates::AggregateMode,
913
expressions::create_aggregate_expr,
1014
joins::{
11-
utils::{ColumnIndex, JoinFilter}, CrossJoinExec, PartitionMode
15+
utils::{ColumnIndex, JoinFilter},
16+
CrossJoinExec, PartitionMode,
1217
},
1318
projection::ProjectionExec,
1419
AggregateExpr, ExecutionPlan, PhysicalExpr,
15-
}, scalar::ScalarValue
20+
},
21+
scalar::ScalarValue,
1622
};
1723
use optd_datafusion_repr::{
1824
plan_nodes::{
1925
BinOpExpr, BinOpType, ColumnRefExpr, ConstantExpr, ConstantType, Expr, FuncExpr, FuncType,
2026
JoinType, LogOpExpr, LogOpType, OptRelNode, OptRelNodeRef, OptRelNodeTyp, PhysicalAgg,
21-
PhysicalFilter, PhysicalHashJoin, PhysicalNestedLoopJoin, PhysicalProjection, PhysicalScan,
22-
PhysicalSort, PhysicalEmptyRelation, PlanNode, SortOrderExpr, SortOrderType,
27+
PhysicalEmptyRelation, PhysicalFilter, PhysicalHashJoin, PhysicalNestedLoopJoin,
28+
PhysicalProjection, PhysicalScan, PhysicalSort, PlanNode, SortOrderExpr, SortOrderType,
2329
},
24-
PhysicalCollector,
2530
properties::schema::Schema as OptdSchema,
31+
PhysicalCollector,
2632
};
2733

2834
use crate::{physical_collector::CollectorExec, OptdPlanContext};
@@ -313,7 +319,8 @@ impl OptdPlanContext<'_> {
313319
let physical_expr = self.from_optd_expr(node.cond(), &Arc::new(filter_schema.clone()))?;
314320

315321
if let JoinType::Cross = node.join_type() {
316-
return Ok(Arc::new(CrossJoinExec::new(left_exec, right_exec)) as Arc<dyn ExecutionPlan + 'static>);
322+
return Ok(Arc::new(CrossJoinExec::new(left_exec, right_exec))
323+
as Arc<dyn ExecutionPlan + 'static>);
317324
}
318325

319326
let join_type = match node.join_type() {
@@ -442,7 +449,7 @@ impl OptdPlanContext<'_> {
442449
}
443450
OptRelNodeTyp::PhysicalEmptyRelation => {
444451
let physical_node = PhysicalEmptyRelation::from_rel_node(rel_node).unwrap();
445-
let datafusion_schema : Schema = schema.into();
452+
let datafusion_schema: Schema = schema.into();
446453
Ok(Arc::new(datafusion::physical_plan::empty::EmptyExec::new(
447454
physical_node.produce_one_row(),
448455
Arc::new(datafusion_schema),

optd-datafusion-bridge/src/into_optd.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use datafusion::{
77
use optd_core::rel_node::RelNode;
88
use optd_datafusion_repr::plan_nodes::{
99
BinOpExpr, BinOpType, ColumnRefExpr, ConstantExpr, Expr, ExprList, FuncExpr, FuncType,
10-
JoinType, LogOpExpr, LogOpType, LogicalAgg, LogicalFilter, LogicalJoin, LogicalProjection,
11-
LogicalScan, LogicalSort, LogicalEmptyRelation, OptRelNode, OptRelNodeRef, OptRelNodeTyp, PlanNode, SortOrderExpr,
12-
SortOrderType,
10+
JoinType, LogOpExpr, LogOpType, LogicalAgg, LogicalEmptyRelation, LogicalFilter, LogicalJoin,
11+
LogicalProjection, LogicalScan, LogicalSort, OptRelNode, OptRelNodeRef, OptRelNodeTyp,
12+
PlanNode, SortOrderExpr, SortOrderType,
1313
};
1414

1515
use crate::OptdPlanContext;
@@ -117,7 +117,7 @@ impl OptdPlanContext<'_> {
117117
expr,
118118
)
119119
.into_expr())
120-
}
120+
}
121121
_ => bail!("Unsupported expression: {:?}", expr),
122122
}
123123
}
@@ -237,10 +237,18 @@ impl OptdPlanContext<'_> {
237237
fn into_optd_cross_join(&mut self, node: &logical_plan::CrossJoin) -> Result<LogicalJoin> {
238238
let left = self.into_optd_plan_node(node.left.as_ref())?;
239239
let right = self.into_optd_plan_node(node.right.as_ref())?;
240-
Ok(LogicalJoin::new(left, right, ConstantExpr::bool(true).into_expr(), JoinType::Cross))
240+
Ok(LogicalJoin::new(
241+
left,
242+
right,
243+
ConstantExpr::bool(true).into_expr(),
244+
JoinType::Cross,
245+
))
241246
}
242247

243-
fn into_optd_empty_relation(&mut self, node: &logical_plan::EmptyRelation) -> Result<LogicalEmptyRelation> {
248+
fn into_optd_empty_relation(
249+
&mut self,
250+
node: &logical_plan::EmptyRelation,
251+
) -> Result<LogicalEmptyRelation> {
244252
Ok(LogicalEmptyRelation::new(node.produce_one_row))
245253
}
246254

@@ -254,7 +262,9 @@ impl OptdPlanContext<'_> {
254262
LogicalPlan::Join(node) => self.into_optd_join(node)?.into_plan_node(),
255263
LogicalPlan::Filter(node) => self.into_optd_filter(node)?.into_plan_node(),
256264
LogicalPlan::CrossJoin(node) => self.into_optd_cross_join(node)?.into_plan_node(),
257-
LogicalPlan::EmptyRelation(node) => self.into_optd_empty_relation(node)?.into_plan_node(),
265+
LogicalPlan::EmptyRelation(node) => {
266+
self.into_optd_empty_relation(node)?.into_plan_node()
267+
}
258268
_ => bail!(
259269
"unsupported plan node: {}",
260270
format!("{:?}", node).split('\n').next().unwrap()

optd-datafusion-repr/src/plan_nodes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
33
mod agg;
44
mod apply;
5+
mod empty_relation;
56
mod expr;
67
mod filter;
78
mod join;
89
pub(super) mod macros;
910
mod projection;
1011
mod scan;
1112
mod sort;
12-
mod empty_relation;
1313

1414
use std::sync::Arc;
1515

@@ -20,6 +20,7 @@ use optd_core::{
2020

2121
pub use agg::{LogicalAgg, PhysicalAgg};
2222
pub use apply::{ApplyType, LogicalApply};
23+
pub use empty_relation::{LogicalEmptyRelation, PhysicalEmptyRelation};
2324
pub use expr::{
2425
BinOpExpr, BinOpType, ColumnRefExpr, ConstantExpr, ConstantType, ExprList, FuncExpr, FuncType,
2526
LogOpExpr, LogOpType, SortOrderExpr, SortOrderType, UnOpExpr, UnOpType,
@@ -30,7 +31,6 @@ use pretty_xmlish::{Pretty, PrettyConfig};
3031
pub use projection::{LogicalProjection, PhysicalProjection};
3132
pub use scan::{LogicalScan, PhysicalScan};
3233
pub use sort::{LogicalSort, PhysicalSort};
33-
pub use empty_relation::{LogicalEmptyRelation, PhysicalEmptyRelation};
3434

3535
use crate::{
3636
adaptive::PhysicalCollector,

optd-datafusion-repr/src/plan_nodes/empty_relation.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ impl LogicalEmptyRelation {
4040
}
4141

4242
pub fn produce_one_row(&self) -> bool {
43-
self.clone().into_rel_node().data.as_ref().unwrap().as_bool()
43+
self.clone()
44+
.into_rel_node()
45+
.data
46+
.as_ref()
47+
.unwrap()
48+
.as_bool()
4449
}
4550
}
4651

@@ -73,6 +78,11 @@ impl PhysicalEmptyRelation {
7378
}
7479

7580
pub fn produce_one_row(&self) -> bool {
76-
self.clone().into_rel_node().data.as_ref().unwrap().as_bool()
81+
self.clone()
82+
.into_rel_node()
83+
.data
84+
.as_ref()
85+
.unwrap()
86+
.as_bool()
7787
}
7888
}

optd-datafusion-repr/src/properties/schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl Into<DatafusionSchema> for Schema {
3131
ConstantType::Decimal => DataType::Float64,
3232
ConstantType::Utf8String => DataType::Utf8,
3333
};
34-
let fields : Vec<_> = self
34+
let fields: Vec<_> = self
3535
.0
3636
.iter()
3737
.enumerate()

0 commit comments

Comments
 (0)