haizhou-zhao commented on code in PR #6045: URL: https://github.com/apache/iceberg/pull/6045#discussion_r1013005818
########## hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java: ########## @@ -358,6 +359,63 @@ public void testCreateNamespace() throws Exception { "There no same location for db and namespace", database2.getLocationUri(), hiveLocalDir); } + @Test + public void testCreateNamespaceWithOwnership() throws Exception { + Map<String, String> prop = + ImmutableMap.of( + TableProperties.HMS_DB_OWNER, + "apache", + TableProperties.HMS_DB_OWNER_TYPE, + PrincipalType.USER.name()); + + String expectedOwner = "apache"; + PrincipalType expectedOwnerType = PrincipalType.USER; + + createNamespaceAndVerifyOwnership("userOwnership", prop, expectedOwner, expectedOwnerType); + + prop = + ImmutableMap.of( + TableProperties.HMS_DB_OWNER, + "iceberg", + TableProperties.HMS_DB_OWNER_TYPE, + PrincipalType.GROUP.name()); + expectedOwner = "iceberg"; + expectedOwnerType = PrincipalType.GROUP; + + createNamespaceAndVerifyOwnership("groupOwnership", prop, expectedOwner, expectedOwnerType); + + prop = ImmutableMap.of(TableProperties.HMS_DB_OWNER, "someone"); + expectedOwner = "someone"; + expectedOwnerType = PrincipalType.USER; // default is user if not specified + + createNamespaceAndVerifyOwnership("ownedBySomeone", prop, expectedOwner, expectedOwnerType); + + prop = ImmutableMap.of(); + expectedOwner = System.getProperty("user.name"); // default value if not specified + expectedOwnerType = PrincipalType.USER; // default is user if not specified + + createNamespaceAndVerifyOwnership("ownedByDefaultUser", prop, expectedOwner, expectedOwnerType); + + prop = ImmutableMap.of(TableProperties.HMS_DB_OWNER_TYPE, PrincipalType.GROUP.name()); Review Comment: Yes, let's add a precondition check to forbid setting owner type without setting owner. -- 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