[format] Support writing and reading Arrow schema metadata for file formats#8321
Open
lxy-9602 wants to merge 1 commit into
Open
[format] Support writing and reading Arrow schema metadata for file formats#8321lxy-9602 wants to merge 1 commit into
lxy-9602 wants to merge 1 commit into
Conversation
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.
Purpose
This PR is a sub-PR for shared-shredding.
Shared-shredding needs to attach dictionary and other field-level metadata before closing data files. To support that flow, this PR adds a generic metadata write/read path for file formats, so upper layers can provide raw key-value metadata during writing, and readers can parse the stored metadata back when opening files.
The metadata representation follows Arrow Parquet's existing schema metadata convention: Arrow stores the original serialized schema under the
ARROW:schemafile metadata key, base64-decodes it on read, and deserializes it with Arrow IPC schema reading. See Apache Arrow's Parquet schema implementation, wherekArrowSchemaKeyisARROW:schemaand the value is base64-decoded beforeReadSchema.Related design:
https://cwiki.apache.org/confluence/display/PAIMON/PIP-43%3A+Columnar+Storage+Optimization+for+MAP+Type+in+Paimon
Brief change log
SupportsWriterMetadataso format writers can accept rawMap<String, byte[]>metadata before file close.SupportsReaderArrowSchemaso format readers can return the stored Arrow schema metadata.FormatMetadataUtilsfor:ARROW:schemakey into an ArrowSchema;Map<String, Map<String, String>>.Compatibility
The metadata value is stored using Arrow-compatible base64 encoding. For Arrow schema metadata, the key is
ARROW:schema, matching Arrow Parquet's convention.Tests
mvn -pl paimon-format -am -Pfast-build -DfailIfNoTests=false \ -Dtest=ParquetFormatReadWriteTest#testWriteMetadata,OrcFormatReadWriteTest#testWriteMetadata,FormatMetadataUtilsTest test