fn truncate_table_summary()

in crates/iceberg/src/spec/snapshot_summary.rs [428:482]


fn truncate_table_summary(mut summary: Summary, previous_summary: &Summary) -> Result<Summary> {
    for prop in [
        TOTAL_DATA_FILES,
        TOTAL_DELETE_FILES,
        TOTAL_RECORDS,
        TOTAL_FILE_SIZE,
        TOTAL_POSITION_DELETES,
        TOTAL_EQUALITY_DELETES,
    ] {
        summary
            .additional_properties
            .insert(prop.to_string(), "0".to_string());
    }

    let value = get_prop(previous_summary, TOTAL_DATA_FILES)?;
    if value != 0 {
        summary
            .additional_properties
            .insert(DELETED_DATA_FILES.to_string(), value.to_string());
    }
    let value = get_prop(previous_summary, TOTAL_DELETE_FILES)?;
    if value != 0 {
        summary
            .additional_properties
            .insert(REMOVED_DELETE_FILES.to_string(), value.to_string());
    }
    let value = get_prop(previous_summary, TOTAL_RECORDS)?;
    if value != 0 {
        summary
            .additional_properties
            .insert(DELETED_RECORDS.to_string(), value.to_string());
    }
    let value = get_prop(previous_summary, TOTAL_FILE_SIZE)?;
    if value != 0 {
        summary
            .additional_properties
            .insert(REMOVED_FILE_SIZE.to_string(), value.to_string());
    }

    let value = get_prop(previous_summary, TOTAL_POSITION_DELETES)?;
    if value != 0 {
        summary
            .additional_properties
            .insert(REMOVED_POSITION_DELETES.to_string(), value.to_string());
    }

    let value = get_prop(previous_summary, TOTAL_EQUALITY_DELETES)?;
    if value != 0 {
        summary
            .additional_properties
            .insert(REMOVED_EQUALITY_DELETES.to_string(), value.to_string());
    }

    Ok(summary)
}