Skip to main content

flatten_record_batch

Function flatten_record_batch 

Source
pub fn flatten_record_batch(batch: &RecordBatch) -> Result<RecordBatch>
Expand description

Flattens all Struct columns in a RecordBatch into top-level columns, dot-joining names as it recurses.

  • Struct(a, b) with name foo → columns foo.a, foo.b
  • FixedSizeList(n, Struct(...)) with name foo → columns foo.0, foo.1, … foo.n-1, each further expanded if the struct has fields
  • List(Struct(...)) with name foo → single foo column serialised to UTF-8 string
  • Any other type is emitted unchanged

When two expanded names collide the second occurrence is renamed name_1, the third name_2, and so on (the first occurrence keeps its original name).