Skip to content

Commit

Permalink
Fix issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Dandandan committed Oct 22, 2022
1 parent 5871a79 commit 275ef8e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions datafusion/core/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,10 +1343,10 @@ mod tests {
\n Inner Join: t1.c1 = t2.c1\
\n Projection: aggregate_test_100.c1, aggregate_test_100.c2, aggregate_test_100.c3, alias=t1\
\n Projection: aggregate_test_100.c1, aggregate_test_100.c2, aggregate_test_100.c3\
\n TableScan: aggregate_test_100\
\n TableScan: aggregate_test_100 projection=[c1, c2, c3]\
\n Projection: aggregate_test_100.c1, aggregate_test_100.c2, aggregate_test_100.c3, alias=t2\
\n Projection: aggregate_test_100.c1, aggregate_test_100.c2, aggregate_test_100.c3\
\n TableScan: aggregate_test_100",
\n TableScan: aggregate_test_100 projection=[c1, c2, c3]",
format!("{:?}", df_renamed.to_logical_plan()?)
);

Expand Down
13 changes: 5 additions & 8 deletions datafusion/optimizer/src/inline_table_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,17 @@ fn inline_table_scan(plan: &LogicalPlan) -> Result<LogicalPlan> {
// during the early stage of planning
LogicalPlan::TableScan(TableScan {
source,
table_name: _table_name,
table_name,
filters,
fetch: None,
projected_schema,
projection: None,
..
}) if filters.is_empty() => {
if let Some(sub_plan) = source.get_logical_plan() {
// Recursively apply optimization
let plan = inline_table_scan(sub_plan)?;
let plan = LogicalPlanBuilder::from(plan).project(
projected_schema
.fields()
.iter()
.map(|field| Expr::Column(field.qualified_column())),
let plan = LogicalPlanBuilder::from(plan).project_with_alias(
vec![Expr::Wildcard],
Some(table_name.to_string()),
)?;
plan.build()
} else {
Expand Down
4 changes: 3 additions & 1 deletion datafusion/optimizer/src/projection_push_down.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,9 @@ fn optimize_plan(
}

fn projection_equal(p: &Projection, p2: &Projection) -> bool {
p.expr.len() == p2.expr.len() && p.expr.iter().zip(&p2.expr).all(|(l, r)| l == r)
p.expr.len() == p2.expr.len()
&& p.alias == p2.alias
&& p.expr.iter().zip(&p2.expr).all(|(l, r)| l == r)
}

#[cfg(test)]
Expand Down

0 comments on commit 275ef8e

Please sign in to comment.