Xuanwo commented on code in PR #797: URL: https://github.com/apache/iceberg-rust/pull/797#discussion_r1900533257
########## crates/iceberg/src/spec/manifest.rs: ########## @@ -1189,6 +1212,49 @@ impl DataFile { self.sort_order_id } } + +/// Convert data files to avro bytes and write to writer. +/// Return the bytes written. +pub fn write_data_files_to_avro<W: Write>( + writer: &mut W, + data_files: impl IntoIterator<Item = DataFile>, + partition_type: &StructType, + version: FormatVersion, +) -> Result<usize> { + let avro_schema = match version { + FormatVersion::V1 => _const_schema::data_file_schema_v1(partition_type).unwrap(), + FormatVersion::V2 => _const_schema::data_file_schema_v2(partition_type).unwrap(), + }; + let mut writer = AvroWriter::new(&avro_schema, writer); + + for data_file in data_files { + let value = to_value(_serde::DataFile::try_from(data_file, partition_type, true)?)? + .resolve(&avro_schema)?; + writer.append(value)?; + } + + Ok(writer.flush()?) +} + +/// Parse data files from avro bytes. +pub fn parse_data_file_from_avro<R: Read>( Review Comment: ```suggestion pub fn read_data_files_from_avro<R: Read>( ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org