private void testTruncateTable(String databaseName, String tableName, Table icebergTable, List<Record> records,
      Schema schema, boolean externalTablePurge, boolean force) throws TException, InterruptedException {
    TableIdentifier identifier = TableIdentifier.of(databaseName, tableName);
    // Set the 'external.table.purge' table property on the table
    String alterTableCommand =
        "ALTER TABLE " + identifier + " SET TBLPROPERTIES('external.table.purge'='" + externalTablePurge + "')";
    shell.executeStatement(alterTableCommand);

    // Validate the initial data and the table statistics
    List<Object[]> rows = shell.executeStatement("SELECT * FROM " + identifier);
    HiveIcebergTestUtils.validateData(records, HiveIcebergTestUtils.valueForRow(schema, rows), 0);
    shell.executeStatement("ANALYZE TABLE " + identifier + " COMPUTE STATISTICS");
    validateBasicStats(icebergTable, databaseName, tableName);

    // Run a 'truncate table' or 'truncate table force' command
    String truncateCommand = "TRUNCATE " + identifier;
    if (force) {
      truncateCommand = truncateCommand + " FORCE";
    }
    shell.executeStatement(truncateCommand);

    // Validate if the data is deleted from the table and also that the table
    // statistics are reset to 0.
    Table table = testTables.loadTable(identifier);
    Map<String, String> summary = table.currentSnapshot().summary();
    for (String key : STATS_MAPPING.values()) {
      Assert.assertEquals("0", summary.get(key));
    }
    rows = shell.executeStatement("SELECT * FROM " + identifier);
    Assert.assertEquals(0, rows.size());
    validateBasicStats(table, databaseName, tableName);
  }
Tests truncate table feature on Iceberg tables.
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergTruncateTable.java