@Test
  public void testTruncateTableWithPartitionSpecOnPartitionedTable() {
    // Create an Iceberg table with some record and try to run a truncate table command with partition
    // spec. The command should fail as the table is unpartitioned in Hive. Then check if the
    // initial data and the table statistics are not changed.
    String databaseName = "default";
    String tableName = "customers";
    TableIdentifier identifier = TableIdentifier.of(databaseName, tableName);
    PartitionSpec spec =
        PartitionSpec.builderFor(HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA).identity("customer_id").build();
    testTables.createTable(shell, tableName, HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA,
        spec, fileFormat, HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS);
    shell.executeStatement("ALTER TABLE " + identifier + " SET TBLPROPERTIES('external.table.purge'='true')");
    shell.executeStatement("ANALYZE TABLE " + identifier + " COMPUTE STATISTICS");

    shell.executeStatement("TRUNCATE " + identifier + " PARTITION (customer_id=1)");

    List<Object[]> rows = shell.executeStatement("SELECT * FROM " + identifier);
    List<Record> truncatedRecords = TestHelper.RecordsBuilder
        .newInstance(HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA)
        .add(0L, "Alice", "Brown")
        .add(2L, "Trudy", "Pink")
        .build();
    HiveIcebergTestUtils.validateData(truncatedRecords,
        HiveIcebergTestUtils.valueForRow(HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA, rows), 0);
  }
Tests truncate table feature on Iceberg tables.
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergTruncateTable.java