From 6515cc03a00fe671abc96f492baab5976c31cbe2 Mon Sep 17 00:00:00 2001 From: xuyu <11161569@vivo.com> Date: Mon, 12 Aug 2024 09:39:14 +0800 Subject: [PATCH] fix with bigint --- .../TimestampToNumericPrimitiveCastRule.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/paimon-core/src/main/java/org/apache/paimon/casting/TimestampToNumericPrimitiveCastRule.java b/paimon-core/src/main/java/org/apache/paimon/casting/TimestampToNumericPrimitiveCastRule.java index 9654e94dbb5d..c772366115cf 100644 --- a/paimon-core/src/main/java/org/apache/paimon/casting/TimestampToNumericPrimitiveCastRule.java +++ b/paimon-core/src/main/java/org/apache/paimon/casting/TimestampToNumericPrimitiveCastRule.java @@ -44,12 +44,15 @@ private TimestampToNumericPrimitiveCastRule() { @Override public CastExecutor create(DataType inputType, DataType targetType) { - if (inputType.is(DataTypeRoot.TIMESTAMP_WITHOUT_TIME_ZONE)) { - return value -> DateTimeUtils.unixTimestamp(value.getMillisecond()); - } else if (inputType.is(DataTypeRoot.TIMESTAMP_WITH_LOCAL_TIME_ZONE)) { - return value -> - DateTimeUtils.unixTimestamp( - Timestamp.fromLocalDateTime(value.toLocalDateTime()).getMillisecond()); + if (targetType.is(DataTypeRoot.BIGINT)) { + if (inputType.is(DataTypeRoot.TIMESTAMP_WITHOUT_TIME_ZONE)) { + return value -> DateTimeUtils.unixTimestamp(value.getMillisecond()); + } else if (inputType.is(DataTypeRoot.TIMESTAMP_WITH_LOCAL_TIME_ZONE)) { + return value -> + DateTimeUtils.unixTimestamp( + Timestamp.fromLocalDateTime(value.toLocalDateTime()) + .getMillisecond()); + } } return null; }