org.eigenbase.sql2rel
Class SqlToRelConverter.HistogramShuttle
java.lang.Object
org.eigenbase.rex.RexShuttle
org.eigenbase.sql2rel.SqlToRelConverter.HistogramShuttle
- All Implemented Interfaces:
- RexVisitor<RexNode>
- Enclosing class:
- SqlToRelConverter
private class SqlToRelConverter.HistogramShuttle
- extends RexShuttle
Shuttle which walks over a tree of RexNode
s and applies 'over' to
all agg functions.
This is necessary because the returned expression is not necessarily a
call to an agg function. For example,
AVG(x)
becomes
SUM(x) / COUNT(x)
Any aggregate functions are converted to calls to the internal
$Histogram
aggregation function and accessors such as
$HistogramMin
; for example,
MIN(x), MAX(x)
are converted to
$HistogramMin($Histogram(x)),
$HistogramMax($Histogram(x))
Common sub-expression elmination will ensure that only one histogram is
computed.
Methods inherited from class org.eigenbase.rex.RexShuttle |
apply, apply, visitArray, visitCorrelVariable, visitDynamicParam, visitFieldAccess, visitInputRef, visitLiteral, visitLocalRef, visitOver, visitRangeRef, visitWindow |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
partitionKeys
private final RexNode[] partitionKeys
orderKeys
private final RexNode[] orderKeys
window
private final SqlWindow window
SqlToRelConverter.HistogramShuttle
SqlToRelConverter.HistogramShuttle(RexNode[] partitionKeys,
RexNode[] orderKeys,
SqlWindow window)
visitCall
public RexNode visitCall(RexCall call)
- Specified by:
visitCall
in interface RexVisitor<RexNode>
- Overrides:
visitCall
in class RexShuttle
getHistogramOp
SqlFunction getHistogramOp(SqlAggFunction aggFunction)
- Returns the histogram operator corresponding to a given aggregate
function.
For example, getHistogramOp(SqlStdOperatorTable.minOperator
}
returns SqlStdOperatorTable.histogramMinFunction
.
- Parameters:
aggFunction
- An aggregate function
- Returns:
- Its histogram function, or null
computeHistogramType
private RelDataType computeHistogramType(RelDataType type)
- Returns the type for a histogram function. It is either the actual
type or an an approximation to it.