Skip to content

Commit

Permalink
Make ZonedDateTimeRangeFilter compare ZoneDateTimes
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauernfeind committed Jun 24, 2024
1 parent 4441809 commit 3d211fc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ public void init(
} else if (colClass == LocalDateTime.class) {
filter = makeComparableRangeFilter(columnName, condition, (LocalDateTime) realValue.getValue());
} else if (colClass == ZonedDateTime.class) {
filter = makeZonedDateTimeRangeFilter(columnName, condition,
DateTimeUtils.epochNanos((ZonedDateTime) realValue.getValue()));
filter = makeComparableRangeFilter(columnName, condition, (ZonedDateTime) realValue.getValue());
} else if (BigDecimal.class.isAssignableFrom(colClass)) {
filter = makeComparableRangeFilter(columnName, condition, (BigDecimal) realValue.getValue());
} else if (BigInteger.class.isAssignableFrom(colClass)) {
Expand Down Expand Up @@ -279,21 +278,6 @@ private static LongRangeFilter makeInstantRangeFilter(String columnName, Conditi
}
}

private static LongRangeFilter makeZonedDateTimeRangeFilter(String columnName, Condition condition, long value) {
switch (condition) {
case LESS_THAN:
return new ZonedDateTimeRangeFilter(columnName, value, Long.MIN_VALUE, true, false);
case LESS_THAN_OR_EQUAL:
return new ZonedDateTimeRangeFilter(columnName, value, Long.MIN_VALUE, true, true);
case GREATER_THAN:
return new ZonedDateTimeRangeFilter(columnName, value, Long.MAX_VALUE, false, true);
case GREATER_THAN_OR_EQUAL:
return new ZonedDateTimeRangeFilter(columnName, value, Long.MAX_VALUE, true, true);
default:
throw new IllegalArgumentException("RangeFilter does not support condition " + condition);
}
}

private static SingleSidedComparableRangeFilter makeComparableRangeFilter(String columnName, Condition condition,
Comparable<?> comparable) {
switch (condition) {
Expand Down

This file was deleted.

0 comments on commit 3d211fc

Please sign in to comment.