hareshkh commented on code in PR #54:
URL: https://github.com/apache/datafusion-iceberg/pull/54#discussion_r4247932521
##########
crates/datafusion/src/write/commit.rs:
##########
@@ -259,35 +262,39 @@ impl ExecutionPlan for IcebergCommitExec {
)
})?
.as_any()
- .downcast_ref::<StringArray>()
+ .downcast_ref::<LargeBinaryArray>()
.ok_or_else(|| {
internal_datafusion_err!(
- "Expected 'data_files' column to be StringArray"
+ "Expected 'data_files' column to be
LargeBinaryArray"
)
})?;
- // Deserialize all data files from the StringArray
- let batch_files: Vec<DataFile> = files_array
- .into_iter()
- .flatten()
- .map(|f| -> Result<DataFile> {
- // Parse JSON to DataFileSerde and convert to DataFile
- deserialize_data_file_from_json(
- f,
- spec_id,
- &partition_type,
- ¤t_schema,
+ // Each value is a separate Avro container with one or more
data files.
+ files_array.iter().try_for_each(|payload| {
+ let mut payload = payload.ok_or_else(|| {
+ DataFusionError::Execution(
+ "Null Avro data file payload".to_string(),
)
- .map_err(to_datafusion_error)
- })
- .collect::<Result<_>>()?;
-
- // add record_counts from the current batch to total record
count
- total_record_count +=
- batch_files.iter().map(|f| f.record_count()).sum::<u64>();
-
- // Add all deserialized files to our collection
- data_files.extend(batch_files);
+ })?;
+ if payload.is_empty() {
+ return Err(DataFusionError::Execution(
+ "Empty Avro data file payload".to_string(),
+ ));
+ }
Review Comment:
Added a test and shifted to using internal_datafusion_err
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]