lcspinter commented on a change in pull request #2038:
URL: https://github.com/apache/iceberg/pull/2038#discussion_r553847684
##########
File path:
mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandler.java
##########
@@ -1044,6 +1046,161 @@ public void testStructOfStructsInTable() throws
IOException {
}
}
+ @Test
+ public void testInsert() throws IOException {
+ Assume.assumeTrue("Tez write is not implemented yet",
executionEngine.equals("mr"));
+
+ Table table = testTables.createTable(shell, "customers", 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 ");
+ 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<>(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", CUSTOMER_SCHEMA,
fileFormat, CUSTOMER_RECORDS);
+
+ shell.executeStatement("INSERT INTO customers SELECT * FROM customers");
+
+ // Check that everything is duplicated as expected
+ List<Record> records = new ArrayList<>(CUSTOMER_RECORDS);
+ records.addAll(CUSTOMER_RECORDS);
+ HiveIcebergTestUtils.validateData(table, records, 0);
+ }
+
+ @Test
+ public void testInsertFromSelectWithOrderBy() throws IOException {
+ Assume.assumeTrue("Tez write is not implemented yet",
executionEngine.equals("mr"));
+
+ // We expect that there will be Mappers and Reducers here
+ Table table = testTables.createTable(shell, "customers", CUSTOMER_SCHEMA,
fileFormat, CUSTOMER_RECORDS);
+
+ shell.executeStatement("INSERT INTO customers SELECT * FROM customers
ORDER BY customer_id");
+
+ // Check that everything is duplicated as expected
+ List<Record> records = new ArrayList<>(CUSTOMER_RECORDS);
+ records.addAll(CUSTOMER_RECORDS);
+ HiveIcebergTestUtils.validateData(table, records, 0);
+ }
+
+ @Test
+ public void testWriteMapOfStructsInTable() throws IOException {
Review comment:
Do you plan to add the other complexType tests as well?
----------------------------------------------------------------
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]