Skip to content

Commit

Permalink
🐛 Refactor text deserialization, allow null value assignments
Browse files Browse the repository at this point in the history
Modified the TextDeserializationSchema to allow key-value pairs with null values. This adjustment helps to handle data records with missing values more accurately. The code was also reformatted for improved readability.
  • Loading branch information
yangpeng committed Aug 11, 2023
1 parent 8ef294a commit 88d8962
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public static class Builder {
DateTimeUtils.Formatter.YYYY_MM_DD_HH_MM_SS;
private TimeUtils.Formatter timeFormatter = TimeUtils.Formatter.HH_MM_SS;

private Builder() {}
private Builder() {
}

public Builder seaTunnelRowType(SeaTunnelRowType seaTunnelRowType) {
this.seaTunnelRowType = seaTunnelRowType;
Expand Down Expand Up @@ -186,10 +187,10 @@ private Object convert(String field, SeaTunnelDataType<?> fieldType, int level)
LinkedHashMap<Object, Object> objectMap = new LinkedHashMap<>();
String[] kvs = field.split(separators[level + 1]);
for (String kv : kvs) {
if (kvs.length < 2) {
return null;
String[] splits = kv.split(separators[level + 2]);
if (splits.length < 2) {
objectMap.put(convert(splits[0], keyType, level + 1), null);
} else {
String[] splits = kv.split(separators[level + 2]);
objectMap.put(
convert(splits[0], keyType, level + 1),
convert(splits[1], valueType, level + 1));
Expand Down

0 comments on commit 88d8962

Please sign in to comment.