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
Nested ClassesModifier and TypeClassDescriptionstatic classRule that converts EXTRACT, FLOOR and CEIL in aFilterinto a date range. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RelOptRuleRule that matches aFilterand converts calls toEXTRACT,FLOORandCEILfunctions to date ranges (typically using theBETWEENoperator). -
Method Summary
Modifier and TypeMethodDescriptionstatic RexNodereplaceTimeUnits(RexBuilder rexBuilder, RexNode e, String timeZone) Replaces calls to EXTRACT, FLOOR and CEIL in an expression.
-
Field Details
-
FILTER_INSTANCE
Rule that matches aFilterand converts calls toEXTRACT,FLOORandCEILfunctions to date ranges (typically using theBETWEENoperator).
-
-
Method Details
-
replaceTimeUnits
Replaces calls to EXTRACT, FLOOR and CEIL in an expression.
-