public class WindowFunction extends DataAnalysisOperation
over, overOrderBySort, select, STAGE_GROUP, STAGE_RESET, STAGE_WINDOWAUTO_PARENTHESES, MAP_IN_AGGREGATE, MAP_IN_WINDOW, MAP_INITIAL, WITH_PARENTHESES, WITHOUT_PARENTHESESADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS| Constructor and Description |
|---|
WindowFunction(WindowFunctionType type,
Select select,
Expression[] args)
Creates new instance of a window function.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Object |
createAggregateData()
Create aggregate data object specific to the subclass.
|
protected Value |
getAggregatedValue(SessionLocal session,
java.lang.Object aggregateData)
Returns aggregated value.
|
int |
getCost()
Estimate the cost to process the expression.
|
WindowFunctionType |
getFunctionType()
Returns the type of this function.
|
static int |
getMaxArgumentCount(WindowFunctionType type)
Returns maximal number of arguments for the specified type.
|
static int |
getMinArgumentCount(WindowFunctionType type)
Returns minimal number of arguments for the specified type.
|
protected int |
getNumExpressions()
Returns the number of expressions, excluding OVER clause.
|
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.
|
TypeInfo |
getType()
Returns the data type.
|
java.lang.StringBuilder |
getUnenclosedSQL(java.lang.StringBuilder builder,
int sqlFlags)
Get the SQL statement of this expression.
|
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.
|
protected void |
rememberExpressions(SessionLocal session,
Value[] array)
Stores current values of expressions into the specified array.
|
void |
setEvaluatable(TableFilter tableFilter,
boolean b)
Tell the expression columns whether the table filter can return values
now.
|
void |
setFromLast(boolean fromLast)
Sets FROM FIRST or FROM LAST clause value.
|
void |
setIgnoreNulls(boolean ignoreNulls)
Sets RESPECT NULLS or IGNORE NULLS clause value.
|
protected void |
updateAggregate(SessionLocal session,
SelectGroups groupData,
int groupRowId)
Update a row of an aggregate.
|
protected void |
updateGroupAggregates(SessionLocal session,
int stage)
Invoked when processing group stage of grouped window queries to update
arguments of this aggregate.
|
appendTailConditions, createOrder, getGroupData, getOverOrderBySort, getValue, getWindowData, isEverything, mapColumns, setOverCondition, updateAggregate, updateOrderedAggregateaddFilterConditions, createIndexConditions, getAlias, getBooleanValue, getColumnName, getColumnNameForView, getEnclosedSQL, getNonAliasExpression, getNotIfPossible, getNullable, getSchemaName, getSQL, getSQL, getSQL, getSQL, getSubexpression, getSubexpressionCount, getTableAlias, getTableName, getWhenSQL, getWhenValue, isConstant, isIdentity, isNullConstant, isValueSet, isWhenConditionOperand, needParentheses, optimizeCondition, toString, writeExpressions, writeExpressionsclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetTraceSQLpublic WindowFunction(WindowFunctionType type, Select select, Expression[] args)
type - the typeselect - the select statementargs - arguments, or nullpublic static int getMinArgumentCount(WindowFunctionType type)
type - the type of a window functionpublic static int getMaxArgumentCount(WindowFunctionType type)
type - the type of a window functionpublic WindowFunctionType getFunctionType()
public void setFromLast(boolean fromLast)
fromLast - whether FROM LAST clause was specified.public void setIgnoreNulls(boolean ignoreNulls)
ignoreNulls - whether IGNORE NULLS clause was specifiedpublic boolean isAggregate()
DataAnalysisOperationisAggregate in class DataAnalysisOperationprotected void updateAggregate(SessionLocal session, SelectGroups groupData, int groupRowId)
DataAnalysisOperationupdateAggregate in class DataAnalysisOperationsession - the database sessiongroupData - data for the aggregate groupgroupRowId - row id of groupprotected void updateGroupAggregates(SessionLocal session, int stage)
DataAnalysisOperationupdateGroupAggregates in class DataAnalysisOperationsession - the sessionstage - select stageprotected int getNumExpressions()
DataAnalysisOperationgetNumExpressions in class DataAnalysisOperationprotected void rememberExpressions(SessionLocal session, Value[] array)
DataAnalysisOperationrememberExpressions in class DataAnalysisOperationsession - the sessionarray - array to store values of expressionsprotected java.lang.Object createAggregateData()
DataAnalysisOperationcreateAggregateData in class DataAnalysisOperationprotected void getOrderedResultLoop(SessionLocal session, java.util.HashMap<java.lang.Integer,Value> result, java.util.ArrayList<Value[]> ordered, int rowIdColumn)
DataAnalysisOperationgetOrderedResultLoop in class DataAnalysisOperationsession - the sessionresult - the map to append result toordered - ordered datarowIdColumn - the index of row id valueprotected Value getAggregatedValue(SessionLocal session, java.lang.Object aggregateData)
DataAnalysisOperationgetAggregatedValue in class DataAnalysisOperationsession - the sessionaggregateData - the aggregate datapublic void mapColumnsAnalysis(ColumnResolver resolver, int level, int innerState)
DataAnalysisOperationmapColumnsAnalysis in class DataAnalysisOperationresolver - the column resolverlevel - the subquery nesting levelinnerState - one of the Expression MAP_IN_* valuespublic Expression optimize(SessionLocal session)
Expressionoptimize in class DataAnalysisOperationsession - the sessionpublic void setEvaluatable(TableFilter tableFilter, boolean b)
ExpressionsetEvaluatable in class DataAnalysisOperationtableFilter - the table filterb - true if the table filter can return valuepublic TypeInfo getType()
ExpressiongetType in interface TypedgetType in class Expressionpublic java.lang.StringBuilder getUnenclosedSQL(java.lang.StringBuilder builder,
int sqlFlags)
ExpressiongetUnenclosedSQL in class Expressionbuilder - string buildersqlFlags - formatting flagspublic int getCost()
ExpressiongetCost in class Expression