Package org.apache.calcite.rel.rules
Class DateRangeRules
java.lang.Object
org.apache.calcite.rel.rules.DateRangeRules
Collection of planner rules that convert
EXTRACT(timeUnit FROM dateTime) = constant
,
FLOOR(dateTime to timeUnit
= constant} and
CEIL(dateTime to timeUnit
= constant} to
dateTime BETWEEN lower AND upper
.
The rules allow conversion of queries on time dimension tables, such as
SELECT ... FROM sales JOIN time_by_day USING (time_id) WHERE time_by_day.the_year = 1997 AND time_by_day.the_month IN (4, 5, 6)
into
SELECT ... FROM sales JOIN time_by_day USING (time_id) WHERE the_date BETWEEN DATE '2016-04-01' AND DATE '2016-06-30'
and is especially useful for Druid, which has a single timestamp column.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Rule that converts EXTRACT, FLOOR and CEIL in aFilter
into a date range. -
Field Summary
Modifier and TypeFieldDescriptionstatic final RelOptRule
Rule that matches aFilter
and converts calls toEXTRACT
,FLOOR
andCEIL
functions to date ranges (typically using theBETWEEN
operator). -
Method Summary
Modifier and TypeMethodDescriptionstatic RexNode
replaceTimeUnits
(RexBuilder rexBuilder, RexNode e, String timeZone) Replaces calls to EXTRACT, FLOOR and CEIL in an expression.
-
Field Details
-
FILTER_INSTANCE
Rule that matches aFilter
and converts calls toEXTRACT
,FLOOR
andCEIL
functions to date ranges (typically using theBETWEEN
operator).
-
-
Method Details
-
replaceTimeUnits
Replaces calls to EXTRACT, FLOOR and CEIL in an expression.
-