Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-2926: Fix issue reading buggy parquet files with incorrect compressed size #2927

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
@@ -0,0 +1,29 @@
package org.apache.parquet.avro;

import com.google.common.io.Resources;
import org.apache.avro.generic.GenericData;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.parquet.hadoop.ParquetReader;
import org.junit.Test;

/**
* Validates that old files which have compressed size excluding the dictionary page size are readable
*/
public class TestParquetReaderBadCompressedSize {
private static final String STATIC_FILE_BAD_COMPRESSED_SIZE = "test-bad-compressed-size.parquet";

@Test
public void testBadCompressedSize() throws Exception {
Path testFile =
new Path(Resources.getResource(STATIC_FILE_BAD_COMPRESSED_SIZE).getFile());
Configuration configuration = new Configuration();
try (ParquetReader<Object> parquet = AvroParquetReader.builder(testFile)
.disableCompatibility()
.withDataModel(GenericData.get())
.withConf(configuration)
.build()) {
parquet.read();
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typically parquet files are checked into the parquet-testing repo

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,9 @@ public BytesInput readAsBytesInput(int size) throws IOException {

ByteBuffer lastBuffer = ByteBuffer.allocate(missingBytes);
f.readFully(lastBuffer);
lastBuffer.flip();
LOG.warn(
"compressedLength underflow occurred, possibly due to older files not including dict header len");

List<ByteBuffer> buffers = new ArrayList<>(streamBuffers.size() + 1);
buffers.addAll(streamBuffers);
Expand Down
Loading