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

[WIP][SQL] Avoid parquet footer reads twice #44853

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<kafka.version>3.6.1</kafka.version>
<!-- After 10.17.1.0, the minimum required version is JDK19 -->
<derby.version>10.16.1.1</derby.version>
<parquet.version>1.13.1</parquet.version>
<parquet.version>1.14.0-SNAPSHOT</parquet.version>
<orc.version>1.9.2</orc.version>
<orc.classifier>shaded-protobuf</orc.classifier>
<jetty.version>9.4.53.v20231009</jetty.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Map;
import java.util.Set;

import org.apache.parquet.io.InputFile;
import scala.Option;

import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -100,13 +101,17 @@ public void initialize(
FileSplit split = (FileSplit) inputSplit;
this.file = split.getPath();
ParquetFileReader fileReader;
ParquetReadOptions options = HadoopReadOptions
.builder(configuration, file)
.withRange(split.getStart(), split.getStart() + split.getLength())
.build();
if (fileFooter.isDefined()) {
fileReader = new ParquetFileReader(configuration, file, fileFooter.get());
InputFile inputFile = fileFooter.get().getInputFile();
if (inputFile == null) {
inputFile = HadoopInputFile.fromPath(file, configuration);
}
fileReader = new ParquetFileReader(inputFile, options, fileFooter.get());
} else {
ParquetReadOptions options = HadoopReadOptions
.builder(configuration, file)
.withRange(split.getStart(), split.getStart() + split.getLength())
.build();
fileReader = new ParquetFileReader(
HadoopInputFile.fromPath(file, configuration), options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ class ParquetFileFormat
} else {
ParquetFooterReader.readFooter(sharedConf, file, ParquetFooterReader.SKIP_ROW_GROUPS)
}
val parquetSplit =
new ParquetInputSplit(filePath, file.start, file.start + file.length, file.length,
Array.empty[String], null)
parquetSplit.setFooter(fileFooter)

val footerFileMetaData = fileFooter.getFileMetaData
val datetimeRebaseSpec = DataSourceUtils.datetimeRebaseSpec(
Expand Down Expand Up @@ -322,7 +326,7 @@ class ParquetFileFormat
requiredSchema)
val iter = new RecordReaderIterator[InternalRow](readerWithRowIndexes)
try {
readerWithRowIndexes.initialize(split, hadoopAttemptContext)
readerWithRowIndexes.initialize(parquetSplit, hadoopAttemptContext)

val fullSchema = toAttributes(requiredSchema) ++ toAttributes(partitionSchema)
val unsafeProjection = GenerateUnsafeProjection.generate(fullSchema, fullSchema)
Expand Down
Loading