use of com.facebook.presto.common.type.ArrayType in project presto by prestodb.
the class AbstractTestParquetReader method testStructOfMaps.
@Test
public void testStructOfMaps() throws Exception {
Iterable<Integer> mapKeys = Stream.generate(() -> ThreadLocalRandom.current().nextInt(10_000)).limit(10_000).collect(Collectors.toList());
Iterable<Integer> intPrimitives = limit(cycle(asList(1, null, 3, null, 5, null, 7, null, null, null, 11, null, 13)), 10_000);
Iterable<String> stringPrimitives = limit(cycle(asList(null, "value2", "value3", null, null, "value6", "value7")), 10_000);
Iterable<Map<Integer, String>> maps = createNullableTestMaps(mapKeys, stringPrimitives);
Iterable<List<String>> stringArrayField = createNullableTestArrays(stringPrimitives);
List<List> values = createTestStructs(maps, stringArrayField, intPrimitives);
List<String> structFieldNames = asList("mapIntStringField", "stringArrayField", "intField");
Type structType = RowType.from(asList(field("mapIntStringField", mapType(INTEGER, VARCHAR)), field("stringArrayField", new ArrayType(VARCHAR)), field("intField", INTEGER)));
tester.testRoundTrip(getStandardStructObjectInspector(structFieldNames, asList(getStandardMapObjectInspector(javaIntObjectInspector, javaStringObjectInspector), getStandardListObjectInspector(javaStringObjectInspector), javaIntObjectInspector)), values, values, structType);
}
use of com.facebook.presto.common.type.ArrayType in project presto by prestodb.
the class AbstractTestParquetReader method testSchemaWithRepeatedOptionalRequiredFields.
@Test
public void testSchemaWithRepeatedOptionalRequiredFields() throws Exception {
MessageType parquetSchema = parseMessageType("message hive_schema {" + " optional group address_book {" + " required binary owner (UTF8);" + " optional group owner_phone_numbers (LIST) {" + " repeated group bag {" + " optional binary array_element (UTF8);" + " }" + " }" + " optional group contacts (LIST) {" + " repeated group bag {" + " optional group array_element {" + " required binary name (UTF8);" + " optional binary phone_number (UTF8);" + " }" + " }" + " }" + " }" + "} ");
Iterable<String> owner = limit(cycle(asList("owner1", "owner2", "owner3")), 50_000);
Iterable<List<String>> ownerPhoneNumbers = limit(cycle(asList(null, asList("phoneNumber2", "phoneNumber3", null), asList(null, "phoneNumber6", "phoneNumber7"))), 50_000);
Iterable<String> name = asList("name1", "name2", "name3", "name4", "name5", "name6", "name7");
Iterable<String> phoneNumber = asList(null, "phoneNumber2", "phoneNumber3", null, null, "phoneNumber6", "phoneNumber7");
Iterable<List> contact = createNullableTestStructs(name, phoneNumber);
Iterable<List<List>> contacts = createNullableTestArrays(limit(cycle(contact), 50_000));
List<List> values = createTestStructs(owner, ownerPhoneNumbers, contacts);
List<String> addressBookFieldNames = asList("owner", "owner_phone_numbers", "contacts");
List<String> contactsFieldNames = asList("name", "phone_number");
Type contactsType = new ArrayType(RowType.from(asList(field("name", VARCHAR), field("phone_number", VARCHAR))));
Type addressBookType = RowType.from(asList(field("owner", VARCHAR), field("owner_phone_numbers", new ArrayType(VARCHAR)), field("contacts", contactsType)));
tester.testRoundTrip(getStandardStructObjectInspector(addressBookFieldNames, asList(javaStringObjectInspector, getStandardListObjectInspector(javaStringObjectInspector), getStandardListObjectInspector(getStandardStructObjectInspector(contactsFieldNames, asList(javaStringObjectInspector, javaStringObjectInspector))))), values, values, "address_book", addressBookType, Optional.of(parquetSchema));
}
use of com.facebook.presto.common.type.ArrayType in project presto by prestodb.
the class AbstractTestParquetReader method testStructOfPrimitiveAndArray.
@Test
public void testStructOfPrimitiveAndArray() throws Exception {
Iterable<List<String>> stringArrayField = createNullableTestArrays(transform(intsBetween(0, 31_234), Object::toString));
Iterable<Integer> intField = limit(cycle(ImmutableList.of(1, 3, 5, 7, 11, 13, 17)), 31_234);
List<List> values = createTestStructs(intField, stringArrayField);
List<String> structFieldNames = asList("intField", "stringArrayField");
Type structType = RowType.from(asList(field("intField", INTEGER), field("stringArrayField", new ArrayType(VARCHAR))));
tester.testRoundTrip(getStandardStructObjectInspector(structFieldNames, asList(javaIntObjectInspector, getStandardListObjectInspector(javaStringObjectInspector))), values, values, structType);
}
use of com.facebook.presto.common.type.ArrayType in project presto by prestodb.
the class AbstractTestParquetReader method testArrayOfMapOfStruct.
@Test
public void testArrayOfMapOfStruct() throws Exception {
Iterable<Integer> keys = intsBetween(0, 10_000);
Iterable<List> structs = createNullableTestStructs(transform(intsBetween(0, 10_000), Object::toString), longsBetween(0, 10_000));
List<String> structFieldNames = asList("stringField", "longField");
Type structType = RowType.from(asList(field("stringField", VARCHAR), field("longField", BIGINT)));
Iterable<Map<Integer, List>> maps = createNullableTestMaps(keys, structs);
List<List<Map<Integer, List>>> values = createTestArrays(maps);
tester.testRoundTrip(getStandardListObjectInspector(getStandardMapObjectInspector(javaIntObjectInspector, getStandardStructObjectInspector(structFieldNames, asList(javaStringObjectInspector, javaLongObjectInspector)))), values, values, new ArrayType(mapType(INTEGER, structType)));
}
use of com.facebook.presto.common.type.ArrayType in project presto by prestodb.
the class AbstractTestParquetReader method testSingleLevelArrayOfMapOfStruct.
@Test
public void testSingleLevelArrayOfMapOfStruct() throws Exception {
Iterable<Integer> keys = intsBetween(0, 10_000);
Iterable<List> structs = createNullableTestStructs(transform(intsBetween(0, 10_000), Object::toString), longsBetween(0, 10_000));
List<String> structFieldNames = asList("stringField", "longField");
Type structType = RowType.from(asList(field("stringField", VARCHAR), field("longField", BIGINT)));
Iterable<Map<Integer, List>> maps = createTestMaps(keys, structs);
List<List<Map<Integer, List>>> values = createTestArrays(maps);
tester.testSingleLevelArraySchemaRoundTrip(getStandardListObjectInspector(getStandardMapObjectInspector(javaIntObjectInspector, getStandardStructObjectInspector(structFieldNames, asList(javaStringObjectInspector, javaLongObjectInspector)))), values, values, new ArrayType(mapType(INTEGER, structType)));
}
Aggregations