Skip to content

Commit 0939010

Browse files
authored
Revert "[fix][hive-source][bug] fix An error occurred reading an empty directory (#5427)" (#5487)
1 parent d308e27 commit 0939010

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/AbstractReadStrategy.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
2525
import org.apache.seatunnel.connectors.seatunnel.file.config.BaseSourceConfig;
2626
import org.apache.seatunnel.connectors.seatunnel.file.config.HadoopConf;
27+
import org.apache.seatunnel.connectors.seatunnel.file.exception.FileConnectorErrorCode;
28+
import org.apache.seatunnel.connectors.seatunnel.file.exception.FileConnectorException;
2729
import org.apache.seatunnel.connectors.seatunnel.file.sink.util.FileSystemUtils;
2830

2931
import org.apache.hadoop.conf.Configuration;
@@ -151,9 +153,15 @@ public List<String> getFileNamesByPath(HadoopConf hadoopConf, String path) throw
151153
}
152154
}
153155
}
154-
if (this.fileNames.isEmpty()) {
155-
log.error("The current directory is empty " + path);
156+
157+
if (fileNames.isEmpty()) {
158+
throw new FileConnectorException(
159+
FileConnectorErrorCode.FILE_LIST_EMPTY,
160+
"The target file list is empty,"
161+
+ "SeaTunnel will not be able to sync empty table, "
162+
+ "please check the configuration parameters such as: [file_filter_pattern]");
156163
}
164+
157165
return fileNames;
158166
}
159167

@@ -188,12 +196,10 @@ public SeaTunnelRowType getActualSeaTunnelRowTypeInfo() {
188196

189197
protected Map<String, String> parsePartitionsByPath(String path) {
190198
LinkedHashMap<String, String> partitions = new LinkedHashMap<>();
191-
if (path != null && !path.isEmpty()) {
192-
Arrays.stream(path.split("/", -1))
193-
.filter(split -> split.contains("="))
194-
.map(split -> split.split("=", -1))
195-
.forEach(kv -> partitions.put(kv[0], kv[1]));
196-
}
199+
Arrays.stream(path.split("/", -1))
200+
.filter(split -> split.contains("="))
201+
.map(split -> split.split("=", -1))
202+
.forEach(kv -> partitions.put(kv[0], kv[1]));
197203
return partitions;
198204
}
199205

seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/ExcelReadStrategy.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ public void setSeaTunnelRowTypeInfo(SeaTunnelRowType seaTunnelRowType) {
136136
"Schmea information is not set or incorrect schmea settings");
137137
}
138138
SeaTunnelRowType userDefinedRowTypeWithPartition =
139-
mergePartitionTypes(
140-
fileNames.size() > 0 ? fileNames.get(0) : null, seaTunnelRowType);
139+
mergePartitionTypes(fileNames.get(0), seaTunnelRowType);
141140
// column projection
142141
if (pluginConfig.hasPath(BaseSourceConfig.READ_COLUMNS.key())) {
143142
// get the read column index from user-defined row type

seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/TextReadStrategy.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ public SeaTunnelRowType getSeaTunnelRowTypeInfo(HadoopConf hadoopConf, String pa
138138
@Override
139139
public void setSeaTunnelRowTypeInfo(SeaTunnelRowType seaTunnelRowType) {
140140
SeaTunnelRowType userDefinedRowTypeWithPartition =
141-
mergePartitionTypes(
142-
fileNames.size() > 0 ? fileNames.get(0) : null, seaTunnelRowType);
141+
mergePartitionTypes(fileNames.get(0), seaTunnelRowType);
143142
if (pluginConfig.hasPath(BaseSourceConfig.DELIMITER.key())) {
144143
fieldDelimiter = pluginConfig.getString(BaseSourceConfig.DELIMITER.key());
145144
} else {

0 commit comments

Comments
 (0)