marton-bod commented on a change in pull request #2316:
URL: https://github.com/apache/hive/pull/2316#discussion_r640709779
##########
File path:
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerWithEngine.java
##########
@@ -540,6 +540,43 @@ public void testCTASFromHiveTable() {
Assert.assertArrayEquals(new Object[]{2L, "Linda", "Finance"},
objects.get(1));
}
+ @Test
+ public void testCTASPartitionedFromHiveTable() throws TException,
InterruptedException {
+ Assume.assumeTrue("CTAS target table is supported fully only for
HiveCatalog tables." +
+ "For other catalog types, the HiveIcebergSerDe will create the target
Iceberg table in the correct catalog " +
+ "using the Catalogs.createTable function, but will not register the
table in HMS since those catalogs do not " +
+ "use HiveTableOperations. This means that even though the CTAS query
succeeds, the user would not be able to " +
+ "query this new table from Hive, since HMS does not know about it.",
+ 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 PARTITIONED BY (dept, name) " +
+ "STORED BY '%s' TBLPROPERTIES ('%s'='%s') AS SELECT * FROM source",
+ HiveIcebergStorageHandler.class.getName(),
+ TableProperties.DEFAULT_FILE_FORMAT, fileFormat));
+
+ // check table can be read back correctly
+ List<Object[]> objects = shell.executeStatement("SELECT * FROM target
ORDER BY id");
Review comment:
That's true. However, it might not apply in this very specific case,
because the target table will have a different column order than the source
table (because in the `PARTITIONED BY` syntax, I flipped the column order
relative to the source table), so the comparison will fail. So in this case,
this check is the simplest way to do 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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]