Repository navigation
feat(arrow/extensions): add UnshredVariant to collapse a shredded variant array - #859
Merged
Merged
Conversation
nssalian
marked this pull request as ready for review
June 22, 2026 17:17
zeroshade
approved these changes
Jun 23, 2026
zeroshade
pushed a commit
to apache/iceberg-go
that referenced
this pull request
Jun 23, 2026
Closes [#986](#986). At scan time, reassembles shredded variant columns (metadata + residual value + typed_value) back into the plain unshredded layout, so a shredded variant reads the same as a non-shredded one. arrow-go's VariantArray does the per-row work. The code change is only in the projection visitor's Variant method. Note: This PR also bumps arrow-go to 4a540f5 (apache/arrow-go@4a540f5) (v18.6.1-0.20260623163317-4a540f514484) to pick up `UnshredVariant` (apache/arrow-go#859), which does the per-row reassembly. ## Fixture based Testing The fixtures come from [apache/parquet-testing](https://github.com/apache/parquet-testing/tree/master/shredded_variant) (written by Iceberg Java's TestVariantReaders). I first ran all 137 upstream cases through arrow-go to see where it stands (128 pass, 4 reject, 2 lenient, 3 spec-invalid), then committed 17 of them. These represent one per distinct reader behaviour instead of all 137: - 9 success cases checked against the Java golden value (array, empty array, scalar, object with a field that falls back to the residual value, object with no value column, nested array, null variant, unshredded data under a shredded schema, and a multi-row column with nulls). Compared as JSON because reassembly is valid but not byte-identical for nested objects. - 5 cases the reader should reject (value/typed_value conflicts, non-object-with-shredded-fields, and a spec-invalid file). - 3 cases where arrow-go reads something Java would reject (uint32 and fixed_size_binary typed_value, plus one spec-invalid file it reads). These pin the current behaviour so we notice if arrow-go changes it. ## Additional Testing - compute.Take / FilterRecordBatch leave a shredded column alone (they run before projection). - rows surviving a positional delete still reassemble correctly. - a leak check on the reassembly path. - a Spark 4 integration test that writes a shredded table and reads it back (checks the file is actually shredded first). --------- Signed-off-by: Neelesh Salian <[email protected]>
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.
Rationale for this change
A shredded variant array reads back in the shredded storage layout, which shares the
parquet.variantextension name with the non-shredded layout but has a different storage type. There was no way to collapse it short of decoding row by row. iceberg-go needs this at scan-projection time to read a shredded variant column identically to a non-shredded one (apache/iceberg-go#986) (PR: apache/iceberg-go#1238).What changes are included in this PR?
extensions.UnshredVariant(arr, mem), returning an equivalent non-shreddedVariantArray. An already-non-shredded array is returned unchanged with an added reference.UntypedValues()'s doc string tooAre these changes tested?
Yes.
TestUnshredVariantcovers scalar, list, nested object, residual fields, null vs present variant-null, and passthrough.Are there any user-facing changes?
One new exported function. No change to existing behavior.