in catalogs/catalog-jdbc-doris/src/main/java/org/apache/gravitino/catalog/doris/converter/DorisTypeConverter.java [75:123]
public String fromGravitino(Type type) {
if (type instanceof Types.BooleanType) {
return BOOLEAN;
} else if (type instanceof Types.ByteType) {
return TINYINT;
} else if (type instanceof Types.ShortType) {
return SMALLINT;
} else if (type instanceof Types.IntegerType) {
return INT;
} else if (type instanceof Types.LongType) {
return BIGINT;
} else if (type instanceof Types.FloatType) {
return FLOAT;
} else if (type instanceof Types.DoubleType) {
return DOUBLE;
} else if (type instanceof Types.DecimalType) {
return DECIMAL
+ "("
+ ((Types.DecimalType) type).precision()
+ ","
+ ((Types.DecimalType) type).scale()
+ ")";
} else if (type instanceof Types.DateType) {
return DATE;
} else if (type instanceof Types.TimestampType) {
return DATETIME;
} else if (type instanceof Types.VarCharType) {
int length = ((Types.VarCharType) type).length();
if (length < 1 || length > 65533) {
throw new IllegalArgumentException(
String.format(
"Type %s is invalid, length should be between 1 and 65533", type.simpleString()));
}
return VARCHAR + "(" + ((Types.VarCharType) type).length() + ")";
} else if (type instanceof Types.FixedCharType) {
int length = ((Types.FixedCharType) type).length();
if (length < 1 || length > 255) {
throw new IllegalArgumentException(
String.format(
"Type %s is invalid, length should be between 1 and 255", type.simpleString()));
}
return CHAR + "(" + ((Types.FixedCharType) type).length() + ")";
} else if (type instanceof Types.StringType) {
return STRING;
}
throw new IllegalArgumentException(
String.format("Couldn't convert Gravitino type %s to Doris type", type.simpleString()));
}