in crates/catalog/hms/src/schema.rs [298:459]
fn test_schema_with_simple_fields() -> Result<()> {
let record = r#"{
"type": "struct",
"schema-id": 1,
"fields": [
{
"id": 1,
"name": "c1",
"required": true,
"type": "boolean"
},
{
"id": 2,
"name": "c2",
"required": true,
"type": "int"
},
{
"id": 3,
"name": "c3",
"required": true,
"type": "long"
},
{
"id": 4,
"name": "c4",
"required": true,
"type": "float"
},
{
"id": 5,
"name": "c5",
"required": true,
"type": "double"
},
{
"id": 6,
"name": "c6",
"required": true,
"type": "decimal(2,2)"
},
{
"id": 7,
"name": "c7",
"required": true,
"type": "date"
},
{
"id": 8,
"name": "c8",
"required": true,
"type": "time"
},
{
"id": 9,
"name": "c9",
"required": true,
"type": "timestamp"
},
{
"id": 10,
"name": "c10",
"required": true,
"type": "string"
},
{
"id": 11,
"name": "c11",
"required": true,
"type": "uuid"
},
{
"id": 12,
"name": "c12",
"required": true,
"type": "fixed[4]"
},
{
"id": 13,
"name": "c13",
"required": true,
"type": "binary"
}
]
}"#;
let schema = serde_json::from_str::<Schema>(record)?;
let result = HiveSchemaBuilder::from_iceberg(&schema)?.build();
let expected = vec![
FieldSchema {
name: Some("c1".into()),
r#type: Some("boolean".into()),
comment: None,
},
FieldSchema {
name: Some("c2".into()),
r#type: Some("int".into()),
comment: None,
},
FieldSchema {
name: Some("c3".into()),
r#type: Some("bigint".into()),
comment: None,
},
FieldSchema {
name: Some("c4".into()),
r#type: Some("float".into()),
comment: None,
},
FieldSchema {
name: Some("c5".into()),
r#type: Some("double".into()),
comment: None,
},
FieldSchema {
name: Some("c6".into()),
r#type: Some("decimal(2,2)".into()),
comment: None,
},
FieldSchema {
name: Some("c7".into()),
r#type: Some("date".into()),
comment: None,
},
FieldSchema {
name: Some("c8".into()),
r#type: Some("string".into()),
comment: None,
},
FieldSchema {
name: Some("c9".into()),
r#type: Some("timestamp".into()),
comment: None,
},
FieldSchema {
name: Some("c10".into()),
r#type: Some("string".into()),
comment: None,
},
FieldSchema {
name: Some("c11".into()),
r#type: Some("string".into()),
comment: None,
},
FieldSchema {
name: Some("c12".into()),
r#type: Some("binary".into()),
comment: None,
},
FieldSchema {
name: Some("c13".into()),
r#type: Some("binary".into()),
comment: None,
},
];
assert_eq!(result, expected);
Ok(())
}