Skip to main content

align_schema_by_nested_paths

Function align_schema_by_nested_paths 

Source
pub(crate) fn align_schema_by_nested_paths<'a, I>(
    schema: &mut Schema,
    nested_paths: I,
)
where I: IntoIterator<Item = &'a [NestedPath]>,
Expand description

Aligns nested struct fields according to the requested nested paths.

For each root field:

  • An empty path list keeps the whole field unchanged.
  • Non-JSON root fields ignore nested paths and keep the whole field unchanged.
  • JSON2 root fields are rebuilt from nested_paths.
  • Existing schema fields are preserved only when they are the requested leaf.
  • Requested paths missing from the schema are synthesized with JSONB (Binary) leaves.

For example, if the schema has j: struct<a: struct<x: Int64, y: Utf8>> and nested_paths requests j.a.x and j.a.z, the result is j: struct<a: struct<x: Int64, z: Binary>>.