pvary commented on a change in pull request #1607:
URL: https://github.com/apache/iceberg/pull/1607#discussion_r528672289
##########
File path:
mr/src/test/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandlerBaseTest.java
##########
@@ -481,6 +482,263 @@ public void testCreateTableAboveExistingTable() throws
TException, IOException,
}
}
+ @Test
+ public void testArrayOfPrimitivesInTable() throws IOException {
+ Schema schema =
+ new Schema(required(1, "arrayofprimitives",
Types.ListType.ofRequired(2, Types.IntegerType.get())));
+ List<Record> records = createTableWithGeneratedRecords(schema, 1, 0L,
"arraytable");
+ // access a single element from the array
+ for (int i = 0; i < records.size(); i++) {
+ List<?> expectedList = (List<?>)
records.get(i).getField("arrayofprimitives");
+ for (int j = 0; j < expectedList.size(); j++) {
+ List<Object[]> queryResult = shell.executeStatement(
+ String.format("SELECT arrayofprimitives[%d] FROM
default.arraytable " + "LIMIT 1 OFFSET %d", j, i));
+ Assert.assertEquals(expectedList.get(j), queryResult.get(0)[0]);
+ }
+ }
+ }
+
+ @Test
+ public void testArrayOfArraysInTable() throws IOException {
+ Schema schema =
+ new Schema(
+ required(1, "arrayofarrays",
+ Types.ListType.ofRequired(2,
Types.ListType.ofRequired(3, Types.DateType.get()))));
+ List<Record> records = createTableWithGeneratedRecords(schema, 1, 0L,
"arraytable");
+ // access an element from a matrix
+ for (int i = 0; i < records.size(); i++) {
+ List<?> expectedList = (List<?>)
records.get(i).getField("arrayofarrays");
+ for (int j = 0; j < expectedList.size(); j++) {
+ List<?> expectedInnerList = (List<?>) expectedList.get(j);
+ for (int k = 0; k < expectedInnerList.size(); k++) {
+ List<Object[]> queryResult = shell.executeStatement(
+ String.format("SELECT arrayofarrays[%d][%d] FROM
default.arraytable " + "LIMIT 1 OFFSET %d",
+ j, k, i));
+ Assert.assertEquals(expectedInnerList.get(k).toString(),
queryResult.get(0)[0]);
+ }
+
Review comment:
nit: would you mind removing this line?
----------------------------------------------------------------
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]