voonhous commented on code in PR #19162:
URL: https://github.com/apache/hudi/pull/19162#discussion_r3886100473
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hive/TestSparkCatalogMetaStoreClient.scala:
##########
@@ -203,6 +203,202 @@ class TestSparkCatalogMetaStoreClient extends FunSuite
with BeforeAndAfterAll {
}
}
+ test("supported client edge cases: empty partitions, no-op setMetaConf,
default database location") {
+ val client = newClient()
+
+ // add_partitions with an empty list is a no-op that returns an empty
result.
+ assertTrue(client.add_partitions(new util.ArrayList[Partition](), false,
true).isEmpty)
+
+ // setMetaConf is intentionally a silent no-op, while getMetaConf stays
unsupported.
+ client.setMetaConf("hive.metastore.callerContext", "hudi")
+
assertThrows[UnsupportedOperationException](client.getMetaConf("hive.metastore.callerContext"))
+
+ // createDatabase without an explicit location falls back to the warehouse
path.
+ val databaseName = generateName("db")
+ client.createDatabase(new Database(databaseName, "no-location db", null,
new util.HashMap[String, String]()))
+ assertNotNull(client.getDatabase(databaseName).getLocationUri)
Review Comment:
Done in 39aaae78dff6: asserts the location URI contains
`warehouseDir.getCanonicalPath`; the duplicate `getMetaConf` assertion is
dropped from this test.
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hive/TestSparkCatalogMetaStoreClient.scala:
##########
@@ -203,6 +203,202 @@ class TestSparkCatalogMetaStoreClient extends FunSuite
with BeforeAndAfterAll {
}
}
+ test("supported client edge cases: empty partitions, no-op setMetaConf,
default database location") {
+ val client = newClient()
+
+ // add_partitions with an empty list is a no-op that returns an empty
result.
+ assertTrue(client.add_partitions(new util.ArrayList[Partition](), false,
true).isEmpty)
+
+ // setMetaConf is intentionally a silent no-op, while getMetaConf stays
unsupported.
+ client.setMetaConf("hive.metastore.callerContext", "hudi")
+
assertThrows[UnsupportedOperationException](client.getMetaConf("hive.metastore.callerContext"))
+
+ // createDatabase without an explicit location falls back to the warehouse
path.
+ val databaseName = generateName("db")
+ client.createDatabase(new Database(databaseName, "no-location db", null,
new util.HashMap[String, String]()))
+ assertNotNull(client.getDatabase(databaseName).getLocationUri)
+ assertFalse(client.tableExists(databaseName, "missing_table"))
+ }
+
+ test("unsupported IMetaStoreClient operations throw
UnsupportedOperationException") {
+ // SparkCatalogMetaStoreClient only implements the subset of
IMetaStoreClient exercised by
+ // HoodieHiveSyncClient/HMSDDLExecutor. Every other method must fail fast
rather than return
+ // a misleading default. This locks in that contract across the delegated
surface.
+ val client = newClient()
+
+ // Connection / config lifecycle.
+ assertUnsupported(client.isCompatibleWith(null:
org.apache.hadoop.hive.conf.HiveConf))
Review Comment:
Imported in 39aaae78dff6 (the file now has zero `null: org.apache...`
casts). Left the list hand-written rather than reflective; it is exact today
and a stale entry now fails in CI since the package is in both wildcard lists.
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hive/TestSparkCatalogMetaStoreClient.scala:
##########
@@ -203,6 +203,202 @@ class TestSparkCatalogMetaStoreClient extends FunSuite
with BeforeAndAfterAll {
}
}
+ test("supported client edge cases: empty partitions, no-op setMetaConf,
default database location") {
+ val client = newClient()
+
+ // add_partitions with an empty list is a no-op that returns an empty
result.
+ assertTrue(client.add_partitions(new util.ArrayList[Partition](), false,
true).isEmpty)
+
+ // setMetaConf is intentionally a silent no-op, while getMetaConf stays
unsupported.
+ client.setMetaConf("hive.metastore.callerContext", "hudi")
+
assertThrows[UnsupportedOperationException](client.getMetaConf("hive.metastore.callerContext"))
+
+ // createDatabase without an explicit location falls back to the warehouse
path.
+ val databaseName = generateName("db")
+ client.createDatabase(new Database(databaseName, "no-location db", null,
new util.HashMap[String, String]()))
+ assertNotNull(client.getDatabase(databaseName).getLocationUri)
+ assertFalse(client.tableExists(databaseName, "missing_table"))
+ }
+
+ test("unsupported IMetaStoreClient operations throw
UnsupportedOperationException") {
+ // SparkCatalogMetaStoreClient only implements the subset of
IMetaStoreClient exercised by
+ // HoodieHiveSyncClient/HMSDDLExecutor. Every other method must fail fast
rather than return
+ // a misleading default. This locks in that contract across the delegated
surface.
+ val client = newClient()
+
+ // Connection / config lifecycle.
+ assertUnsupported(client.isCompatibleWith(null:
org.apache.hadoop.hive.conf.HiveConf))
+ assertUnsupported(client.isSameConfObj(null:
org.apache.hadoop.hive.conf.HiveConf))
+ assertUnsupported(client.setHiveAddedJars(null: String))
+ assertUnsupported(client.isLocalMetaStore())
+ assertUnsupported(client.reconnect())
+ assertUnsupported(client.close())
Review Comment:
Done in 39aaae78dff6: `close()` is a no-op and `getPartition(db, table,
values)` resolves through `externalCatalog.getPartitionOption`, throwing
`NoSuchObjectException` when absent (the signal
`HivePartitionUtil.partitionExists` expects). The contract test no longer lists
them; the partition test asserts the hit and the miss, and the edge-case test
calls `close()`.
--
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]