MCPcopy Create free account
hub / github.com/apache/datafusion / read_avro_schema_from_reader

Function read_avro_schema_from_reader

datafusion/datasource-avro/src/mod.rs:41–50  ·  view source on GitHub ↗

Read Avro schema given a reader

(
    reader: &mut R,
)

Source from the content-addressed store, hash-verified

39
40/// Read Avro schema given a reader
41pub fn read_avro_schema_from_reader<R: Read>(
42 reader: &mut R,
43) -> datafusion_common::Result<Schema> {
44 let avro_reader = ReaderBuilder::new().build(BufReader::new(reader))?;
45 // Avro readers perform strict schema resolution rules (e.g. record identity checks)
46 // that are stricter than DataFusion's table schema handling needs for inferred schemas.
47 // Drop metadata from inferred schemas so runtime batches and inferred table schemas
48 // compare consistently without requiring strict Avro metadata identity.
49 Ok(strip_metadata_from_schema(avro_reader.schema().as_ref()))
50}
51
52fn strip_metadata_from_schema(schema: &Schema) -> Schema {
53 let fields = schema

Callers 2

infer_schemaMethod · 0.85

Calls 5

newFunction · 0.85
buildMethod · 0.45
as_refMethod · 0.45
schemaMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…