Class DruidDateTimeUtils


public class DruidDateTimeUtils extends Object
Utilities for generating intervals from RexNode.
  • Field Details

    • LOGGER

      protected static final org.slf4j.Logger LOGGER
  • Method Details

    • createInterval

      public static @Nullable List<org.joda.time.Interval> createInterval(RexNode e)
      Generates a list of Intervals equivalent to a given expression. Assumes that all the predicates in the input reference a single column: the timestamp column.
    • toInterval

      protected static List<org.joda.time.Interval> toInterval(List<<Long>> ranges)
    • extractRanges

      protected static @Nullable List<<Long>> extractRanges(RexNode node, boolean withNot)
    • leafToRanges

      protected static @Nullable List<<Long>> leafToRanges(RexCall call, boolean withNot)
    • literalValue

      protected static @Nullable Long literalValue(RexNode node)
      Returns the literal value for the given node, assuming it is a literal with datetime type, or a cast that only alters nullability on top of a literal with datetime type.
    • extractGranularity

      public static @Nullable Granularity extractGranularity(RexNode node, String timeZone)
      Infers granularity from a time unit. It supports FLOOR(<time> TO <timeunit>) and EXTRACT(<timeunit> FROM <time>). Returns null if it cannot be inferred.
      node - the Rex node
      the granularity, or null if it cannot be inferred
    • toISOPeriodFormat

      public static @Nullable String toISOPeriodFormat(Granularity.Type type)
      Converts a granularity to ISO period format.
      type - Druid Granularity to translate as period of time
      String representing the granularity as ISO8601 Period of Time; null for unknown case
    • toDruidGranularity

      public static @Nullable Granularity.Type toDruidGranularity(org.apache.calcite.avatica.util.TimeUnitRange timeUnit)
      Translates a Calcite TimeUnitRange to a Druid Granularity.
      timeUnit - Calcite Time unit to convert
      Druid Granularity or null