Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use source schema to find time column instead of projected schema #16

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()),
Rachelint marked this conversation as resolved.
Show resolved Hide resolved
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
Loading