Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
chenkovsky committed Jan 11, 2025
1 parent e9a0d6f commit a4dee3e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions datafusion/common/src/dfschema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ impl DFSchema {
pub fn fields_with_unqualified_name(&self, name: &str) -> Vec<&Field> {
let mut fields: Vec<&Field> = self.inner.fields_with_unqualified_name(name);
if let Some(schema) = self.metadata_schema() {
fields.append(&mut schema.fields_with_unqualified_name(name));
fields.extend(schema.fields_with_unqualified_name(name));
}
fields
}
Expand All @@ -618,7 +618,7 @@ impl DFSchema {
let mut fields: Vec<(Option<&TableReference>, &Field)> =
self.inner.qualified_fields_with_unqualified_name(name);
if let Some(schema) = self.metadata_schema() {
fields.append(&mut schema.qualified_fields_with_unqualified_name(name));
fields.extend(schema.qualified_fields_with_unqualified_name(name));
}
fields
}
Expand Down
20 changes: 14 additions & 6 deletions datafusion/expr/src/logical_plan/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2615,23 +2615,31 @@ impl TableScan {
.map(|p| {
let projected_func_dependencies =
func_dependencies.project_functional_dependencies(p, p.len());

let df_schema = DFSchema::new_with_metadata(
let qualified_fields: Result<Vec<_>, _> =
p.iter()
.map(|i| {
if *i >= schema.fields.len() {
if *i >= METADATA_OFFSET {
if let Some(metadata) = &metadata {
return (
return Ok((
Some(table_name.clone()),
Arc::new(
metadata.field(*i - METADATA_OFFSET).clone(),
),
));
} else {
return plan_err!(
"table doesn't support metadata column"
);
}
}
(Some(table_name.clone()), Arc::new(schema.field(*i).clone()))
Ok((
Some(table_name.clone()),
Arc::new(schema.field(*i).clone()),
))
})
.collect(),
.collect();
let df_schema = DFSchema::new_with_metadata(
qualified_fields?,
schema.metadata.clone(),
)?;
df_schema.with_functional_dependencies(projected_func_dependencies)
Expand Down

0 comments on commit a4dee3e

Please sign in to comment.