Skip to content

Commit c0d960f

Browse files
author
dujie
committed
hotfix 修改greenplum单次插入失败【30201】
1 parent 86acbe2 commit c0d960f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

flinkx-postgresql/flinkx-postgresql-writer/src/main/java/com/dtstack/flinkx/postgresql/format/PostgresqlOutputFormat.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,14 @@ protected void writeSingleRecordInternal(Row row) throws WriteRecordException {
100100
int index = 0;
101101
try {
102102
StringBuilder sb = new StringBuilder();
103+
int lastIndex = row.getArity() - 1;
103104
for (; index < row.getArity(); index++) {
104105
Object rowData = getField(row, index);
105-
sb.append(rowData)
106-
.append(DEFAULT_FIELD_DELIM);
106+
sb.append(rowData==null ? DEFAULT_NULL_DELIM : rowData);
107+
if(index != lastIndex){
108+
sb.append(DEFAULT_FIELD_DELIM);
109+
}
107110
}
108-
109111
String rowVal = sb.toString();
110112
ByteArrayInputStream bi = new ByteArrayInputStream(rowVal.getBytes(StandardCharsets.UTF_8));
111113
copyManager.copyIn(copySql, bi);

0 commit comments

Comments
 (0)