Skip to content

Commit b60d9ec

Browse files
committed
[FLINK-22294] Fix throw IllegalArgumentException when getNumFiles with partitions on different hdfs nameservices
1 parent 067f237 commit b60d9ec

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
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: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,10 @@ public InputSplitAssigner getInputSplitAssigner(HiveTableInputSplit[] inputSplit
345345

346346
public int getNumFiles() throws IOException {
347347
int numFiles = 0;
348-
FileSystem fs = null;
349348
for (HiveTablePartition partition : partitions) {
350349
StorageDescriptor sd = partition.getStorageDescriptor();
351350
Path inputPath = new Path(sd.getLocation());
352-
if (fs == null) {
353-
fs = inputPath.getFileSystem(jobConf.conf());
354-
}
351+
FileSystem fs = inputPath.getFileSystem(jobConf.conf());
355352
// it's possible a partition exists in metastore but the data has been removed
356353
if (!fs.exists(inputPath)) {
357354
continue;

0 commit comments

Comments
 (0)