haizhou-zhao commented on code in PR #6045:
URL: https://github.com/apache/iceberg/pull/6045#discussion_r1005081704
##########
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java:
##########
@@ -270,9 +275,34 @@ public void testCreateTableWithOwner() throws Exception {
Assert.assertEquals(owner, hmsTable.getOwner());
Map<String, String> hmsTableParams = hmsTable.getParameters();
Assert.assertFalse(hmsTableParams.containsKey(TableProperties.HMS_TABLE_OWNER));
+ Assert.assertEquals(
+ PrincipalType.USER.name(),
hmsTableParams.get(TableProperties.HMS_TABLE_OWNER_TYPE));
} finally {
catalog.dropTable(tableIdent);
}
+
+ TableIdentifier tableIdent2 = TableIdentifier.of(DB_NAME,
"tbl_group_owned");
+ String location2 = temp.newFolder("tbl_group_owned").toString();
+ String owner2 = "some_group_owner";
+ ImmutableMap<String, String> properties2 =
+ ImmutableMap.of(
+ TableProperties.HMS_TABLE_OWNER,
+ owner2,
+ TableProperties.HMS_TABLE_OWNER_TYPE,
+ PrincipalType.GROUP.name());
+
+ try {
+ Table table2 = catalog.createTable(tableIdent2, schema, spec, location2,
properties2);
+ org.apache.hadoop.hive.metastore.api.Table hmsTable =
+ metastoreClient.getTable(DB_NAME, "tbl_group_owned");
+ Assert.assertEquals(owner2, hmsTable.getOwner());
+ Map<String, String> hmsTableParams = hmsTable.getParameters();
+
Assert.assertFalse(hmsTableParams.containsKey(TableProperties.HMS_TABLE_OWNER));
+ Assert.assertEquals(
+ PrincipalType.GROUP.name(),
hmsTableParams.get(TableProperties.HMS_TABLE_OWNER_TYPE));
+ } finally {
+ catalog.dropTable(tableIdent2);
+ }
Review Comment:
Yes, it definitely would. I should add a test case with no prop specified.
Though we should probably figure out what is the correct behavior in previous
comments/conversations. Such as, if we can't figure out the owner, should be
just set null to both owner and ownerTypes.
##########
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java:
##########
@@ -358,6 +388,36 @@ public void testCreateNamespace() throws Exception {
"There no same location for db and namespace",
database2.getLocationUri(), hiveLocalDir);
}
+ @Test
+ public void testCreateNamespaceWithOwnership() throws Exception {
+ Namespace namespace1 = Namespace.of("userOwnership");
+ Map<String, String> prop1 =
+ ImmutableMap.of(
+ TableProperties.HMS_DB_OWNER,
+ "apache",
+ TableProperties.HMS_DB_OWNER_TYPE,
+ PrincipalType.USER.name());
+ catalog.createNamespace(namespace1, prop1);
+ Database database1 = metastoreClient.getDatabase(namespace1.toString());
+
+ Assert.assertEquals("apache", database1.getOwnerName());
+ Assert.assertEquals(PrincipalType.USER, database1.getOwnerType());
+
+ Map<String, String> prop2 =
+ ImmutableMap.of(
+ TableProperties.HMS_DB_OWNER,
+ "iceberg",
+ TableProperties.HMS_DB_OWNER_TYPE,
+ PrincipalType.GROUP.name());
+ Namespace namespace2 = Namespace.of("groupOwnership");
+
+ catalog.createNamespace(namespace2, prop2);
+ Database database2 = metastoreClient.getDatabase(namespace2.toString());
+
+ Assert.assertEquals("iceberg", database2.getOwnerName());
+ Assert.assertEquals(PrincipalType.GROUP, database2.getOwnerType());
+ }
Review Comment:
Yes, good idea.
--
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]