nastra commented on code in PR #9980:
URL: https://github.com/apache/iceberg/pull/9980#discussion_r1535430072


##########
hive-metastore/src/test/java/org/apache/iceberg/hive/HiveTableTest.java:
##########
@@ -349,8 +351,70 @@ public void testListTables() throws TException, 
IOException {
     HIVE_METASTORE_EXTENSION.metastoreClient().dropTable(DB_NAME, 
hiveTableName);
   }
 
-  private org.apache.hadoop.hive.metastore.api.Table createHiveTable(String 
hiveTableName)
-      throws IOException {
+  @Test
+  public void testHiveTableAndIcebergTableWithSameName() throws TException, 
IOException {
+    List<TableIdentifier> tableIdents = 
catalog.listTables(TABLE_IDENTIFIER.namespace());
+    assertThat(tableIdents).as("should be 1 table in namespace .").hasSize(1);
+
+    // create a hive table
+    String hiveTableName = "test_hive_table";
+    org.apache.hadoop.hive.metastore.api.Table hiveTable =
+        createHiveTable(hiveTableName, TableType.EXTERNAL_TABLE);
+    HIVE_METASTORE_EXTENSION.metastoreClient().createTable(hiveTable);
+
+    catalog.setListAllTables(true);
+    List<TableIdentifier> tableIdents2 = 
catalog.listTables(TABLE_IDENTIFIER.namespace());
+    assertThat(tableIdents2).as("should be 2 tables in namespace 
.").hasSize(2);
+
+    TableIdentifier identifierWithHiveTableName = TableIdentifier.of(DB_NAME, 
hiveTableName);
+
+    // create an iceberg table with the same name
+    assertThatThrownBy(
+            () ->
+                catalog.createTable(
+                    identifierWithHiveTableName, schema, 
PartitionSpec.unpartitioned()))
+        .isInstanceOf(NoSuchIcebergTableException.class)
+        .hasMessageStartingWith("Not an iceberg table: 
hive.hivedb.test_hive_table");

Review Comment:
   ```suggestion
           .hasMessageStartingWith(String.format("Not an iceberg table: %s", 
identifier));
   ```



##########
hive-metastore/src/test/java/org/apache/iceberg/hive/HiveTableTest.java:
##########
@@ -349,8 +351,70 @@ public void testListTables() throws TException, 
IOException {
     HIVE_METASTORE_EXTENSION.metastoreClient().dropTable(DB_NAME, 
hiveTableName);
   }
 
-  private org.apache.hadoop.hive.metastore.api.Table createHiveTable(String 
hiveTableName)
-      throws IOException {
+  @Test
+  public void testHiveTableAndIcebergTableWithSameName() throws TException, 
IOException {
+    List<TableIdentifier> tableIdents = 
catalog.listTables(TABLE_IDENTIFIER.namespace());
+    assertThat(tableIdents).as("should be 1 table in namespace .").hasSize(1);
+
+    // create a hive table
+    String hiveTableName = "test_hive_table";
+    org.apache.hadoop.hive.metastore.api.Table hiveTable =
+        createHiveTable(hiveTableName, TableType.EXTERNAL_TABLE);
+    HIVE_METASTORE_EXTENSION.metastoreClient().createTable(hiveTable);
+
+    catalog.setListAllTables(true);
+    List<TableIdentifier> tableIdents2 = 
catalog.listTables(TABLE_IDENTIFIER.namespace());
+    assertThat(tableIdents2).as("should be 2 tables in namespace 
.").hasSize(2);
+
+    TableIdentifier identifierWithHiveTableName = TableIdentifier.of(DB_NAME, 
hiveTableName);

Review Comment:
   ```suggestion
       TableIdentifier identifier = TableIdentifier.of(DB_NAME, hiveTableName);
   ```



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