Thalweg · API reference ← Main docs

build_arrow_schema

Function build_arrow_schema 

Source
pub fn build_arrow_schema(
    descriptor_set_bytes: &[u8],
    message_type: &str,
    flatten_depth: u32,
) -> Result<SchemaRef, ProtoSchemaError>
Expand description

Decodes descriptor_set_bytes as a protobuf FileDescriptorSet (must be compiled with protoc --include_imports so every referenced type is present in the set), resolves message_type (fully-qualified; a leading ‘.’ is added if missing), and flattens its fields into an Arrow schema.

flatten_depth controls how many levels of singular nested messages get expanded into individually-named flat columns before the remainder becomes a single nested Struct column instead - see the flatten module doc comment for the full policy set (wrapper unwrap, native-Map, enum-as-symbol, repeated-as-List).

The nested-Struct recursion safety limit defaults to MAX_STRUCT_DEPTH; use build_arrow_schema_with_struct_depth to override it per deployment.

§Errors

Returns ProtoSchemaError::Decode if descriptor_set_bytes is not a valid protobuf FileDescriptorSet, or ProtoSchemaError::MessageNotFound if message_type is not present in the set.