You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@paimon.apache.org by lz...@apache.org on 2023/07/20 08:51:22 UTC

[incubator-paimon-trino] branch main updated: [types] Support more types (#22)

This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-paimon-trino.git


The following commit(s) were added to refs/heads/main by this push:
     new 604a068  [types] Support more types (#22)
604a068 is described below

commit 604a0683c781d76118df5e74d2886f0cd4d95af3
Author: Jingsong Lee <ji...@gmail.com>
AuthorDate: Thu Jul 20 16:51:18 2023 +0800

    [types] Support more types (#22)
---
 .../java/org/apache/paimon/trino/TrinoPageSourceBase.java | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoPageSourceBase.java b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoPageSourceBase.java
index 02f77e5..1343d94 100644
--- a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoPageSourceBase.java
+++ b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoPageSourceBase.java
@@ -62,11 +62,14 @@ 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;
 import static io.trino.spi.type.TimeZoneKey.UTC_KEY;
 import static io.trino.spi.type.TimestampType.TIMESTAMP_MILLIS;
 import static io.trino.spi.type.TimestampWithTimeZoneType.TIMESTAMP_TZ_MILLIS;
 import static io.trino.spi.type.Timestamps.MICROSECONDS_PER_MILLISECOND;
+import static io.trino.spi.type.TinyintType.TINYINT;
 import static java.lang.String.format;
 
 /** Trino {@link ConnectorPageSource}. */
@@ -160,16 +163,18 @@ public abstract class TrinoPageSourceBase implements ConnectorPageSource {
         if (javaType == boolean.class) {
             type.writeBoolean(output, (Boolean) value);
         } else if (javaType == long.class) {
-            if (type.equals(BIGINT)) {
+            if (type.equals(BIGINT)
+                    || type.equals(INTEGER)
+                    || type.equals(TINYINT)
+                    || type.equals(SMALLINT)
+                    || type.equals(DATE)) {
                 type.writeLong(output, ((Number) value).longValue());
-            } else if (type.equals(INTEGER)) {
-                type.writeLong(output, ((Number) value).intValue());
+            } else if (type.equals(REAL)) {
+                type.writeLong(output, Float.floatToIntBits((Float) value));
             } else if (type instanceof DecimalType) {
                 DecimalType decimalType = (DecimalType) type;
                 BigDecimal decimal = ((Decimal) value).toBigDecimal();
                 type.writeLong(output, encodeShortScaledValue(decimal, decimalType.getScale()));
-            } else if (type.equals(DATE)) {
-                type.writeLong(output, (int) value);
             } else if (type.equals(TIMESTAMP_MILLIS)) {
                 type.writeLong(
                         output,