diff --git a/.palantir/revapi.yml b/.palantir/revapi.yml index c5c92dba0d29..47e7a762a690 100644 --- a/.palantir/revapi.yml +++ b/.palantir/revapi.yml @@ -874,6 +874,10 @@ acceptedBreaks: justification: "Static utility class - should not have public constructor" "1.4.0": org.apache.iceberg:iceberg-core: + - code: "java.class.defaultSerializationChanged" + old: "class org.apache.iceberg.mapping.NameMapping" + new: "class org.apache.iceberg.mapping.NameMapping" + justification: "Serialization across versions is not guaranteed" - code: "java.class.noLongerImplementsInterface" old: "class org.apache.iceberg.AllDataFilesTable" new: "class org.apache.iceberg.AllDataFilesTable" @@ -942,25 +946,74 @@ acceptedBreaks: old: "class org.apache.iceberg.SnapshotsTable" new: "class org.apache.iceberg.SnapshotsTable" justification: "Removing deprecated code" - - code: "java.class.defaultSerializationChanged" - old: "class org.apache.iceberg.mapping.NameMapping" - new: "class org.apache.iceberg.mapping.NameMapping" - justification: "Serialization across versions is not guaranteed" - code: "java.class.removed" old: "class org.apache.iceberg.actions.BinPackStrategy" justification: "Removing deprecated code" - code: "java.class.removed" old: "class org.apache.iceberg.actions.SortStrategy" justification: "Removing deprecated code" + - code: "java.class.removed" + old: "class org.apache.iceberg.rest.RESTSerializers.UpdateRequirementDeserializer" + justification: "Removing deprecated code" + - code: "java.class.removed" + old: "class org.apache.iceberg.rest.RESTSerializers.UpdateRequirementSerializer" + justification: "Removing deprecated code" + - code: "java.class.removed" + old: "class org.apache.iceberg.rest.requests.UpdateRequirementParser" + justification: "Removing deprecated code" + - code: "java.class.removed" + old: "class org.apache.iceberg.rest.requests.UpdateTableRequest.Builder" + justification: "Removing deprecated code" - code: "java.class.removed" old: "interface org.apache.iceberg.actions.RewriteStrategy" justification: "Removing deprecated code" + - code: "java.class.removed" + old: "interface org.apache.iceberg.rest.requests.UpdateTableRequest.UpdateRequirement" + justification: "Removing deprecated code" - code: "java.field.serialVersionUIDChanged" new: "field org.apache.iceberg.util.SerializableMap.serialVersionUID" justification: "Serialization is not be used" - code: "java.method.removed" old: "method org.apache.iceberg.TableOperations org.apache.iceberg.BaseMetadataTable::operations()" justification: "Removing deprecated code" + - code: "java.method.removed" + old: "method org.apache.iceberg.encryption.EncryptedOutputFile org.apache.iceberg.io.ClusteredWriter::newOutputFile(org.apache.iceberg.io.OutputFileFactory, org.apache.iceberg.PartitionSpec,\ + \ org.apache.iceberg.StructLike) @ org.apache.iceberg.io.ClusteredDataWriter" + justification: "Removing deprecated code" + - code: "java.method.removed" + old: "method org.apache.iceberg.encryption.EncryptedOutputFile org.apache.iceberg.io.ClusteredWriter::newOutputFile(org.apache.iceberg.io.OutputFileFactory, org.apache.iceberg.PartitionSpec,\ + \ org.apache.iceberg.StructLike) @ org.apache.iceberg.io.ClusteredEqualityDeleteWriter" + justification: "Removing deprecated code" + - code: "java.method.removed" + old: "method org.apache.iceberg.encryption.EncryptedOutputFile org.apache.iceberg.io.ClusteredWriter::newOutputFile(org.apache.iceberg.io.OutputFileFactory, org.apache.iceberg.PartitionSpec,\ + \ org.apache.iceberg.StructLike) @ org.apache.iceberg.io.ClusteredPositionDeleteWriter" + justification: "Removing deprecated code" + - code: "java.method.removed" + old: "method org.apache.iceberg.encryption.EncryptedOutputFile org.apache.iceberg.io.FanoutWriter::newOutputFile(org.apache.iceberg.io.OutputFileFactory, org.apache.iceberg.PartitionSpec,\ + \ org.apache.iceberg.StructLike) @ org.apache.iceberg.io.FanoutDataWriter" + justification: "Removing deprecated code" + - code: "java.method.removed" + old: "method org.apache.iceberg.encryption.EncryptedOutputFile org.apache.iceberg.io.FanoutWriter::newOutputFile(org.apache.iceberg.io.OutputFileFactory, org.apache.iceberg.PartitionSpec,\ + \ org.apache.iceberg.StructLike) @ org.apache.iceberg.io.FanoutPositionOnlyDeleteWriter" + justification: "Removing deprecated code" + - code: "java.method.removed" + old: "method org.apache.iceberg.rest.requests.UpdateTableRequest.Builder org.apache.iceberg.rest.requests.UpdateTableRequest::builderFor(org.apache.iceberg.TableMetadata)" + justification: "Removing deprecated code" + - code: "java.method.removed" + old: "method org.apache.iceberg.rest.requests.UpdateTableRequest.Builder org.apache.iceberg.rest.requests.UpdateTableRequest::builderForCreate()" + justification: "Removing deprecated code" + - code: "java.method.removed" + old: "method org.apache.iceberg.rest.requests.UpdateTableRequest.Builder org.apache.iceberg.rest.requests.UpdateTableRequest::builderForReplace(org.apache.iceberg.TableMetadata)" + justification: "Removing deprecated code" + - code: "java.method.removed" + old: "method void org.apache.iceberg.PositionDeletesTable.PositionDeletesBatchScan::(org.apache.iceberg.Table,\ + \ org.apache.iceberg.Schema, org.apache.iceberg.TableScanContext)" + justification: "Removing deprecated code" apache-iceberg-0.14.0: org.apache.iceberg:iceberg-api: - code: "java.class.defaultSerializationChanged" diff --git a/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorHolder.java b/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorHolder.java index 6bd7fc6ab6fd..8919c3b6f702 100644 --- a/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorHolder.java +++ b/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorHolder.java @@ -119,12 +119,6 @@ public static VectorHolder constantHolder( return new ConstantVectorHolder<>(icebergField, numRows, constantValue); } - /** @deprecated since 1.4.0, will be removed in 1.5.0; use typed constant holders instead. */ - @Deprecated - public static VectorHolder constantHolder(int numRows, T constantValue) { - return new ConstantVectorHolder<>(numRows, constantValue); - } - public static VectorHolder deletedVectorHolder(int numRows) { return new DeletedVectorHolder(numRows); } @@ -150,13 +144,6 @@ public ConstantVectorHolder(int numRows) { this.constantValue = null; } - /** @deprecated since 1.4.0, will be removed in 1.5.0; use typed constant holders instead. */ - @Deprecated - public ConstantVectorHolder(int numRows, T constantValue) { - this.numRows = numRows; - this.constantValue = constantValue; - } - public ConstantVectorHolder(Types.NestedField icebergField, int numRows, T constantValue) { super(icebergField); this.numRows = numRows; diff --git a/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorizedArrowReader.java b/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorizedArrowReader.java index 35a6e8daa8e7..27ee25124f16 100644 --- a/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorizedArrowReader.java +++ b/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorizedArrowReader.java @@ -572,12 +572,6 @@ public void close() { public static class ConstantVectorReader extends VectorizedArrowReader { private final T value; - /** @deprecated since 1.4.0, will be removed in 1.5.0; use typed constant readers. */ - @Deprecated - public ConstantVectorReader(T value) { - this.value = value; - } - public ConstantVectorReader(Types.NestedField icebergField, T value) { super(icebergField); this.value = value; diff --git a/aws/src/main/java/org/apache/iceberg/aws/AwsClientFactories.java b/aws/src/main/java/org/apache/iceberg/aws/AwsClientFactories.java index df31f6ab8032..580e7303ffca 100644 --- a/aws/src/main/java/org/apache/iceberg/aws/AwsClientFactories.java +++ b/aws/src/main/java/org/apache/iceberg/aws/AwsClientFactories.java @@ -122,7 +122,7 @@ public GlueClient glue() { .applyMutation(awsClientProperties::applyClientRegionConfiguration) .applyMutation(httpClientProperties::applyHttpClientConfigurations) .applyMutation(awsProperties::applyGlueEndpointConfigurations) - .applyMutation(awsProperties::applyClientCredentialConfigurations) + .applyMutation(awsClientProperties::applyClientCredentialConfigurations) .build(); } @@ -131,7 +131,7 @@ public KmsClient kms() { return KmsClient.builder() .applyMutation(awsClientProperties::applyClientRegionConfiguration) .applyMutation(httpClientProperties::applyHttpClientConfigurations) - .applyMutation(awsProperties::applyClientCredentialConfigurations) + .applyMutation(awsClientProperties::applyClientCredentialConfigurations) .build(); } @@ -140,7 +140,7 @@ public DynamoDbClient dynamo() { return DynamoDbClient.builder() .applyMutation(awsClientProperties::applyClientRegionConfiguration) .applyMutation(httpClientProperties::applyHttpClientConfigurations) - .applyMutation(awsProperties::applyClientCredentialConfigurations) + .applyMutation(awsClientProperties::applyClientCredentialConfigurations) .applyMutation(awsProperties::applyDynamoDbEndpointConfigurations) .build(); } diff --git a/aws/src/main/java/org/apache/iceberg/aws/AwsProperties.java b/aws/src/main/java/org/apache/iceberg/aws/AwsProperties.java index 849445f86f3a..0d75e2451629 100644 --- a/aws/src/main/java/org/apache/iceberg/aws/AwsProperties.java +++ b/aws/src/main/java/org/apache/iceberg/aws/AwsProperties.java @@ -20,7 +20,6 @@ import java.io.Serializable; import java.net.URI; -import java.util.Collections; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -30,10 +29,8 @@ import org.apache.iceberg.common.DynMethods; import org.apache.iceberg.relocated.com.google.common.base.Preconditions; import org.apache.iceberg.relocated.com.google.common.base.Strings; -import org.apache.iceberg.relocated.com.google.common.collect.Maps; import org.apache.iceberg.relocated.com.google.common.collect.Sets; import org.apache.iceberg.util.PropertyUtil; -import org.apache.iceberg.util.SerializableMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; @@ -41,7 +38,6 @@ import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider; import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder; import software.amazon.awssdk.core.client.builder.SdkClientBuilder; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain; @@ -215,7 +211,6 @@ public class AwsProperties implements Serializable { public static final String REST_SESSION_TOKEN = "rest.session-token"; private static final String HTTP_CLIENT_PREFIX = "http-client."; - private final Map httpClientProperties; private final Set stsClientAssumeRoleTags; private String clientAssumeRoleArn; @@ -223,7 +218,6 @@ public class AwsProperties implements Serializable { private int clientAssumeRoleTimeoutSec; private String clientAssumeRoleRegion; private String clientAssumeRoleSessionName; - private String clientRegion; private String clientCredentialsProvider; private final Map clientCredentialsProviderProperties; @@ -235,7 +229,6 @@ public class AwsProperties implements Serializable { private String dynamoDbTableName; private String dynamoDbEndpoint; - private final Map allProperties; private String restSigningRegion; private String restSigningName; @@ -244,7 +237,6 @@ public class AwsProperties implements Serializable { private String restSessionToken; public AwsProperties() { - this.httpClientProperties = Collections.emptyMap(); this.stsClientAssumeRoleTags = Sets.newHashSet(); this.clientAssumeRoleArn = null; @@ -252,7 +244,6 @@ public AwsProperties() { this.clientAssumeRoleExternalId = null; this.clientAssumeRoleRegion = null; this.clientAssumeRoleSessionName = null; - this.clientRegion = null; this.clientCredentialsProvider = null; this.clientCredentialsProviderProperties = null; @@ -265,15 +256,11 @@ public AwsProperties() { this.dynamoDbEndpoint = null; this.dynamoDbTableName = DYNAMODB_TABLE_NAME_DEFAULT; - this.allProperties = Maps.newHashMap(); - this.restSigningName = REST_SIGNING_NAME_DEFAULT; } @SuppressWarnings("MethodLength") public AwsProperties(Map properties) { - this.httpClientProperties = - PropertyUtil.filterProperties(properties, key -> key.startsWith(HTTP_CLIENT_PREFIX)); this.stsClientAssumeRoleTags = toStsTags(properties, CLIENT_ASSUME_ROLE_TAGS_PREFIX); this.clientAssumeRoleArn = properties.get(CLIENT_ASSUME_ROLE_ARN); this.clientAssumeRoleTimeoutSec = @@ -282,7 +269,6 @@ public AwsProperties(Map properties) { this.clientAssumeRoleExternalId = properties.get(CLIENT_ASSUME_ROLE_EXTERNAL_ID); this.clientAssumeRoleRegion = properties.get(CLIENT_ASSUME_ROLE_REGION); this.clientAssumeRoleSessionName = properties.get(CLIENT_ASSUME_ROLE_SESSION_NAME); - this.clientRegion = properties.get(AwsClientProperties.CLIENT_REGION); this.clientCredentialsProvider = properties.get(AwsClientProperties.CLIENT_CREDENTIALS_PROVIDER); this.clientCredentialsProviderProperties = @@ -307,8 +293,6 @@ public AwsProperties(Map properties) { this.dynamoDbTableName = PropertyUtil.propertyAsString(properties, DYNAMODB_TABLE_NAME, DYNAMODB_TABLE_NAME_DEFAULT); - this.allProperties = SerializableMap.copyOf(properties); - this.restSigningRegion = properties.get(REST_SIGNER_REGION); this.restSigningName = properties.getOrDefault(REST_SIGNING_NAME, REST_SIGNING_NAME_DEFAULT); this.restAccessKeyId = properties.get(REST_ACCESS_KEY_ID); @@ -380,40 +364,6 @@ public void setDynamoDbTableName(String name) { this.dynamoDbTableName = name; } - /** @deprecated will be removed in 1.5.0, use {@link HttpClientProperties} instead */ - @Deprecated - public Map httpClientProperties() { - return httpClientProperties; - } - - /** - * @deprecated will be removed in 1.5.0, use {@link AwsClientProperties#clientRegion()} instead - */ - @Deprecated - public String clientRegion() { - return clientRegion; - } - - /** - * @deprecated will be removed in 1.5.0, use {@link AwsClientProperties#setClientRegion(String)} - * instead - */ - @Deprecated - public void setClientRegion(String clientRegion) { - this.clientRegion = clientRegion; - } - - /** - * @deprecated will be removed in 1.5.0, use {@link - * AwsClientProperties#applyClientCredentialConfigurations(AwsClientBuilder)} instead - */ - @Deprecated - public void applyClientCredentialConfigurations(T builder) { - if (!Strings.isNullOrEmpty(this.clientCredentialsProvider)) { - builder.credentialsProvider(credentialsProvider(this.clientCredentialsProvider)); - } - } - /** * Override the endpoint for a glue client. * diff --git a/aws/src/test/java/org/apache/iceberg/aws/TestAwsProperties.java b/aws/src/test/java/org/apache/iceberg/aws/TestAwsProperties.java index c4b9bd4d5bc1..510c84215eb9 100644 --- a/aws/src/test/java/org/apache/iceberg/aws/TestAwsProperties.java +++ b/aws/src/test/java/org/apache/iceberg/aws/TestAwsProperties.java @@ -18,8 +18,10 @@ */ package org.apache.iceberg.aws; +import static org.apache.iceberg.aws.AwsProperties.DYNAMODB_TABLE_NAME; +import static org.apache.iceberg.aws.AwsProperties.GLUE_CATALOG_ID; + import java.io.IOException; -import java.util.Collections; import org.apache.iceberg.TestHelpers; import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; import org.assertj.core.api.Assertions; @@ -29,22 +31,13 @@ public class TestAwsProperties { @Test public void testKryoSerialization() throws IOException { - AwsProperties awsProperties = new AwsProperties(); - AwsProperties deSerializedAwsProperties = - TestHelpers.KryoHelpers.roundTripSerialize(awsProperties); - Assertions.assertThat(deSerializedAwsProperties.httpClientProperties()) - .isEqualTo(awsProperties.httpClientProperties()); - - AwsProperties awsPropertiesWithProps = new AwsProperties(ImmutableMap.of("a", "b")); + AwsProperties awsPropertiesWithProps = + new AwsProperties(ImmutableMap.of(GLUE_CATALOG_ID, "foo", DYNAMODB_TABLE_NAME, "ice")); AwsProperties deSerializedAwsPropertiesWithProps = TestHelpers.KryoHelpers.roundTripSerialize(awsPropertiesWithProps); - Assertions.assertThat(deSerializedAwsPropertiesWithProps.httpClientProperties()) - .isEqualTo(awsProperties.httpClientProperties()); - - AwsProperties awsPropertiesWithEmptyProps = new AwsProperties(Collections.emptyMap()); - AwsProperties deSerializedAwsPropertiesWithEmptyProps = - TestHelpers.KryoHelpers.roundTripSerialize(awsPropertiesWithProps); - Assertions.assertThat(deSerializedAwsPropertiesWithEmptyProps.httpClientProperties()) - .isEqualTo(awsProperties.httpClientProperties()); + Assertions.assertThat(deSerializedAwsPropertiesWithProps.glueCatalogId()) + .isEqualTo(awsPropertiesWithProps.glueCatalogId()); + Assertions.assertThat(deSerializedAwsPropertiesWithProps.dynamoDbTableName()) + .isEqualTo(awsPropertiesWithProps.dynamoDbTableName()); } } diff --git a/aws/src/test/java/org/apache/iceberg/aws/TestHttpClientConfigurations.java b/aws/src/test/java/org/apache/iceberg/aws/TestHttpClientConfigurations.java index 8ad4cc9538eb..17ac7ca72828 100644 --- a/aws/src/test/java/org/apache/iceberg/aws/TestHttpClientConfigurations.java +++ b/aws/src/test/java/org/apache/iceberg/aws/TestHttpClientConfigurations.java @@ -34,9 +34,8 @@ public void testUrlConnectionOverrideConfigurations() { properties.put(HttpClientProperties.URLCONNECTION_CONNECTION_TIMEOUT_MS, "80"); properties.put(HttpClientProperties.APACHE_SOCKET_TIMEOUT_MS, "100"); properties.put(HttpClientProperties.APACHE_CONNECTION_TIMEOUT_MS, "200"); - AwsProperties awsProperties = new AwsProperties(properties); UrlConnectionHttpClientConfigurations urlConnectionHttpClientConfigurations = - UrlConnectionHttpClientConfigurations.create(awsProperties.httpClientProperties()); + UrlConnectionHttpClientConfigurations.create(properties); UrlConnectionHttpClient.Builder urlConnectionHttpClientBuilder = UrlConnectionHttpClient.builder(); UrlConnectionHttpClient.Builder spyUrlConnectionHttpClientBuilder = @@ -51,10 +50,8 @@ public void testUrlConnectionOverrideConfigurations() { @Test public void testUrlConnectionDefaultConfigurations() { - Map properties = Maps.newHashMap(); - AwsProperties awsProperties = new AwsProperties(properties); UrlConnectionHttpClientConfigurations urlConnectionHttpClientConfigurations = - UrlConnectionHttpClientConfigurations.create(awsProperties.httpClientProperties()); + UrlConnectionHttpClientConfigurations.create(Maps.newHashMap()); UrlConnectionHttpClient.Builder urlConnectionHttpClientBuilder = UrlConnectionHttpClient.builder(); UrlConnectionHttpClient.Builder spyUrlConnectionHttpClientBuilder = @@ -83,9 +80,8 @@ public void testApacheOverrideConfigurations() { properties.put(HttpClientProperties.APACHE_MAX_CONNECTIONS, "104"); properties.put(HttpClientProperties.APACHE_TCP_KEEP_ALIVE_ENABLED, "true"); properties.put(HttpClientProperties.APACHE_USE_IDLE_CONNECTION_REAPER_ENABLED, "false"); - AwsProperties awsProperties = new AwsProperties(properties); ApacheHttpClientConfigurations apacheHttpClientConfigurations = - ApacheHttpClientConfigurations.create(awsProperties.httpClientProperties()); + ApacheHttpClientConfigurations.create(properties); ApacheHttpClient.Builder apacheHttpClientBuilder = ApacheHttpClient.builder(); ApacheHttpClient.Builder spyApacheHttpClientBuilder = Mockito.spy(apacheHttpClientBuilder); @@ -104,10 +100,8 @@ public void testApacheOverrideConfigurations() { @Test public void testApacheDefaultConfigurations() { - Map properties = Maps.newHashMap(); - AwsProperties awsProperties = new AwsProperties(properties); ApacheHttpClientConfigurations apacheHttpClientConfigurations = - ApacheHttpClientConfigurations.create(awsProperties.httpClientProperties()); + ApacheHttpClientConfigurations.create(Maps.newHashMap()); ApacheHttpClient.Builder apacheHttpClientBuilder = ApacheHttpClient.builder(); ApacheHttpClient.Builder spyApacheHttpClientBuilder = Mockito.spy(apacheHttpClientBuilder); diff --git a/core/src/main/java/org/apache/iceberg/PositionDeletesTable.java b/core/src/main/java/org/apache/iceberg/PositionDeletesTable.java index 68f2e0d4522a..56270635809b 100644 --- a/core/src/main/java/org/apache/iceberg/PositionDeletesTable.java +++ b/core/src/main/java/org/apache/iceberg/PositionDeletesTable.java @@ -150,12 +150,6 @@ protected PositionDeletesBatchScan(Table table, Schema schema) { super(table, schema, TableScanContext.empty()); } - /** @deprecated the API will be removed in v1.5.0 */ - @Deprecated - protected PositionDeletesBatchScan(Table table, Schema schema, TableScanContext context) { - super(table, schema, context); - } - protected PositionDeletesBatchScan( Table table, Schema schema, TableScanContext context, Expression baseTableFilter) { super(table, schema, context); diff --git a/core/src/main/java/org/apache/iceberg/io/ClusteredWriter.java b/core/src/main/java/org/apache/iceberg/io/ClusteredWriter.java index 12ceda1bfd4f..1dc4871f0a12 100644 --- a/core/src/main/java/org/apache/iceberg/io/ClusteredWriter.java +++ b/core/src/main/java/org/apache/iceberg/io/ClusteredWriter.java @@ -24,7 +24,6 @@ import java.util.Set; import org.apache.iceberg.PartitionSpec; import org.apache.iceberg.StructLike; -import org.apache.iceberg.encryption.EncryptedOutputFile; import org.apache.iceberg.relocated.com.google.common.base.Preconditions; import org.apache.iceberg.relocated.com.google.common.collect.Sets; import org.apache.iceberg.types.Comparators; @@ -131,18 +130,4 @@ public final R result() { Preconditions.checkState(closed, "Cannot get result from unclosed writer"); return aggregatedResult(); } - - /** @deprecated will be removed in 1.5.0 */ - @Deprecated - protected EncryptedOutputFile newOutputFile( - OutputFileFactory fileFactory, PartitionSpec spec, StructLike partition) { - Preconditions.checkArgument( - spec.isUnpartitioned() || partition != null, - "Partition must not be null when creating output file for partitioned spec"); - if (spec.isUnpartitioned() || partition == null) { - return fileFactory.newOutputFile(); - } else { - return fileFactory.newOutputFile(spec, partition); - } - } } diff --git a/core/src/main/java/org/apache/iceberg/io/FanoutWriter.java b/core/src/main/java/org/apache/iceberg/io/FanoutWriter.java index 9b88e4011cf1..95d5cc1afcc9 100644 --- a/core/src/main/java/org/apache/iceberg/io/FanoutWriter.java +++ b/core/src/main/java/org/apache/iceberg/io/FanoutWriter.java @@ -22,7 +22,6 @@ import java.util.Map; import org.apache.iceberg.PartitionSpec; import org.apache.iceberg.StructLike; -import org.apache.iceberg.encryption.EncryptedOutputFile; import org.apache.iceberg.relocated.com.google.common.base.Preconditions; import org.apache.iceberg.relocated.com.google.common.collect.Maps; import org.apache.iceberg.util.StructLikeMap; @@ -94,18 +93,4 @@ public final R result() { Preconditions.checkState(closed, "Cannot get result from unclosed writer"); return aggregatedResult(); } - - /** @deprecated will be removed in 1.5.0 */ - @Deprecated - protected EncryptedOutputFile newOutputFile( - OutputFileFactory fileFactory, PartitionSpec spec, StructLike partition) { - Preconditions.checkArgument( - spec.isUnpartitioned() || partition != null, - "Partition must not be null when creating output file for partitioned spec"); - if (spec.isUnpartitioned() || partition == null) { - return fileFactory.newOutputFile(); - } else { - return fileFactory.newOutputFile(spec, partition); - } - } } diff --git a/core/src/main/java/org/apache/iceberg/rest/RESTSerializers.java b/core/src/main/java/org/apache/iceberg/rest/RESTSerializers.java index 7d4f327b67df..4311b9aa7701 100644 --- a/core/src/main/java/org/apache/iceberg/rest/RESTSerializers.java +++ b/core/src/main/java/org/apache/iceberg/rest/RESTSerializers.java @@ -53,9 +53,7 @@ import org.apache.iceberg.rest.requests.RegisterTableRequestParser; import org.apache.iceberg.rest.requests.ReportMetricsRequest; import org.apache.iceberg.rest.requests.ReportMetricsRequestParser; -import org.apache.iceberg.rest.requests.UpdateRequirementParser; import org.apache.iceberg.rest.requests.UpdateTableRequest; -import org.apache.iceberg.rest.requests.UpdateTableRequest.UpdateRequirement; import org.apache.iceberg.rest.requests.UpdateTableRequestParser; import org.apache.iceberg.rest.responses.ErrorResponse; import org.apache.iceberg.rest.responses.ErrorResponseParser; @@ -88,8 +86,6 @@ public static void registerAll(ObjectMapper mapper) { .addDeserializer(MetadataUpdate.class, new MetadataUpdateDeserializer()) .addSerializer(TableMetadata.class, new TableMetadataSerializer()) .addDeserializer(TableMetadata.class, new TableMetadataDeserializer()) - .addSerializer(UpdateRequirement.class, new UpdateRequirementSerializer()) - .addDeserializer(UpdateRequirement.class, new UpdateRequirementDeserializer()) .addSerializer(org.apache.iceberg.UpdateRequirement.class, new UpdateReqSerializer()) .addDeserializer(org.apache.iceberg.UpdateRequirement.class, new UpdateReqDeserializer()) .addSerializer(OAuthTokenResponse.class, new OAuthTokenResponseSerializer()) @@ -120,28 +116,6 @@ public static void registerAll(ObjectMapper mapper) { mapper.registerModule(module); } - /** @deprecated will be removed in 1.5.0, use {@link UpdateReqDeserializer} instead. */ - @Deprecated - public static class UpdateRequirementDeserializer extends JsonDeserializer { - @Override - public UpdateRequirement deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - JsonNode node = p.getCodec().readTree(p); - return UpdateRequirementParser.fromJson(node); - } - } - - /** @deprecated will be removed in 1.5.0, use {@link UpdateReqSerializer} instead. */ - @Deprecated - public static class UpdateRequirementSerializer extends JsonSerializer { - @Override - public void serialize( - UpdateRequirement value, JsonGenerator gen, SerializerProvider serializers) - throws IOException { - UpdateRequirementParser.toJson(value, gen); - } - } - static class UpdateReqDeserializer extends JsonDeserializer { @Override diff --git a/core/src/main/java/org/apache/iceberg/rest/requests/UpdateRequirementParser.java b/core/src/main/java/org/apache/iceberg/rest/requests/UpdateRequirementParser.java deleted file mode 100644 index 2df522b9aac7..000000000000 --- a/core/src/main/java/org/apache/iceberg/rest/requests/UpdateRequirementParser.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.iceberg.rest.requests; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonNode; -import java.io.IOException; -import java.util.Locale; -import java.util.Map; -import org.apache.iceberg.relocated.com.google.common.base.Preconditions; -import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; -import org.apache.iceberg.rest.requests.UpdateTableRequest.UpdateRequirement; -import org.apache.iceberg.util.JsonUtil; - -/** - * @deprecated will be removed in 1.5.0, use {@link org.apache.iceberg.UpdateRequirementParser} - * instead. - */ -@Deprecated -public class UpdateRequirementParser { - - private UpdateRequirementParser() {} - - private static final String TYPE = "type"; - - // assertion types - static final String ASSERT_TABLE_UUID = "assert-table-uuid"; - static final String ASSERT_TABLE_DOES_NOT_EXIST = "assert-create"; - static final String ASSERT_REF_SNAPSHOT_ID = "assert-ref-snapshot-id"; - static final String ASSERT_LAST_ASSIGNED_FIELD_ID = "assert-last-assigned-field-id"; - static final String ASSERT_CURRENT_SCHEMA_ID = "assert-current-schema-id"; - static final String ASSERT_LAST_ASSIGNED_PARTITION_ID = "assert-last-assigned-partition-id"; - static final String ASSERT_DEFAULT_SPEC_ID = "assert-default-spec-id"; - static final String ASSERT_DEFAULT_SORT_ORDER_ID = "assert-default-sort-order-id"; - - // AssertTableUUID - private static final String UUID = "uuid"; - - // AssertRefSnapshotID - private static final String NAME = "ref"; - private static final String SNAPSHOT_ID = "snapshot-id"; - - // AssertLastAssignedFieldId - private static final String LAST_ASSIGNED_FIELD_ID = "last-assigned-field-id"; - - // AssertCurrentSchemaID - private static final String SCHEMA_ID = "current-schema-id"; - - // AssertLastAssignedPartitionId - private static final String LAST_ASSIGNED_PARTITION_ID = "last-assigned-partition-id"; - - // AssertDefaultSpecID - private static final String SPEC_ID = "default-spec-id"; - - // AssertDefaultSortOrderID - private static final String SORT_ORDER_ID = "default-sort-order-id"; - - private static final Map, String> TYPES = - ImmutableMap., String>builder() - .put(UpdateRequirement.AssertTableUUID.class, ASSERT_TABLE_UUID) - .put(UpdateRequirement.AssertTableDoesNotExist.class, ASSERT_TABLE_DOES_NOT_EXIST) - .put(UpdateRequirement.AssertRefSnapshotID.class, ASSERT_REF_SNAPSHOT_ID) - .put(UpdateRequirement.AssertLastAssignedFieldId.class, ASSERT_LAST_ASSIGNED_FIELD_ID) - .put(UpdateRequirement.AssertCurrentSchemaID.class, ASSERT_CURRENT_SCHEMA_ID) - .put( - UpdateRequirement.AssertLastAssignedPartitionId.class, - ASSERT_LAST_ASSIGNED_PARTITION_ID) - .put(UpdateRequirement.AssertDefaultSpecID.class, ASSERT_DEFAULT_SPEC_ID) - .put(UpdateRequirement.AssertDefaultSortOrderID.class, ASSERT_DEFAULT_SORT_ORDER_ID) - .buildOrThrow(); - - public static String toJson(UpdateRequirement updateRequirement) { - return toJson(updateRequirement, false); - } - - public static String toJson(UpdateRequirement updateRequirement, boolean pretty) { - return JsonUtil.generate(gen -> toJson(updateRequirement, gen), pretty); - } - - public static void toJson(UpdateRequirement updateRequirement, JsonGenerator generator) - throws IOException { - String requirementType = TYPES.get(updateRequirement.getClass()); - - generator.writeStartObject(); - generator.writeStringField(TYPE, requirementType); - - switch (requirementType) { - case ASSERT_TABLE_DOES_NOT_EXIST: - // No fields beyond the requirement itself - break; - case ASSERT_TABLE_UUID: - writeAssertTableUUID((UpdateRequirement.AssertTableUUID) updateRequirement, generator); - break; - case ASSERT_REF_SNAPSHOT_ID: - writeAssertRefSnapshotId( - (UpdateRequirement.AssertRefSnapshotID) updateRequirement, generator); - break; - case ASSERT_LAST_ASSIGNED_FIELD_ID: - writeAssertLastAssignedFieldId( - (UpdateRequirement.AssertLastAssignedFieldId) updateRequirement, generator); - break; - case ASSERT_LAST_ASSIGNED_PARTITION_ID: - writeAssertLastAssignedPartitionId( - (UpdateRequirement.AssertLastAssignedPartitionId) updateRequirement, generator); - break; - case ASSERT_CURRENT_SCHEMA_ID: - writeAssertCurrentSchemaId( - (UpdateRequirement.AssertCurrentSchemaID) updateRequirement, generator); - break; - case ASSERT_DEFAULT_SPEC_ID: - writeAssertDefaultSpecId( - (UpdateRequirement.AssertDefaultSpecID) updateRequirement, generator); - break; - case ASSERT_DEFAULT_SORT_ORDER_ID: - writeAssertDefaultSortOrderId( - (UpdateRequirement.AssertDefaultSortOrderID) updateRequirement, generator); - break; - default: - throw new IllegalArgumentException( - String.format( - "Cannot convert update requirement to json. Unrecognized type: %s", - requirementType)); - } - - generator.writeEndObject(); - } - - /** - * Read MetadataUpdate from a JSON string. - * - * @param json a JSON string of a MetadataUpdate - * @return a MetadataUpdate object - */ - public static UpdateRequirement fromJson(String json) { - return JsonUtil.parse(json, UpdateRequirementParser::fromJson); - } - - public static UpdateRequirement fromJson(JsonNode jsonNode) { - Preconditions.checkArgument( - jsonNode != null && jsonNode.isObject(), - "Cannot parse update requirement from non-object value: %s", - jsonNode); - Preconditions.checkArgument( - jsonNode.hasNonNull(TYPE), "Cannot parse update requirement. Missing field: type"); - String type = JsonUtil.getString(TYPE, jsonNode).toLowerCase(Locale.ROOT); - - switch (type) { - case ASSERT_TABLE_DOES_NOT_EXIST: - return readAssertTableDoesNotExist(jsonNode); - case ASSERT_TABLE_UUID: - return readAssertTableUUID(jsonNode); - case ASSERT_REF_SNAPSHOT_ID: - return readAssertRefSnapshotId(jsonNode); - case ASSERT_LAST_ASSIGNED_FIELD_ID: - return readAssertLastAssignedFieldId(jsonNode); - case ASSERT_LAST_ASSIGNED_PARTITION_ID: - return readAssertLastAssignedPartitionId(jsonNode); - case ASSERT_CURRENT_SCHEMA_ID: - return readAssertCurrentSchemaId(jsonNode); - case ASSERT_DEFAULT_SPEC_ID: - return readAssertDefaultSpecId(jsonNode); - case ASSERT_DEFAULT_SORT_ORDER_ID: - return readAssertDefaultSortOrderId(jsonNode); - default: - throw new UnsupportedOperationException( - String.format("Unrecognized update requirement. Cannot convert to json: %s", type)); - } - } - - private static void writeAssertTableUUID( - UpdateRequirement.AssertTableUUID requirement, JsonGenerator gen) throws IOException { - gen.writeStringField(UUID, requirement.uuid()); - } - - private static void writeAssertRefSnapshotId( - UpdateRequirement.AssertRefSnapshotID requirement, JsonGenerator gen) throws IOException { - gen.writeStringField(NAME, requirement.refName()); - if (requirement.snapshotId() != null) { - gen.writeNumberField(SNAPSHOT_ID, requirement.snapshotId()); - } else { - gen.writeNullField(SNAPSHOT_ID); - } - } - - private static void writeAssertLastAssignedFieldId( - UpdateRequirement.AssertLastAssignedFieldId requirement, JsonGenerator gen) - throws IOException { - gen.writeNumberField(LAST_ASSIGNED_FIELD_ID, requirement.lastAssignedFieldId()); - } - - private static void writeAssertLastAssignedPartitionId( - UpdateRequirement.AssertLastAssignedPartitionId requirement, JsonGenerator gen) - throws IOException { - gen.writeNumberField(LAST_ASSIGNED_PARTITION_ID, requirement.lastAssignedPartitionId()); - } - - private static void writeAssertCurrentSchemaId( - UpdateRequirement.AssertCurrentSchemaID requirement, JsonGenerator gen) throws IOException { - gen.writeNumberField(SCHEMA_ID, requirement.schemaId()); - } - - private static void writeAssertDefaultSpecId( - UpdateRequirement.AssertDefaultSpecID requirement, JsonGenerator gen) throws IOException { - gen.writeNumberField(SPEC_ID, requirement.specId()); - } - - private static void writeAssertDefaultSortOrderId( - UpdateRequirement.AssertDefaultSortOrderID requirement, JsonGenerator gen) - throws IOException { - gen.writeNumberField(SORT_ORDER_ID, requirement.sortOrderId()); - } - - @SuppressWarnings( - "unused") // Keep same signature in case this requirement class evolves and gets fields - private static UpdateRequirement readAssertTableDoesNotExist(JsonNode node) { - return new UpdateRequirement.AssertTableDoesNotExist(); - } - - private static UpdateRequirement readAssertTableUUID(JsonNode node) { - String uuid = JsonUtil.getString(UUID, node); - return new UpdateRequirement.AssertTableUUID(uuid); - } - - private static UpdateRequirement readAssertRefSnapshotId(JsonNode node) { - String name = JsonUtil.getString(NAME, node); - Long snapshotId = JsonUtil.getLongOrNull(SNAPSHOT_ID, node); - return new UpdateRequirement.AssertRefSnapshotID(name, snapshotId); - } - - private static UpdateRequirement readAssertLastAssignedFieldId(JsonNode node) { - int lastAssignedFieldId = JsonUtil.getInt(LAST_ASSIGNED_FIELD_ID, node); - return new UpdateRequirement.AssertLastAssignedFieldId(lastAssignedFieldId); - } - - private static UpdateRequirement readAssertCurrentSchemaId(JsonNode node) { - int schemaId = JsonUtil.getInt(SCHEMA_ID, node); - return new UpdateRequirement.AssertCurrentSchemaID(schemaId); - } - - private static UpdateRequirement readAssertLastAssignedPartitionId(JsonNode node) { - int lastAssignedPartitionId = JsonUtil.getInt(LAST_ASSIGNED_PARTITION_ID, node); - return new UpdateRequirement.AssertLastAssignedPartitionId(lastAssignedPartitionId); - } - - private static UpdateRequirement readAssertDefaultSpecId(JsonNode node) { - int specId = JsonUtil.getInt(SPEC_ID, node); - return new UpdateRequirement.AssertDefaultSpecID(specId); - } - - private static UpdateRequirement readAssertDefaultSortOrderId(JsonNode node) { - int sortOrderId = JsonUtil.getInt(SORT_ORDER_ID, node); - return new UpdateRequirement.AssertDefaultSortOrderID(sortOrderId); - } -} diff --git a/core/src/main/java/org/apache/iceberg/rest/requests/UpdateTableRequest.java b/core/src/main/java/org/apache/iceberg/rest/requests/UpdateTableRequest.java index 088875d472f7..d077defa5926 100644 --- a/core/src/main/java/org/apache/iceberg/rest/requests/UpdateTableRequest.java +++ b/core/src/main/java/org/apache/iceberg/rest/requests/UpdateTableRequest.java @@ -19,17 +19,10 @@ package org.apache.iceberg.rest.requests; import java.util.List; -import java.util.Set; import org.apache.iceberg.MetadataUpdate; -import org.apache.iceberg.SnapshotRef; -import org.apache.iceberg.TableMetadata; import org.apache.iceberg.catalog.TableIdentifier; -import org.apache.iceberg.exceptions.CommitFailedException; import org.apache.iceberg.relocated.com.google.common.base.MoreObjects; -import org.apache.iceberg.relocated.com.google.common.base.Preconditions; import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList; -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; public class UpdateTableRequest implements RESTRequest { @@ -85,363 +78,4 @@ public static UpdateTableRequest create( List updates) { return new UpdateTableRequest(identifier, requirements, updates); } - - /** - * @deprecated will be removed in 1.5.0, use {@link - * org.apache.iceberg.UpdateRequirements#forCreateTable(List)} instead. - */ - @Deprecated - public static Builder builderForCreate() { - return new Builder(null, false).requireCreate(); - } - - /** - * @deprecated will be removed in 1.5.0, use {@link - * org.apache.iceberg.UpdateRequirements#forReplaceTable(TableMetadata, List)} instead. - */ - @Deprecated - public static Builder builderForReplace(TableMetadata base) { - Preconditions.checkNotNull(base, "Cannot create a builder from table metadata: null"); - return new Builder(base, true).requireTableUUID(base.uuid()); - } - - /** - * @deprecated will be removed in 1.5.0, use {@link - * org.apache.iceberg.UpdateRequirements#forUpdateTable(TableMetadata, List)} instead. - */ - @Deprecated - public static Builder builderFor(TableMetadata base) { - Preconditions.checkNotNull(base, "Cannot create a builder from table metadata: null"); - return new Builder(base, false).requireTableUUID(base.uuid()); - } - - /** - * @deprecated will be removed in 1.5.0, use {@link org.apache.iceberg.UpdateRequirements} - * instead. - */ - @Deprecated - public static class Builder { - private final TableMetadata base; - private final ImmutableList.Builder requirements = - ImmutableList.builder(); - private final List updates = Lists.newArrayList(); - private final Set changedRefs = Sets.newHashSet(); - private final boolean isReplace; - private boolean addedSchema = false; - private boolean setSchemaId = false; - private boolean addedSpec = false; - private boolean setSpecId = false; - private boolean setOrderId = false; - - public Builder(TableMetadata base, boolean isReplace) { - this.base = base; - this.isReplace = isReplace; - } - - private Builder require(UpdateRequirement requirement) { - Preconditions.checkArgument(requirement != null, "Invalid requirement: null"); - requirements.add(requirement); - return this; - } - - private Builder requireCreate() { - return require(new UpdateRequirement.AssertTableDoesNotExist()); - } - - private Builder requireTableUUID(String uuid) { - Preconditions.checkArgument(uuid != null, "Invalid required UUID: null"); - return require(new UpdateRequirement.AssertTableUUID(uuid)); - } - - private Builder requireRefSnapshotId(String ref, Long snapshotId) { - return require(new UpdateRequirement.AssertRefSnapshotID(ref, snapshotId)); - } - - private Builder requireLastAssignedFieldId(int fieldId) { - return require(new UpdateRequirement.AssertLastAssignedFieldId(fieldId)); - } - - private Builder requireCurrentSchemaId(int schemaId) { - return require(new UpdateRequirement.AssertCurrentSchemaID(schemaId)); - } - - private Builder requireLastAssignedPartitionId(int partitionId) { - return require(new UpdateRequirement.AssertLastAssignedPartitionId(partitionId)); - } - - private Builder requireDefaultSpecId(int specId) { - return require(new UpdateRequirement.AssertDefaultSpecID(specId)); - } - - private Builder requireDefaultSortOrderId(int orderId) { - return require(new UpdateRequirement.AssertDefaultSortOrderID(orderId)); - } - - public Builder update(MetadataUpdate update) { - Preconditions.checkArgument(update != null, "Invalid update: null"); - updates.add(update); - - // add requirements based on the change - if (update instanceof MetadataUpdate.SetSnapshotRef) { - update((MetadataUpdate.SetSnapshotRef) update); - } else if (update instanceof MetadataUpdate.AddSchema) { - update((MetadataUpdate.AddSchema) update); - } else if (update instanceof MetadataUpdate.SetCurrentSchema) { - update((MetadataUpdate.SetCurrentSchema) update); - } else if (update instanceof MetadataUpdate.AddPartitionSpec) { - update((MetadataUpdate.AddPartitionSpec) update); - } else if (update instanceof MetadataUpdate.SetDefaultPartitionSpec) { - update((MetadataUpdate.SetDefaultPartitionSpec) update); - } else if (update instanceof MetadataUpdate.SetDefaultSortOrder) { - update((MetadataUpdate.SetDefaultSortOrder) update); - } - - return this; - } - - private void update(MetadataUpdate.SetSnapshotRef setRef) { - // require that the ref is unchanged from the base - String name = setRef.name(); - // add returns true the first time the ref name is added - boolean added = changedRefs.add(name); - if (added && base != null && !isReplace) { - SnapshotRef baseRef = base.ref(name); - // require that the ref does not exist (null) or is the same as the base snapshot - requireRefSnapshotId(name, baseRef != null ? baseRef.snapshotId() : null); - } - } - - private void update(MetadataUpdate.AddSchema update) { - if (!addedSchema) { - if (base != null) { - requireLastAssignedFieldId(base.lastColumnId()); - } - this.addedSchema = true; - } - } - - private void update(MetadataUpdate.SetCurrentSchema update) { - if (!setSchemaId) { - if (base != null && !isReplace) { - // require that the current schema has not changed - requireCurrentSchemaId(base.currentSchemaId()); - } - this.setSchemaId = true; - } - } - - private void update(MetadataUpdate.AddPartitionSpec update) { - if (!addedSpec) { - if (base != null) { - requireLastAssignedPartitionId(base.lastAssignedPartitionId()); - } - this.addedSpec = true; - } - } - - private void update(MetadataUpdate.SetDefaultPartitionSpec update) { - if (!setSpecId) { - if (base != null && !isReplace) { - // require that the default spec has not changed - requireDefaultSpecId(base.defaultSpecId()); - } - this.setSpecId = true; - } - } - - private void update(MetadataUpdate.SetDefaultSortOrder update) { - if (!setOrderId) { - if (base != null && !isReplace) { - // require that the default write order has not changed - requireDefaultSortOrderId(base.defaultSortOrderId()); - } - this.setOrderId = true; - } - } - - public UpdateTableRequest build() { - return new UpdateTableRequest(requirements.build(), ImmutableList.copyOf(updates)); - } - } - - /** - * @deprecated will be removed in 1.5.0, use {@link org.apache.iceberg.UpdateRequirement} instead. - */ - @Deprecated - public interface UpdateRequirement extends org.apache.iceberg.UpdateRequirement { - - class AssertTableDoesNotExist implements UpdateRequirement { - AssertTableDoesNotExist() {} - - @Override - public void validate(TableMetadata base) { - if (base != null) { - throw new CommitFailedException("Requirement failed: table already exists"); - } - } - } - - class AssertTableUUID implements UpdateRequirement { - private final String uuid; - - AssertTableUUID(String uuid) { - this.uuid = uuid; - } - - public String uuid() { - return uuid; - } - - @Override - public void validate(TableMetadata base) { - if (!uuid.equalsIgnoreCase(base.uuid())) { - throw new CommitFailedException( - "Requirement failed: UUID does not match: expected %s != %s", base.uuid(), uuid); - } - } - } - - class AssertRefSnapshotID implements UpdateRequirement { - private final String name; - private final Long snapshotId; - - AssertRefSnapshotID(String name, Long snapshotId) { - this.name = name; - this.snapshotId = snapshotId; - } - - public String refName() { - return name; - } - - public Long snapshotId() { - return snapshotId; - } - - @Override - public void validate(TableMetadata base) { - SnapshotRef ref = base.ref(name); - if (ref != null) { - String type = ref.isBranch() ? "branch" : "tag"; - if (snapshotId == null) { - // a null snapshot ID means the ref should not exist already - throw new CommitFailedException( - "Requirement failed: %s %s was created concurrently", type, name); - } else if (snapshotId != ref.snapshotId()) { - throw new CommitFailedException( - "Requirement failed: %s %s has changed: expected id %s != %s", - type, name, snapshotId, ref.snapshotId()); - } - } else if (snapshotId != null) { - throw new CommitFailedException( - "Requirement failed: branch or tag %s is missing, expected %s", name, snapshotId); - } - } - } - - class AssertLastAssignedFieldId implements UpdateRequirement { - private final int lastAssignedFieldId; - - public AssertLastAssignedFieldId(int lastAssignedFieldId) { - this.lastAssignedFieldId = lastAssignedFieldId; - } - - public int lastAssignedFieldId() { - return lastAssignedFieldId; - } - - @Override - public void validate(TableMetadata base) { - if (base != null && base.lastColumnId() != lastAssignedFieldId) { - throw new CommitFailedException( - "Requirement failed: last assigned field id changed: expected id %s != %s", - lastAssignedFieldId, base.lastColumnId()); - } - } - } - - class AssertCurrentSchemaID implements UpdateRequirement { - private final int schemaId; - - AssertCurrentSchemaID(int schemaId) { - this.schemaId = schemaId; - } - - public int schemaId() { - return schemaId; - } - - @Override - public void validate(TableMetadata base) { - if (schemaId != base.currentSchemaId()) { - throw new CommitFailedException( - "Requirement failed: current schema changed: expected id %s != %s", - schemaId, base.currentSchemaId()); - } - } - } - - class AssertLastAssignedPartitionId implements UpdateRequirement { - private final int lastAssignedPartitionId; - - public AssertLastAssignedPartitionId(int lastAssignedPartitionId) { - this.lastAssignedPartitionId = lastAssignedPartitionId; - } - - public int lastAssignedPartitionId() { - return lastAssignedPartitionId; - } - - @Override - public void validate(TableMetadata base) { - if (base != null && base.lastAssignedPartitionId() != lastAssignedPartitionId) { - throw new CommitFailedException( - "Requirement failed: last assigned partition id changed: expected id %s != %s", - lastAssignedPartitionId, base.lastAssignedPartitionId()); - } - } - } - - class AssertDefaultSpecID implements UpdateRequirement { - private final int specId; - - AssertDefaultSpecID(int specId) { - this.specId = specId; - } - - public int specId() { - return specId; - } - - @Override - public void validate(TableMetadata base) { - if (specId != base.defaultSpecId()) { - throw new CommitFailedException( - "Requirement failed: default partition spec changed: expected id %s != %s", - specId, base.defaultSpecId()); - } - } - } - - class AssertDefaultSortOrderID implements UpdateRequirement { - private final int sortOrderId; - - AssertDefaultSortOrderID(int sortOrderId) { - this.sortOrderId = sortOrderId; - } - - public int sortOrderId() { - return sortOrderId; - } - - @Override - public void validate(TableMetadata base) { - if (sortOrderId != base.defaultSortOrderId()) { - throw new CommitFailedException( - "Requirement failed: default sort order changed: expected id %s != %s", - sortOrderId, base.defaultSortOrderId()); - } - } - } - } }