[ 
https://issues.apache.org/jira/browse/HIVE-25034?focusedWorklogId=599739&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-599739
 ]

ASF GitHub Bot logged work on HIVE-25034:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/May/21 11:12
            Start Date: 20/May/21 11:12
    Worklog Time Spent: 10m 
      Work Description: pvary commented on a change in pull request #2243:
URL: https://github.com/apache/hive/pull/2243#discussion_r636004243



##########
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:
       We might want to check if we can move this method to TestTables. We have 
several variations of `createTable` already there.




-- 
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 599739)
    Time Spent: 4.5h  (was: 4h 20m)

> Implement CTAS for Iceberg
> --------------------------
>
>                 Key: HIVE-25034
>                 URL: https://issues.apache.org/jira/browse/HIVE-25034
>             Project: Hive
>          Issue Type: New Feature
>            Reporter: Marton Bod
>            Assignee: Marton Bod
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 4.5h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to