Skip to content
Permalink
Browse files
[Bug][Flink] Fix when data null , flink-connector throw NullPointerEx…
…ception (#6165)
  • Loading branch information
JNSimba committed Jul 8, 2021
1 parent 31f359c commit aa4013d03ca8ce014c14b2fc9da3d92ae6a769ba
Showing 1 changed file with 7 additions and 1 deletion.
@@ -54,6 +54,7 @@ public class DorisDynamicOutputFormat extends RichOutputFormat<RowData> {
private DorisStreamLoad dorisStreamLoad;
private final String fieldDelimiter = "\t";
private final String lineDelimiter = "\n";
private final String NULL_VALUE = "\\N";
private final List<String> batch = new ArrayList<>();
private transient volatile boolean closed = false;

@@ -118,7 +119,12 @@ private void addBatch(RowData row) {
StringJoiner value = new StringJoiner(this.fieldDelimiter);
GenericRowData rowData = (GenericRowData) row;
for(int i = 0; i < row.getArity(); ++i) {
value.add(rowData.getField(i).toString());
Object field = rowData.getField(i);
if(field != null){
value.add(field.toString());
}else{
value.add(this.NULL_VALUE);
}
}
batch.add(value.toString());
}

0 comments on commit aa4013d

Please sign in to comment.