Skip to content

Commit

Permalink
fix: schema metadata retrieval when listing parquet table (apache#9134)
Browse files Browse the repository at this point in the history
* fix: schema metadata retrieval when listing parquet table

* fix: modified code formatting

* fix: replaced unnecessary use of deref with as_ref
  • Loading branch information
brayanjuls authored Feb 6, 2024
1 parent d1aca48 commit 9669520
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion datafusion/core/src/datasource/listing/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ impl ListingTable {
})?;

// Add the partition columns to the file schema
let mut builder = SchemaBuilder::from(file_schema.fields());
let mut builder = SchemaBuilder::from(file_schema.as_ref().to_owned());
for (part_col_name, part_col_type) in &options.table_partition_cols {
builder.push(Field::new(part_col_name, part_col_type.clone(), false));
}
Expand Down
17 changes: 10 additions & 7 deletions datafusion/core/tests/parquet/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ async fn schema_merge_can_preserve_metadata() {
.read_parquet(&table_path, options.clone())
.await
.unwrap();

let actual = df.schema().metadata();
assert_eq!(actual.clone(), expected_metadata,);

let actual = df.collect().await.unwrap();

assert_batches_sorted_eq!(expected, &actual);
Expand All @@ -158,13 +162,12 @@ async fn schema_merge_can_preserve_metadata() {
.await
.unwrap();

let actual = ctx
.sql("SELECT * from t")
.await
.unwrap()
.collect()
.await
.unwrap();
let df = ctx.sql("SELECT * from t").await.unwrap();

let actual = df.schema().metadata();
assert_eq!(actual.clone(), expected_metadata);

let actual = df.collect().await.unwrap();
assert_batches_sorted_eq!(expected, &actual);
assert_metadata(&actual, &expected_metadata);
}
Expand Down

0 comments on commit 9669520

Please sign in to comment.