Skip to content

[Variant] Infer a shredding schema from sampled values #11951

Open

Description

@sdf-jkl

Is your feature request related to a problem or challenge?

shred_variant and ShreddedSchemaBuilder let callers shred Variant values using an explicit schema. For semi-structured data whose shape is not known in advance, callers must decide which paths and types to extract themselves.

A reusable schema-selection API would let applications automatically choose a layout for Parquet output without each implementing its own inference policy.

Describe the solution you'd like

Infer a logical target schema from a bounded sample of Variant values, suitable for passing to shred_variant. For example, a sample of events with string service and integer status fields could produce a target equivalent to STRUCT(service Utf8, status Int64).

The inference policy should consider field frequency and type compatibility, with limits on schema width, depth, and inference memory. Define how mixed types are handled—for example, selecting a common type versus leaving that path unshredded—and make the result deterministic for the same sample and options. Empty or all-null samples should have a defined fallback.

For Parquet writing, callers would collect a bounded sample, select the layout before creating the writer, then apply it to the sampled and subsequent batches. The layout stays fixed for the file. Later fields and incompatible values remain in residual Variant storage; the sample must not constrain which logical values can be written.

The API shape, default thresholds, and whether sampling belongs in a separate writer adapter are open for discussion. Inference should be usable independently of writer integration in #11950.

Describe alternatives you've considered

Use an explicit schema, leave values unshredded, or implement inference downstream. Explicit schemas remain useful when callers know which paths their workloads access; sampling cannot discover that information by itself.

Additional context

Activity

  1. added
    enhancement
    on Oct 27, 2026
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