rdblue commented on code in PR #6324:
URL: https://github.com/apache/iceberg/pull/6324#discussion_r1051690764


##########
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java:
##########
@@ -246,23 +248,33 @@ public void testReplaceTxnBuilder() throws Exception {
   }
 
   @Test
-  public void testCreateTableWithOwner() throws Exception {
-    Schema schema = getTestSchema();
-    PartitionSpec spec = PartitionSpec.builderFor(schema).bucket("data", 
16).build();
-    TableIdentifier tableIdent = TableIdentifier.of(DB_NAME, "tbl");
-    String location = temp.newFolder("tbl").toString();
-    String owner = "some_owner";
-    ImmutableMap<String, String> properties = 
ImmutableMap.of(HiveCatalog.HMS_TABLE_OWNER, owner);
+  public void testCreateTableWithOwner() throws IOException {
+    createTableAndVerifyOwner(
+        DB_NAME,
+        "tbl_specified_owner",
+        ImmutableMap.of(HiveCatalog.HMS_TABLE_OWNER, "some_owner"),
+        "some_owner");
+    createTableAndVerifyOwner(
+        DB_NAME,
+        "tbl_default_owner",
+        ImmutableMap.of(),
+        UserGroupInformation.getCurrentUser().getUserName());
+  }
 
+  private void createTableAndVerifyOwner(
+      String db, String tbl, Map<String, String> prop, String expectedOwner) {
     try {
-      Table table = catalog.createTable(tableIdent, schema, spec, location, 
properties);
-      org.apache.hadoop.hive.metastore.api.Table hmsTable =
-          metastoreClient.getTable(DB_NAME, "tbl");
-      Assert.assertEquals(owner, hmsTable.getOwner());
-      Map<String, String> hmsTableParams = hmsTable.getParameters();
-      
Assert.assertFalse(hmsTableParams.containsKey(HiveCatalog.HMS_TABLE_OWNER));
+      Schema schema = getTestSchema();
+      PartitionSpec spec = PartitionSpec.builderFor(schema).bucket("data", 
16).build();
+      String location = temp.newFolder(tbl).toString();
+      catalog.createTable(TableIdentifier.of(db, tbl), schema, spec, location, 
prop);
+      org.apache.hadoop.hive.metastore.api.Table hmsTable = 
metastoreClient.getTable(db, tbl);
+      Assert.assertEquals(expectedOwner, hmsTable.getOwner());
+      
Assert.assertFalse(hmsTable.getParameters().containsKey(HiveCatalog.HMS_TABLE_OWNER));

Review Comment:
   Please roll back unnecessary changes to this code block. For example, 
removing `hmsTableParams`. We want to minimize changes.
   
   Also, this can throw Exception. There is no need for try/catch.



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to