JosephLenton commented on PR #656:
URL: https://github.com/apache/avro-rs/pull/656#issuecomment-5573466407
Hey @Kriskras99 , I have pulled down your PR and can confirm my Avro test
passes and so does my Iceberg test! Thank you very much for getting this done.
If it helps the tests I have are these. They failed before, and pass now.
Feel free to add them to your PR (or a followup) if you find them helpful.
I had them in: `avro/tests/schema.rs`
```rust
#[test]
fn it_should_preserve_map_logical_type_on_outer_item() -> TestResult {
let raw_schema = r#"{
"type": "array",
"logicalType": "map",
"items": {
"type": "record",
"name": "k12_v13",
"fields": [
{
"name": "key",
"type": "int",
"field-id": 12
},
{
"name": "value",
"type": "string",
"field-id": 13
}
]
}
}"#;
let schema = Schema::parse_str(raw_schema)?;
let output = serde_json::to_string_pretty(&schema).unwrap();
pretty_assertions::assert_eq!(
r#"{
"type": "array",
"items": {
"type": "record",
"name": "k12_v13",
"fields": [
{
"name": "key",
"type": "int",
"field-id": 12
},
{
"name": "value",
"type": "string",
"field-id": 13
}
]
},
"logicalType": "map"
}"#,
output
);
let logical_type =
schema.custom_attributes().unwrap().get("logicalType");
assert_eq!(
logical_type,
Some(&serde_json::Value::String("map".to_string()))
);
Ok(())
}
#[test]
fn it_should_preserve_map_logical_type_on_inner_item() -> TestResult {
let raw_schema = r#"{
"type": "record",
"name": "test_record",
"fields": [
{
"name": "example_map",
"type": {
"type": "array",
"logicalType": "map",
"items": {
"type": "record",
"name": "k12_v13",
"fields": [
{
"name": "key",
"type": "int",
"field-id": 12
},
{
"name": "value",
"type": "string",
"field-id": 13
}
]
}
}
}
]
}"#;
let schema = Schema::parse_str(raw_schema)?;
let Schema::Record(record) = &schema else {
panic!("Expected a record schema");
};
let example_map_schema = &record.fields[0].schema;
let logical_type = example_map_schema
.custom_attributes()
.unwrap()
.get("logicalType");
assert_eq!(
logical_type,
Some(&serde_json::Value::String("map".to_string()))
);
Ok(())
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]