in catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/converter/PostgreSqlTypeConverter.java [87:131]
public String fromGravitino(Type type) {
if (type instanceof Types.BooleanType) {
return BOOL;
} else if (type instanceof Types.ShortType) {
return INT_2;
} else if (type instanceof Types.IntegerType) {
return INT_4;
} else if (type instanceof Types.LongType) {
return INT_8;
} else if (type instanceof Types.FloatType) {
return FLOAT_4;
} else if (type instanceof Types.DoubleType) {
return FLOAT_8;
} else if (type instanceof Types.StringType) {
return TEXT;
} else if (type instanceof Types.DateType) {
return type.simpleString();
} else if (type instanceof Types.TimeType) {
return type.simpleString();
} else if (type instanceof Types.TimestampType && !((Types.TimestampType) type).hasTimeZone()) {
return TIMESTAMP;
} else if (type instanceof Types.TimestampType && ((Types.TimestampType) type).hasTimeZone()) {
return TIMESTAMP_TZ;
} else if (type instanceof Types.DecimalType) {
return NUMERIC
+ "("
+ ((Types.DecimalType) type).precision()
+ ","
+ ((Types.DecimalType) type).scale()
+ ")";
} else if (type instanceof Types.VarCharType) {
return VARCHAR + "(" + ((Types.VarCharType) type).length() + ")";
} else if (type instanceof Types.FixedCharType) {
return BPCHAR + "(" + ((Types.FixedCharType) type).length() + ")";
} else if (type instanceof Types.BinaryType) {
return BYTEA;
} else if (type instanceof Types.ListType) {
return fromGravitinoArrayType((ListType) type);
} else if (type instanceof Types.ExternalType) {
return ((Types.ExternalType) type).catalogString();
}
throw new IllegalArgumentException(
String.format(
"Couldn't convert Gravitino type %s to PostgreSQL type", type.simpleString()));
}