use of org.apache.iceberg.Schema in project hive by apache.
the class TestHiveIcebergComplexTypeWrites method testWriteStructOfStructsInTable.
@Test
public void testWriteStructOfStructsInTable() throws IOException {
Schema schema = new Schema(required(1, "id", Types.LongType.get()), required(2, "structofstructs", Types.StructType.of(required(3, "struct1", Types.StructType.of(required(4, "key", Types.StringType.get()), required(5, "value", Types.StringType.get()))))));
List<Record> records = TestHelper.generateRandomRecords(schema, 5, 0L);
testComplexTypeWrite(schema, records);
}
use of org.apache.iceberg.Schema in project hive by apache.
the class TestHiveIcebergComplexTypeWrites method testWriteStructOfMapsInTable.
@Test
public void testWriteStructOfMapsInTable() throws IOException {
Schema schema = new Schema(required(1, "id", Types.LongType.get()), required(2, "structofmaps", Types.StructType.of(required(3, "map1", Types.MapType.ofRequired(4, 5, Types.StringType.get(), Types.StringType.get())), required(6, "map2", Types.MapType.ofRequired(7, 8, Types.StringType.get(), Types.StringType.get())))));
List<Record> records = TestHelper.generateRandomRecords(schema, 5, 0L);
testComplexTypeWrite(schema, records);
}
use of org.apache.iceberg.Schema in project hive by apache.
the class TestHiveIcebergComplexTypeWrites method testWriteArrayOfStructsInTable.
@Test
public void testWriteArrayOfStructsInTable() throws IOException {
Schema schema = new Schema(required(1, "id", Types.LongType.get()), required(2, "arrayofstructs", Types.ListType.ofRequired(3, Types.StructType.of(required(4, "something", Types.StringType.get()), required(5, "someone", Types.StringType.get()), required(6, "somewhere", Types.StringType.get())))));
List<Record> records = TestHelper.generateRandomRecords(schema, 5, 0L);
testComplexTypeWrite(schema, records);
}
use of org.apache.iceberg.Schema in project hive by apache.
the class TestHiveIcebergStorageHandlerLocalScan method testScanEmptyTable.
@Test
public void testScanEmptyTable() throws IOException {
Schema emptySchema = new Schema(required(1, "empty", Types.StringType.get()));
testTables.createTable(shell, "empty", emptySchema, fileFormat, ImmutableList.of());
List<Object[]> rows = shell.executeStatement("SELECT * FROM default.empty");
Assert.assertEquals(0, rows.size());
}
use of org.apache.iceberg.Schema in project hive by apache.
the class TestHiveIcebergStorageHandlerLocalScan method testArrayOfStructsInTable.
@Test
public void testArrayOfStructsInTable() throws IOException {
Schema schema = new Schema(required(1, "arrayofstructs", Types.ListType.ofRequired(2, Types.StructType.of(required(3, "something", Types.DoubleType.get()), required(4, "someone", Types.LongType.get()), required(5, "somewhere", Types.StringType.get())))));
List<Record> records = testTables.createTableWithGeneratedRecords(shell, "arraytable", schema, fileFormat, 1);
// access an element from a struct in an array
for (int i = 0; i < records.size(); i++) {
List<?> expectedList = (List<?>) records.get(i).getField("arrayofstructs");
for (int j = 0; j < expectedList.size(); j++) {
List<Object[]> queryResult = shell.executeStatement(String.format("SELECT arrayofstructs[%d].something, " + "arrayofstructs[%d].someone, arrayofstructs[%d].somewhere FROM default.arraytable LIMIT 1 " + "OFFSET %d", j, j, j, i));
GenericRecord genericRecord = (GenericRecord) expectedList.get(j);
Assert.assertEquals(genericRecord.getField("something"), queryResult.get(0)[0]);
Assert.assertEquals(genericRecord.getField("someone"), queryResult.get(0)[1]);
Assert.assertEquals(genericRecord.getField("somewhere"), queryResult.get(0)[2]);
}
}
}
Aggregations