public abstract class DataAnalysisOperation extends Expression
Modifier and Type | Field and Description |
---|---|
protected Window |
over
OVER clause
|
protected SortOrder |
overOrderBySort
Sort order for OVER
|
protected Select |
select
SELECT
|
static int |
STAGE_GROUP
Group stage, used for explicit or implicit GROUP BY operation.
|
static int |
STAGE_RESET
Reset stage.
|
static int |
STAGE_WINDOW
Window processing stage.
|
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 | Constructor and Description |
---|---|
protected |
DataAnalysisOperation(Select select) |
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.
|
protected abstract java.lang.Object |
createAggregateData()
Create aggregate data object specific to the subclass.
|
protected static SortOrder |
createOrder(SessionLocal session,
java.util.ArrayList<QueryOrderBy> orderBy,
int offset)
Create sort order.
|
protected abstract Value |
getAggregatedValue(SessionLocal session,
java.lang.Object aggregateData)
Returns aggregated value.
|
protected java.lang.Object |
getGroupData(SelectGroups groupData,
boolean ifExists)
Get the aggregate group data object from the collector object.
|
protected abstract int |
getNumExpressions()
Returns the number of expressions, excluding OVER clause.
|
protected abstract 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.
|
Window |
getOverCondition()
Returns the OVER condition.
|
protected SortOrder |
getOverOrderBySort()
Returns the sort order for OVER clause.
|
Value |
getValue(SessionLocal session)
Return the resulting value for the current row.
|
protected java.lang.Object |
getWindowData(SessionLocal session,
SelectGroups groupData,
boolean forOrderBy)
Get the aggregate data for a window clause.
|
abstract boolean |
isAggregate()
Checks whether this expression is an aggregate function.
|
boolean |
isEverything(ExpressionVisitor visitor)
Check if this expression and all sub-expressions can fulfill a criteria.
|
void |
mapColumns(ColumnResolver resolver,
int level,
int state)
Map the columns of the resolver to expression columns.
|
protected 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 abstract 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 |
setOverCondition(Window over)
Sets the OVER condition.
|
void |
updateAggregate(SessionLocal session,
int stage)
Update an aggregate value.
|
protected abstract 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.
|
protected void |
updateOrderedAggregate(SessionLocal session,
SelectGroups groupData,
int groupRowId,
java.util.ArrayList<QueryOrderBy> orderBy)
Update a row of an ordered aggregate.
|
addFilterConditions, createIndexConditions, getAlias, getBooleanValue, getColumnName, getColumnNameForView, getCost, getEnclosedSQL, getNonAliasExpression, getNotIfPossible, getNullable, getSchemaName, getSQL, getSQL, getSQL, getSQL, getSubexpression, getSubexpressionCount, getTableAlias, getTableName, getType, getUnenclosedSQL, getWhenSQL, getWhenValue, isConstant, isIdentity, isNullConstant, isValueSet, isWhenConditionOperand, needParentheses, optimizeCondition, toString, writeExpressions, writeExpressions
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getTraceSQL
public static final int STAGE_RESET
public static final int STAGE_GROUP
public static final int STAGE_WINDOW
protected final Select select
protected Window over
protected SortOrder overOrderBySort
protected DataAnalysisOperation(Select select)
protected static SortOrder createOrder(SessionLocal session, java.util.ArrayList<QueryOrderBy> orderBy, int offset)
session
- database sessionorderBy
- array of order by expressionsoffset
- index offsetpublic Window getOverCondition()
public void setOverCondition(Window over)
over
- OVER conditionpublic abstract boolean isAggregate()
protected SortOrder getOverOrderBySort()
public final void mapColumns(ColumnResolver resolver, int level, int state)
Expression
mapColumns
in class Expression
resolver
- the column resolverlevel
- the subquery nesting levelstate
- current state for nesting checks, initial value is
Expression.MAP_INITIAL
protected void mapColumnsAnalysis(ColumnResolver resolver, int level, int innerState)
resolver
- the column resolverlevel
- the subquery nesting levelinnerState
- one of the Expression MAP_IN_* valuespublic Expression optimize(SessionLocal session)
Expression
optimize
in class Expression
session
- the sessionpublic void setEvaluatable(TableFilter tableFilter, boolean b)
Expression
setEvaluatable
in class Expression
tableFilter
- the table filterb
- true if the table filter can return valuepublic final void updateAggregate(SessionLocal session, int stage)
Expression
updateAggregate
in class Expression
session
- the sessionstage
- select stageprotected abstract void updateAggregate(SessionLocal session, SelectGroups groupData, int groupRowId)
session
- the database sessiongroupData
- data for the aggregate groupgroupRowId
- row id of groupprotected void updateGroupAggregates(SessionLocal session, int stage)
session
- the sessionstage
- select stageprotected abstract int getNumExpressions()
protected abstract void rememberExpressions(SessionLocal session, Value[] array)
session
- the sessionarray
- array to store values of expressionsprotected java.lang.Object getWindowData(SessionLocal session, SelectGroups groupData, boolean forOrderBy)
session
- database sessiongroupData
- aggregate group dataforOrderBy
- true if this is for ORDER BYprotected java.lang.Object getGroupData(SelectGroups groupData, boolean ifExists)
groupData
- the collector objectifExists
- if true, return null if object not found, if false, return new
object if nothing foundprotected abstract java.lang.Object createAggregateData()
public boolean isEverything(ExpressionVisitor visitor)
Expression
isEverything
in class Expression
visitor
- the visitorpublic Value getValue(SessionLocal session)
Expression
getValue
in class Expression
session
- the sessionprotected abstract Value getAggregatedValue(SessionLocal session, java.lang.Object aggregateData)
session
- the sessionaggregateData
- the aggregate dataprotected void updateOrderedAggregate(SessionLocal session, SelectGroups groupData, int groupRowId, java.util.ArrayList<QueryOrderBy> orderBy)
session
- the database sessiongroupData
- data for the aggregate groupgroupRowId
- row id of grouporderBy
- list of order by expressionsprotected abstract void getOrderedResultLoop(SessionLocal session, java.util.HashMap<java.lang.Integer,Value> result, java.util.ArrayList<Value[]> ordered, int rowIdColumn)
session
- the sessionresult
- the map to append result toordered
- ordered datarowIdColumn
- the index of row id valueprotected java.lang.StringBuilder appendTailConditions(java.lang.StringBuilder builder, int sqlFlags, boolean forceOrderBy)
builder
- string buildersqlFlags
- formatting flagsforceOrderBy
- whether synthetic ORDER BY clause should be generated when it
is missing