pvary commented on a change in pull request #2191:
URL: https://github.com/apache/iceberg/pull/2191#discussion_r570095602



##########
File path: 
mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java
##########
@@ -568,6 +571,53 @@ public void testIcebergAndHmsTableProperties() throws 
TException, InterruptedExc
     }
   }
 
+  @Test
+  public void testDropTableWithAppendedData() throws IOException {
+    TableIdentifier identifier = TableIdentifier.of("default", "customers");
+
+    shell.executeStatement(String.format("CREATE EXTERNAL TABLE %s STORED BY 
'%s' %s" +

Review comment:
       Would `testTables.createTable` be usable here?

##########
File path: 
mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java
##########
@@ -568,6 +571,53 @@ public void testIcebergAndHmsTableProperties() throws 
TException, InterruptedExc
     }
   }
 
+  @Test
+  public void testDropTableWithAppendedData() throws IOException {
+    TableIdentifier identifier = TableIdentifier.of("default", "customers");
+
+    shell.executeStatement(String.format("CREATE EXTERNAL TABLE %s STORED BY 
'%s' %s" +
+        "TBLPROPERTIES ('%s'='%s', '%s'='%s')",
+        identifier,
+        HiveIcebergStorageHandler.class.getName(),
+        testTables.locationForCreateTableSQL(identifier),
+        InputFormatConfig.TABLE_SCHEMA, 
SchemaParser.toJson(HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA),
+        InputFormatConfig.PARTITION_SPEC, PartitionSpecParser.toJson(SPEC)));
+
+    org.apache.iceberg.Table icebergTable = testTables.loadTable(identifier);
+    testTables.appendIcebergTable(shell.getHiveConf(), icebergTable, 
FileFormat.PARQUET, null, CUSTOMER_RECORDS);
+
+    shell.executeStatement("DROP TABLE customers");
+  }
+
+  @Test
+  public void testDropHiveTableWithoutUnderlyingTable() throws IOException {
+    TableIdentifier identifier = TableIdentifier.of("default", "customers");
+
+    if (!Catalogs.hiveCatalog(shell.getHiveConf())) {
+      // Create the Iceberg table in non-HiveCatalog
+      testTables.createIcebergTable(shell.getHiveConf(), identifier.name(), 
CUSTOMER_SCHEMA, FileFormat.PARQUET,
+              CUSTOMER_RECORDS);
+
+      // Create Hive table on top
+      String tableLocation = testTables.locationForCreateTableSQL(identifier);

Review comment:
       Same here? `testTables.createTable`

##########
File path: 
mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java
##########
@@ -64,6 +66,8 @@
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
+import static 
org.apache.iceberg.mr.hive.HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS;
+import static 
org.apache.iceberg.mr.hive.HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA;

Review comment:
       If we import like this, can we change the other occurrences?

##########
File path: 
mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java
##########
@@ -568,6 +571,53 @@ public void testIcebergAndHmsTableProperties() throws 
TException, InterruptedExc
     }
   }
 
+  @Test
+  public void testDropTableWithAppendedData() throws IOException {
+    TableIdentifier identifier = TableIdentifier.of("default", "customers");
+
+    shell.executeStatement(String.format("CREATE EXTERNAL TABLE %s STORED BY 
'%s' %s" +
+        "TBLPROPERTIES ('%s'='%s', '%s'='%s')",
+        identifier,
+        HiveIcebergStorageHandler.class.getName(),
+        testTables.locationForCreateTableSQL(identifier),
+        InputFormatConfig.TABLE_SCHEMA, 
SchemaParser.toJson(HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA),
+        InputFormatConfig.PARTITION_SPEC, PartitionSpecParser.toJson(SPEC)));
+
+    org.apache.iceberg.Table icebergTable = testTables.loadTable(identifier);
+    testTables.appendIcebergTable(shell.getHiveConf(), icebergTable, 
FileFormat.PARQUET, null, CUSTOMER_RECORDS);
+
+    shell.executeStatement("DROP TABLE customers");
+  }
+
+  @Test
+  public void testDropHiveTableWithoutUnderlyingTable() throws IOException {
+    TableIdentifier identifier = TableIdentifier.of("default", "customers");
+
+    if (!Catalogs.hiveCatalog(shell.getHiveConf())) {
+      // Create the Iceberg table in non-HiveCatalog
+      testTables.createIcebergTable(shell.getHiveConf(), identifier.name(), 
CUSTOMER_SCHEMA, FileFormat.PARQUET,
+              CUSTOMER_RECORDS);
+
+      // Create Hive table on top
+      String tableLocation = testTables.locationForCreateTableSQL(identifier);

Review comment:
       Looks good

##########
File path: 
mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java
##########
@@ -568,6 +570,46 @@ public void testIcebergAndHmsTableProperties() throws 
TException, InterruptedExc
     }
   }
 
+  @Test
+  public void testDropTableWithAppendedData() throws IOException {
+    TableIdentifier identifier = TableIdentifier.of("default", "customers");
+
+    testTables.createTable(shell, identifier.name(), 
HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA, SPEC,
+        FileFormat.PARQUET, ImmutableList.of());
+
+    org.apache.iceberg.Table icebergTable = testTables.loadTable(identifier);
+    testTables.appendIcebergTable(shell.getHiveConf(), icebergTable, 
FileFormat.PARQUET, null,
+        HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS);
+
+    shell.executeStatement("DROP TABLE customers");
+  }
+
+  @Test
+  public void testDropHiveTableWithoutUnderlyingTable() throws IOException {
+    TableIdentifier identifier = TableIdentifier.of("default", "customers");
+
+    if (!Catalogs.hiveCatalog(shell.getHiveConf())) {

Review comment:
       Just realized that probably this would be easier to read. Sorry for the 
late notice, should have caught earlier 😢 
   `Assume.assumeFalse("Not relevant for HiveCatalog", 
Catalogs.hiveCatalog(shell.getHiveConf()));`




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

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to