mchades commented on code in PR #6657: URL: https://github.com/apache/gravitino/pull/6657#discussion_r1997862300
########## 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: > When the user doesn't specify the precision, different systems(Iceberg, Hive, MySQL, etc.) have their own default value, you use `0` as the default precision here, does it match the user's intuition? How did you solve this problem? -- 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