in crates/iceberg/src/catalog/mod.rs [1303:1390]
fn test_add_schema() {
let test_schema = Schema::builder()
.with_schema_id(1)
.with_identifier_field_ids(vec![2])
.with_fields(vec![
NestedField::optional(1, "foo", Type::Primitive(PrimitiveType::String)).into(),
NestedField::required(2, "bar", Type::Primitive(PrimitiveType::Int)).into(),
NestedField::optional(3, "baz", Type::Primitive(PrimitiveType::Boolean)).into(),
])
.build()
.unwrap();
test_serde_json(
r#"
{
"action": "add-schema",
"schema": {
"type": "struct",
"schema-id": 1,
"fields": [
{
"id": 1,
"name": "foo",
"required": false,
"type": "string"
},
{
"id": 2,
"name": "bar",
"required": true,
"type": "int"
},
{
"id": 3,
"name": "baz",
"required": false,
"type": "boolean"
}
],
"identifier-field-ids": [
2
]
},
"last-column-id": 3
}
"#,
TableUpdate::AddSchema {
schema: test_schema.clone(),
},
);
test_serde_json(
r#"
{
"action": "add-schema",
"schema": {
"type": "struct",
"schema-id": 1,
"fields": [
{
"id": 1,
"name": "foo",
"required": false,
"type": "string"
},
{
"id": 2,
"name": "bar",
"required": true,
"type": "int"
},
{
"id": 3,
"name": "baz",
"required": false,
"type": "boolean"
}
],
"identifier-field-ids": [
2
]
}
}
"#,
TableUpdate::AddSchema {
schema: test_schema.clone(),
},
);
}