Skip to content

Commit

Permalink
test: confirm user-added metadata is included
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedld committed Apr 24, 2024
1 parent 6bea5a7 commit dd38fd1
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions datafusion/core/src/datasource/file_format/parquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ mod tests {
};
use parquet::arrow::arrow_reader::ArrowReaderOptions;
use parquet::arrow::ParquetRecordBatchStreamBuilder;
use parquet::file::metadata::{ParquetColumnIndex, ParquetOffsetIndex};
use parquet::file::metadata::{KeyValue, ParquetColumnIndex, ParquetOffsetIndex};
use parquet::file::page_index::index::Index;
use tokio::fs::File;
use tokio::io::AsyncWrite;
Expand Down Expand Up @@ -1865,7 +1865,10 @@ mod tests {
output_schema: schema.clone(),
table_partition_cols: vec![],
overwrite: true,
key_value_metadata: None,
key_value_metadata: Some(vec![KeyValue {
key: "my-data".into(),
value: Some("stuff".to_string()),
}]),
};
let parquet_sink = Arc::new(ParquetSink::new(
file_sink_config,
Expand Down Expand Up @@ -1903,7 +1906,10 @@ mod tests {
let (
path,
FileMetaData {
num_rows, schema, ..
num_rows,
schema,
key_value_metadata,
..
},
) = written.take(1).next().unwrap();
let path_parts = path.parts().collect::<Vec<_>>();
Expand All @@ -1919,6 +1925,13 @@ mod tests {
"output file metadata should contain col b"
);

let key_value_metadata = key_value_metadata.unwrap();
let my_metadata = key_value_metadata
.iter()
.filter(|kv| kv.key == "my-data")
.collect::<Vec<_>>();
assert_eq!(my_metadata.len(), 1);

Ok(())
}

Expand Down

0 comments on commit dd38fd1

Please sign in to comment.