Skip to content
Open
Show file tree
Hide file tree
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 @@ -149,7 +149,7 @@ private void readValues(
int remaining = total;
int currentRowId = rowId;
// First value
if (valuesRead == 0) {
if (valuesRead == 0 && total > 0) {
outputWriter.write(vec, ((long) (currentRowId + valuesRead) * typeWidth), firstValue);
lastValueRead = firstValue;
currentRowId++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.apache.iceberg.types.TypeUtil;
import org.apache.iceberg.types.Types;
import org.apache.parquet.column.ParquetProperties;
import org.apache.parquet.hadoop.ParquetOutputFormat;
import org.apache.parquet.schema.GroupType;
import org.apache.parquet.schema.MessageType;
import org.apache.parquet.schema.Type;
Expand Down Expand Up @@ -254,6 +255,17 @@ FileAppender<Record> getParquetV2Writer(Schema schema, File testFile) throws IOE
.build();
}

FileAppender<Record> parquetV2WriterWithoutDictionary(Schema schema, File testFile)
throws IOException {
return Parquet.write(Files.localOutput(testFile))
.schema(schema)
.createWriterFunc(GenericParquetWriter::create)
.named("test")
.writerVersion(ParquetProperties.WriterVersion.PARQUET_2_0)
.set(ParquetOutputFormat.ENABLE_DICTIONARY, "false")
.build();
}

void assertRecordsMatch(
Schema schema,
int expectedSize,
Expand Down Expand Up @@ -430,6 +442,37 @@ public void testSupportedReadsForParquetV2() throws Exception {
assertRecordsMatch(schema, 30000, data, dataFile, false, BATCH_SIZE);
}

@Test
public void testAllNullStringAndBinaryColumnsParquetV2() throws Exception {
// V2 string/binary uses DELTA_BYTE_ARRAY; an all-null page decodes to a delta length stream
// with totalValueCount == 0.
Schema schema =
new Schema(
required(100, "id", Types.LongType.get()),
optional(101, "string_data", Types.StringType.get()),
optional(102, "binary_data", Types.BinaryType.get()));

int stringOrdinal = 1;
int binaryOrdinal = 2;
File dataFile = temp.resolve("all-null-v2.parquet").toFile();
Iterable<Record> data =
generateData(
schema,
100,
0L,
RandomData.DEFAULT_NULL_PERCENTAGE,
record -> {
record.set(stringOrdinal, null);
record.set(binaryOrdinal, null);
return record;
});
try (FileAppender<Record> writer = parquetV2WriterWithoutDictionary(schema, dataFile)) {
writer.addAll(data);
}

assertRecordsMatch(schema, 100, data, dataFile, false, BATCH_SIZE);
}

@Test
public void testUnsupportedReadsForParquetV2() throws Exception {
// Some types use delta encoding and which are not supported for vectorized reads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.apache.iceberg.types.TypeUtil;
import org.apache.iceberg.types.Types;
import org.apache.parquet.column.ParquetProperties;
import org.apache.parquet.hadoop.ParquetOutputFormat;
import org.apache.parquet.schema.GroupType;
import org.apache.parquet.schema.MessageType;
import org.apache.parquet.schema.Type;
Expand Down Expand Up @@ -254,6 +255,17 @@ FileAppender<Record> getParquetV2Writer(Schema schema, File testFile) throws IOE
.build();
}

FileAppender<Record> parquetV2WriterWithoutDictionary(Schema schema, File testFile)
throws IOException {
return Parquet.write(Files.localOutput(testFile))
.schema(schema)
.createWriterFunc(GenericParquetWriter::create)
.named("test")
.writerVersion(ParquetProperties.WriterVersion.PARQUET_2_0)
.set(ParquetOutputFormat.ENABLE_DICTIONARY, "false")
.build();
}

void assertRecordsMatch(
Schema schema,
int expectedSize,
Expand Down Expand Up @@ -430,6 +442,37 @@ public void testSupportedReadsForParquetV2() throws Exception {
assertRecordsMatch(schema, 30000, data, dataFile, false, BATCH_SIZE);
}

@Test
public void testAllNullStringAndBinaryColumnsParquetV2() throws Exception {
// V2 string/binary uses DELTA_BYTE_ARRAY; an all-null page decodes to a delta length stream
// with totalValueCount == 0.
Schema schema =
new Schema(
required(100, "id", Types.LongType.get()),
optional(101, "string_data", Types.StringType.get()),
optional(102, "binary_data", Types.BinaryType.get()));

int stringOrdinal = 1;
int binaryOrdinal = 2;
File dataFile = temp.resolve("all-null-v2.parquet").toFile();
Iterable<Record> data =
generateData(
schema,
100,
0L,
RandomData.DEFAULT_NULL_PERCENTAGE,
record -> {
record.set(stringOrdinal, null);
record.set(binaryOrdinal, null);
return record;
});
try (FileAppender<Record> writer = parquetV2WriterWithoutDictionary(schema, dataFile)) {
writer.addAll(data);
}

assertRecordsMatch(schema, 100, data, dataFile, false, BATCH_SIZE);
}

@Test
public void testUnsupportedReadsForParquetV2() throws Exception {
// Some types use delta encoding and which are not supported for vectorized reads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,17 @@ FileAppender<Record> parquetWriterWithoutDictionary(Schema schema, File testFile
.build();
}

FileAppender<Record> parquetV2WriterWithoutDictionary(Schema schema, File testFile)
Comment thread
raunaqmorarka marked this conversation as resolved.
throws IOException {
return Parquet.write(Files.localOutput(testFile))
.schema(schema)
.createWriterFunc(GenericParquetWriter::create)
.named("test")
.writerVersion(ParquetProperties.WriterVersion.PARQUET_2_0)
.set(ParquetOutputFormat.ENABLE_DICTIONARY, "false")
.build();
}

void assertRecordsMatch(
Schema schema,
int expectedSize,
Expand Down Expand Up @@ -443,6 +454,37 @@ public void testSupportedReadsForParquetV2() throws Exception {
assertRecordsMatch(schema, 30000, data, dataFile, false, BATCH_SIZE);
}

@Test
public void testAllNullStringAndBinaryColumnsParquetV2() throws Exception {
// V2 string/binary uses DELTA_BYTE_ARRAY; an all-null page decodes to a delta length stream
// with totalValueCount == 0.
Schema schema =
new Schema(
required(100, "id", Types.LongType.get()),
optional(101, "string_data", Types.StringType.get()),
optional(102, "binary_data", Types.BinaryType.get()));

int stringOrdinal = 1;
int binaryOrdinal = 2;
File dataFile = temp.resolve("all-null-v2.parquet").toFile();
Iterable<Record> data =
generateData(
schema,
100,
0L,
RandomData.DEFAULT_NULL_PERCENTAGE,
record -> {
record.set(stringOrdinal, null);
record.set(binaryOrdinal, null);
return record;
});
try (FileAppender<Record> writer = parquetV2WriterWithoutDictionary(schema, dataFile)) {
writer.addAll(data);
}

assertRecordsMatch(schema, 100, data, dataFile, false, BATCH_SIZE);
}

@Test
public void testUnsupportedReadsForParquetV2() throws Exception {
// Some types use delta encoding and which are not supported for vectorized reads
Expand Down
Loading