Repository navigation
[feature](iceberg) Write Iceberg VARIANT columns and require NULL VARIANT defaults #69194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
morningman
merged 4 commits into
apache:master
from
morningman:b2m-t29-iceberg-variant-write
Oct 19, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ed28e47
[feature](iceberg) Write Iceberg VARIANT columns and require NULL VAR…
morningman 4a6b393
[fix](fe) Follow every path a Variant write takes through CTEs and se…
morningman b45604b
[fix](fe) Leave window keys and aggregate ORDER BY out of the Variant…
morningman 7e9ef14
[fix](fe) Trace each output of a shared CTE producer once in the Vari…
morningman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Compact shared dictionaries before serializing VARIANT rows
This newly enabled Arrow mapping reaches
DataTypeVariantV2SerDe::write_column_to_iceberg_arrow, which callswrite_parquet_variant_arrow(..., compact_metadata=false)and appends each row's entire batch-shared dictionary. For an unpartitioned v3 Parquet target, withbatch_size=4096and one pipeline task, a batch of 4,096 values fromPARSE_TO_VARIANT(CONCAT('{"', REPEAT('x',240), CAST(number AS STRING), '":1}'))has only about 1 MiB of JSON but repeats its dictionary into about 4 GB of Arrow metadata.VParquetWriter::writeconverts the whole block before row-group handling, so it hits the cumulative 2 GiB limit in Arrow 24 BinaryBuilder and fails a valid insert (or exhausts the query memory first). Compact unused dictionary keys per row before this path writes them; the existingcompact_metadata=truebranch provides that machinery.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed.
PARSE_TO_VARIANTencodes a block with one encoder, so its rows share one dictionary, andwrite_column_to_iceberg_arrowpassescompact_metadata=false, so every row appends the whole dictionary. With many distinct keys in one batch, the metadata column passes the 2 GiB limit of Arrow'sBinaryBuilderand the INSERT fails; it fails rather than writing anything wrong. That serde came with #68883, and Paimon'swrite_binary_variant_arrowappends the same shared dictionary for every row on master today. The fix therefore belongs in the shared serde, for both table writers, rather than in this PR's schema mapping. We will fix it in a separate PR for Iceberg and Paimon: compact the dictionary of a row that does not use all of its keys, as thecompact_metadata=truebranch already does for Flight, with a BE test that bounds the metadata bytes of a high-cardinality batch.