Skip to content

Commit

Permalink
Minor: comments that explain the schema used in simply_expressions (a…
Browse files Browse the repository at this point in the history
…pache#7747)

* Minor: comments that explain the schema used in simply_expressions

* Apply suggestions from code review

Co-authored-by: comphead <comphead@users.noreply.github.com>

---------

Co-authored-by: comphead <comphead@users.noreply.github.com>
  • Loading branch information
2 people authored and devinjdangelo committed Oct 11, 2023
1 parent c4f2ab5 commit 0567654
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,16 @@ impl SimplifyExpressions {
let schema = if !plan.inputs().is_empty() {
DFSchemaRef::new(merge_schema(plan.inputs()))
} else if let LogicalPlan::TableScan(scan) = plan {
// When predicates are pushed into a table scan, there needs to be
// a schema to resolve the fields against.
// When predicates are pushed into a table scan, there is no input
// schema to resolve predicates against, so it must be handled specially
//
// Note that this is not `plan.schema()` which is the *output*
// schema, and reflects any pushed down projection. The output schema
// will not contain columns that *only* appear in pushed down predicates
// (and no where else) in the plan.
//
// Thus, use the full schema of the inner provider without any
// projection applied for simplification
Arc::new(DFSchema::try_from_qualified_schema(
&scan.table_name,
&scan.source.schema(),
Expand Down

0 comments on commit 0567654

Please sign in to comment.