Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dandandan committed Oct 21, 2022
1 parent 4de241e commit f17be35
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions datafusion/optimizer/src/inline_table_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ impl InlineTableScan {
/// Inline
fn inline_table_scan(plan: &LogicalPlan) -> Result<LogicalPlan> {
match plan {
// Match only on scans without filter/projection
// As DataFrames / Views don't have those
// Match only on scans without filter / projection / fetch
// Views and DataFrames won't have those added
// during the early stage of planning
LogicalPlan::TableScan(TableScan {
source,
table_name,
Expand All @@ -50,18 +51,16 @@ fn inline_table_scan(plan: &LogicalPlan) -> Result<LogicalPlan> {
projection: None,
}) if filters.is_empty() => {
if let Some(sub_plan) = source.get_logical_plan() {
// Recurse into scan
// Recursively apply optimization
let plan = inline_table_scan(sub_plan)?;
let schema = plan.schema().clone();
let plan = LogicalPlanBuilder::from(plan)
.project_with_alias(
schema
.fields()
.iter()
.map(|field| Expr::Column(field.qualified_column())),
Some(table_name.clone()),
)
.unwrap();
let plan = LogicalPlanBuilder::from(plan).project_with_alias(
schema
.fields()
.iter()
.map(|field| Expr::Column(field.qualified_column())),
Some(table_name.clone()),
)?;
plan.build()
} else {
// No plan available, return with table scan as is
Expand Down

0 comments on commit f17be35

Please sign in to comment.