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

Python: Add list-refs CLI command #8570

Closed

Conversation

amogh-jahagirdar
Copy link
Contributor

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

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
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
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
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

python/pyiceberg/cli/console.py Outdated Show resolved Hide resolved
"""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
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
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!

python/pyiceberg/cli/console.py Outdated Show resolved Hide resolved
python/pyiceberg/cli/output.py Outdated Show resolved Hide resolved
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
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 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
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)

"""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
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
Copy link
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