rdblue commented on a change in pull request #4011:
URL: https://github.com/apache/iceberg/pull/4011#discussion_r810541080



##########
File path: 
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
##########
@@ -468,4 +469,84 @@ public void testUUIDinTableProperties() throws Exception {
       catalog.dropTable(tableIdentifier);
     }
   }
+
+  @Test
+  public void testTablePropsDefaultsWithoutConflict() {
+    Schema schema = new Schema(
+        required(1, "id", Types.IntegerType.get(), "unique ID")
+    );
+    TableIdentifier tableIdent = TableIdentifier.of(DB_NAME, "tbl");
+
+    ImmutableMap<String, String> catalogProps = 
ImmutableMap.of("table-default.key3", "value3",
+        "table-override.key4", "value4");
+    HiveCatalog hiveCatalog = (HiveCatalog) 
CatalogUtil.loadCatalog(HiveCatalog.class.getName(),
+        CatalogUtil.ICEBERG_CATALOG_TYPE_HIVE, catalogProps, hiveConf);
+
+    try {
+      Table table = hiveCatalog.buildTable(tableIdent, schema)
+          .withProperty("key1", "value1")
+          .withProperty("key2", "value2")
+          .create();
+
+      Assert.assertEquals("value1", table.properties().get("key1"));
+      Assert.assertEquals("value2", table.properties().get("key2"));
+      Assert.assertEquals("value3", table.properties().get("key3"));
+      Assert.assertEquals("value4", table.properties().get("key4"));
+    } finally {
+      hiveCatalog.dropTable(tableIdent);
+    }
+  }
+
+  @Test
+  public void testTablePropsOverrideCatalogDefaultProps() {
+    Schema schema = new Schema(
+        required(1, "id", Types.IntegerType.get(), "unique ID")
+    );
+    TableIdentifier tableIdent = TableIdentifier.of(DB_NAME, "tbl");
+
+    ImmutableMap<String, String> catalogProps = 
ImmutableMap.of("table-default.key3", "value3");
+    HiveCatalog hiveCatalog = (HiveCatalog) 
CatalogUtil.loadCatalog(HiveCatalog.class.getName(),
+        CatalogUtil.ICEBERG_CATALOG_TYPE_HIVE, catalogProps, hiveConf);
+
+    try {
+      Table table = hiveCatalog.buildTable(tableIdent, schema)
+          .withProperty("key1", "value1")
+          .withProperty("key2", "value2")
+          .withProperty("key3", "value31")
+          .create();
+
+      Assert.assertEquals("value1", table.properties().get("key1"));
+      Assert.assertEquals("value2", table.properties().get("key2"));
+      Assert.assertEquals("value31", table.properties().get("key3"));
+    } finally {
+      hiveCatalog.dropTable(tableIdent);
+    }
+  }
+
+  @Test
+  public void testCatalogOverridePropsOverrideTableDefaults() {

Review comment:
       I think these tests can be simplified into a single case. This should 
use:
   * One default key that is not overridden by either table properties or 
overrides
   * One default key that is overridden by a table property
   * One default key that is overridden by an override property
   * One default key that is overridden by a table property and then overridden 
by an override property
   * One table key that is not overridden by an override property
   * One table key that is overridden by an override property
   * One override property that doesn't override anything




-- 
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]

Reply via email to