use of io.trino.spi.type.ArrayType in project trino by trinodb.
the class AbstractTestParquetReader method testStructOfArrayAndPrimitive.
@Test
public void testStructOfArrayAndPrimitive() throws Exception {
Iterable<List<String>> stringArrayField = createNullableTestArrays(transform(intsBetween(0, 31_234), Object::toString));
List<List<?>> values = createTestStructs(stringArrayField, limit(cycle(ImmutableList.of(1, 3, 5, 7, 11, 13, 17)), 31_234));
List<String> structFieldNames = asList("stringArrayField", "intField");
Type structType = RowType.from(asList(field("stringArrayField", new ArrayType(VARCHAR)), field("intField", INTEGER)));
tester.testRoundTrip(getStandardStructObjectInspector(structFieldNames, asList(getStandardListObjectInspector(javaStringObjectInspector), javaIntObjectInspector)), values, values, structType);
}
use of io.trino.spi.type.ArrayType in project trino by trinodb.
the class AbstractTestParquetReader method testStructOfSingleLevelArrayAndPrimitive.
@Test
public void testStructOfSingleLevelArrayAndPrimitive() throws Exception {
Iterable<List<String>> stringArrayField = createNullableTestArrays(transform(intsBetween(0, 31_234), Object::toString));
List<List<?>> values = createTestStructs(stringArrayField, limit(cycle(ImmutableList.of(1, 3, 5, 7, 11, 13, 17)), 31_234));
List<String> structFieldNames = asList("stringArrayField", "intField");
Type structType = RowType.from(asList(field("stringArrayField", new ArrayType(VARCHAR)), field("intField", INTEGER)));
tester.testSingleLevelArraySchemaRoundTrip(getStandardStructObjectInspector(structFieldNames, asList(getStandardListObjectInspector(javaStringObjectInspector), javaIntObjectInspector)), values, values, structType);
}
use of io.trino.spi.type.ArrayType in project trino by trinodb.
the class AbstractTestParquetReader method testEmptyArrays.
@Test
public void testEmptyArrays() throws Exception {
Iterable<List<Integer>> values = limit(cycle(singletonList(Collections.emptyList())), 30_000);
tester.testRoundTrip(getStandardListObjectInspector(javaIntObjectInspector), values, values, new ArrayType(INTEGER));
}
use of io.trino.spi.type.ArrayType in project trino by trinodb.
the class AbstractTestParquetReader method testSingleLevelSchemaArrayOfStructs.
@Test
public void testSingleLevelSchemaArrayOfStructs() throws Exception {
Iterable<Long> aValues = limit(cycle(asList(1L, null, 3L, 5L, null, null, null, 7L, 11L, null, 13L, 17L)), 30_000);
Iterable<Boolean> bValues = limit(cycle(asList(null, true, false, null, null, true, false)), 30_000);
Iterable<String> cValues = transform(intsBetween(0, 31_234), Object::toString);
Iterable<List<?>> structs = createTestStructs(aValues, bValues, cValues);
Iterable<List<List<?>>> values = createTestArrays(structs);
List<String> structFieldNames = asList("a", "b", "c");
Type structType = RowType.from(asList(field("a", BIGINT), field("b", BOOLEAN), field("c", VARCHAR)));
ObjectInspector objectInspector = getStandardListObjectInspector(getStandardStructObjectInspector(structFieldNames, asList(javaLongObjectInspector, javaBooleanObjectInspector, javaStringObjectInspector)));
tester.testSingleLevelArraySchemaRoundTrip(objectInspector, values, values, new ArrayType(structType));
}
use of io.trino.spi.type.ArrayType in project trino by trinodb.
the class AbstractTestParquetReader method testCustomSchemaArrayOfStructs.
@Test
public void testCustomSchemaArrayOfStructs() throws Exception {
MessageType customSchemaArrayOfStructs = parseMessageType("message ParquetSchema { " + " optional group self (LIST) { " + " repeated group self_tuple { " + " optional int64 a; " + " optional boolean b; " + " required binary c (UTF8); " + " } " + " } " + "}");
Iterable<Long> aValues = limit(cycle(asList(1L, null, 3L, 5L, null, null, null, 7L, 11L, null, 13L, 17L)), 30_000);
Iterable<Boolean> bValues = limit(cycle(asList(null, true, false, null, null, true, false)), 30_000);
Iterable<String> cValues = transform(intsBetween(0, 31_234), Object::toString);
Iterable<List<?>> structs = createTestStructs(aValues, bValues, cValues);
Iterable<List<List<?>>> values = createTestArrays(structs);
List<String> structFieldNames = asList("a", "b", "c");
Type structType = RowType.from(asList(field("a", BIGINT), field("b", BOOLEAN), field("c", VARCHAR)));
tester.testSingleLevelArrayRoundTrip(getStandardListObjectInspector(getStandardStructObjectInspector(structFieldNames, asList(javaLongObjectInspector, javaBooleanObjectInspector, javaStringObjectInspector))), values, values, "self", new ArrayType(structType), Optional.of(customSchemaArrayOfStructs));
}
Aggregations