in crates/iceberg/src/spec/table_metadata.rs [2271:2402]
fn test_partition_statistics_file() {
let data = r#"
{
"format-version": 2,
"table-uuid": "9c12d441-03fe-4693-9a96-a0705ddf69c1",
"location": "s3://bucket/test/location",
"last-sequence-number": 34,
"last-updated-ms": 1602638573590,
"last-column-id": 3,
"current-schema-id": 0,
"schemas": [
{
"type": "struct",
"schema-id": 0,
"fields": [
{
"id": 1,
"name": "x",
"required": true,
"type": "long"
}
]
}
],
"default-spec-id": 0,
"partition-specs": [
{
"spec-id": 0,
"fields": []
}
],
"last-partition-id": 1000,
"default-sort-order-id": 0,
"sort-orders": [
{
"order-id": 0,
"fields": []
}
],
"properties": {},
"current-snapshot-id": 3055729675574597004,
"snapshots": [
{
"snapshot-id": 3055729675574597004,
"timestamp-ms": 1555100955770,
"sequence-number": 1,
"summary": {
"operation": "append"
},
"manifest-list": "s3://a/b/2.avro",
"schema-id": 0
}
],
"partition-statistics": [
{
"snapshot-id": 3055729675574597004,
"statistics-path": "s3://a/b/partition-stats.parquet",
"file-size-in-bytes": 43
}
],
"snapshot-log": [],
"metadata-log": []
}
"#;
let schema = Schema::builder()
.with_schema_id(0)
.with_fields(vec![Arc::new(NestedField::required(
1,
"x",
Type::Primitive(PrimitiveType::Long),
))])
.build()
.unwrap();
let partition_spec = PartitionSpec::builder(schema.clone())
.with_spec_id(0)
.build()
.unwrap();
let snapshot = Snapshot::builder()
.with_snapshot_id(3055729675574597004)
.with_timestamp_ms(1555100955770)
.with_sequence_number(1)
.with_manifest_list("s3://a/b/2.avro")
.with_schema_id(0)
.with_summary(Summary {
operation: Operation::Append,
additional_properties: HashMap::new(),
})
.build();
let default_partition_type = partition_spec.partition_type(&schema).unwrap();
let expected = TableMetadata {
format_version: FormatVersion::V2,
table_uuid: Uuid::parse_str("9c12d441-03fe-4693-9a96-a0705ddf69c1").unwrap(),
location: "s3://bucket/test/location".to_string(),
last_updated_ms: 1602638573590,
last_column_id: 3,
schemas: HashMap::from_iter(vec![(0, Arc::new(schema))]),
current_schema_id: 0,
partition_specs: HashMap::from_iter(vec![(0, partition_spec.clone().into())]),
default_spec: Arc::new(partition_spec),
default_partition_type,
last_partition_id: 1000,
default_sort_order_id: 0,
sort_orders: HashMap::from_iter(vec![(0, SortOrder::unsorted_order().into())]),
snapshots: HashMap::from_iter(vec![(3055729675574597004, Arc::new(snapshot))]),
current_snapshot_id: Some(3055729675574597004),
last_sequence_number: 34,
properties: HashMap::new(),
snapshot_log: Vec::new(),
metadata_log: Vec::new(),
statistics: HashMap::new(),
partition_statistics: HashMap::from_iter(vec![(
3055729675574597004,
PartitionStatisticsFile {
snapshot_id: 3055729675574597004,
statistics_path: "s3://a/b/partition-stats.parquet".to_string(),
file_size_in_bytes: 43,
},
)]),
refs: HashMap::from_iter(vec![("main".to_string(), SnapshotReference {
snapshot_id: 3055729675574597004,
retention: SnapshotRetention::Branch {
min_snapshots_to_keep: None,
max_snapshot_age_ms: None,
max_ref_age_ms: None,
},
})]),
};
check_table_metadata_serde(data, expected);
}