You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2022/11/04 00:38:04 UTC

[GitHub] [calcite] julianhyde commented on a diff in pull request #2960: [CALCITE-5155] Custom time frame

julianhyde commented on code in PR #2960:
URL: https://github.com/apache/calcite/pull/2960#discussion_r1013510382


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -2553,6 +2555,70 @@ public static Locale locale(DataContext root) {
     return (Locale) DataContext.Variable.LOCALE.get(root);
   }
 
+  public static int customDateAdd(DataContext root,
+      String timeFrameName, int interval, int date) {
+    final TimeFrameSet timeFrameSet =
+        requireNonNull(DataContext.Variable.TIME_FRAME_SET.get(root));
+    final TimeFrame timeFrame = timeFrameSet.get(timeFrameName);
+    return timeFrameSet.addDate(date, interval, timeFrame);
+  }
+
+  public static long customTimestampAdd(DataContext root,
+      String timeFrameName, long interval, long timestamp) {
+    final TimeFrameSet timeFrameSet =
+        requireNonNull(DataContext.Variable.TIME_FRAME_SET.get(root));

Review Comment:
   I plan to add the following javadoc, plus improve the javadoc of `class TimeFrameSet`:
   ```
     /** SQL {@code DATEADD} function applied to a custom time frame.
      *
      * <p>Custom time frames are created as part of a {@link TimeFrameSet}.
      * This method retrieves the session's time frame set from the
      * {@link DataContext.Variable#TIME_FRAME_SET} variable, then looks up the
      * time frame by name. */
   ```



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org