Skip to content

Conversation

@rambleraptor
Copy link
Contributor

@rambleraptor rambleraptor commented Jul 9, 2025

Closes #2191

Rationale for this change

apache/iceberg supports these two event types. We should do the same to match the Java implementation and allow users to alter their partition statistics files.

REST Spec Reference

Are these changes tested?

Unit test included.

Are there any user-facing changes?

  • Adds RemovePartitionStatisticsUpdate and SetPartitionStatisticsUpdate actions.

events

This allows us to add, update, and remove partition statistics files.
@rambleraptor rambleraptor force-pushed the partition_statistics_events branch from 42a82ca to 8d31af0 Compare July 10, 2025 16:27
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.

LGTM, added 1 nit comment about function reuse.

Could you also add the rest spec reference to the PR description? https://github.com/apache/iceberg/blob/09140e52836048b112c42c9cfe721295bd57048b/open-api/rest-catalog-open-api.yaml#L2981-L3004

return [stat for stat in statistics if stat.snapshot_id != reject_snapshot_id]


def filter_partition_statistics_by_snapshot_id(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: wdyt about combing this with the function above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I gave this a try and couldn't get it to work without very strange looking type errors / wonky annotations (this could also be my Python-foo failing me). I'm going to keep it as-is if that's alright.

Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW don't think we've released #2146 yet so can maybe rename StatisticsCommonFields to BaseStatisticsFile but unsure.

Copy link
Contributor

@smaheshwar-pltr smaheshwar-pltr Jul 10, 2025

Choose a reason for hiding this comment

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

Then or otherwise I'd have thought S = TypeVar("S", bound=BaseStatisticsFile) (or StatisticsCommonFields without rename) may work? But not tested it 😄

@rambleraptor
Copy link
Contributor Author

@kevinjqliu please merge whenever you're ready!

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.

LGTM! I managed to get type hint working with Union. The | operator only works for python 3.10+ and we still supports 3.9 currently

@kevinjqliu kevinjqliu merged commit 66df396 into apache:main Jul 15, 2025
10 checks passed
@kevinjqliu
Copy link
Contributor

Thanks for the PR @rambleraptor and @smaheshwar-pltr for the review! :)

gabeiglio pushed a commit to Netflix/iceberg-python that referenced this pull request Aug 13, 2025
…pache#2192)

<!--
Thanks for opening a pull request!
-->

<!-- In the case this PR will resolve an issue, please replace
${GITHUB_ISSUE_ID} below with the actual Github issue id. -->
Closes apache#2191 

# Rationale for this change
apache/iceberg supports these two event types. We should do the same to
match the Java implementation and allow users to alter their partition
statistics files.

[REST Spec
Reference]([apache/iceberg@09140e5/open-api/rest-catalog-open-api.yaml#L2981-L3004](https://github.com/apache/iceberg/blob/09140e52836048b112c42c9cfe721295bd57048b/open-api/rest-catalog-open-api.yaml#L2981-L3004))

# Are these changes tested?
Unit test included.

# Are there any user-facing changes?
- Adds `RemovePartitionStatisticsUpdate` and
`SetPartitionStatisticsUpdate` actions.

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

---------

Co-authored-by: Kevin Liu <kevin.jq.liu@gmail.com>
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.

Support SetPartitionStatistics and RemovePartitionStatistics

3 participants