Skip to content

Commit

Permalink
fix with bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyu committed Aug 12, 2024
1 parent 80e601a commit 6515cc0
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ private TimestampToNumericPrimitiveCastRule() {

@Override
public CastExecutor<Timestamp, Number> 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;
}
Expand Down

0 comments on commit 6515cc0

Please sign in to comment.