private class SqlToRelConverter.HistogramShuttle extends RexShuttle
RexNodes 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 elimination will ensure that only one histogram is computed.
| Modifier and Type | Field and Description |
|---|---|
private boolean |
distinct |
(package private) static boolean |
ENABLE_HISTOGRAM_AGG
Whether to convert calls to MIN(x) to HISTOGRAM_MIN(HISTOGRAM(x)).
|
private RexWindowBound |
lowerBound |
private com.google.common.collect.ImmutableList<RexFieldCollation> |
orderKeys |
private List<RexNode> |
partitionKeys |
private RexWindowBound |
upperBound |
private SqlWindow |
window |
| Constructor and Description |
|---|
HistogramShuttle(List<RexNode> partitionKeys,
com.google.common.collect.ImmutableList<RexFieldCollation> orderKeys,
RexWindowBound lowerBound,
RexWindowBound upperBound,
SqlWindow window,
boolean distinct) |
| Modifier and Type | Method and Description |
|---|---|
private RelDataType |
computeHistogramType(RelDataType type)
Returns the type for a histogram function.
|
(package private) SqlFunction |
getHistogramOp(SqlAggFunction aggFunction)
Returns the histogram operator corresponding to a given aggregate
function.
|
RexNode |
visitCall(RexCall call) |
apply, apply, apply, mutate, visitArray, visitCorrelVariable, visitDynamicParam, visitFieldAccess, visitFieldCollations, visitInputRef, visitList, visitList, visitLiteral, visitLocalRef, visitOver, visitPatternFieldRef, visitRangeRef, visitSubQuery, visitTableInputRef, visitWindowstatic final boolean ENABLE_HISTOGRAM_AGG
private final com.google.common.collect.ImmutableList<RexFieldCollation> orderKeys
private final RexWindowBound lowerBound
private final RexWindowBound upperBound
private final SqlWindow window
private final boolean distinct
HistogramShuttle(List<RexNode> partitionKeys, com.google.common.collect.ImmutableList<RexFieldCollation> orderKeys, RexWindowBound lowerBound, RexWindowBound upperBound, SqlWindow window, boolean distinct)
public RexNode visitCall(RexCall call)
visitCall in interface RexVisitor<RexNode>visitCall in class RexShuttleSqlFunction getHistogramOp(SqlAggFunction aggFunction)
For example, getHistogramOp
( returns
SqlStdOperatorTable.MIN}SqlStdOperatorTable.HISTOGRAM_MIN.
aggFunction - An aggregate functionprivate RelDataType computeHistogramType(RelDataType type)
Copyright © 2012–2018 The Apache Software Foundation. All rights reserved.