chunweilei commented on a change in pull request #1099: [CALCITE-2908]
Implement SQL LAST_DAY function
URL: https://github.com/apache/calcite/pull/1099#discussion_r264487812
##########
File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
##########
@@ -1924,6 +1924,22 @@ public static int truncate(int v, int x) {
return v - remainder;
}
+ /** SQL {@code LAST_DAY} function. */
+ public static int lastDay(int date) {
+ int y0 = (int) DateTimeUtils.unixDateExtract(TimeUnitRange.YEAR, date);
+ int m0 = (int) DateTimeUtils.unixDateExtract(TimeUnitRange.MONTH, date);
+ int last = lastDay(y0, m0);
+ return DateTimeUtils.ymdToUnixDate(y0, m0, last);
+ }
+
+ public static int lastDay(long timestamp) {
Review comment:
Ok.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services