Package org.apache.calcite.adapter.druid
Class DruidDateTimeUtils
java.lang.Object
org.apache.calcite.adapter.druid.DruidDateTimeUtils
Utilities for generating intervals from RexNode.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable List<org.joda.time.Interval>
Generates a list ofInterval
s equivalent to a given expression.static @Nullable Granularity
extractGranularity
(RexNode node, String timeZone) Infers granularity from a time unit.extractRanges
(RexNode node, boolean withNot) leafToRanges
(RexCall call, boolean withNot) 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.static @Nullable Granularity.Type
toDruidGranularity
(org.apache.calcite.avatica.util.TimeUnitRange timeUnit) Translates a CalciteTimeUnitRange
to a DruidGranularity
.protected static List<org.joda.time.Interval>
toInterval
(List<com.google.common.collect.Range<Long>> ranges) static @Nullable String
Converts a granularity to ISO period format.
-
Field Details
-
LOGGER
protected static final org.slf4j.Logger LOGGER
-
-
Method Details
-
createInterval
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
-
extractRanges
-
leafToRanges
-
literalValue
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
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
Converts a granularity to ISO period format.- 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
public static @Nullable Granularity.Type toDruidGranularity(org.apache.calcite.avatica.util.TimeUnitRange timeUnit) Translates a CalciteTimeUnitRange
to a DruidGranularity
.- Parameters:
timeUnit
- Calcite Time unit to convert- Returns:
- Druid Granularity or null
-