Skip to content

fix: Read large_binary and binary_view storage in shredded variant readers - #449

Merged
CurtHagenlocher merged 3 commits into
apache:mainfrom
CurtHagenlocher:variant-shredded-binary-types
Sep 27, 2026
Merged

CurtHagenlocher merged 3 commits into
apache:mainfrom
CurtHagenlocher:variant-shredded-binary-types

Conversation

@CurtHagenlocher

@CurtHagenlocher CurtHagenlocher commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

What's Changed

VariantArray accepts binary, large_binary or binary_view for metadata and value at every nesting level, and ShredSchema.FromArrowType maps large_utf8 / large_binary typed_value columns. The shredded readers (ShreddedVariant, ShreddedObject, ShreddedArray) cast those columns to BinaryArray / StringArray, so any other representation threw InvalidCastException. This even affected GetLogicalVariantValue on unshredded large_binary columns.

This replaces the casts with two small helpers in ShreddingHelpers, GetBytes and GetString, that read from any binary or string representation. (IBinaryArray would have been the natural abstraction, but it's internal to Apache.Arrow.)

The new tests shred a column that has residuals at the top level, in a partially shredded object, in an object field, and in a list element. They then convert every binary field, recursively, to large_binary or binary_view (and string/binary typed_value columns to large_utf8 / large_binary), and read everything back, both directly and through the Shred / Reassemble entry points added in #447. All of these tests fail without the fix.

Performance: GetLogicalVariantValue over 100k rows (BenchmarkDotNet, medium job, two runs) is indistinguishable from the old cast for both shredded and unshredded binary columns. An inlinable BinaryArray fast path was also tried and measured slower, so it isn't included.

Closes #448.

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Updates shredded variant readers to support large binary, binary view, and large UTF-8 storage representations.

Changes:

  • Adds representation-independent binary and string helpers.
  • Replaces concrete array casts in shredded readers.
  • Adds nested coverage for alternate storage types.
File Summary
test/​Apache.Arrow.Operations.Tests/​Shredding/​ShreddedVariantStorageTypeTests.cs Tests alternate storage across nesting levels.
src/​Apache.Arrow.Operations/​Shredding/​ShreddingHelpers.cs Adds binary and string representation helpers.
src/​Apache.Arrow.Operations/​Shredding/​ShreddedVariant.cs Uses helpers for residual and typed values.
src/​Apache.Arrow.Operations/​Shredding/​ShreddedObject.cs Supports alternate residual storage.
src/​Apache.Arrow.Operations/​Shredding/​ShreddedArray.cs Supports alternate array residual storage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

CurtHagenlocher and others added 3 commits September 27, 2026 09:14
…aders

The shredded readers cast value columns to BinaryArray and string/binary
typed_value columns to StringArray/BinaryArray, throwing for the other
storage types VariantArray and ShredSchema accept. Read through helpers
that handle every binary and string representation instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

@CurtHagenlocher
CurtHagenlocher merged commit d952f30 into apache:main Sep 27, 2026
14 checks passed
@CurtHagenlocher
CurtHagenlocher deleted the variant-shredded-binary-types branch September 27, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shredded variant readers throw InvalidCastException for large_binary and binary_view storage

2 participants