Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ public void testSimpleTypes() throws IOException {
GenericRow.of(1, 1L), GenericRow.of(2, 2L), GenericRow.of(3, null));
}

/**
* Currently, Parquet format doesn't support nested row in array, so this test handles Parquet
* specially.
*/
@Test
public void testFullTypes() throws IOException {
RowType rowType = rowTypeForFullTypesTest();
Expand All @@ -133,6 +129,48 @@ public void testFullTypes() throws IOException {
validateFullTypesResult(result.get(0), expected);
}

@Test
public void testNestedReadPruning() throws Exception {
FileFormat format = fileFormat();

RowType writeType =
DataTypes.ROW(
DataTypes.FIELD(0, "f0", DataTypes.INT()),
DataTypes.FIELD(
1,
"f1",
DataTypes.ROW(
DataTypes.FIELD(2, "f0", DataTypes.INT()),
DataTypes.FIELD(3, "f1", DataTypes.INT()),
DataTypes.FIELD(4, "f2", DataTypes.INT()))));

try (PositionOutputStream out = fileIO.newOutputStream(file, false);
FormatWriter writer = format.createWriterFactory(writeType).create(out, "zstd")) {
writer.addElement(GenericRow.of(0, GenericRow.of(10, 11, 12)));
}

// skip read f0, f1.f1
RowType readType =
DataTypes.ROW(
DataTypes.FIELD(
1,
"f1",
DataTypes.ROW(
DataTypes.FIELD(2, "f0", DataTypes.INT()),
DataTypes.FIELD(4, "f2", DataTypes.INT()))));

List<InternalRow> result = new ArrayList<>();
try (RecordReader<InternalRow> reader =
format.createReaderFactory(readType)
.createReader(
new FormatReaderContext(fileIO, file, fileIO.getFileSize(file)))) {
InternalRowSerializer serializer = new InternalRowSerializer(readType);
reader.forEachRemaining(row -> result.add(serializer.copy(row)));
}

assertThat(result).containsExactly(GenericRow.of(GenericRow.of(10, 12)));
}

private RowType rowTypeForFullTypesTest() {
RowType.Builder builder =
RowType.builder()
Expand Down