Skip to content

Commit

Permalink
API, Core: Add uuid() to View (#8851)
Browse files Browse the repository at this point in the history
  • Loading branch information
nastra authored Oct 31, 2023
1 parent 86bb1c0 commit 4433aa8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/src/main/java/org/apache/iceberg/view/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.iceberg.Schema;
import org.apache.iceberg.UpdateLocation;

Expand Down Expand Up @@ -111,4 +112,13 @@ default ReplaceViewVersion replaceVersion() {
default UpdateLocation updateLocation() {
throw new UnsupportedOperationException("Updating a view's location is not supported");
}

/**
* Returns the view's UUID
*
* @return the view's UUID
*/
default UUID uuid() {
throw new UnsupportedOperationException("Retrieving a view's uuid is not supported");
}
}
6 changes: 6 additions & 0 deletions core/src/main/java/org/apache/iceberg/view/BaseView.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.iceberg.Schema;
import org.apache.iceberg.UpdateLocation;

Expand Down Expand Up @@ -97,4 +98,9 @@ public ReplaceViewVersion replaceVersion() {
public UpdateLocation updateLocation() {
return new SetViewLocation(ops);
}

@Override
public UUID uuid() {
return UUID.fromString(ops.current().uuid());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.UUID;
import org.apache.iceberg.Schema;
import org.apache.iceberg.Transaction;
import org.apache.iceberg.UpdateLocation;
Expand Down Expand Up @@ -158,6 +159,8 @@ public void completeCreateView() {
}

// validate view settings
assertThat(view.uuid())
.isEqualTo(UUID.fromString(((BaseView) view).operations().current().uuid()));
assertThat(view.name()).isEqualTo(ViewUtil.fullViewName(catalog().name(), identifier));
assertThat(view.properties()).containsEntry("prop1", "val1").containsEntry("prop2", "val2");
assertThat(view.history())
Expand Down

0 comments on commit 4433aa8

Please sign in to comment.