add the convertion of bytes columns

This commit is contained in:
hffariel 2021-10-09 18:38:33 +08:00
parent cbc93b98ff
commit 4450ccadd8
2 changed files with 10 additions and 3 deletions

View File

@ -158,7 +158,6 @@ public class StarRocksWriterOptions implements Serializable {
private void validateRequired() {
final String[] requiredOptionKeys = new String[]{
KEY_USERNAME,
KEY_PASSWORD,
KEY_DATABASE,
KEY_TABLE,
KEY_COLUMN,

View File

@ -6,12 +6,20 @@ import com.alibaba.datax.common.element.Column.Type;
public class StarRocksBaseSerializer {
protected String fieldConvertion(Column col) {
if (null == col.getRawData()) {
if (null == col.getRawData() || Type.NULL == col.getType()) {
return null;
}
if (Type.BOOL == col.getType()) {
return String.valueOf(col.asLong());
}
if (Type.BYTES == col.getType()) {
byte[] bts = (byte[])col.getRawData();
long value = 0;
for (int i = 0; i < bts.length; i++) {
value += (bts[bts.length - i - 1] & 0xffL) << (8 * i);
}
return String.valueOf(value);
}
return col.asString();
}