Skip to content

Core: expose labels on the loaded table via SupportsLabels - #17410

Closed
laskoviymishka wants to merge 4 commits into
apache:mainfrom
laskoviymishka:labels-catalog
Closed

laskoviymishka wants to merge 4 commits into
apache:mainfrom
laskoviymishka:labels-catalog

Conversation

@laskoviymishka

Copy link
Copy Markdown
Contributor

Exposes the catalog-provided labels obtained from the load response on the loaded Table, so engines and tooling can read them.

Stacked on #17337 (the labels read-path serde). Review the top commit — the serde layer belongs to #17337.

What changed

  • New SupportsLabels mixin interface (mirroring SupportsDistributedScanPlanning) with a single labels() accessor.
  • BaseTable implements SupportsLabels via a new constructor carrying an optional Labels; existing constructors default to an empty instance. The field is transient and is not copied into SerializableTable, so labels are ephemeral catalog enrichment and are not preserved across table serialization (driver-side only).
  • RESTSessionCatalog populates labels from the load response for both the plain BaseTable and the server-side scan-planning RESTTable paths, across loadTable, registerTable, and createTable.

Read-only; the write path is out of scope.

Comment on lines +52 to +54
// Ephemeral catalog enrichment, not table state. Transient because it is not preserved across
// serialization: writeReplace() swaps in a SerializableTable for Java serialization, and any
// path that bypasses writeReplace (e.g. Kryo) leaves this null, handled by labels().

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.

This is a little verbose. I think the first sentence is enough.

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.

Actually, I'm not sure why we're not preserving these. I'm a little concerned because it creates some weird behaviors through serialization. This table will say it supports labels, but once serialized, it doesn't (since SerializedTable doesn't support the interface). Maybe this isn't an issue but I'm also not clear on why we would not maintain it through serialization for anything wanting this info on a worker/executor side.

import org.apache.iceberg.rest.labels.Labels;

/**
* Implemented by tables that can expose catalog-provided labels obtained from the load response.

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.

Remove the obtained from the load response from the end since you can implement this for other non-REST catalogs (e.g. BigLake)

*/
package org.apache.iceberg;

import org.apache.iceberg.rest.labels.Labels;

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.

See comment here: https://github.com/apache/iceberg/pull/17337/changes#r3739125412

I think the Labels class itself is general enough to put in the top level package.

Reference client implementation for the IRC labels read-path spec change
(apache#15750). Without it, RESTObjectMapper (which sets
FAIL_ON_UNKNOWN_PROPERTIES = false) silently drops the labels field on
deserialization, so labels returned by a catalog are invisible to the Java
client.

New rest.labels package (mirroring rest.credentials): Labels (object + fields
sub-scopes, with a shared empty instance) and FieldLabels (per-field, keyed by
field-id) value types as immutables interfaces, each with a JSON parser.
FieldLabels validates field-id >= 1 and a non-empty labels map, matching
Credential.

Wire an optional labels field into LoadTableResponse / LoadViewResponse and
their parsers. labels() never returns null (empty instance when absent), on
LoadViewResponse via a @Value.Default default method so no interface API break
is introduced. Labels are omitted from the wire when absent (or empty), so the
change is additive and backward compatible.
@laskoviymishka
laskoviymishka force-pushed the labels-catalog branch 2 times, most recently from 3a8d980 to 5056726 Compare August 10, 2026 13:50
Adds an `include-labels` flag to the REST server test fixture that attaches
labels to load table and load view responses, mirroring how
`include-credentials` vends credentials.

The injected labels are derived from the catalog name and the server hostname,
and the first column of the schema is labeled so that both object-level and
field-level labels are covered. This gives other client implementations a
reference server that actually returns labels to test against.
The raw HTTP client used to read the load responses requires an auth session,
so requests failed with "Invalid auth session: null". The local fixture does
not authenticate requests, so the empty session is used.
Builds on the labels read-path serde: make the catalog-provided labels from
the load response reachable by consumers.

- New SupportsLabels mixin interface (mirroring SupportsDistributedScanPlanning)
  with a single labels() accessor.
- BaseTable implements SupportsLabels via a new constructor that carries an
  optional Labels; existing constructors default to an empty instance. The field
  is transient and not copied into SerializableTable, so labels are ephemeral
  catalog enrichment and are not preserved across table serialization.
- RESTSessionCatalog populates labels from the load response for both the plain
  BaseTable and the server-side scan-planning RESTTable paths, across loadTable,
  registerTable, and createTable.
@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Sep 11, 2026
@laskoviymishka

Copy link
Copy Markdown
Contributor Author

Close in favor for #18045

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants