Thalweg · API reference ← Main docs

decode_to_record_batch

Function decode_to_record_batch 

Source
pub fn decode_to_record_batch(
    bytes: &[u8],
    descriptor_set: &FileDescriptorSet,
    root_type: &str,
    flatten_depth: u32,
) -> Result<RecordBatch, ProtoDecodeError>
Expand description

Decodes one message straight to a single-row RecordBatch: the schema comes from twg_proto_schema::build_arrow_schema (so it’s guaranteed consistent with whatever the validator/schema side computed), and every column whose type is List/Struct/Map gets a genuine native Arrow array via json_to_native_array; everything else is the scalar JSON value, stringified for Utf8 columns exactly like the JSON path.

§Errors

Returns a ProtoDecodeError if the wire bytes cannot be decoded, if schema derivation from the descriptor set fails, or if the decoded columns cannot be assembled into a RecordBatch.

§Panics

Panics only if re-encoding the caller-supplied FileDescriptorSet fails — an impossibility for a set we already hold in memory, so this indicates memory corruption rather than a recoverable error.