Skip to content

Fix the snapshot summary of a partial overwrite #1879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 16, 2025

Conversation

Fokko
Copy link
Contributor

@Fokko Fokko commented Apr 3, 2025

Rationale for this change

@kevinjqliu PTAL. I took the liberty of providing a fix for this since I was curious where this was coming from, hope you don't mind! I've cherry-picked your commit with the test.

image

Java produces:

{
    "added-data-files": "1",
    "added-files-size": "707",
    "added-records": "2",
    "app-id": "local-1743678304626",
    "changed-partition-count": "1",
    "deleted-data-files": "1",
    "deleted-records": "3",
    "engine-name": "spark",
    "engine-version": "3.5.5",
    "iceberg-version": "Apache Iceberg 1.8.1 (commit 9ce0fcf0af7becf25ad9fc996c3bad2afdcfd33d)",
    "removed-files-size": "693",
    "spark.app.id": "local-1743678304626",
    "total-data-files": "3",
    "total-delete-files": "0",
    "total-equality-deletes": "0",
    "total-files-size": "1993",
    "total-position-deletes": "0",
    "total-records": "4"
}

Are these changes tested?

Are there any user-facing changes?

Copy link
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont mind at all. Thanks for picking this up

@kevinjqliu kevinjqliu added this to the PyIceberg 0.9.1 milestone Apr 3, 2025
@Fokko Fokko requested a review from kevinjqliu April 9, 2025 20:04
Copy link
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix @Fokko, LGTM.

I just have a few comments on whether Spark is generating the correct snapshot summary.

@@ -467,21 +467,19 @@ def test_partitioned_table_positional_deletes_sequence_number(spark: SparkSessio
assert snapshots[2].summary == Summary(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i ran this locally. snapshot 0 has the following metadata, which is correct

{
    'added-data-files': '2',
    'added-files-size': '1490',
    'added-records': '5',
    'changed-partition-count': '2',
    'total-data-files': '2',
    'total-delete-files': '0',
    'total-equality-deletes': '0',
    'total-files-size': '1490',
    'total-position-deletes': '0',
    'total-records': '5'
}

but snapshot 1, DELETE op with the positional delete, has the following metadata,

{
    'added-delete-files': '1',
    'added-files-size': '1710',
    'added-position-delete-files': '1',
    'added-position-deletes': '1',
    'changed-partition-count': '1',
    'total-data-files': '2',
    'total-delete-files': '1',
    'total-equality-deletes': '0',
    'total-files-size': '3200',
    'total-position-deletes': '1',
    'total-records': '5'
}

everything looks right except for the total-records. we started off with 5 records, and the DELETE op removed 1 record. So total-records should be 4 here.
Is this a bug in the spark snapshot summary?

Copy link
Contributor Author

@Fokko Fokko Apr 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Looking at it, snapshot summary 1 seems incorrect. Could you open up an issue on the Java side? It would be good to get some historical context around this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to reproduce it using #1926. I'll also open an issue on the java side

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apache/iceberg#12823 opened an issue on the java side

Co-authored-by: Kevin Liu <[email protected]>
@Fokko Fokko merged commit 3c52167 into apache:main Apr 16, 2025
7 checks passed
@Fokko Fokko deleted the fd-fix-summary branch April 16, 2025 19:56
@Fokko
Copy link
Contributor Author

Fokko commented Apr 16, 2025

Thanks for the review @kevinjqliu 🙌

Fokko added a commit that referenced this pull request Apr 17, 2025
# Rationale for this change

@kevinjqliu PTAL. I took the liberty of providing a fix for this since I
was curious where this was coming from, hope you don't mind! I've
cherry-picked your commit with the test.


![image](https://github.com/user-attachments/assets/14227da9-1f4a-4411-88f0-309907d3d332)


Java produces:

```json
{
    "added-data-files": "1",
    "added-files-size": "707",
    "added-records": "2",
    "app-id": "local-1743678304626",
    "changed-partition-count": "1",
    "deleted-data-files": "1",
    "deleted-records": "3",
    "engine-name": "spark",
    "engine-version": "3.5.5",
    "iceberg-version": "Apache Iceberg 1.8.1 (commit 9ce0fcf0af7becf25ad9fc996c3bad2afdcfd33d)",
    "removed-files-size": "693",
    "spark.app.id": "local-1743678304626",
    "total-data-files": "3",
    "total-delete-files": "0",
    "total-equality-deletes": "0",
    "total-files-size": "1993",
    "total-position-deletes": "0",
    "total-records": "4"
}
```

# Are these changes tested?

# Are there any user-facing changes?

<!-- In the case of user-facing changes, please add the changelog label.
-->

---------

Co-authored-by: Kevin Liu <[email protected]>
Co-authored-by: Kevin Liu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants