Skip to content

Python: Add list-refs CLI command#8570

Closed
amogh-jahagirdar wants to merge 1 commit intoapache:masterfrom
amogh-jahagirdar:pythoncli-list-refs
Closed

Python: Add list-refs CLI command#8570
amogh-jahagirdar wants to merge 1 commit intoapache:masterfrom
amogh-jahagirdar:pythoncli-list-refs

Conversation

@amogh-jahagirdar
Copy link
Copy Markdown
Contributor

This change adds a list-refs CLI command
Screenshot from 2023-09-15 21-17-00

Comment thread python/pyiceberg/cli/output.py Outdated
name = ref_tup[0]
ref = ref_tup[1]
if ref.snapshot_ref_type == 'branch':
min_snapshots_to_keep = str(ref.min_snapshots_to_keep)
Copy link
Copy Markdown
Contributor Author

@amogh-jahagirdar amogh-jahagirdar Sep 16, 2023

Choose a reason for hiding this comment

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

Still thinking through what's best to surface to a user when the retention properties aren't set. I wonder if the current outputting of "None" will confuse users into thinking somehow there isn't any retention but that's not really the case. During snapshot expiration we fall back to the table level property. Maybe I just load the table property to fill in these values in case it's None.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree that it is best to pull in the table properties, and show the fall back expiration time.

Copy link
Copy Markdown
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.

Great work @amogh-jahagirdar, some small suggestions

Comment thread python/pyiceberg/cli/console.py Outdated
Comment thread python/pyiceberg/cli/console.py Outdated
"""List all the refs in the provided table"""
catalog, output = _catalog_and_output(ctx)
table = catalog.load_table(identifier)
refs = table.metadata.refs
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We try to avoid accessing the metadata directly (that should have been private ..)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, I added a new refs() API on Table, let me know what you think!

Comment thread python/pyiceberg/cli/console.py Outdated
Comment thread python/pyiceberg/cli/output.py Outdated
Comment thread python/pyiceberg/cli/output.py Outdated
name = ref_tup[0]
ref = ref_tup[1]
if ref.snapshot_ref_type == 'branch':
min_snapshots_to_keep = str(ref.min_snapshots_to_keep)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree that it is best to pull in the table properties, and show the fall back expiration time.

@amogh-jahagirdar amogh-jahagirdar force-pushed the pythoncli-list-refs branch 7 times, most recently from e046aed to e954c7e Compare September 30, 2023 12:49
Comment thread python/pyiceberg/cli/output.py Outdated
Comment on lines +142 to +143
for name, type, ref_detail in ref_details:
refs_table.add_row(name, type, ref_detail['max_ref_age_ms'], ref_detail['min_snapshots_to_keep'], ref_detail['max_snapshot_age_ms'])
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I changed it to putting the ref name in the first column, followed by the type (previously it was the other way around, but it made more sense to me to have the name be first)

Comment thread python/pyiceberg/cli/console.py Outdated
"""List all the refs in the provided table"""
catalog, output = _catalog_and_output(ctx)
table = catalog.load_table(identifier)
refs = table.metadata.refs
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, I added a new refs() API on Table, let me know what you think!

@amogh-jahagirdar amogh-jahagirdar requested a review from Fokko October 1, 2023 17:40
@amogh-jahagirdar
Copy link
Copy Markdown
Contributor Author

amogh-jahagirdar commented Oct 1, 2023

Will publish this PR to the new iceberg-python repo https://github.com/apache/iceberg-python, closing this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants