You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@paimon.apache.org by ju...@apache.org on 2025/12/23 11:12:44 UTC
(paimon-trino) branch main updated: [hotfix] Fix trino read TIMESTAMP_TZ_MICROS issue (#116)
This is an automated email from the ASF dual-hosted git repository.
junhao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/paimon-trino.git
The following commit(s) were added to refs/heads/main by this push:
new dc35a05 [hotfix] Fix trino read TIMESTAMP_TZ_MICROS issue (#116)
dc35a05 is described below
commit dc35a051684c22e006ef48276134d091d1069451
Author: yuxia Luo <lu...@alumni.sjtu.edu.cn>
AuthorDate: Tue Dec 23 19:12:39 2025 +0800
[hotfix] Fix trino read TIMESTAMP_TZ_MICROS issue (#116)
---
.../org/apache/paimon/trino/TrinoPageSource.java | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/paimon/trino/TrinoPageSource.java b/src/main/java/org/apache/paimon/trino/TrinoPageSource.java
index 736728e..58847c1 100644
--- a/src/main/java/org/apache/paimon/trino/TrinoPageSource.java
+++ b/src/main/java/org/apache/paimon/trino/TrinoPageSource.java
@@ -69,7 +69,6 @@ import static io.trino.spi.type.DateTimeEncoding.packDateTimeWithZone;
import static io.trino.spi.type.DateType.DATE;
import static io.trino.spi.type.Decimals.encodeShortScaledValue;
import static io.trino.spi.type.IntegerType.INTEGER;
-import static io.trino.spi.type.LongTimestampWithTimeZone.fromEpochMillisAndFraction;
import static io.trino.spi.type.RealType.REAL;
import static io.trino.spi.type.SmallintType.SMALLINT;
import static io.trino.spi.type.TimeType.TIME_MICROS;
@@ -77,11 +76,12 @@ import static io.trino.spi.type.TimeZoneKey.UTC_KEY;
import static io.trino.spi.type.TimestampType.TIMESTAMP_MICROS;
import static io.trino.spi.type.TimestampType.TIMESTAMP_MILLIS;
import static io.trino.spi.type.TimestampType.TIMESTAMP_SECONDS;
+import static io.trino.spi.type.TimestampWithTimeZoneType.TIMESTAMP_TZ_MICROS;
import static io.trino.spi.type.TimestampWithTimeZoneType.TIMESTAMP_TZ_MILLIS;
+import static io.trino.spi.type.TimestampWithTimeZoneType.TIMESTAMP_TZ_SECONDS;
import static io.trino.spi.type.Timestamps.MICROSECONDS_PER_MILLISECOND;
import static io.trino.spi.type.TinyintType.TINYINT;
import static java.lang.String.format;
-import static org.apache.paimon.utils.Preconditions.checkArgument;
/** Trino {@link ConnectorPageSource}. */
public class TrinoPageSource implements ConnectorPageSource {
@@ -242,10 +242,18 @@ public class TrinoPageSource implements ConnectorPageSource {
} else if (javaType == Slice.class) {
writeSlice(output, type, value);
} else if (javaType == LongTimestampWithTimeZone.class) {
- checkArgument(type.equals(TIMESTAMP_TZ_MILLIS));
- Timestamp timestamp = (org.apache.paimon.data.Timestamp) value;
- type.writeObject(
- output, fromEpochMillisAndFraction(timestamp.getMillisecond(), 0, UTC_KEY));
+ if (type.equals(TIMESTAMP_TZ_MILLIS) || type.equals(TIMESTAMP_TZ_SECONDS)) {
+ type.writeLong(
+ output,
+ packDateTimeWithZone(((Timestamp) value).getMillisecond(), UTC_KEY));
+ } else if (type.equals(TIMESTAMP_TZ_MICROS)) {
+ type.writeLong(
+ output, packDateTimeWithZone(((Timestamp) value).toMicros(), UTC_KEY));
+ } else {
+ throw new TrinoException(
+ GENERIC_INTERNAL_ERROR,
+ format("Unhandled type for %s: %s", javaType.getSimpleName(), type));
+ }
} else if (type instanceof ArrayType
|| type instanceof MapType
|| type instanceof RowType) {