Skip to content

[Variant] Support extracting struct fields as Variant using ExtensionType #9519

Open

Description

@codephage2020

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

/// TODO: How would a caller request a struct or list type where the fields/elements can be any
/// variant? Caller can pass None as the requested type to fetch a specific path, but it would
/// quickly become annoying (and inefficient) to call `variant_get` for each leaf value in a struct or
/// list and then try to assemble the results.

Given data like:

{"user": {"id": 123, "metadata": {"tags": ["a"], "score": 95.5}}}

Users want to extract user with:

  • id as Int32
  • metadata as Variant (not expanded)

Currently, this requires multiple variant_get calls and manual StructArray assembly.

Describe the solution you'd like

Use ExtensionType to mark fields that should remain as Variant:

let field = Field::new("user", DataType::Struct(Fields::from(vec![
    Field::new("id", DataType::Int32, true),
    Field::new("metadata", ..., true).with_extension_type(VariantType),  // Keep as Variant
])), true);

let result = variant_get(&array, GetOptions::new().with_as_type(Some(Arc::new(field))))?;

Activity

  1. added
    enhancement
    on Mar 6, 2026
  2. sdf-jkl commented on Mar 18, 2026

    @sdf-jkl
    Member

    This seems related - #8154

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions