in crates/iceberg/src/spec/table_metadata.rs [1942:2034]
fn test_branch_snapshot_missing() {
let data = r#"
{
"format-version" : 2,
"table-uuid": "fb072c92-a02b-11e9-ae9c-1bb7bc9eca94",
"location": "s3://b/wh/data.db/table",
"last-sequence-number" : 1,
"last-updated-ms": 1515100955770,
"last-column-id": 1,
"schemas": [
{
"schema-id" : 1,
"type" : "struct",
"fields" :[
{
"id": 1,
"name": "struct_name",
"required": true,
"type": "fixed[1]"
},
{
"id": 4,
"name": "ts",
"required": true,
"type": "timestamp"
}
]
}
],
"current-schema-id" : 1,
"partition-specs": [
{
"spec-id": 0,
"fields": [
{
"source-id": 4,
"field-id": 1000,
"name": "ts_day",
"transform": "day"
}
]
}
],
"default-spec-id": 0,
"last-partition-id": 1000,
"properties": {
"commit.retry.num-retries": "1"
},
"metadata-log": [
{
"metadata-file": "s3://bucket/.../v1.json",
"timestamp-ms": 1515100
}
],
"sort-orders": [
{
"order-id": 0,
"fields": []
}
],
"default-sort-order-id": 0,
"refs" : {
"main" : {
"snapshot-id" : 1,
"type" : "branch"
},
"foo" : {
"snapshot-id" : 2,
"type" : "branch"
}
},
"snapshots" : [ {
"snapshot-id" : 1,
"timestamp-ms" : 1662532818843,
"sequence-number" : 0,
"summary" : {
"operation" : "append",
"spark.app.id" : "local-1662532784305",
"added-data-files" : "4",
"added-records" : "4",
"added-files-size" : "6001"
},
"manifest-list" : "/home/iceberg/warehouse/nyc/taxis/metadata/snap-638933773299822130-1-7e6760f0-4f6c-4b23-b907-0a5a174e3863.avro",
"schema-id" : 0
} ]
}
"#;
let err = serde_json::from_str::<TableMetadata>(data).unwrap_err();
assert!(err
.to_string()
.contains("Snapshot for reference foo does not exist in the existing snapshots list"));
}