You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/07/15 09:06:51 UTC

[GitHub] [hive] pvary commented on a change in pull request #2471: HIVE-25325: Add TRUNCATE TABLE support for Hive Iceberg tables

pvary commented on a change in pull request #2471:
URL: https://github.com/apache/hive/pull/2471#discussion_r670278116



##########
File path: iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerWithEngine.java
##########
@@ -1313,6 +1313,186 @@ public void testScanTableCaseInsensitive() throws IOException {
     Assert.assertArrayEquals(new Object[] {1L, "Bob", "Green"}, rows.get(1));
   }
 
+  @Test
+  public void testTruncateTable() throws IOException, TException, InterruptedException {
+    // Create an Iceberg table with some records in it then execute a truncate table command.
+    // Then check if the data is deleted and the table statistics are reset to 0.
+    String databaseName = "default";
+    String tableName = "customers";
+    Table icebergTable = testTables.createTable(shell, tableName, HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA,
+        fileFormat, HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS);
+    testTruncateTable(databaseName, tableName, icebergTable, HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS,
+        HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA, true, false);
+  }
+
+  @Test
+  public void testTruncateEmptyTable() throws IOException, TException, InterruptedException {
+    // Create an empty Iceberg table and execute a truncate table command on it.
+    String databaseName = "default";
+    String tableName = "customers";
+    String fullTableName = databaseName + "." + tableName;

Review comment:
       nit: I usually use:
   ```
   TableIdentifier identifier = TableIdentifier.of(databaseName, tableName);
   [...]
   String alterTableCommand =
           "ALTER TABLE " + identifier + " SET TBLPROPERTIES('external.table.purge'='true')";
   ```




-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org