yayaha opened a new pull request, #4321:
URL: https://github.com/apache/iceberg-python/pull/4321
# Rationale for this change
This PR is part 2 of 2. It depends on #4320. Only the last commit is new.
This PR adds `Table.labels`, the same as `SupportsLabels` in
apache/iceberg#18046:
- The REST catalog sets `Table.labels` in `load_table`, `create_table`, and
`register_table`. `rename_table` gets labels through `load_table`.
- Tables from other catalogs, staged tables from `create_table_transaction`,
and tables built directly have empty labels.
- Labels are not table state, the same as in Java. `Table.__eq__` ignores
them. `refresh()` and commits keep the labels from the first load.
- `View` has no `labels` attribute. Java does not expose view labels either.
Difference from Java: a pickled table keeps its labels. Java does not
serialize them.
```python
table = catalog.load_table("db.events")
table.labels.object_labels # {"owner": "team-a"}
for field in table.labels.fields:
print(table.schema().find_column_name(field.field_id), field.labels)
```
## Are these changes tested?
Yes. `test_load_table_with_labels` tests three things: a load response sets
`Table.labels`, `__eq__` ignores labels, and `refresh()` keeps the first
labels. `test_labels_default_to_empty` tests a table built without labels. I
also loaded a tagged table from a Unity Catalog REST endpoint. `Table.labels`
matched the `labels` JSON in the response.
## Are there any user-facing changes?
Yes. `Table` has a new `labels` attribute and a new optional `labels`
keyword argument. It is the last argument, so existing calls do not change.
Please add the `changelog` label.
AI disclosure: This pull request and its description were written by Claude.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]