strongduanmu commented on code in PR #4029:
URL: https://github.com/apache/calcite/pull/4029#discussion_r1828584063
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -5364,6 +5364,24 @@ public static int localTime(DataContext root) {
return timestampToTime(localTimestamp(root));
}
+ /** SQL {@code SYSTIMESTAMP} function. */
+ @NonDeterministic
+ public static long sysTimestamp(DataContext root) {
+ return DataContext.Variable.SYS_TIMESTAMP.get(root);
+ }
+
+ /** SQL {@code SYSDATE} function. */
+ @NonDeterministic
+ public static int sysDate(DataContext root) {
+ final long timestamp = sysTimestamp(root);
+ int date = timestampToDate(timestamp);
+ final int time = timestampToTime(timestamp);
Review Comment:
Yes, when the date is before `1970-1-1`, for example: `1969-12-31 23:59:59`,
timestamp will return `-1000`, and the date(days since epoch) calculated by
`timestampToDate(-1000)` is 0, so we need to additionally judge the result of
`timestampToTime(-1000)`. If its value is less than 0, we need to reduce date
by 1 to ensure the accuracy of date.
--
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]