Skip to content

Commit

Permalink
finish core
Browse files Browse the repository at this point in the history
  • Loading branch information
xudong963 committed Feb 4, 2022
1 parent 3c8fd30 commit ad84513
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion datafusion/src/logical_plan/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ impl Expr {
// finally, return the column contains `bool`
Expr::Column(Column {
relation: None,
name: "".to_string(),
name: "exists_subquery_col".to_string(),
})
}
})
Expand Down
22 changes: 20 additions & 2 deletions datafusion/src/logical_plan/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,13 +686,31 @@ impl LogicalPlan {
/// process subqueries
pub fn process_subquery(self, expr: &LogicalPlan) -> Result<LogicalPlan> {
let outer_table = self.get_table_scan().unwrap();
let distinct_outer_table = LogicalPlanBuilder::from(outer_table)
let distinct_outer_table = LogicalPlanBuilder::from(outer_table.clone())
.distinct()?
.build()
.unwrap();
let result_plan = distinct_outer_table.compute(expr).unwrap();
// join with outer_table
todo!()
let join_keys = outer_table
.schema()
.fields()
.iter()
.zip(
result_plan.schema().fields().as_slice()
[0..outer_table.schema().fields().len()]
.iter(),
)
.map(|(left_field, right_field)| {
(
(Column::from_name(left_field.name())),
(Column::from_name(right_field.name())),
)
})
.unzip();
LogicalPlanBuilder::from(outer_table)
.join(&result_plan, JoinType::Inner, join_keys)?
.build()
}

/// compute every row in outer_table for subquery
Expand Down

0 comments on commit ad84513

Please sign in to comment.