in flink-doris-connector/src/main/java/org/apache/doris/flink/tools/cdc/db2/Db2Type.java [45:93]
public static String toDorisType(String db2Type, Integer precision, Integer scale) {
db2Type = db2Type.toUpperCase();
switch (db2Type) {
case BOOLEAN:
return DorisType.BOOLEAN;
case SMALLINT:
return DorisType.SMALLINT;
case INTEGER:
case INT:
return DorisType.INT;
case BIGINT:
return DorisType.BIGINT;
case REAL:
return DorisType.FLOAT;
case DOUBLE:
return DorisType.DOUBLE;
case DATE:
return DorisType.DATE_V2;
case DECFLOAT:
case DECIMAL:
case NUMERIC:
if (precision != null && precision > 0 && precision <= 38) {
if (scale != null && scale >= 0) {
return String.format("%s(%s,%s)", DorisType.DECIMAL_V3, precision, scale);
}
return String.format("%s(%s,%s)", DorisType.DECIMAL_V3, precision, 0);
} else {
return DorisType.STRING;
}
case CHARACTER:
case CHAR:
case VARCHAR:
case LONG_VARCHAR:
Preconditions.checkNotNull(precision);
return precision * 3 > 65533
? DorisType.STRING
: String.format("%s(%s)", DorisType.VARCHAR, precision * 3);
case TIMESTAMP:
return String.format(
"%s(%s)", DorisType.DATETIME_V2, Math.min(scale == null ? 0 : scale, 6));
case TIME:
case VARGRAPHIC:
// Currently, the Flink CDC connector does not support the XML data type from DB2.
// Case XML:
return DorisType.STRING;
default:
throw new UnsupportedOperationException("Unsupported DB2 Type: " + db2Type);
}
}