rdblue commented on a change in pull request #2038:
URL: https://github.com/apache/iceberg/pull/2038#discussion_r559739650
##########
File path:
mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerWithEngine.java
##########
@@ -256,4 +265,293 @@ public void testSelectDistinctFromTable() throws
IOException {
Assert.assertEquals(tableName, size, distinctIds);
}
}
+
+ @Test
+ public void testInsert() throws IOException {
+ Assume.assumeTrue("Tez write is not implemented yet",
executionEngine.equals("mr"));
+
+ Table table = testTables.createTable(shell, "customers",
HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA,
+ fileFormat, ImmutableList.of());
+
+ // The expected query is like
+ // INSERT INTO customers VALUES (0, 'Alice'), (1, 'Bob'), (2, 'Trudy')
+ StringBuilder query = new StringBuilder().append("INSERT INTO customers
VALUES ");
+ HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS.forEach(record ->
query.append("(")
+ .append(record.get(0)).append(",'")
+ .append(record.get(1)).append("','")
+ .append(record.get(2)).append("'),"));
+ query.setLength(query.length() - 1);
+
+ shell.executeStatement(query.toString());
+
+ HiveIcebergTestUtils.validateData(table, new
ArrayList<>(HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS), 0);
+ }
+
+ @Test
+ public void testInsertFromSelect() throws IOException {
+ Assume.assumeTrue("Tez write is not implemented yet",
executionEngine.equals("mr"));
+
+ Table table = testTables.createTable(shell, "customers",
HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA,
+ fileFormat, HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS);
+
+ shell.executeStatement("INSERT INTO customers SELECT * FROM customers");
+
+ // Check that everything is duplicated as expected
+ List<Record> records = new
ArrayList<>(HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS);
+ records.addAll(HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS);
+ HiveIcebergTestUtils.validateData(table, records, 0);
+ }
+
+ @Test
+ public void testInsertFromSelectWithOrderBy() throws IOException {
Review comment:
Makes sense! Thanks for the additional context.
----------------------------------------------------------------
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]