Skip to content

[Variant] unshred_variant panics on malformed bytes despite returning Result #9740

Closed

Description

@friendlymatthew

unshred_variant returns Result<VariantArray, ArrowError> and its docs say it errors on spec violations.

However, it internally calls VariantMetadata::new, Variant::new_with_metadata, and VariantObject::iter. All of which panics on bad input.

This is clearly bad because unshred_varaint is meant to consume bytes that came off disk, which by definition can be wrong. Though the fix is fairly mechanical since the panicking call sites have their try_ counterparts

/// Removes all (nested) typed_value columns from a VariantArray by converting them back to binary
/// variant and merging the resulting values back into the value column.
///
/// This function efficiently converts a shredded VariantArray back to an unshredded form where all
/// data resides in the value column.
///
/// # Arguments
/// * `array` - The VariantArray to unshred
///
/// # Returns
/// A new VariantArray with all data in the value column and no typed_value column
///
/// # Errors
/// - If the shredded data contains spec violations (e.g., field name conflicts)
/// - If unsupported data types are encountered in typed_value columns
pub fn unshred_variant(array: &VariantArray) -> Result<VariantArray> {

Activity

  1. added
    bug
    on Apr 16, 2026
  2. friendlymatthew commented on Apr 16, 2026

    @friendlymatthew
    ContributorAuthor

    cc @scovich

    We're actively bringing variants into production

  3. added a commit that references this issue on Apr 16, 2026
  4. added
    parquet-variant
    on Apr 23, 2026
  5. alamb commented on Apr 23, 2026

    @alamb
    Contributor

    label_issue.py automatically added labels {'parquet-variant'} from #9741

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugparquet-variant

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions