cshuo commented on code in PR #19393:
URL: https://github.com/apache/hudi/pull/19393#discussion_r3670565155


##########
hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/table/catalog/TestHoodieHiveCatalog.java:
##########
@@ -149,6 +164,259 @@ public static void closeCatalog() {
     }
   }
 
+  @Test
+  void testDatabaseAndTableApiAgainstMetastore() throws Exception {
+    String databaseName = "catalog_api_db";
+    ObjectPath databaseTablePath = new ObjectPath(databaseName, 
"catalog_api_table");
+    hoodieCatalog.dropDatabase(databaseName, true, true);
+
+    try {
+      CatalogDatabase database =
+          new CatalogDatabaseImpl(new HashMap<>(), "catalog api database");
+      hoodieCatalog.createDatabase(databaseName, database, false);
+
+      assertTrue(hoodieCatalog.databaseExists(databaseName));
+      assertTrue(hoodieCatalog.listDatabases().contains(databaseName));
+      CatalogDatabase storedDatabase = hoodieCatalog.getDatabase(databaseName);
+      assertEquals("catalog api database", storedDatabase.getComment());
+      assertNotNull(storedDatabase.getProperties().get(DATABASE_LOCATION_URI));
+      assertThrows(
+          DatabaseAlreadyExistException.class,
+          () -> hoodieCatalog.createDatabase(databaseName, database, false));
+      hoodieCatalog.createDatabase(databaseName, database, true);
+
+      Map<String, String> changedProperties = new HashMap<>();
+      changedProperties.put("purpose", "coverage");
+      changedProperties.put("is_generic", "true");
+      hoodieCatalog.alterDatabase(
+          databaseName,
+          new CatalogDatabaseImpl(changedProperties, null),
+          false);
+      assertEquals(
+          "coverage",
+          
hoodieCatalog.getDatabase(databaseName).getProperties().get("purpose"));
+      assertFalse(
+          
hoodieCatalog.getDatabase(databaseName).getProperties().containsKey("is_generic"));
+
+      String newLocation = new Path(
+          hoodieCatalog.getHiveConf().getVar(
+              
org.apache.hadoop.hive.conf.HiveConf.ConfVars.METASTOREWAREHOUSE),
+          databaseName + "_relocated").toString();
+      Map<String, String> locationProperties = new HashMap<>();
+      locationProperties.put(ALTER_DATABASE_OP, 
AlterHiveDatabaseOp.CHANGE_LOCATION.name());
+      locationProperties.put(DATABASE_LOCATION_URI, newLocation);
+      hoodieCatalog.alterDatabase(
+          databaseName,
+          new CatalogDatabaseImpl(locationProperties, null),
+          false);
+      assertNotNull(

Review Comment:
   Please assert the altered database metadata values. The location was already 
non-null before `CHANGE_LOCATION`, so this assertion still passes if the 
operation ignores `newLocation`. Similarly, the owner assertions only check 
`PrincipalType`, allowing a regression that drops or corrupts the owner name. 
Please compare the stored URI with `newLocation` and assert `getOwnerName()` 
after both owner changes.



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

Reply via email to