Package org.apache.calcite.adapter.druid
Class DruidDateTimeUtils
- java.lang.Object
-
- org.apache.calcite.adapter.druid.DruidDateTimeUtils
-
public class DruidDateTimeUtils extends java.lang.Object
Utilities for generating intervals from RexNode.
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Logger
LOGGER
-
Constructor Summary
Constructors Modifier Constructor Description private
DruidDateTimeUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<org.joda.time.Interval>
createInterval(RexNode e)
Generates a list ofInterval
s equivalent to a given expression.static Granularity
extractGranularity(RexNode node, java.lang.String timeZone)
Infers granularity from a time unit.protected static java.util.List<com.google.common.collect.Range<java.lang.Long>>
extractRanges(RexNode node, boolean withNot)
protected static java.util.List<com.google.common.collect.Range<java.lang.Long>>
leafToRanges(RexCall call, boolean withNot)
protected static java.lang.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.static Granularity.Type
toDruidGranularity(org.apache.calcite.avatica.util.TimeUnitRange timeUnit)
Translates Calcite TimeUnitRange to DruidGranularity
protected static java.util.List<org.joda.time.Interval>
toInterval(java.util.List<com.google.common.collect.Range<java.lang.Long>> ranges)
static java.lang.String
toISOPeriodFormat(Granularity.Type type)
-
-
-
Method Detail
-
createInterval
@Nullable public static java.util.List<org.joda.time.Interval> createInterval(RexNode e)
Generates a list ofInterval
s equivalent to a given expression. Assumes that all the predicates in the input reference a single column: the timestamp column.
-
toInterval
protected static java.util.List<org.joda.time.Interval> toInterval(java.util.List<com.google.common.collect.Range<java.lang.Long>> ranges)
-
extractRanges
@Nullable protected static java.util.List<com.google.common.collect.Range<java.lang.Long>> extractRanges(RexNode node, boolean withNot)
-
leafToRanges
@Nullable protected static java.util.List<com.google.common.collect.Range<java.lang.Long>> leafToRanges(RexCall call, boolean withNot)
-
literalValue
@Nullable protected static java.lang.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
@Nullable public static Granularity extractGranularity(RexNode node, java.lang.String timeZone)
Infers granularity from a time unit. It supportsFLOOR(<time> TO <timeunit>)
andEXTRACT(<timeunit> FROM <time>)
. Returns null if it cannot be inferred.- Parameters:
node
- the Rex node- Returns:
- the granularity, or null if it cannot be inferred
-
toISOPeriodFormat
@Nullable public static java.lang.String toISOPeriodFormat(Granularity.Type type)
- Parameters:
type
- Druid Granularity to translate as period of time- Returns:
- String representing the granularity as ISO8601 Period of Time, null for unknown case.
-
toDruidGranularity
@Nullable public static Granularity.Type toDruidGranularity(org.apache.calcite.avatica.util.TimeUnitRange timeUnit)
Translates Calcite TimeUnitRange to DruidGranularity
- Parameters:
timeUnit
- Calcite Time unit to convert- Returns:
- Druid Granularity or null
-
-