in catalogs/catalog-jdbc-mysql/src/main/java/org/apache/gravitino/catalog/mysql/converter/MysqlTypeConverter.java [100:155]
public String fromGravitino(Type type) {
if (type instanceof Types.ByteType) {
if (((Types.ByteType) type).signed()) {
return TINYINT;
} else {
return TINYINT_UNSIGNED;
}
} else if (type instanceof Types.ShortType) {
if (((Types.ShortType) type).signed()) {
return SMALLINT;
} else {
return SMALLINT_UNSIGNED;
}
} else if (type instanceof Types.IntegerType) {
if (((Types.IntegerType) type).signed()) {
return INT;
} else {
return INT_UNSIGNED;
}
} else if (type instanceof Types.LongType) {
if (((Types.LongType) type).signed()) {
return BIGINT;
} else {
return BIGINT_UNSIGNED;
}
} else if (type instanceof Types.FloatType) {
return type.simpleString();
} else if (type instanceof Types.DoubleType) {
return type.simpleString();
} 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) {
// MySQL converts TIMESTAMP values from the current time zone to UTC for storage, and back
// from UTC to the current time zone for retrieval. (This does not occur for other types
// such as DATETIME.) see more details: https://dev.mysql.com/doc/refman/8.0/en/datetime.html
return ((Types.TimestampType) type).hasTimeZone() ? TIMESTAMP : DATETIME;
} else if (type instanceof Types.DecimalType) {
return type.simpleString();
} else if (type instanceof Types.VarCharType) {
return type.simpleString();
} else if (type instanceof Types.FixedCharType) {
return type.simpleString();
} else if (type instanceof Types.BinaryType) {
return type.simpleString();
} else if (type instanceof Types.BooleanType) {
return BIT;
} else if (type instanceof Types.ExternalType) {
return ((Types.ExternalType) type).catalogString();
}
throw new IllegalArgumentException(
String.format("Couldn't convert Gravitino type %s to MySQL type", type.simpleString()));
}