aokolnychyi commented on a change in pull request #2936: URL: https://github.com/apache/iceberg/pull/2936#discussion_r682933119
########## File path: core/src/test/java/org/apache/iceberg/TestPartitioning.java ########## @@ -0,0 +1,78 @@ +/* + * 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; + +import java.io.File; +import java.io.IOException; +import org.apache.iceberg.exceptions.ValidationException; +import org.apache.iceberg.types.Types; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import static org.apache.iceberg.types.Types.NestedField.required; + +public class TestPartitioning { + + private static final Schema SCHEMA = new Schema( + required(1, "id", Types.IntegerType.get()), + required(2, "data", Types.StringType.get()), + required(3, "category", Types.StringType.get()) + ); + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + private File tableDir = null; + + @Before + public void setupTableDir() throws IOException { + this.tableDir = temp.newFolder(); + } + + @After + public void cleanupTables() { + TestTables.clearTables(); + } + + @Test + public void testPartitionTypeWithIncompatibleSchemaEvolutionInV1Tables() { + PartitionSpec initialSpec = PartitionSpec.builderFor(SCHEMA) + .identity("data") + .build(); + TestTables.TestTable table = TestTables.create(tableDir, "test", SCHEMA, initialSpec, 1); + + PartitionSpec newSpec = PartitionSpec.builderFor(table.schema()) + .identity("category") + .build(); + + TableOperations ops = ((HasTableOperations) table).operations(); + TableMetadata current = ops.current(); + ops.commit(current, current.updatePartitionSpec(newSpec)); Review comment: This API is hidden from users. The user-facing API is `UpdatePartitionSpec` accessible via `Table`. That one actually ensures we don't hit this case. The spec evolution in v1 tables is actually limited as described [here](https://iceberg.apache.org/spec/#partitioning). There could be some tables where people evolved partitioning before the public API appeared. It is an edge case but this test ensures we get a reasonable exception for such tables. -- 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]
