rdblue commented on code in PR #8147:
URL: https://github.com/apache/iceberg/pull/8147#discussion_r1292846188
##########
core/src/main/java/org/apache/iceberg/MetadataUpdate.java:
##########
@@ -377,5 +409,56 @@ public String location() {
public void applyTo(TableMetadata.Builder metadataBuilder) {
metadataBuilder.setLocation(location);
}
+
+ @Override
+ public void applyTo(ViewMetadata.Builder viewMetadataBuilder) {
+ viewMetadataBuilder.setLocation(location);
+ }
+ }
+
+ class AddViewVersion implements MetadataUpdate {
+ private final ViewVersion viewVersion;
+
+ public AddViewVersion(ViewVersion viewVersion) {
+ this.viewVersion = viewVersion;
+ }
+
+ public ViewVersion viewVersion() {
+ return viewVersion;
+ }
+
+ @Override
+ public void applyTo(TableMetadata.Builder metadataBuilder) {
+ throw new UnsupportedOperationException(
+ String.format("Cannot apply update %s to a table",
this.getClass().getSimpleName()));
+ }
+
+ @Override
+ public void applyTo(ViewMetadata.Builder viewMetadataBuilder) {
+ viewMetadataBuilder.addVersion(viewVersion);
+ }
+ }
+
+ class SetCurrentViewVersion implements MetadataUpdate {
+ private final int versionId;
+
+ public SetCurrentViewVersion(int versionId) {
+ this.versionId = versionId;
+ }
+
+ public int versionId() {
+ return versionId;
+ }
+
+ @Override
+ public void applyTo(TableMetadata.Builder metadataBuilder) {
+ throw new UnsupportedOperationException(
+ String.format("Cannot apply update %s to a table",
this.getClass().getSimpleName()));
Review Comment:
An alternative is to make this the default implementation for `void
applyTo(TableMetadata.Builder)` so that we don't need it in two places (or more
if we add more view mutations).
##########
core/src/main/java/org/apache/iceberg/MetadataUpdate.java:
##########
@@ -377,5 +409,56 @@ public String location() {
public void applyTo(TableMetadata.Builder metadataBuilder) {
metadataBuilder.setLocation(location);
}
+
+ @Override
+ public void applyTo(ViewMetadata.Builder viewMetadataBuilder) {
+ viewMetadataBuilder.setLocation(location);
+ }
+ }
+
+ class AddViewVersion implements MetadataUpdate {
+ private final ViewVersion viewVersion;
+
+ public AddViewVersion(ViewVersion viewVersion) {
+ this.viewVersion = viewVersion;
+ }
+
+ public ViewVersion viewVersion() {
+ return viewVersion;
+ }
+
+ @Override
+ public void applyTo(TableMetadata.Builder metadataBuilder) {
+ throw new UnsupportedOperationException(
+ String.format("Cannot apply update %s to a table",
this.getClass().getSimpleName()));
+ }
+
+ @Override
+ public void applyTo(ViewMetadata.Builder viewMetadataBuilder) {
+ viewMetadataBuilder.addVersion(viewVersion);
+ }
+ }
+
+ class SetCurrentViewVersion implements MetadataUpdate {
+ private final int versionId;
+
+ public SetCurrentViewVersion(int versionId) {
+ this.versionId = versionId;
+ }
+
+ public int versionId() {
+ return versionId;
+ }
+
+ @Override
+ public void applyTo(TableMetadata.Builder metadataBuilder) {
+ throw new UnsupportedOperationException(
+ String.format("Cannot apply update %s to a table",
this.getClass().getSimpleName()));
Review Comment:
Minor: An alternative is to make this the default implementation for `void
applyTo(TableMetadata.Builder)` so that we don't need it in two places (or more
if we add more view mutations).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]