diqiu50 commented on code in PR #6657:
URL: https://github.com/apache/gravitino/pull/6657#discussion_r2005563110
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/jdbc/mysql/MySQLDataTypeTransformer.java:
##########
@@ -45,18 +45,36 @@ public io.trino.spi.type.Type getTrinoType(Type type) {
return io.trino.spi.type.VarcharType.createUnboundedVarcharType();
} else if (Name.TIMESTAMP == type.name()) {
Types.TimestampType timestampType = (Types.TimestampType) type;
- if (timestampType.hasTimeZone()) {
- return TimestampWithTimeZoneType.TIMESTAMP_TZ_SECONDS;
- } else {
- return TimestampType.TIMESTAMP_SECONDS;
- }
+ return timestampType.hasTimeZone()
+ ? getTimestampWithTimeZoneType(timestampType.precision())
+ : getTimestampType(timestampType.precision());
} else if (Name.TIME == type.name()) {
- return TimeType.TIME_SECONDS;
+ return getTimeType(((Types.TimeType) type).precision());
}
-
return super.getTrinoType(type);
}
+ private static TimestampWithTimeZoneType getTimestampWithTimeZoneType(int
precision) {
+ if (precision == 0) return TimestampWithTimeZoneType.TIMESTAMP_TZ_SECONDS;
+ if (precision <= 3) return TimestampWithTimeZoneType.TIMESTAMP_TZ_MILLIS;
+ if (precision <= 6) return TimestampWithTimeZoneType.TIMESTAMP_TZ_MICROS;
+ return TimestampWithTimeZoneType.TIMESTAMP_TZ_NANOS;
+ }
+
+ private static TimestampType getTimestampType(int precision) {
Review Comment:
@predator4ann When implementing these functions, Time and Timestamp did not
yet support precision, and the default precision was used. After adding
precision handling for Time and Timestamp types, they need to be converted to
the corresponding time precision.
```
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]