diff --git a/bindings/python/src/manifest.rs b/bindings/python/src/manifest.rs index 6c042475b6..41f9612c90 100644 --- a/bindings/python/src/manifest.rs +++ b/bindings/python/src/manifest.rs @@ -145,14 +145,13 @@ impl PyManifestFile { } #[getter] - fn partitions(&self) -> Vec { - self.inner - .partitions - .clone() - .unwrap() - .iter() - .map(|s| PyFieldSummary { inner: s.clone() }) - .collect() + fn partitions(&self) -> Option> { + self.inner.partitions.as_ref().map(|partitions| { + partitions + .iter() + .map(|s| PyFieldSummary { inner: s.clone() }) + .collect() + }) } #[getter] @@ -238,3 +237,36 @@ pub fn register_module(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> .getattr("modules")? .set_item("pyiceberg_core.manifest", this) } + +#[cfg(test)] +mod tests { + use iceberg::spec::ManifestContentType; + + use super::*; + + #[test] + fn test_manifest_partitions_without_summaries() { + let manifest_file = PyManifestFile { + inner: ManifestFile { + manifest_path: "memory://manifest.avro".to_string(), + manifest_length: 1, + partition_spec_id: 0, + content: ManifestContentType::Data, + sequence_number: 0, + min_sequence_number: 0, + added_snapshot_id: 1, + added_files_count: Some(1), + existing_files_count: Some(0), + deleted_files_count: Some(0), + added_rows_count: Some(1), + existing_rows_count: Some(0), + deleted_rows_count: Some(0), + partitions: None, + key_metadata: None, + first_row_id: None, + }, + }; + + assert!(manifest_file.partitions().is_none()); + } +}