Skip to content

Commit

Permalink
API, Core: Add uuid API to Table
Browse files Browse the repository at this point in the history
  • Loading branch information
amogh-jahagirdar committed Oct 11, 2023
1 parent b5ea0d5 commit 5848761
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/src/main/java/org/apache/iceberg/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,15 @@ default UpdateStatistics updateStatistics() {
*/
Map<String, SnapshotRef> refs();

/**
* Returns the UUID of the table
*
* @return the UUID of the table
*/
default String uuid() {
throw new UnsupportedOperationException(this.getClass().getName() + " doesn't implement uuid");
}

/**
* Returns the snapshot referenced by the given name or null if no such reference exists.
*
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/org/apache/iceberg/BaseMetadataTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ public Map<String, SnapshotRef> refs() {
return table().refs();
}

@Override
public String uuid() {
return table().uuid();
}

@Override
public String toString() {
return name();
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/org/apache/iceberg/BaseTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ public Map<String, SnapshotRef> refs() {
return ops.current().refs();
}

@Override
public String uuid() {
return ops.current().uuid();
}

@Override
public String toString() {
return name();
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/org/apache/iceberg/BaseTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,11 @@ public Map<String, SnapshotRef> refs() {
return current.refs();
}

@Override
public String uuid() {
return current.uuid();
}

@Override
public String toString() {
return name();
Expand Down
7 changes: 7 additions & 0 deletions core/src/main/java/org/apache/iceberg/SerializableTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class SerializableTable implements Table, Serializable {
private transient volatile Schema lazySchema = null;
private transient volatile Map<Integer, PartitionSpec> lazySpecs = null;
private transient volatile SortOrder lazySortOrder = null;
private final String uuid;

protected SerializableTable(Table table) {
this.name = table.name();
Expand All @@ -83,6 +84,7 @@ protected SerializableTable(Table table) {
this.encryption = table.encryption();
this.locationProvider = table.locationProvider();
this.refs = SerializableMap.copyOf(table.refs());
this.uuid = table.uuid();
}

/**
Expand Down Expand Up @@ -247,6 +249,11 @@ public Map<String, SnapshotRef> refs() {
return refs;
}

@Override
public String uuid() {
return uuid;
}

@Override
public void refresh() {
throw new UnsupportedOperationException(errorMsg("refresh"));
Expand Down

0 comments on commit 5848761

Please sign in to comment.