huaxingao commented on code in PR #13195:
URL: https://github.com/apache/iceberg/pull/13195#discussion_r2595897129
##########
api/src/main/java/org/apache/iceberg/expressions/VariantExpressionUtil.java:
##########
@@ -111,8 +113,41 @@ static <T> T castTo(VariantValue value, Type type) {
}
break;
+ case TIMESTAMP:
+ if (value.type() == PhysicalType.TIMESTAMPTZ_NANOS
+ || value.type() == PhysicalType.TIMESTAMPNTZ_NANOS) {
+ return (T)
+ (Long) DateTimeUtil.nanosToMicros(((Number)
value.asPrimitive().get()).longValue());
+ } else if (value.type() == PhysicalType.DATE) {
+ return (T)
+ (Long)
+ DateTimeUtil.microsFromTimestamp(
+ DateTimeUtil.dateFromDays(((Number)
value.asPrimitive().get()).intValue())
+ .atStartOfDay());
+ }
+ break;
+ case TIMESTAMP_NANO:
+ if (value.type() == PhysicalType.TIMESTAMPTZ || value.type() ==
PhysicalType.TIMESTAMPNTZ) {
+ return (T)
+ (Long) DateTimeUtil.microsToNanos(((Number)
value.asPrimitive().get()).longValue());
+ } else if (value.type() == PhysicalType.DATE) {
+ return (T)
+ (Long)
+ DateTimeUtil.nanosFromTimestamp(
+ DateTimeUtil.dateFromDays(((Number)
value.asPrimitive().get()).intValue())
+ .atStartOfDay());
+ }
+ break;
+ case DATE:
+ if (value.type() == PhysicalType.TIMESTAMPTZ || value.type() ==
PhysicalType.TIMESTAMPNTZ) {
+ return (T)
+ (Integer) DateTimeUtil.microsToDays(((Number)
value.asPrimitive().get()).longValue());
+ } else if (value.type() == PhysicalType.TIMESTAMPTZ_NANOS
+ || value.type() == PhysicalType.TIMESTAMPNTZ_NANOS) {
+ return (T)
+ (Integer) DateTimeUtil.nanosToDays(((Number)
value.asPrimitive().get()).longValue());
+ }
}
-
Review Comment:
nit: unnecessary change
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]