Skip to content
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

Add Refs metadata table #602

Merged
merged 7 commits into from
Apr 17, 2024
Merged

Add Refs metadata table #602

merged 7 commits into from
Apr 17, 2024

Conversation

geruh
Copy link
Contributor

@geruh geruh commented Apr 12, 2024

This PR adds the Refs metadata table the existing inspect logic for Iceberg tables as listed in #511. The refs metadata table in Iceberg stores the table's known snapshot references including branches, and tags.

Usage

> table.inspect.refs()
pyarrow.Table
name: string not null
type: string not null
snapshot_id: int64 not null
max_reference_age_in_ms: int64
min_snapshots_to_keep: int32
max_snapshot_age_in_ms: int64
----
name: [["testBranch","main","testTag"]]
type: [["BRANCH","BRANCH","TAG"]]
snapshot_id: [[4549716733136159472,4549716733136159472,4549716733136159472]]
max_reference_age_in_ms: [[604800000,null,15552000000]]
min_snapshots_to_keep: [[2,null,null]]
max_snapshot_age_in_ms: [[null,null,null]]

@amogh-jahagirdar amogh-jahagirdar self-requested a review April 12, 2024 21:31
Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

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

Looking good @geruh. I've left one small comment 👍


ref_schema = pa.schema([
pa.field('name', pa.string(), nullable=False),
pa.field('type', pa.string(), nullable=False),
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of changing this field into a categorical? https://pandas.pydata.org/docs/user_guide/categorical.html#series-creation

Copy link
Contributor Author

@geruh geruh Apr 15, 2024

Choose a reason for hiding this comment

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

Hey Fokko, I looked into this for both pandas and pyarrow and it offers a few benefits like reduced memory usage and improved performance on sorting and filtering. Since we're only dealing with branch or tag, this is ideal. However, this does stray from the Java implementation which uses a string type. But I think we should be fine with this difference, because in both pyarrow and pandas, this type seems to be well supported and can be easily converted to string if needed. Also, this would be beneficial for huge tables with many references.

In pyarrow, this would be implemented as a dictionary type mapping integers to strings. Also, this could be added to the other metadata tables such as the operation field in the snapshots table.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, and yes, I agree that it is okay to diverge from the Java implementation here since it is just an implementation detail.

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

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

Looks great, just a nit in the test from my side!

tests/integration/test_inspect_table.py Show resolved Hide resolved
@Fokko
Copy link
Contributor

Fokko commented Apr 16, 2024

@geruh Thanks for creating this PR! Can you resolve the conflicts so we can get this in? Thanks!

@Fokko Fokko mentioned this pull request Apr 17, 2024
8 tasks
@Fokko Fokko merged commit 2ee2d19 into apache:main Apr 17, 2024
7 checks passed
@Fokko
Copy link
Contributor

Fokko commented Apr 17, 2024

Thanks @geruh for working on this 🙌

@geruh geruh deleted the refs-table branch April 17, 2024 15:58
@geruh geruh mentioned this pull request Apr 18, 2024
@kevinjqliu kevinjqliu mentioned this pull request May 14, 2024
39 tasks
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.

3 participants