From 986351cf54020a66d67aacec309c00fe0ed9fd20 Mon Sep 17 00:00:00 2001 From: "lucky.fei" <332901848@qq.com> Date: Fri, 10 Jan 2025 05:49:38 +0000 Subject: [PATCH] =?UTF-8?q?[fix]=20=E5=A2=9E=E5=8A=A0=E5=B8=B8=E9=87=8F?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F=E4=B8=BAtimestampWithTimeZoneType?= =?UTF-8?q?=E6=97=B6=E6=A0=BC=E5=BC=8F=E5=8C=96=E7=9A=84=E6=94=AF=E6=8C=81?= =?UTF-8?q?=20[fix]=20=E5=A2=9E=E5=8A=A0=E5=B8=B8=E9=87=8F=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E4=B8=BAtimestampWithTimeZoneType=E6=97=B6?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lucky.fei <332901848@qq.com> --- .../BaseJdbcRowExpressionConverter.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/optimization/BaseJdbcRowExpressionConverter.java b/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/optimization/BaseJdbcRowExpressionConverter.java index 7b128f942..946eff78f 100644 --- a/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/optimization/BaseJdbcRowExpressionConverter.java +++ b/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/optimization/BaseJdbcRowExpressionConverter.java @@ -30,19 +30,7 @@ import io.prestosql.spi.relation.RowExpressionService; import io.prestosql.spi.relation.SpecialForm; import io.prestosql.spi.relation.VariableReferenceExpression; import io.prestosql.spi.sql.RowExpressionConverter; -import io.prestosql.spi.type.BigintType; -import io.prestosql.spi.type.BooleanType; -import io.prestosql.spi.type.CharType; -import io.prestosql.spi.type.DecimalType; -import io.prestosql.spi.type.DoubleType; -import io.prestosql.spi.type.IntegerType; -import io.prestosql.spi.type.RealType; -import io.prestosql.spi.type.SmallintType; -import io.prestosql.spi.type.StandardTypes; -import io.prestosql.spi.type.TimestampType; -import io.prestosql.spi.type.TinyintType; -import io.prestosql.spi.type.Type; -import io.prestosql.spi.type.VarcharType; +import io.prestosql.spi.type.*; import io.prestosql.sql.ExpressionFormatter; import java.math.BigDecimal; @@ -258,6 +246,11 @@ public class BaseJdbcRowExpressionConverter Long time = (Long) literal.getValue(); return format("TIMESTAMP '%s'", formatter.format(Instant.ofEpochMilli(time).atZone(UTC).toLocalDateTime())); } + if (type instanceof TimestampWithTimeZoneType) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); + Long time = unpackMillisUtc((Long) literal.getValue()); + return format("timestamp with time zone '%s'", formatter.format(Instant.ofEpochMilli(time).atZone(UTC).toLocalDateTime())); + } throw new PrestoException(NOT_SUPPORTED, String.format("Cannot handle the constant expression %s with value of type %s", literal.getValue(), type)); } -- Gitee