Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions crates/iceberg/src/spec/manifest/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,29 @@ impl ManifestMetadata {
"partition-spec is required in manifest metadata but not found",
)
})?;
serde_json::from_slice::<Vec<PartitionField>>(bs).map_err(|err| {
Error::new(
ErrorKind::DataInvalid,
"Fail to parse partition spec in manifest metadata",
)
.with_source(err)
})?
// Accept either shape that Iceberg writers produce here:
// - bare JSON array `[{...}]` — historical iceberg-rust shortcut
// - spec-compliant object `{"spec-id":N,"fields":[{...}]}` —
// iceberg-java / iceberg-cpp / pyiceberg
// Previously only the bare array was accepted, which made
// fast_append fail against tables where any non-rust writer
// had committed before (the parent-manifest load for the
// duplicate-file check tripped on the object shape).
serde_json::from_slice::<Vec<PartitionField>>(bs)
.or_else(|_| {
#[derive(serde::Deserialize)]
struct PartitionSpecJson {
fields: Vec<PartitionField>,
}
serde_json::from_slice::<PartitionSpecJson>(bs).map(|s| s.fields)
})
.map_err(|err| {
Error::new(
ErrorKind::DataInvalid,
"Fail to parse partition spec in manifest metadata",
)
.with_source(err)
})?
};
let spec_id = meta
.get("partition-spec-id")
Expand Down
7 changes: 6 additions & 1 deletion crates/iceberg/src/spec/manifest/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,12 @@ impl ManifestWriter {
)?;
avro_writer.add_user_metadata(
"partition-spec".to_string(),
to_vec(&self.metadata.partition_spec.fields()).map_err(|err| {
// Serialize the full PartitionSpec object ({"spec-id":N,"fields":[...]})
// so iceberg-java / iceberg-cpp / pyiceberg can read manifests
// written by iceberg-rust. The previous output (bare `fields`
// array) is a rust-only shortcut that other Iceberg
// implementations reject.
to_vec(&self.metadata.partition_spec).map_err(|err| {
Error::new(ErrorKind::DataInvalid, "Fail to serialize partition spec")
.with_source(err)
})?,
Expand Down
Loading