Skip to content

Variant: Write Variant Values as JSON #7426

@alamb

Description

@alamb

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

A major use case for Variant values in Parquet and Arrow is efficiently
processing JSON encoded data. Thus, an important capability is being able to
very efficiently write Variant binary values (described in XXX and in
VariantEncoding.md) to JSON.

This ticket covers an API to convert a single Variant to JSON. Other tickets
will cover converting multiple Variant values to JSON as well as converting
to/from Arrow Utf8* arrays and Variant arrays as well as writing this to/from
parquet.

Describe the solution you'd like

I would like an API to write a variant to json

Describe alternatives you've considered

I suggest an API like this:

// Use API from XXX to read variant values
let metadata: &[u8] = ...;
let value: &[u8] = ...;
let variant = Variant::try_new(metadata, value);

// Location for writing json bytes
// Should be anything that implements std::io::Write or some other trait
let mut json_buffer = vec![];
// Convert the variant value to JSON
variant_to_json(&mut json_buffer, variant)?;
// json_buffer now contains json encoded values

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAny new improvement worthy of a entry in the changelog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions