predator4ann commented on code in PR #6657:
URL: https://github.com/apache/gravitino/pull/6657#discussion_r1988362111


##########
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:
   I think it's always same, and default value is `private static final 
TimeType INSTANCE = new TimeType(0);`



-- 
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: commits-unsubscr...@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to