You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by at...@apache.org on 2026/09/10 11:33:00 UTC

(iceberg) 01/01: Spark 4.1: expose catalog labels via DESCRIBE

This is an automated email from the ASF dual-hosted git repository.

laskoviymishka pushed a commit to branch laskoviymishka/labels-spark
in repository https://gitbox.apache.org/repos/asf/iceberg.git

commit e39314119118b68bf83731d90c4f6d053b391418
Author: laskoviymishka <la...@gmail.com>
AuthorDate: Thu Sep 10 13:23:32 2026 +0200

    Spark 4.1: expose catalog labels via DESCRIBE
    
    Surface catalog-provided labels as reserved table properties on the Spark
    table so they appear in DESCRIBE EXTENDED. The labels metadata table remains
    the queryable counterpart.
---
 .../iceberg/spark/source/BaseSparkTable.java       | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/BaseSparkTable.java b/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/BaseSparkTable.java
index 464f3cd353..4ee478cb3c 100644
--- a/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/BaseSparkTable.java
+++ b/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/BaseSparkTable.java
@@ -27,8 +27,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import org.apache.iceberg.BaseTable;
+import org.apache.iceberg.FieldLabels;
+import org.apache.iceberg.Labels;
 import org.apache.iceberg.Schema;
 import org.apache.iceberg.Snapshot;
+import org.apache.iceberg.SupportsLabels;
 import org.apache.iceberg.Table;
 import org.apache.iceberg.TableOperations;
 import org.apache.iceberg.TableUtil;
@@ -55,6 +58,8 @@ abstract class BaseSparkTable
   private static final String LOCATION = "location";
   private static final String SORT_ORDER = "sort-order";
   private static final String IDENTIFIER_FIELDS = "identifier-fields";
+  private static final String LABELS_OBJECT_PREFIX = "labels.object.";
+  private static final String LABELS_FIELD_PREFIX = "labels.field.";
   private static final Set<String> RESERVED_PROPERTIES =
       ImmutableSet.of(
           PROVIDER,
@@ -157,6 +162,23 @@ abstract class BaseSparkTable
         .filter(entry -> !RESERVED_PROPERTIES.contains(entry.getKey()))
         .forEach(propsBuilder::put);
 
+    // Surface catalog-provided labels (driver-side only; not part of table state) so they are
+    // visible in DESCRIBE EXTENDED. The tbl.labels metadata table is the queryable counterpart.
+    if (table instanceof SupportsLabels) {
+      Labels labels = ((SupportsLabels) table).labels();
+      labels
+          .objectLabels()
+          .forEach((key, value) -> propsBuilder.put(LABELS_OBJECT_PREFIX + key, value));
+      for (FieldLabels fieldLabels : labels.fields()) {
+        fieldLabels
+            .labels()
+            .forEach(
+                (key, value) ->
+                    propsBuilder.put(
+                        LABELS_FIELD_PREFIX + fieldLabels.fieldId() + "." + key, value));
+      }
+    }
+
     return propsBuilder.build();
   }