Skip to content

Spark 4.1: expose catalog labels via metadata table and DESCRIBE - #17411

Draft
laskoviymishka wants to merge 3 commits into
apache:mainfrom
laskoviymishka:labels-spark
Draft

Spark 4.1: expose catalog labels via metadata table and DESCRIBE#17411
laskoviymishka wants to merge 3 commits into
apache:mainfrom
laskoviymishka:labels-spark

Conversation

@laskoviymishka

Copy link
Copy Markdown
Contributor

Makes the catalog-provided labels reachable from Spark.

Stacked on the catalog PR (which is stacked on #17337). Review the top commit — the lower layers belong to the parent PRs.

What changed

  • New LabelsTable metadata table (core): MetadataTableType.LABELS plus a BaseMetadataTable that flattens a table's labels into rows {scope, field_id, key, value}. Object-level labels use scope object with a null field_id; field-level labels use scope field. Registered in MetadataTableUtils, so it is queryable as SELECT * FROM tbl.labels (Spark routes metadata tables generically, no Spark-side change needed for query access).
  • BaseSparkTable.properties() surfaces labels under labels.object.* and labels.field.<id>.* so they appear in DESCRIBE EXTENDED. Driver-side only; labels are ephemeral catalog enrichment and are not distributed to executors.

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.
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.
Builds on the SupportsLabels table exposure to make catalog-provided labels
reachable from Spark.

- New LabelsTable metadata table (core): MetadataTableType.LABELS plus a
  BaseMetadataTable that flattens a table's labels into rows
  {scope, field_id, key, value}. object-level labels use scope "object" with a
  null field_id; field-level labels use scope "field". Registered in
  MetadataTableUtils, so it is queryable as `SELECT * FROM tbl.labels` (Spark
  routes metadata tables generically, no Spark-side change needed).
- Spark BaseSparkTable.properties() surfaces labels under labels.object.* and
  labels.field.<id>.* so they appear in DESCRIBE EXTENDED. Driver-side only;
  labels are ephemeral catalog enrichment and are not distributed to executors.
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.

1 participant