static class DateRangeRules.ExtractShuttle extends RexShuttle
EXTRACT
, FLOOR
and CEIL
with date ranges.Modifier and Type | Field and Description |
---|---|
private java.util.Deque<RexCall> |
calls |
private java.util.Map<RexNode,com.google.common.collect.RangeSet<java.util.Calendar>> |
operandRanges |
private RexBuilder |
rexBuilder |
private org.apache.calcite.avatica.util.TimeUnitRange |
timeUnit |
private com.google.common.collect.ImmutableSortedSet<org.apache.calcite.avatica.util.TimeUnitRange> |
timeUnitRanges |
private java.lang.String |
timeZone |
Constructor and Description |
---|
ExtractShuttle(RexBuilder rexBuilder,
org.apache.calcite.avatica.util.TimeUnitRange timeUnit,
java.util.Map<RexNode,com.google.common.collect.RangeSet<java.util.Calendar>> operandRanges,
com.google.common.collect.ImmutableSortedSet<org.apache.calcite.avatica.util.TimeUnitRange> timeUnitRanges,
java.lang.String timeZone) |
Modifier and Type | Method and Description |
---|---|
private boolean |
canRewriteExtract(RexNode operand) |
private java.util.Calendar |
ceil(java.util.Calendar c,
org.apache.calcite.avatica.util.TimeUnitRange timeUnit) |
private com.google.common.collect.Range<java.util.Calendar> |
ceilRange(org.apache.calcite.avatica.util.TimeUnitRange timeUnit,
SqlKind comparison,
java.util.Calendar c) |
(package private) RexNode |
compareExtract(SqlKind comparison,
RexNode operand,
RexLiteral literal) |
private RexNode |
compareFloorCeil(SqlKind comparison,
RexNode operand,
RexLiteral timeLiteral,
org.apache.calcite.avatica.util.TimeUnitRange timeUnit,
boolean floor) |
private RexLiteral |
dateTimeLiteral(RexBuilder rexBuilder,
java.util.Calendar calendar,
RexNode operand) |
private java.util.Calendar |
decrement(java.util.Calendar c,
org.apache.calcite.avatica.util.TimeUnitRange timeUnit) |
private com.google.common.collect.Range<java.util.Calendar> |
extractRange(org.apache.calcite.avatica.util.TimeUnitRange timeUnit,
SqlKind comparison,
java.util.Calendar c) |
private java.util.Calendar |
floor(java.util.Calendar c,
org.apache.calcite.avatica.util.TimeUnitRange timeUnit)
Computes floor of a calendar to a given time unit.
|
private com.google.common.collect.Range<java.util.Calendar> |
floorRange(org.apache.calcite.avatica.util.TimeUnitRange timeUnit,
SqlKind comparison,
java.util.Calendar c) |
private java.util.Calendar |
increment(java.util.Calendar c,
org.apache.calcite.avatica.util.TimeUnitRange timeUnit) |
(package private) boolean |
isExtractCall(RexNode e) |
(package private) boolean |
isFloorCeilCall(RexNode e) |
private static boolean |
isValid(int v,
org.apache.calcite.avatica.util.TimeUnitRange timeUnit) |
private boolean |
next(java.util.Calendar c,
org.apache.calcite.avatica.util.TimeUnitRange timeUnit,
int v,
com.google.common.collect.Range<java.util.Calendar> r,
boolean strict) |
private java.util.Calendar |
round(java.util.Calendar c,
org.apache.calcite.avatica.util.TimeUnitRange timeUnit,
boolean down)
Returns a copy of a calendar, optionally rounded up to the next time
unit.
|
private java.util.Calendar |
timestampValue(RexLiteral timeLiteral) |
private RexNode |
toRex(RexNode operand,
com.google.common.collect.Range<java.util.Calendar> r) |
RexNode |
visitCall(RexCall call) |
protected java.util.List<RexNode> |
visitList(java.util.List<? extends RexNode> exprs,
boolean[] update)
Visits each of a list of expressions and returns a list of the
results.
|
apply, apply, apply, mutate, visitArray, visitCorrelVariable, visitDynamicParam, visitFieldAccess, visitFieldCollations, visitInputRef, visitList, visitLiteral, visitLocalRef, visitOver, visitPatternFieldRef, visitRangeRef, visitSubQuery, visitTableInputRef, visitWindow
private final RexBuilder rexBuilder
private final org.apache.calcite.avatica.util.TimeUnitRange timeUnit
private final java.util.Map<RexNode,com.google.common.collect.RangeSet<java.util.Calendar>> operandRanges
private final java.util.Deque<RexCall> calls
private final com.google.common.collect.ImmutableSortedSet<org.apache.calcite.avatica.util.TimeUnitRange> timeUnitRanges
private final java.lang.String timeZone
ExtractShuttle(RexBuilder rexBuilder, org.apache.calcite.avatica.util.TimeUnitRange timeUnit, java.util.Map<RexNode,com.google.common.collect.RangeSet<java.util.Calendar>> operandRanges, com.google.common.collect.ImmutableSortedSet<org.apache.calcite.avatica.util.TimeUnitRange> timeUnitRanges, java.lang.String timeZone)
public RexNode visitCall(RexCall call)
visitCall
in interface RexVisitor<RexNode>
visitCall
in class RexShuttle
private boolean canRewriteExtract(RexNode operand)
protected java.util.List<RexNode> visitList(java.util.List<? extends RexNode> exprs, boolean[] update)
RexShuttle
visitList
in class RexShuttle
exprs
- List of expressionsupdate
- If not null, sets this to true if any of the expressions
was modifiedboolean isExtractCall(RexNode e)
RexNode compareExtract(SqlKind comparison, RexNode operand, RexLiteral literal)
private boolean next(java.util.Calendar c, org.apache.calcite.avatica.util.TimeUnitRange timeUnit, int v, com.google.common.collect.Range<java.util.Calendar> r, boolean strict)
private static boolean isValid(int v, org.apache.calcite.avatica.util.TimeUnitRange timeUnit)
@Nonnull private RexNode toRex(RexNode operand, com.google.common.collect.Range<java.util.Calendar> r)
private RexLiteral dateTimeLiteral(RexBuilder rexBuilder, java.util.Calendar calendar, RexNode operand)
private com.google.common.collect.Range<java.util.Calendar> extractRange(org.apache.calcite.avatica.util.TimeUnitRange timeUnit, SqlKind comparison, java.util.Calendar c)
private java.util.Calendar round(java.util.Calendar c, org.apache.calcite.avatica.util.TimeUnitRange timeUnit, boolean down)
private RexNode compareFloorCeil(SqlKind comparison, RexNode operand, RexLiteral timeLiteral, org.apache.calcite.avatica.util.TimeUnitRange timeUnit, boolean floor)
private java.util.Calendar timestampValue(RexLiteral timeLiteral)
private com.google.common.collect.Range<java.util.Calendar> floorRange(org.apache.calcite.avatica.util.TimeUnitRange timeUnit, SqlKind comparison, java.util.Calendar c)
private com.google.common.collect.Range<java.util.Calendar> ceilRange(org.apache.calcite.avatica.util.TimeUnitRange timeUnit, SqlKind comparison, java.util.Calendar c)
boolean isFloorCeilCall(RexNode e)
private java.util.Calendar increment(java.util.Calendar c, org.apache.calcite.avatica.util.TimeUnitRange timeUnit)
private java.util.Calendar decrement(java.util.Calendar c, org.apache.calcite.avatica.util.TimeUnitRange timeUnit)
private java.util.Calendar ceil(java.util.Calendar c, org.apache.calcite.avatica.util.TimeUnitRange timeUnit)
private java.util.Calendar floor(java.util.Calendar c, org.apache.calcite.avatica.util.TimeUnitRange timeUnit)
Copyright © 2012–2019 The Apache Software Foundation. All rights reserved.