RussellSpitzer commented on a change in pull request #1342:
URL: https://github.com/apache/iceberg/pull/1342#discussion_r470834157
##########
File path: core/src/test/java/org/apache/iceberg/hadoop/TestStaticTable.java
##########
@@ -0,0 +1,79 @@
+package org.apache.iceberg.hadoop;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+import org.apache.iceberg.HasTableOperations;
+import org.apache.iceberg.MetadataTableType;
+import org.apache.iceberg.StaticTableOperations;
+import org.apache.iceberg.Table;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestStaticTable extends HadoopTableTestBase {
+
+ private Table getStaticTable() {
+ return TABLES.load(((HasTableOperations)
table).operations().current().metadataFileLocation());
+ }
+
+ private Table getStaticTable(MetadataTableType type) {
+ return TABLES.load(((HasTableOperations)
table).operations().current().metadataFileLocation() + "#" + type);
+ }
+
+ @Test
+ public void testLoadFromMetadata() {
+ Table staticTable = getStaticTable();
+ Assert.assertTrue("Loading a metadata file based table should return
StaticTableOperations",
+ ((HasTableOperations) staticTable).operations() instanceof
StaticTableOperations);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testCannotBeAddedTo(){
+ Table staticTable = getStaticTable();
+ staticTable.newOverwrite().addFile(FILE_A).commit();
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testCannotBeDeletedFrom(){
+ table.newAppend().appendFile(FILE_A).commit();
+ Table staticTable = getStaticTable();
+ staticTable.newDelete().deleteFile(FILE_A).commit();
+ }
+
+ @Test
+ public void testHasSameProperties(){
+ table.newAppend().appendFile(FILE_A).commit();
+ table.newAppend().appendFile(FILE_B).commit();
+ table.newOverwrite().deleteFile(FILE_B).addFile(FILE_C).commit();
+ Table staticTable = getStaticTable();
+ Assert.assertTrue("Same history?",
+ table.history().containsAll(staticTable.history()));
+ Assert.assertTrue("Same snapshot?",
+ table.currentSnapshot().snapshotId() ==
staticTable.currentSnapshot().snapshotId());
+ Assert.assertTrue("Same properties?",
+ Maps.difference(table.properties(),
staticTable.properties()).areEqual());
+ }
+
+ @Test
+ public void testImmutable() {
+ table.newAppend().appendFile(FILE_A).commit();
+ Table staticTable = getStaticTable();
+ long originalSnapshot = table.currentSnapshot().snapshotId();
+
+ table.newAppend().appendFile(FILE_B).commit();
+ table.newOverwrite().deleteFile(FILE_B).addFile(FILE_C).commit();
+
+ Assert.assertEquals("Snapshot unchanged after table modified",
+ staticTable.currentSnapshot().snapshotId(), originalSnapshot);
+ }
+
+ @Test
+ public void testMetadataTables() {
+ for (MetadataTableType type: MetadataTableType.values()) {
+ String enumName = type.name().replace("_","").toLowerCase();
Review comment:
ALL_DATA_FILES, ALL_MANIFESTS, ALL_ENTRIES
All the style things just make me want to upgrade the Checkstyle version
even more :) I forgot to run in Intellij where I can force the newer version
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]