feat(writer): embed iceberg.schema in Parquet footer metadata#2724
Open
viirya wants to merge 1 commit into
Open
feat(writer): embed iceberg.schema in Parquet footer metadata#2724viirya wants to merge 1 commit into
viirya wants to merge 1 commit into
Conversation
Engines such as Snowflake resolve an Iceberg table's schema from the `iceberg.schema` key in a Parquet file's footer key-value metadata. iceberg-rust did not write this key, so Parquet files it produced (or files produced by nimtable compaction on top of it) were rejected by those engines. Write the Iceberg schema as JSON under the `iceberg.schema` footer key when the Parquet writer is initialized, matching iceberg-java (`Parquet.java`). The value is the same schema JSON that appears in table metadata's `schemas`, produced via `serde_json::to_string`. Scope is the Parquet writer only. iceberg-java writes the same key from its Avro writer too, but in iceberg-rust the Avro writer produces manifests (metadata), not the data files these engines query, so that is left as a follow-up. Closes apache#2184
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
What changes are included in this PR?
Engines such as Snowflake resolve an Iceberg table's schema from the
iceberg.schemakey in a Parquet file's footer key-value metadata. iceberg-rust didn't write this key, so Parquet files it produced (or files produced by nimtable compaction on top of it) were rejected by those engines.This PR writes the Iceberg schema as JSON under the
iceberg.schemafooter key when the Parquet writer is initialized, matching iceberg-java. I verified the Java behavior against the source:parquet/src/main/java/org/apache/iceberg/parquet/Parquet.javawritesmeta("iceberg.schema", SchemaParser.toJson(schema))unconditionally inWriteBuilder.build().SchemaJSON — the same representation that appears in table metadata'sschemasarray. iceberg-rust'sserde_json::to_string(&schema)produces that same JSON.Implementation: in
ParquetWriter, right after the underlyingAsyncArrowWriteris lazily created,append_key_value_metadatais called withiceberg.schema→ schema JSON. It's unconditional, matching Java (the schema is always present).Scope
Parquet writer only. iceberg-java writes the same
iceberg.schemakey from its Avro writer as well, but in iceberg-rust the Avro writer produces manifests (metadata), not the data files these engines query, so it's out of scope here. Adding it to the Avro path can be a follow-up if there's a need.Are these changes tested?
New test
test_parquet_writer_embeds_iceberg_schema_in_footer: writes a Parquet file throughParquetWriter, reads the footer back, asserts theiceberg.schemakey is present, and that its JSON value round-trips to the writtenSchema.All
writer::file_writer::parquet_writertests pass (no regression), fulliceberglib suite (1372 tests) passes, clippy and rustfmt clean.