Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: apache/iceberg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b1e18f1cdb798f545ce99057242105fd697c4072
Choose a base ref
..
head repository: apache/iceberg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d8688f22c67194aaf53834e066ccb16fea568546
Choose a head ref
Showing with 7 additions and 13 deletions.
  1. +7 −13 api/src/main/java/org/apache/iceberg/expressions/Literals.java
20 changes: 7 additions & 13 deletions api/src/main/java/org/apache/iceberg/expressions/Literals.java
Original file line number Diff line number Diff line change
@@ -540,22 +540,16 @@ public <T> Literal<T> to(Type type) {

case TIMESTAMP:
TimestampType tsType = (TimestampType) type;
final java.time.temporal.Temporal valueAsTemporal;
if (tsType.shouldAdjustToUTC()) {
long timestampUnits =
tsType
.unit()
.between(EPOCH, OffsetDateTime.parse(value(), DateTimeFormatter.ISO_DATE_TIME));
return (Literal<T>) new TimestampLiteral(tsType.unit(), timestampUnits);
valueAsTemporal = OffsetDateTime.parse(value(), DateTimeFormatter.ISO_DATE_TIME);
} else {
long timestampUnits =
tsType
.unit()
.between(
EPOCH,
LocalDateTime.parse(value(), DateTimeFormatter.ISO_LOCAL_DATE_TIME)
.atOffset(ZoneOffset.UTC));
return (Literal<T>) new TimestampLiteral(tsType.unit(), timestampUnits);
valueAsTemporal =
LocalDateTime.parse(value(), DateTimeFormatter.ISO_LOCAL_DATE_TIME)
.atOffset(ZoneOffset.UTC);
}
final long timestampUnits = tsType.unit().between(EPOCH, valueAsTemporal);
return (Literal<T>) new TimestampLiteral(tsType.unit(), timestampUnits);

case STRING:
return (Literal<T>) this;