Skip to content

[Variant] Support Shredded Objects in variant_get: untyped path access #8151

Closed

Description

@alamb

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

Note this is likely one of the most complex parts of implementing Shredded Variants , so it is not a good first task

We are trying to support the general case of the variant_get function, which allows runtime dynamic access to Variants (either shredded or unshredded).

This ticket tracks
Support variant_get for any path and no data type. This would extract whatever variant sub-value is found at the path's end

Implementing this functionality will likely require the basic representation for shredded Variant arrays along with path traversal in variant_get. However, it does NOT cover the following (which are / will be broken into separate tickets)

  • Support for retrieving paths as a specified type
  • Retrieving an arbitrary path as a "Struct" (aka implementing shredding)
  • Retrieving any arbitrary path as a Variant (aka "unshredding")

Describe the solution you'd like
@scovich sketched out a high level design for Shredded Objects (see Representing Variant In Arrow Proposal: "Shredding an Object" and Variant Shredding::Objects) in this PR

So roughly that means supporting

// get the named field of variant object as a typed field 
variant_get(array, "$.field_name", None)

Where $.field_name represents some arbitrary VariantPath such as a for field "a", or a.b for field "b" of field "a"

This should work for:

  1. Variants where the field_name is in a typed_value
  2. Variants where the field_name is not in the typed value

Describe alternatives you've considered

  1. Add a test that manually constructs a shredded variant array (follow the example in the arrow proposal)
  2. Add a test that calls variant_get appropriately
  3. Implement the code

I suggest getting this working for non-nested obejcts first, and then working on nesting / pathing as a second pR

Additional context

Reference

Activity

  1. scovich commented on Aug 15, 2025

    @scovich
    Contributor

    I suggest getting this working for non-nested obejcts first, and then working on nesting / pathing as a second pR

    Isn't an untyped non-nested variant_get just the identity function?
    It seems like pathing is the only interesting part of an untyped variant_get call?

  2. alamb commented on Aug 15, 2025

    @alamb
    ContributorAuthor

    I suggest getting this working for non-nested obejcts first, and then working on nesting / pathing as a second pR

    Isn't an untyped non-nested variant_get just the identity function? It seems like pathing is the only interesting part of an untyped variant_get call?

    Yes, I think it is about the pathing (which I suppose is all about nesting). Updated the description

  3. sdf-jkl commented on Mar 19, 2026

    @sdf-jkl
    Member

    It seems like this one is covered, not accounting for the #9443

  4. alamb commented on Mar 31, 2026

    @alamb
    ContributorAuthor

    shall we close this issue?

  5. sdf-jkl commented on Mar 31, 2026

    @sdf-jkl
    Member

    I think we should. My comment above is about Variant::List, so we don't have to wait for that.

    A test showing coverage here:

    fn test_shredded_object_field_access() {
    let array = shredded_object_with_x_field_variant_array();
    // Test: Extract the "x" field as VariantArray first
    let options = GetOptions::new_with_path(VariantPath::try_from("x").unwrap());
    let result = variant_get(&array, options).unwrap();
    let result_variant = VariantArray::try_new(&result).unwrap();
    assert_eq!(result_variant.len(), 2);
    // Row 0: expect x=1
    assert_eq!(result_variant.value(0), Variant::Int32(1));
    // Row 1: expect x=42
    assert_eq!(result_variant.value(1), Variant::Int32(42));
    }

  6. alamb commented on Apr 1, 2026

    @alamb
    ContributorAuthor

    Thanks @sdf-jkl

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions