JingsongLi commented on code in PR #1274:
URL: https://github.com/apache/incubator-paimon/pull/1274#discussion_r1218804972


##########
paimon-core/src/main/java/org/apache/paimon/casting/CastExecutors.java:
##########
@@ -215,19 +246,53 @@ public class CastExecutors {
                                             (((Timestamp) 
value).getMillisecond()
                                                     % 
DateTimeUtils.MILLIS_PER_DAY);
                         }
+                    case TINYINT:
+                        return value -> (byte) unixTimestamp(((Timestamp) 
value).getMillisecond());
+                    case SMALLINT:
+                        return value -> (short) unixTimestamp(((Timestamp) 
value).getMillisecond());
+                    case INTEGER:
+                        return value -> (int) unixTimestamp(((Timestamp) 
value).getMillisecond());
+                    case BIGINT:
+                        return value -> unixTimestamp(((Timestamp) 
value).getMillisecond());
+                    case FLOAT:
+                        return value -> (float) unixTimestamp(((Timestamp) 
value).getMillisecond());
+                    case DOUBLE:
+                        return value ->
+                                (double) unixTimestamp(((Timestamp) 
value).getMillisecond());
+                    case DECIMAL:
+                        final DecimalType decimalType = (DecimalType) 
outputType;
+                        return value ->
+                                DecimalUtils.castFrom(
+                                        unixTimestamp(((Timestamp) 
value).getMillisecond()),
+                                        decimalType.getPrecision(),
+                                        decimalType.getScale());
+                    case CHAR:
+                    case VARCHAR:
+                        return value -> toCharacterString(value.toString(), 
outputType);

Review Comment:
   `Timestamp` to string is `yyyy-MM-ddTHH` ... But we need `yyyy-MM-dd HH`



##########
paimon-core/src/main/java/org/apache/paimon/casting/CastExecutors.java:
##########
@@ -215,19 +246,53 @@ public class CastExecutors {
                                             (((Timestamp) 
value).getMillisecond()
                                                     % 
DateTimeUtils.MILLIS_PER_DAY);
                         }
+                    case TINYINT:
+                        return value -> (byte) unixTimestamp(((Timestamp) 
value).getMillisecond());
+                    case SMALLINT:
+                        return value -> (short) unixTimestamp(((Timestamp) 
value).getMillisecond());
+                    case INTEGER:
+                        return value -> (int) unixTimestamp(((Timestamp) 
value).getMillisecond());
+                    case BIGINT:
+                        return value -> unixTimestamp(((Timestamp) 
value).getMillisecond());
+                    case FLOAT:
+                        return value -> (float) unixTimestamp(((Timestamp) 
value).getMillisecond());
+                    case DOUBLE:
+                        return value ->
+                                (double) unixTimestamp(((Timestamp) 
value).getMillisecond());
+                    case DECIMAL:
+                        final DecimalType decimalType = (DecimalType) 
outputType;
+                        return value ->
+                                DecimalUtils.castFrom(
+                                        unixTimestamp(((Timestamp) 
value).getMillisecond()),
+                                        decimalType.getPrecision(),
+                                        decimalType.getScale());
+                    case CHAR:
+                    case VARCHAR:
+                        return value -> toCharacterString(value.toString(), 
outputType);
                     default:
-                        {
-                            return null;
-                        }
+                        return null;
                 }
             case TIME_WITHOUT_TIME_ZONE:
-                if (outputType.getTypeRoot() == TIMESTAMP_WITHOUT_TIME_ZONE) {
-                    return value ->
-                            (int)
-                                    (((Timestamp) value).getMillisecond()
-                                            % DateTimeUtils.MILLIS_PER_DAY);
+                switch (outputType.getTypeRoot()) {
+                    case TIMESTAMP_WITHOUT_TIME_ZONE:
+                        return value ->
+                                (int)
+                                        (((Timestamp) value).getMillisecond()
+                                                % 
DateTimeUtils.MILLIS_PER_DAY);
+                    case CHAR:
+                    case VARCHAR:
+                        return value -> toCharacterString(value.toString(), 
outputType);
+                    default:
+                        return null;
+                }
+            case DATE:
+                switch (outputType.getTypeRoot()) {
+                    case CHAR:
+                    case VARCHAR:
+                        return value -> toCharacterString(value.toString(), 
outputType);

Review Comment:
   Integer.toString?



-- 
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: issues-unsubscr...@paimon.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to