deniskuzZ commented on code in PR #6925:
URL: https://github.com/apache/hive/pull/6925#discussion_r4742522680
##########
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergCRUD.java:
##########
@@ -761,9 +767,44 @@ public void
testUpdateStatementWithPartitionAndSchemaEvolution() {
HiveIcebergTestUtils.validateData(expected,
HiveIcebergTestUtils.valueForRow(newSchema, objects), 0);
}
+ @Test
+ public void testDeleteFromFilesOfSpecWithDroppedSource() throws IOException {
+ Assume.assumeTrue(formatVersion >= 2 && testTableType ==
TestTableType.HIVE_CATALOG);
+ // Iceberg partition statistics fail once a partition source is dropped
+ shell.setHiveSessionValue("hive.iceberg.stats.source", "metastore");
+ shell.executeStatement(String.format("CREATE EXTERNAL TABLE dropped (id
int, name string, region string) " +
+ "PARTITIONED BY SPEC (region) STORED BY ICEBERG STORED AS %s
TBLPROPERTIES ('format-version'='%d')",
+ fileFormat, formatVersion));
+ shell.executeStatement("INSERT INTO dropped VALUES (1, 'a', 'eu'), (2,
'b', 'us'), (3, 'c', 'eu'), (4, 'd', 'us')");
+ shell.executeStatement("ALTER TABLE dropped SET PARTITION SPEC (bucket(2,
id))");
+ shell.executeStatement("INSERT INTO dropped VALUES (5, 'e', 'eu'), (6,
'f', 'us')");
+ shell.executeStatement("ALTER TABLE dropped DROP COLUMN region");
+
+ // deleting from files of the old spec fails before writing; deleting from
files of the new spec works
+ IllegalArgumentException failure =
Assert.assertThrows(IllegalArgumentException.class,
+ () -> shell.executeStatement("DELETE FROM dropped WHERE id IN (1,
5)"));
+ Assert.assertTrue(failure.getMessage(), failure.getMessage().contains(
+ "Cannot delete from the data files of partition spec 0: the source
column of a partition field was dropped"));
+ Assert.assertEquals(List.of("1:a", "2:b", "3:c", "4:d", "5:e", "6:f"),
+ rows(testTables.loadTable(TableIdentifier.of("default", "dropped"))));
+ shell.executeStatement("DELETE FROM dropped WHERE id IN (5, 6)");
+ Assert.assertEquals(List.of("1:a", "2:b", "3:c", "4:d"),
+ rows(testTables.loadTable(TableIdentifier.of("default", "dropped"))));
+ }
+
+ // reads with Iceberg: Hive cannot plan a query once a partition source is
dropped
Review Comment:
I'll open a JIRA for it
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]