From 1ed543a678196f7d6acc8f244422a2b97f77ccf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=99=93=E6=A0=B9?= Date: Thu, 28 Nov 2024 19:49:36 +0800 Subject: [PATCH] add system default zone when write timestamp type --- .../apache/paimon/prestosql/PrestoSqlPageSourceBase.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/paimon-prestosql-common/src/main/java/org/apache/paimon/prestosql/PrestoSqlPageSourceBase.java b/paimon-prestosql-common/src/main/java/org/apache/paimon/prestosql/PrestoSqlPageSourceBase.java index 9cb0322..082ec82 100644 --- a/paimon-prestosql-common/src/main/java/org/apache/paimon/prestosql/PrestoSqlPageSourceBase.java +++ b/paimon-prestosql-common/src/main/java/org/apache/paimon/prestosql/PrestoSqlPageSourceBase.java @@ -49,6 +49,7 @@ import java.io.IOException; import java.io.UncheckedIOException; import java.math.BigDecimal; +import java.time.ZoneId; import java.util.ArrayList; import java.util.List; @@ -172,7 +173,13 @@ private void appendTo(Type type, DataType logicalType, Object value, BlockBuilde BigDecimal decimal = ((Decimal) value).toBigDecimal(); type.writeLong(output, encodeShortScaledValue(decimal, decimalType.getScale())); } else if (type.equals(TIMESTAMP)) { - type.writeLong(output, ((Timestamp) value).getMillisecond()); + long localMillis = + ((Timestamp) value) + .toLocalDateTime() + .atZone(ZoneId.systemDefault()) + .toInstant() + .toEpochMilli(); + type.writeLong(output, localMillis); } else if (type.equals(TIME)) { type.writeLong(output, (int) value); } else if (type.equals(TIMESTAMP_WITH_TIME_ZONE)) {