Skip to content

Commit

Permalink
fix: use source schema to find time column instead of projected schema (
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 authored Mar 5, 2024
1 parent b9fb3ca commit 05a8a9f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions iox_query/src/logical_optimizer/handle_gapfill/range_predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::ops::{Bound, Range};
use datafusion::{
common::{
tree_node::{TreeNode, TreeNodeVisitor, VisitRecursion},
DFSchema,
DFField, DFSchema,
},
error::Result,
logical_expr::{Between, BinaryExpr, LogicalPlan, Operator},
Expand Down Expand Up @@ -44,13 +44,30 @@ impl TreeNodeVisitor for TimeRangeVisitor {
Ok(VisitRecursion::Continue)
}
LogicalPlan::TableScan(t) => {
let source_schema = t.source.schema();
let qualifier = &t.table_name;
let df_schema = DFSchema::new_with_metadata(
source_schema
.fields()
.iter()
.map(|f| {
DFField::new(
Some(qualifier.clone()),
f.name(),
f.data_type().clone(),
f.is_nullable(),
)
})
.collect(),
source_schema.metadata().clone(),
)?;
let range = self.range.clone();
let range = t
.filters
.iter()
.flat_map(split_conjunction)
.try_fold(range, |range, expr| {
range.with_expr(&t.projected_schema, &self.col, expr)
range.with_expr(&df_schema, &self.col, expr)
})?;
self.range = range;
Ok(VisitRecursion::Continue)
Expand Down

0 comments on commit 05a8a9f

Please sign in to comment.