This is an automated email from the ASF dual-hosted git repository.
wanghailin pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/seatunnel.git
The following commit(s) were added to refs/heads/dev by this push:
new 83e4918536 [Fix][Connector-V2] Fix file reading cannot read empty
strings (#8646)
83e4918536 is described below
commit 83e4918536e22797c0fb108fb14f57420f11fa54
Author: corgy-w <[email protected]>
AuthorDate: Thu Feb 13 17:14:44 2025 +0800
[Fix][Connector-V2] Fix file reading cannot read empty strings (#8646)
---
.../apache/seatunnel/format/text/TextDeserializationSchema.java | 5 +----
.../org/apache/seatunnel/format/text/TextFormatSchemaTest.java | 8 ++++++--
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git
a/seatunnel-formats/seatunnel-format-text/src/main/java/org/apache/seatunnel/format/text/TextDeserializationSchema.java
b/seatunnel-formats/seatunnel-format-text/src/main/java/org/apache/seatunnel/format/text/TextDeserializationSchema.java
index 16c4bb93ea..c88d69ee21 100644
---
a/seatunnel-formats/seatunnel-format-text/src/main/java/org/apache/seatunnel/format/text/TextDeserializationSchema.java
+++
b/seatunnel-formats/seatunnel-format-text/src/main/java/org/apache/seatunnel/format/text/TextDeserializationSchema.java
@@ -178,9 +178,6 @@ public class TextDeserializationSchema implements
DeserializationSchema<SeaTunne
Object[] objects = new Object[seaTunnelRowType.getTotalFields()];
for (int i = 0; i < objects.length; i++) {
String fieldValue = splitsMap.get(i);
- if (StringUtils.isBlank(fieldValue)) {
- continue;
- }
if (StringUtils.equals(fieldValue, nullFormat)) {
continue;
}
@@ -224,7 +221,7 @@ public class TextDeserializationSchema implements
DeserializationSchema<SeaTunne
private Object convert(
String field, SeaTunnelDataType<?> fieldType, int level, String
fieldName) {
- if (StringUtils.isBlank(field)) {
+ if (StringUtils.isEmpty(field)) {
return null;
}
switch (fieldType.getSqlType()) {
diff --git
a/seatunnel-formats/seatunnel-format-text/src/test/java/org/apache/seatunnel/format/text/TextFormatSchemaTest.java
b/seatunnel-formats/seatunnel-format-text/src/test/java/org/apache/seatunnel/format/text/TextFormatSchemaTest.java
index a8ab6decfa..a8ebeae628 100644
---
a/seatunnel-formats/seatunnel-format-text/src/test/java/org/apache/seatunnel/format/text/TextFormatSchemaTest.java
+++
b/seatunnel-formats/seatunnel-format-text/src/test/java/org/apache/seatunnel/format/text/TextFormatSchemaTest.java
@@ -61,6 +61,7 @@ public class TextFormatSchemaTest {
+ '\003'
+ "1231"
+ "\001"
+ + " \001"
+ "tyrantlucifer\001"
+ "true\001"
+ "1\001"
@@ -88,6 +89,7 @@ public class TextFormatSchemaTest {
new String[] {
"array_field",
"map_field",
+ "null_string_field",
"string_field",
"boolean_field",
"tinyint_field",
@@ -108,6 +110,7 @@ public class TextFormatSchemaTest {
ArrayType.INT_ARRAY_TYPE,
new MapType<>(BasicType.STRING_TYPE,
BasicType.INT_TYPE),
BasicType.STRING_TYPE,
+ BasicType.STRING_TYPE,
BasicType.BOOLEAN_TYPE,
BasicType.BYTE_TYPE,
BasicType.SHORT_TYPE,
@@ -149,8 +152,9 @@ public class TextFormatSchemaTest {
Assertions.assertEquals(((Map<?, ?>)
(seaTunnelRow.getField(1))).get("tyrantlucifer"), 18);
Assertions.assertEquals(((Map<?, ?>)
(seaTunnelRow.getField(1))).get("Kris"), 21);
Assertions.assertArrayEquals(
- (byte[]) seaTunnelRow.getField(12),
"tyrantlucifer".getBytes());
- Assertions.assertEquals(seaTunnelRow.getField(2), "tyrantlucifer");
+ (byte[]) seaTunnelRow.getField(13),
"tyrantlucifer".getBytes());
+ Assertions.assertEquals(seaTunnelRow.getField(2), " ");
+ Assertions.assertEquals(seaTunnelRow.getField(3), "tyrantlucifer");
Assertions.assertEquals(data, content);
}