tanclary commented on code in PR #3631:
URL: https://github.com/apache/calcite/pull/3631#discussion_r1457824410


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -4461,6 +4461,51 @@ public static int time(long timestampMillis, String 
timeZone) {
         / (1000L * 1000L)); // milli > micro > nano
   }
 
+  /** SQL {@code TO_TIMESTAMP_LTZ(date)} function
+  * for a date values. */
+  public static long toTimestampLtzDate(int days) {
+    return timestamp(days);
+  }
+
+  /** SQL {@code TO_TIMESTAMP_LTZ(timestampSeconds)}
+  * function for long values. */
+  public static long toTimestampLtz(long timestampSeconds) {
+    return toTimestampLtz(timestampSeconds, 0);
+  }
+
+  /** SQL {@code TO_TIMESTAMP_LTZ(timestampSeconds)} function
+  * for BigDecimal values. */
+  public static long toTimestampLtz(BigDecimal timestampSeconds) {
+    return toTimestampLtz(timestampSeconds.longValue(), 0);
+  }
+
+  /** SQL {@code TO_TIMESTAMP_LTZ(timestampSeconds, scale)}
+  * function for BigDecimal values with a specified scale. */
+  public static long toTimestampLtz(BigDecimal timestampSeconds, int scale) {
+    return toTimestampLtz(timestampSeconds.longValue(), scale);
+  }
+
+  /** SQL {@code TO_TIMESTAMP_LTZ(timestampSeconds, scale)}
+  * function for long values with a specified scale. */
+  public static long toTimestampLtz(long timestampSeconds, int scale) {
+    // 0 means seconds but we receive milliseconds so must adjust
+    final int trueScale = 3 - scale;
+    final double multiplier = Math.pow(10, trueScale);
+    return (long) (timestampSeconds * multiplier);
+  }
+
+  /** SQL {@code TO_TIMESTAMP_LTZ(timestampSeconds, scale)}
+  * function for a String expression of a timestamp. */
+  public static long toTimestampLtz(String timestamp) {
+    return timestamp(timestamp);
+  }
+
+  /** SQL {@code TO_TIMESTAMP_LTZ(timestamp)} function

Review Comment:
   I was under the impression a Calcite `TIMESTAMP` did not have a LTZ but 
`TIMESTAMP WITH LOCAL TIME ZONE` did. So if you provide the function a Calcite 
`TIMESTAMP` it would return a `TIMESTAMP WITH LOCAL TIME ZONE` (not a no-op).



-- 
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-unsubscr...@calcite.apache.org

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

Reply via email to