Skip to content

[Variant] Support Nested Data in VariantBuilder #7696

@alamb

Description

@alamb

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
As discussed by @scovich @PinkCrow007 and I on #7653 (comment) we need to figure out how to build nested objects

Describe the solution you'd like
I would like some way to create an nested structures such as lists of structs

For example

[
  {
   "first_name": "Jiaying",
  "last_name": "Li"
 },
   {
    "first_name": "Malthe",
    "last_name": "Karbo"
 }
]

Describe alternatives you've considered
One way would be to add new_list and new_struct methods to the existing ListBuilder and StructBuilder, something like

let mut builder = VariantBuilder::new();

// create overall list
let mut list = builder.new_list();

// create first object
mut let obj = list.new_object(); // NOTE this is on the `list` builder not the overall builder
obj.set("first_name", "Jiaying");
obj.set("last_name", "Li");
obj.finish(); // finish the first object

// create second object
mut let obj = list.new_object(); // NOTE this is on the `list` builder not the overall builder
obj.set("first_name", "Malthe");
obj.set("last_name", "Karbo");
obj.finish(); // finish the first object

 
// finish the overall list
list.finish()

let (metadata, value) = builder.fiinish();

Additional context

Metadata

Metadata

Labels

enhancementAny new improvement worthy of a entry in the changelogparquetChanges to the parquet crate

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions