Skip to content

Commit ebfb4a5

Browse files
committed
[FLINK-22294][hive] Hive reading fail when getting file numbers on different filesystem nameservices
1 parent 067f237 commit ebfb4a5

File tree

2 files changed

+1
-22
lines changed

2 files changed

+1
-22
lines changed

flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/connectors/hive/HiveSourceFileEnumerator.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,10 @@ public static InputSplit[] createMRSplits(
110110
public static int getNumFiles(List<HiveTablePartition> partitions, JobConf jobConf)
111111
throws IOException {
112112
int numFiles = 0;
113-
FileSystem fs = null;
114113
for (HiveTablePartition partition : partitions) {
115114
StorageDescriptor sd = partition.getStorageDescriptor();
116115
org.apache.hadoop.fs.Path inputPath = new org.apache.hadoop.fs.Path(sd.getLocation());
117-
if (fs == null) {
118-
fs = inputPath.getFileSystem(jobConf);
119-
}
116+
FileSystem fs = inputPath.getFileSystem(jobConf);
120117
// it's possible a partition exists in metastore but the data has been removed
121118
if (!fs.exists(inputPath)) {
122119
continue;

flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/connectors/hive/read/HiveTableInputFormat.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -342,22 +342,4 @@ public BaseStatistics getStatistics(BaseStatistics cachedStats) {
342342
public InputSplitAssigner getInputSplitAssigner(HiveTableInputSplit[] inputSplits) {
343343
return new LocatableInputSplitAssigner(inputSplits);
344344
}
345-
346-
public int getNumFiles() throws IOException {
347-
int numFiles = 0;
348-
FileSystem fs = null;
349-
for (HiveTablePartition partition : partitions) {
350-
StorageDescriptor sd = partition.getStorageDescriptor();
351-
Path inputPath = new Path(sd.getLocation());
352-
if (fs == null) {
353-
fs = inputPath.getFileSystem(jobConf.conf());
354-
}
355-
// it's possible a partition exists in metastore but the data has been removed
356-
if (!fs.exists(inputPath)) {
357-
continue;
358-
}
359-
numFiles += fs.listStatus(inputPath).length;
360-
}
361-
return numFiles;
362-
}
363345
}

0 commit comments

Comments
 (0)