From 141014604b95683a0b0e7df7f1ffd1cee28f54a4 Mon Sep 17 00:00:00 2001 From: vernedeng Date: Sat, 14 Sep 2024 17:22:45 +0800 Subject: [PATCH] [INLONG-11105][SDK] Fix the empty string is converted into a "null" --- .../inlong/sdk/transform/process/TransformProcessor.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/TransformProcessor.java b/inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/TransformProcessor.java index 32024ec1bea..264574d67b5 100644 --- a/inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/TransformProcessor.java +++ b/inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/TransformProcessor.java @@ -167,7 +167,7 @@ public List transform(I input, Map extParams) { for (ValueParserNode node : this.selectItems) { String fieldName = node.getFieldName(); ValueParser parser = node.getParser(); - if (parser == null || StringUtils.equals(fieldName, SinkEncoder.ALL_SOURCE_FIELD_SIGN)) { + if (parser == null && StringUtils.equals(fieldName, SinkEncoder.ALL_SOURCE_FIELD_SIGN)) { if (input instanceof String) { sinkData.addField(fieldName, (String) input); } else { @@ -177,7 +177,11 @@ public List transform(I input, Map extParams) { } try { Object fieldValue = parser.parse(sourceData, i, context); - sinkData.addField(fieldName, String.valueOf(fieldValue)); + if (fieldValue == null) { + sinkData.addField(fieldName, ""); + } else { + sinkData.addField(fieldName, fieldValue.toString()); + } } catch (Throwable t) { sinkData.addField(fieldName, ""); }