Skip to content

Snapshot summary totals appear to be calculated incorrectly when previous totals don't exist #2576

@dannycjones

Description

@dannycjones

Apache Iceberg Rust version

None

Describe the bug

When calculating totals, we initialize the previous as 0 if not set. Given these summaries are optional, we may incorrectly calculate the totals where files exist but don't have total summaries set.

let previous_total = previous_summary.map_or(0, |previous_summary| {
previous_summary
.additional_properties
.get(total_property)
.map_or(0, |value| value.parse::<u64>().unwrap())
});

To Reproduce

No response

Expected behavior

I expect that we should skip calculating the totals when we do not have a previous value to reference. This does mean some other process would need to calculate the totals outside of this commit in order to introduce totals to the snapshot summaries.

Willingness to contribute

I can contribute a fix for this bug independently

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions