Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ project(':iceberg-core') {
implementation project(path: ':iceberg-bundled-guava', configuration: 'shadow')
annotationProcessor "org.immutables:value"
compileOnly "org.immutables:value"
compileOnly "org.immutables:builder"

implementation("org.apache.avro:avro") {
exclude group: 'org.tukaani' // xz compression is not supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;
import org.apache.iceberg.MetadataUpdate;
import org.apache.iceberg.SnapshotRef;
import org.apache.iceberg.TableMetadata;
Expand All @@ -31,7 +32,10 @@
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.relocated.com.google.common.collect.Sets;
import org.apache.iceberg.rest.RESTRequest;
import org.immutables.builder.Builder.Constructor;
import org.immutables.value.Value;

@Value.Style(newBuilder = "newBuilder")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this, one would instantiate the Builder via new UpdateTableRequestBuilder(), which is probably fine as well. We could also add

public static UpdateTableRequestBuilder builder() {
    return new UpdateTableRequestBuilder();
}

to UpdateTableRequest

public class UpdateTableRequest implements RESTRequest {

private TableIdentifier identifier;
Expand All @@ -42,13 +46,19 @@ public UpdateTableRequest() {
// needed for Jackson deserialization
}

/**
* @deprecated will be removed in 1.5.0; use {@link UpdateTableRequestBuilder#newBuilder()}
* instead.
*/
@Deprecated
public UpdateTableRequest(List<UpdateRequirement> requirements, List<MetadataUpdate> updates) {
this.requirements = requirements;
this.updates = updates;
}

@Constructor
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will generate a Builder class from the constructor params and we're indicating in the constructor that TableIdentifier can be null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the constructor needs to be non-private (we could also change it to protected to be more strict and force usage via the generated builder

UpdateTableRequest(
TableIdentifier identifier,
@Nullable TableIdentifier identifier,
List<UpdateRequirement> requirements,
List<MetadataUpdate> updates) {
this(requirements, updates);
Expand All @@ -73,6 +83,7 @@ public TableIdentifier identifier() {
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("identifier", identifier)
.add("requirements", requirements)
.add("updates", updates)
.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,24 @@ public void invalidTableIdentifier() {
public void roundTripSerde() {
String uuid = "2cc52516-5e73-41f2-b139-545d41a4e151";
UpdateTableRequest commitTableRequestOne =
new UpdateTableRequest(
TableIdentifier.of("ns1", "table1"),
ImmutableList.of(
UpdateTableRequestBuilder.newBuilder()
.identifier(TableIdentifier.of("ns1", "table1"))
.addRequirements(
new UpdateRequirement.AssertTableUUID(uuid),
new UpdateRequirement.AssertTableDoesNotExist()),
ImmutableList.of(
new MetadataUpdate.AssignUUID(uuid), new MetadataUpdate.SetCurrentSchema(23)));
new UpdateRequirement.AssertTableDoesNotExist())
.addUpdates(
new MetadataUpdate.AssignUUID(uuid), new MetadataUpdate.SetCurrentSchema(23))
.build();

UpdateTableRequest commitTableRequestTwo =
new UpdateTableRequest(
TableIdentifier.of("ns1", "table2"),
ImmutableList.of(
UpdateTableRequestBuilder.newBuilder()
.identifier(TableIdentifier.of("ns1", "table2"))
.addRequirements(
new UpdateRequirement.AssertDefaultSpecID(4),
new UpdateRequirement.AssertCurrentSchemaID(24)),
ImmutableList.of(
new MetadataUpdate.RemoveSnapshot(101L), new MetadataUpdate.SetCurrentSchema(25)));
new UpdateRequirement.AssertCurrentSchemaID(24))
.addUpdates(
new MetadataUpdate.RemoveSnapshot(101L), new MetadataUpdate.SetCurrentSchema(25))
.build();

CommitTransactionRequest request =
new CommitTransactionRequest(
Expand Down Expand Up @@ -160,8 +162,9 @@ public void emptyRequirementsAndUpdates() {
CommitTransactionRequest commitTxRequest =
new CommitTransactionRequest(
ImmutableList.of(
new UpdateTableRequest(
TableIdentifier.of("ns1", "table1"), ImmutableList.of(), ImmutableList.of())));
UpdateTableRequestBuilder.newBuilder()
.identifier(TableIdentifier.of("ns1", "table1"))
.build()));

String json =
"{\"table-changes\":[{\"identifier\":{\"namespace\":[\"ns1\"],\"name\":\"table1\"},\"requirements\":[],\"updates\":[]}]}";
Expand Down
2 changes: 1 addition & 1 deletion versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ com.google.cloud:libraries-bom = 24.1.0
org.scala-lang.modules:scala-collection-compat_2.12 = 2.6.0
org.scala-lang.modules:scala-collection-compat_2.13 = 2.6.0
com.emc.ecs:object-client-bundle = 3.3.2
org.immutables:value = 2.9.2
org.immutables:* = 2.9.2
net.snowflake:snowflake-jdbc = 3.13.30
io.delta:delta-standalone_* = 0.6.0

Expand Down