marton-bod commented on a change in pull request #2243:
URL: https://github.com/apache/hive/pull/2243#discussion_r636009266
##########
File path:
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerWithMultipleCatalogs.java
##########
@@ -128,13 +130,55 @@ public void testJoinTablesFromDifferentCatalogs() throws
IOException {
HiveIcebergTestUtils.valueForRow(HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA,
rows), 0);
}
+ @Test
+ public void testCTASFromOtherCatalog() throws IOException {
+ testTables2.createTable(shell, "source",
HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA,
+ fileFormat2, HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS);
+
+ shell.executeStatement(String.format(
+ "CREATE TABLE target STORED BY '%s' TBLPROPERTIES ('%s'='%s') AS
SELECT * FROM source",
+ HiveIcebergStorageHandler.class.getName(),
+ InputFormatConfig.CATALOG_NAME, HIVECATALOGNAME));
+
+ List<Object[]> objects = shell.executeStatement("SELECT * FROM target");
+ Assert.assertEquals(3, objects.size());
+
+ Table target = testTables1.loadTable(TableIdentifier.of("default",
"target"));
+ HiveIcebergTestUtils.validateData(target,
HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS, 0);
+ }
+
+ @Test
+ public void testCTASFromOtherCatalogFailureRollback() throws IOException {
+ // force an execution error by passing in a committer class that Tez won't
be able to load
+ shell.setHiveSessionValue("hive.tez.mapreduce.output.committer.class",
"org.apache.NotExistingClass");
+
+ TableIdentifier target = TableIdentifier.of("default", "target");
+ testTables2.createTable(shell, "source",
HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA,
+ fileFormat2, HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS);
+
+ try {
+ shell.executeStatement(String.format(
+ "CREATE TABLE target STORED BY '%s' TBLPROPERTIES ('%s'='%s') AS
SELECT * FROM source",
+ HiveIcebergStorageHandler.class.getName(),
+ InputFormatConfig.CATALOG_NAME, HIVECATALOGNAME));
+ } catch (Exception e) {
+ // expected error
+ }
+
+ // CTAS table should have been dropped by the lifecycle hook
+ Assert.assertThrows(NoSuchTableException.class, () ->
testTables1.loadTable(target));
+ }
+
private void createAndAddRecords(TestTables testTables, FileFormat
fileFormat, TableIdentifier identifier,
Review comment:
Agreed. We've had a conversation about this testTables cleanup with
@lcspinter too. I'll file a ticket for that work.
--
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]