hanyuzheng7 commented on PR #25759: URL: https://github.com/apache/flink/pull/25759#issuecomment-2539107679
@snuyanzin The reason we not support `millisecond`/`nanosecond` is that floor and ceil not support these two perfectly. You can see here ``` /** * Keep the algorithm consistent with Calcite DateTimeUtils.julianDateFloor, but here we take * time zone into account. */ public static long timestampCeil(TimeUnitRange range, long ts, TimeZone tz) { // assume that we are at UTC timezone, just for algorithm performance long offset = tz.getOffset(ts); long utcTs = ts + offset; switch (range) { case NANOSECOND: return ceil(utcTs, 1L) - offset; case MILLISECOND: return ceil(utcTs, MILLIS_PER_MINUTE) - offset; case SECOND: return ceil(utcTs, MILLIS_PER_SECOND) - offset; case MINUTE: return ceil(utcTs, MILLIS_PER_MINUTE) - offset; case HOUR: return ceil(utcTs, MILLIS_PER_HOUR) - offset; case DAY: return ceil(utcTs, MILLIS_PER_DAY) - offset; case MILLENNIUM: case CENTURY: case DECADE: case MONTH: case YEAR: case QUARTER: case WEEK: int days = (int) (utcTs / MILLIS_PER_DAY + EPOCH_JULIAN); return julianDateFloor(range, days, false) * MILLIS_PER_DAY - offset; default: // for MINUTE and SECONDS etc..., // it is more effective to use arithmetic Method throw new AssertionError(range); } } ``` for DAY and HOUR now base on ``` /** The number of milliseconds in a second. */ private static final long MILLIS_PER_SECOND = 1000L; /** The number of milliseconds in a minute. */ private static final long MILLIS_PER_MINUTE = 60000L; /** The number of milliseconds in an hour. */ private static final long MILLIS_PER_HOUR = 3600000L; // = 60 * 60 * 1000 /** * The number of milliseconds in a day. * * <p>This is the modulo 'mask' used when converting TIMESTAMP values to DATE and TIME values. */ public static final long MILLIS_PER_DAY = 86400000L; // = 24 * 60 * 60 * 1000 ``` We can use 1L to stand for MILLIS_PER_MILLISECOND, but how can we stand for NANOSECOND, is smaller than MILLISECOND? -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org