From 806760bc71fda421c08ca070f23c1f677d182f9b Mon Sep 17 00:00:00 2001 From: Volodymyr Vysotskyi Date: Wed, 5 Feb 2020 20:17:08 +0200 Subject: [PATCH] DRILL-5733: Unable to SELECT from parquet file with Hadoop 2.7.4 closes #1969 --- .../ParquetTableMetadataProviderImpl.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetTableMetadataProviderImpl.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetTableMetadataProviderImpl.java index 18167bafbd5..d05c7e82977 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetTableMetadataProviderImpl.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetTableMetadataProviderImpl.java @@ -37,6 +37,8 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; @@ -126,22 +128,23 @@ public Path getSelectionRoot() { * @return list of cache files found in the given directory path */ public List populateMetaPaths(Path p, DrillFileSystem fs) throws IOException { - List metaFilepaths = new ArrayList<>(); - for (String filename : Metadata.CURRENT_METADATA_FILENAMES) { - metaFilepaths.add(new Path(p, filename)); - } - for (String filename : Metadata.OLD_METADATA_FILENAMES) { - // Read the older version of metadata file if the current version of metadata cache files donot exist. + if (fs.isDirectory(p)) { + List metaFilepaths = Arrays.stream(Metadata.CURRENT_METADATA_FILENAMES) + .map(filename -> new Path(p, filename)) + .collect(Collectors.toList()); + for (String filename : Metadata.OLD_METADATA_FILENAMES) { + // Read the older version of metadata file if the current version of metadata cache files does not exist. + if (fileExists(fs, metaFilepaths)) { + return metaFilepaths; + } + metaFilepaths.clear(); + metaFilepaths.add(new Path(p, filename)); + } if (fileExists(fs, metaFilepaths)) { return metaFilepaths; } - metaFilepaths.clear(); - metaFilepaths.add(new Path(p, filename)); - } - if (fileExists(fs, metaFilepaths)) { - return metaFilepaths; } - return new ArrayList<>(); + return Collections.emptyList(); } public boolean fileExists(DrillFileSystem fs, List paths) throws IOException {