Function strip_metadata_from_schema

Source
pub fn strip_metadata_from_schema(schema: &Schema) -> Result<Schema>
Expand description

Strips all metadata from an Arrow schema and its nested fields.

This function recursively removes metadata from all fields at every level of the schema, including nested struct, list, and map fields. This is useful for schema comparison where metadata differences should be ignored.

§Arguments

  • schema - The Arrow schema to strip metadata from

§Returns

A new Arrow schema with all metadata removed, or an error if the schema structure is invalid.

§Example

use std::collections::HashMap;

use arrow_schema::{DataType, Field, Schema as ArrowSchema};
use iceberg::arrow::strip_metadata_from_schema;

let mut metadata = HashMap::new();
metadata.insert("key".to_string(), "value".to_string());

let field = Field::new("col1", DataType::Int32, false).with_metadata(metadata);
let schema = ArrowSchema::new(vec![field]);

let stripped = strip_metadata_from_schema(&schema).unwrap();
assert!(stripped.field(0).metadata().is_empty());