diff --git a/crates/iceberg/src/avro/schema.rs b/crates/iceberg/src/avro/schema.rs index f8420d460..636f1283c 100644 --- a/crates/iceberg/src/avro/schema.rs +++ b/crates/iceberg/src/avro/schema.rs @@ -705,7 +705,7 @@ mod tests { "field-id": 100 } ] -} +} "#, ) .unwrap() @@ -768,7 +768,7 @@ mod tests { "field-id": 100 } ] -} +} "#, ) .unwrap() @@ -915,7 +915,7 @@ mod tests { "type": "string" } ] -} +} "#, ) .unwrap() diff --git a/crates/iceberg/src/spec/manifest.rs b/crates/iceberg/src/spec/manifest.rs index 818f9c678..e3c989f95 100644 --- a/crates/iceberg/src/spec/manifest.rs +++ b/crates/iceberg/src/spec/manifest.rs @@ -695,7 +695,7 @@ mod _const_schema { ])), )), ]; - let schema = Schema::builder().with_fields(fields).build().unwrap(); + let schema = Schema::builder().with_fields(fields).build()?; schema_to_avro_schema("manifest_entry", &schema) } } diff --git a/crates/iceberg/src/spec/schema.rs b/crates/iceberg/src/spec/schema.rs index 6991d5296..34e383f65 100644 --- a/crates/iceberg/src/spec/schema.rs +++ b/crates/iceberg/src/spec/schema.rs @@ -136,7 +136,7 @@ impl SchemaBuilder { id_to_field: &HashMap, identifier_field_ids: impl Iterator, ) -> Result<()> { - let id_to_parent = index_parents(r#struct); + let id_to_parent = index_parents(r#struct)?; for identifier_field_id in identifier_field_ids { let field = id_to_field.get(&identifier_field_id).ok_or_else(|| { Error::new( @@ -406,7 +406,7 @@ pub fn index_by_id(r#struct: &StructType) -> Result } /// Creates a field id to parent field id map. -pub fn index_parents(r#struct: &StructType) -> HashMap { +pub fn index_parents(r#struct: &StructType) -> Result> { struct IndexByParent { parents: Vec, result: HashMap, @@ -487,8 +487,8 @@ pub fn index_parents(r#struct: &StructType) -> HashMap { parents: vec![], result: HashMap::new(), }; - visit_struct(r#struct, &mut index).unwrap(); - index.result + visit_struct(r#struct, &mut index)?; + Ok(index.result) } #[derive(Default)] @@ -971,13 +971,13 @@ mod tests { #[test] fn test_schema_display() { - let expected_str = r#" + let expected_str = " table { - 1: foo: optional string - 2: bar: required int - 3: baz: optional boolean + 1: foo: optional string\x20 + 2: bar: required int\x20 + 3: baz: optional boolean\x20 } -"#; +"; assert_eq!(expected_str, format!("\n{}", table_schema_simple().0)); } diff --git a/crates/iceberg/src/transaction.rs b/crates/iceberg/src/transaction.rs index 5de0ea68b..b26581327 100644 --- a/crates/iceberg/src/transaction.rs +++ b/crates/iceberg/src/transaction.rs @@ -160,7 +160,10 @@ impl<'a> ReplaceSortOrderAction<'a> { .table .metadata() .default_sort_order() - .expect("default sort order impossible to be None") + .ok_or(Error::new( + ErrorKind::Unexpected, + "default sort order impossible to be none", + ))? .order_id, }, ];