public abstract class AbstractAggregate extends DataAnalysisOperation
Modifier and Type | Field and Description |
---|---|
protected Expression[] |
args
The arguments.
|
protected boolean |
distinct
is this a DISTINCT aggregate
|
protected Expression |
filterCondition
FILTER condition for aggregate
|
protected TypeInfo |
type
The type of the result.
|
over, overOrderBySort, select, STAGE_GROUP, STAGE_RESET, STAGE_WINDOW
AUTO_PARENTHESES, MAP_IN_AGGREGATE, MAP_IN_WINDOW, MAP_INITIAL, WITH_PARENTHESES, WITHOUT_PARENTHESES
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS
Modifier and Type | Method and Description |
---|---|
protected java.lang.StringBuilder |
appendTailConditions(java.lang.StringBuilder builder,
int sqlFlags,
boolean forceOrderBy)
Used to create SQL for the OVER and FILTER clauses.
|
Expression |
getFilterCondition()
Returns the FILTER condition.
|
protected void |
getOrderedResultLoop(SessionLocal session,
java.util.HashMap<java.lang.Integer,Value> result,
java.util.ArrayList<Value[]> ordered,
int rowIdColumn)
Returns result of this window function or window aggregate.
|
Expression |
getSubexpression(int index)
Returns subexpression with specified index.
|
int |
getSubexpressionCount()
Returns count of subexpressions.
|
TypeInfo |
getType()
Returns the data type.
|
boolean |
isAggregate()
Checks whether this expression is an aggregate function.
|
void |
mapColumnsAnalysis(ColumnResolver resolver,
int level,
int innerState)
Map the columns of the resolver to expression columns.
|
Expression |
optimize(SessionLocal session)
Try to optimize the expression.
|
void |
setEvaluatable(TableFilter tableFilter,
boolean b)
Tell the expression columns whether the table filter can return values
now.
|
void |
setFilterCondition(Expression filterCondition)
Sets the FILTER condition.
|
protected abstract void |
updateAggregate(SessionLocal session,
java.lang.Object aggregateData)
Updates an aggregate value.
|
protected void |
updateAggregate(SessionLocal session,
SelectGroups groupData,
int groupRowId)
Update a row of an aggregate.
|
protected abstract void |
updateFromExpressions(SessionLocal session,
java.lang.Object aggregateData,
Value[] array)
Updates the provided aggregate data from the remembered expressions.
|
protected void |
updateGroupAggregates(SessionLocal session,
int stage)
Invoked when processing group stage of grouped window queries to update
arguments of this aggregate.
|
createAggregateData, createOrder, getAggregatedValue, getGroupData, getNumExpressions, getOverCondition, getOverOrderBySort, getValue, getWindowData, isEverything, mapColumns, rememberExpressions, setOverCondition, updateAggregate, updateOrderedAggregate
addFilterConditions, createIndexConditions, getAlias, getBooleanValue, getColumnName, getColumnNameForView, getCost, getEnclosedSQL, getNonAliasExpression, getNotIfPossible, getNullable, getSchemaName, getSQL, getSQL, getSQL, getSQL, getTableAlias, getTableName, getUnenclosedSQL, getWhenSQL, getWhenValue, isConstant, isIdentity, isNullConstant, isValueSet, isWhenConditionOperand, needParentheses, optimizeCondition, toString, writeExpressions, writeExpressions
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getTraceSQL
protected final boolean distinct
protected final Expression[] args
protected Expression filterCondition
protected TypeInfo type
public final boolean isAggregate()
DataAnalysisOperation
isAggregate
in class DataAnalysisOperation
public Expression getFilterCondition()
public void setFilterCondition(Expression filterCondition)
filterCondition
- FILTER conditionpublic TypeInfo getType()
Expression
getType
in interface Typed
getType
in class Expression
public void mapColumnsAnalysis(ColumnResolver resolver, int level, int innerState)
DataAnalysisOperation
mapColumnsAnalysis
in class DataAnalysisOperation
resolver
- the column resolverlevel
- the subquery nesting levelinnerState
- one of the Expression MAP_IN_* valuespublic Expression optimize(SessionLocal session)
Expression
optimize
in class DataAnalysisOperation
session
- the sessionpublic void setEvaluatable(TableFilter tableFilter, boolean b)
Expression
setEvaluatable
in class DataAnalysisOperation
tableFilter
- the table filterb
- true if the table filter can return valueprotected void getOrderedResultLoop(SessionLocal session, java.util.HashMap<java.lang.Integer,Value> result, java.util.ArrayList<Value[]> ordered, int rowIdColumn)
DataAnalysisOperation
getOrderedResultLoop
in class DataAnalysisOperation
session
- the sessionresult
- the map to append result toordered
- ordered datarowIdColumn
- the index of row id valueprotected abstract void updateFromExpressions(SessionLocal session, java.lang.Object aggregateData, Value[] array)
session
- the sessionaggregateData
- aggregate dataarray
- values of expressionsprotected void updateAggregate(SessionLocal session, SelectGroups groupData, int groupRowId)
DataAnalysisOperation
updateAggregate
in class DataAnalysisOperation
session
- the database sessiongroupData
- data for the aggregate groupgroupRowId
- row id of groupprotected abstract void updateAggregate(SessionLocal session, java.lang.Object aggregateData)
session
- the sessionaggregateData
- aggregate dataprotected void updateGroupAggregates(SessionLocal session, int stage)
DataAnalysisOperation
updateGroupAggregates
in class DataAnalysisOperation
session
- the sessionstage
- select stageprotected java.lang.StringBuilder appendTailConditions(java.lang.StringBuilder builder, int sqlFlags, boolean forceOrderBy)
DataAnalysisOperation
appendTailConditions
in class DataAnalysisOperation
builder
- string buildersqlFlags
- formatting flagsforceOrderBy
- whether synthetic ORDER BY clause should be generated when it
is missingpublic int getSubexpressionCount()
Expression
getSubexpressionCount
in class Expression
public Expression getSubexpression(int index)
Expression
getSubexpression
in class Expression
index
- 0-based index