Skip to content

Variant: Write Variant Values as JSON #7426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Tracked by #6736
alamb opened this issue Apr 18, 2025 · 0 comments
Open
Tracked by #6736

Variant: Write Variant Values as JSON #7426

alamb opened this issue Apr 18, 2025 · 0 comments
Labels
enhancement Any new improvement worthy of a entry in the changelog

Comments

@alamb
Copy link
Contributor

alamb commented Apr 18, 2025

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

@alamb alamb added the enhancement Any new improvement worthy of a entry in the changelog label Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Any new improvement worthy of a entry in the changelog
Projects
None yet
Development

No branches or pull requests

1 participant