in server/pxf-service/src/main/java/org/greenplum/pxf/service/BridgeOutputBuilder.java [390:469]
void fillOneGPDBWritableField(OneField oneField, int colIdx)
throws BadRecordException {
int type = oneField.type;
Object val = oneField.val;
GPDBWritable gpdbOutput = (GPDBWritable) output;
try {
switch (DataType.get(type)) {
case INTEGER:
gpdbOutput.setInt(colIdx, (Integer) val);
break;
case FLOAT8:
gpdbOutput.setDouble(colIdx, (Double) val);
break;
case REAL:
gpdbOutput.setFloat(colIdx, (Float) val);
break;
case BIGINT:
gpdbOutput.setLong(colIdx, (Long) val);
break;
case SMALLINT:
gpdbOutput.setShort(colIdx, (Short) val);
break;
case BOOLEAN:
gpdbOutput.setBoolean(colIdx, (Boolean) val);
break;
case BYTEA:
byte[] bts = null;
if (val != null) {
int length = Array.getLength(val);
bts = new byte[length];
for (int j = 0; j < length; j++) {
bts[j] = Array.getByte(val, j);
}
}
gpdbOutput.setBytes(colIdx, bts);
break;
case VARCHAR:
case BPCHAR:
case TEXT:
case UUID:
case NUMERIC:
case TIMESTAMP:
case TIMESTAMP_WITH_TIME_ZONE:
case TIME:
case DATE:
case BOOLARRAY:
case BYTEAARRAY:
case INT2ARRAY:
case INT4ARRAY:
case INT8ARRAY:
case FLOAT4ARRAY:
case FLOAT8ARRAY:
case TEXTARRAY:
case BPCHARARRAY:
case VARCHARARRAY:
case DATEARRAY:
case UUIDARRAY:
case NUMERICARRAY:
case TIMEARRAY:
case TIMESTAMPARRAY:
case TIMESTAMP_WITH_TIMEZONE_ARRAY:
/*
* If resolvers support sending arrays to GPDB, they are expected to serialize arrays into Postgres
* array external text representation.
* see https://www.postgresql.org/docs/9.4/arrays.html for details of this format.
*/
gpdbOutput.setString(colIdx,
ObjectUtils.toString(val, null));
break;
default:
LOG.debug("Data type OID is {}", type);
String valClassName = (val != null) ? val.getClass().getSimpleName()
: null;
throw new UnsupportedOperationException(valClassName
+ " is not supported for GPDB conversion");
}
} catch (GPDBWritable.TypeMismatchException e) {
throw new BadRecordException(e);
}
}