Class DateTimeUtils

java.lang.Object
org.apache.beam.sdk.extensions.sql.zetasql.DateTimeUtils

public class DateTimeUtils extends Object
DateTimeUtils.
  • Field Details

    • MILLIS_PER_DAY

      public static final Long MILLIS_PER_DAY
    • MIN_UNIX_MILLIS

      public static final Long MIN_UNIX_MILLIS
    • MAX_UNIX_MILLIS

      public static final Long MAX_UNIX_MILLIS
  • Constructor Details

    • DateTimeUtils

      public DateTimeUtils()
  • Method Details

    • findDateTimePattern

      public static DateTimeFormatter findDateTimePattern(String str)
    • findDateTimePattern

      public static DateTimeFormatter findDateTimePattern(String str, org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableMap<org.apache.beam.sdk.extensions.sql.zetasql.DateTimeUtils.TimestampPatterns,DateTimeFormatter> patternMap)
    • parseTimestampWithUTCTimeZone

      public static DateTime parseTimestampWithUTCTimeZone(String str)
    • parseTimestampWithLocalTimeZone

      public static DateTime parseTimestampWithLocalTimeZone(String str)
    • parseTimestampWithTimeZone

      public static DateTime parseTimestampWithTimeZone(String str)
    • formatTimestampWithTimeZone

      public static String formatTimestampWithTimeZone(DateTime dt)
    • parseTimestampWithoutTimeZone

      public static DateTime parseTimestampWithoutTimeZone(String str)
    • parseDate

      public static DateTime parseDate(String str)
    • parseTime

      public static DateTime parseTime(String str)
    • parseDateToValue

      public static com.google.zetasql.Value parseDateToValue(String dateString)
    • parseTimeToValue

      public static com.google.zetasql.Value parseTimeToValue(String timeString)
    • parseTimestampWithTZToValue

      public static com.google.zetasql.Value parseTimestampWithTZToValue(String timestampString)
    • validateTimestamp

      public static @Nullable Long validateTimestamp(@Nullable Long ts)
      This function validates that Long representation of timestamp is compatible with ZetaSQL timestamp values range.

      Invoked via reflection. @see SqlOperators

      Parameters:
      ts - Timestamp to validate.
      Returns:
      Unchanged timestamp sent for validation.
    • validateTimeInterval

      public static @Nullable Long validateTimeInterval(@Nullable Long arg, org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.avatica.util.TimeUnit unit)
      This function validates that interval is compatible with ZetaSQL timestamp values range.

      ZetaSQL validates that if we represent interval in milliseconds, it will fit into Long.

      In case of SECOND or smaller time unit, it converts timestamp to microseconds, so we need to convert those to microsecond and verify that we do not cause overflow.

      Invoked via reflection. @see SqlOperators

      Parameters:
      arg - Argument for the interval.
      unit - Time unit used in this interval.
      Returns:
      Argument for the interval.