fn test_truncate_table_summary()

in crates/iceberg/src/spec/snapshot_summary.rs [608:716]


    fn test_truncate_table_summary() {
        let prev_props: HashMap<String, String> = [
            (TOTAL_DATA_FILES.to_string(), "10".to_string()),
            (TOTAL_DELETE_FILES.to_string(), "5".to_string()),
            (TOTAL_RECORDS.to_string(), "100".to_string()),
            (TOTAL_FILE_SIZE.to_string(), "1000".to_string()),
            (TOTAL_POSITION_DELETES.to_string(), "3".to_string()),
            (TOTAL_EQUALITY_DELETES.to_string(), "2".to_string()),
        ]
        .into_iter()
        .collect();

        let previous_summary = Summary {
            operation: Operation::Overwrite,
            additional_properties: prev_props,
        };

        let mut new_props = HashMap::new();
        new_props.insert("dummy".to_string(), "value".to_string());
        let summary = Summary {
            operation: Operation::Overwrite,
            additional_properties: new_props,
        };

        let truncated = truncate_table_summary(summary, &previous_summary).unwrap();

        assert_eq!(
            truncated
                .additional_properties
                .get(TOTAL_DATA_FILES)
                .unwrap(),
            "0"
        );
        assert_eq!(
            truncated
                .additional_properties
                .get(TOTAL_DELETE_FILES)
                .unwrap(),
            "0"
        );
        assert_eq!(
            truncated.additional_properties.get(TOTAL_RECORDS).unwrap(),
            "0"
        );
        assert_eq!(
            truncated
                .additional_properties
                .get(TOTAL_FILE_SIZE)
                .unwrap(),
            "0"
        );
        assert_eq!(
            truncated
                .additional_properties
                .get(TOTAL_POSITION_DELETES)
                .unwrap(),
            "0"
        );
        assert_eq!(
            truncated
                .additional_properties
                .get(TOTAL_EQUALITY_DELETES)
                .unwrap(),
            "0"
        );

        assert_eq!(
            truncated
                .additional_properties
                .get(DELETED_DATA_FILES)
                .unwrap(),
            "10"
        );
        assert_eq!(
            truncated
                .additional_properties
                .get(REMOVED_DELETE_FILES)
                .unwrap(),
            "5"
        );
        assert_eq!(
            truncated
                .additional_properties
                .get(DELETED_RECORDS)
                .unwrap(),
            "100"
        );
        assert_eq!(
            truncated
                .additional_properties
                .get(REMOVED_FILE_SIZE)
                .unwrap(),
            "1000"
        );
        assert_eq!(
            truncated
                .additional_properties
                .get(REMOVED_POSITION_DELETES)
                .unwrap(),
            "3"
        );
        assert_eq!(
            truncated
                .additional_properties
                .get(REMOVED_EQUALITY_DELETES)
                .unwrap(),
            "2"
        );
    }