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

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

                Author: ASF GitHub Bot
            Created on: 19/May/21 11:54
            Start Date: 19/May/21 11:54
    Worklog Time Spent: 10m 
      Work Description: marton-bod commented on a change in pull request #2243:
URL: https://github.com/apache/hive/pull/2243#discussion_r635166430



##########
File path: 
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerWithEngine.java
##########
@@ -514,6 +519,75 @@ public void testInsertOverwritePartitionedTable() throws 
IOException {
     HiveIcebergTestUtils.validateData(table, expected, 0);
   }
 
+  @Test
+  public void testCTASFromHiveTable() {
+    Assume.assumeTrue("CTAS target table is supported only for HiveCatalog 
tables",
+        testTableType == TestTables.TestTableType.HIVE_CATALOG);
+
+    shell.executeStatement("CREATE TABLE source (id bigint, name string) 
PARTITIONED BY (dept string) STORED AS ORC");
+    shell.executeStatement("INSERT INTO source VALUES (1, 'Mike', 'HR'), (2, 
'Linda', 'Finance')");
+
+    shell.executeStatement(String.format(
+        "CREATE TABLE target STORED BY '%s' %s TBLPROPERTIES ('%s'='%s') AS 
SELECT * FROM source",
+        HiveIcebergStorageHandler.class.getName(),
+        testTables.locationForCreateTableSQL(TableIdentifier.of("default", 
"target")),
+        TableProperties.DEFAULT_FILE_FORMAT, fileFormat));
+
+    List<Object[]> objects = shell.executeStatement("SELECT * FROM target 
ORDER BY id");
+    Assert.assertEquals(2, objects.size());
+    Assert.assertArrayEquals(new Object[]{1L, "Mike", "HR"}, objects.get(0));
+    Assert.assertArrayEquals(new Object[]{2L, "Linda", "Finance"}, 
objects.get(1));
+  }
+
+  @Test
+  public void testCTASFromDifferentIcebergCatalog() {
+    Assume.assumeTrue("CTAS target table is supported only for HiveCatalog 
tables",
+        testTableType == TestTables.TestTableType.HIVE_CATALOG);
+
+    // get source data from a different catalog
+    shell.executeStatement(String.format(
+        "CREATE TABLE source STORED BY '%s' LOCATION '%s' TBLPROPERTIES 
('%s'='%s', '%s'='%s')",
+        HiveIcebergStorageHandler.class.getName(),
+        temp.getRoot().getPath() + "/default/source/",
+        InputFormatConfig.CATALOG_NAME, Catalogs.ICEBERG_HADOOP_TABLE_NAME,
+        InputFormatConfig.TABLE_SCHEMA, 
SchemaParser.toJson(HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA)));
+    shell.executeStatement("INSERT INTO source VALUES (1, 'Mike', 'Roger'), 
(2, 'Linda', 'Albright')");
+
+    // CTAS into a new HiveCatalog table
+    shell.executeStatement(String.format(
+        "CREATE TABLE target STORED BY '%s' TBLPROPERTIES ('%s'='%s') AS 
SELECT * FROM source",
+        HiveIcebergStorageHandler.class.getName(),
+        TableProperties.DEFAULT_FILE_FORMAT, fileFormat));
+
+    List<Object[]> objects = shell.executeStatement("SELECT * FROM target 
ORDER BY customer_id");
+    Assert.assertEquals(2, objects.size());
+    Assert.assertArrayEquals(new Object[]{1L, "Mike", "Roger"}, 
objects.get(0));
+    Assert.assertArrayEquals(new Object[]{2L, "Linda", "Albright"}, 
objects.get(1));
+  }
+
+  @Test
+  public void testCTASFailureRollback() throws IOException {

Review comment:
       Sure!




-- 
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: 599163)
    Time Spent: 3h 50m  (was: 3h 40m)

> 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: 3h 50m
>  Remaining Estimate: 0h
>




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

Reply via email to