Class WindowFunctionNode
- java.lang.Object
-
- org.apache.derby.impl.sql.compile.QueryTreeNode
-
- org.apache.derby.impl.sql.compile.ValueNode
-
- org.apache.derby.impl.sql.compile.OperatorNode
-
- org.apache.derby.impl.sql.compile.UnaryOperatorNode
-
- org.apache.derby.impl.sql.compile.WindowFunctionNode
-
- All Implemented Interfaces:
Visitable
- Direct Known Subclasses:
AggregateWindowFunctionNode
,RowNumberFunctionNode
public abstract class WindowFunctionNode extends UnaryOperatorNode
Superclass of any window function call.
-
-
Field Summary
Fields Modifier and Type Field Description private ResultColumn
generatedRC
private ColumnReference
generatedRef
private WindowNode
window
-
Fields inherited from class org.apache.derby.impl.sql.compile.UnaryOperatorNode
K_BASE, K_XMLPARSE, K_XMLSERIALIZE, kind, methodName, operand, operator, receiverInterfaceType, resultInterfaceType, UnaryArgTypes, UnaryMethodNames, UnaryOperators, UnaryResultTypes
-
Fields inherited from class org.apache.derby.impl.sql.compile.ValueNode
transformed
-
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
-
-
Constructor Summary
Constructors Constructor Description WindowFunctionNode(ValueNode op, java.lang.String functionName, WindowNode w, ContextManager cm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) ValueNode
bindExpression(FromList fromList, SubqueryList subqueryList, java.util.List<AggregateNode> aggregates)
ValueNode override.(package private) boolean
constantExpression(PredicateList whereClause)
ValueNode override.private WindowDefinitionNode
definedWindow(WindowList windows, java.lang.String name)
(package private) ColumnReference
getGeneratedRef()
Get the generated ColumnReference to this window function after the parent called replaceCallsWithColumnReferences().(package private) ValueNode
getNewNullResultExpression()
Get the null result expression column.(package private) WindowNode
getWindow()
boolean
isConstantExpression()
ValueNode override.void
printSubNodes(int depth)
QueryTreeNode override.(package private) ValueNode
replaceCallsWithColumnReferences(ResultColumnList rcl, int tableNumber)
Replace window function calls in the expression tree with a ColumnReference to that window function, append the aggregate to the supplied RCL (assumed to be from the child ResultSetNode) and return the ColumnReference.(package private) void
setWindow(WindowDefinitionNode wdn)
Set window associated with this window function call.-
Methods inherited from class org.apache.derby.impl.sql.compile.UnaryOperatorNode
acceptChildren, addXmlOpMethodParams, bindOperand, bindParameter, categorize, generateExpression, getOperand, getOperatorString, getOrderableVariantType, getParameterOperand, getReceiverInterfaceName, isEquivalent, isSameNodeKind, preprocess, remapColumnReferencesToExpressions, setMethodName, setOperator, toString
-
Methods inherited from class org.apache.derby.impl.sql.compile.OperatorNode
pushSqlXmlUtil
-
Methods inherited from class org.apache.derby.impl.sql.compile.ValueNode
bindExpression, changeToCNF, checkIsBoolean, checkTopPredicatesForEqualsConditions, copyFields, eliminateNots, evaluateConstantExpressions, genEqualsFalseTree, generate, genIsNullTree, genSQLJavaSQLTree, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getSchemaName, getSourceResultColumn, getTableName, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, getTypeServices, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isInListProbeNode, isParameterNode, isRelationalOperator, optimizableEqualityNode, putAndsOnTop, requiresTypeFromContext, selectivity, setCollationInfo, setCollationInfo, setCollationUsingCompilationSchema, setCollationUsingCompilationSchema, setNullability, setTransformed, setType, setType, setType, updatableByCursor, verifyChangeToCNF, verifyEliminateNots, verifyPutAndsOnTop
-
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContext, getContextManager, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getLongProperty, getNullNode, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, getUDTDesc, isAtomic, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExist
-
-
-
-
Field Detail
-
window
private WindowNode window
-
generatedRC
private ResultColumn generatedRC
-
generatedRef
private ColumnReference generatedRef
-
-
Constructor Detail
-
WindowFunctionNode
WindowFunctionNode(ValueNode op, java.lang.String functionName, WindowNode w, ContextManager cm) throws StandardException
- Parameters:
op
- operand (null for now)functionName
- operatorw
- window node (definition or reference)cm
- context manager- Throws:
StandardException
-
-
Method Detail
-
isConstantExpression
public boolean isConstantExpression()
ValueNode override.- Overrides:
isConstantExpression
in classUnaryOperatorNode
- Returns:
- Whether or not this expression tree represents a constant expression.
- See Also:
ValueNode.isConstantExpression()
-
constantExpression
boolean constantExpression(PredicateList whereClause)
ValueNode override.- Overrides:
constantExpression
in classUnaryOperatorNode
- Returns:
- True means this expression tree represents a constant value.
- See Also:
ValueNode.isConstantExpression()
-
getWindow
WindowNode getWindow()
- Returns:
- window associated with this window function
-
setWindow
void setWindow(WindowDefinitionNode wdn)
Set window associated with this window function call.- Parameters:
wdn
- window definition
-
bindExpression
ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.List<AggregateNode> aggregates) throws StandardException
ValueNode override.- Overrides:
bindExpression
in classUnaryOperatorNode
- Parameters:
fromList
- The FROM list for the query this expression is in, for binding columns.subqueryList
- The subquery list being built as we find SubqueryNodesaggregates
- The aggregate list being built as we find AggregateNodes- Returns:
- The new top of the expression tree.
- Throws:
StandardException
- Thrown on error- See Also:
ValueNode.bindExpression(org.apache.derby.impl.sql.compile.FromList, org.apache.derby.impl.sql.compile.SubqueryList, java.util.List<org.apache.derby.impl.sql.compile.AggregateNode>)
-
definedWindow
private WindowDefinitionNode definedWindow(WindowList windows, java.lang.String name)
- Returns:
- if name matches a defined window (in windows), return the definition of that window, else null.
-
printSubNodes
public void printSubNodes(int depth)
QueryTreeNode override.- Overrides:
printSubNodes
in classUnaryOperatorNode
- Parameters:
depth
- The depth of this node in the tree- See Also:
QueryTreeNode.printSubNodes(int)
-
replaceCallsWithColumnReferences
ValueNode replaceCallsWithColumnReferences(ResultColumnList rcl, int tableNumber) throws StandardException
Replace window function calls in the expression tree with a ColumnReference to that window function, append the aggregate to the supplied RCL (assumed to be from the child ResultSetNode) and return the ColumnReference.- Parameters:
rcl
- The RCL to append to.tableNumber
- The tableNumber for the new ColumnReference- Returns:
- ValueNode The (potentially) modified tree.
- Throws:
StandardException
- Thrown on error
-
getGeneratedRef
ColumnReference getGeneratedRef()
Get the generated ColumnReference to this window function after the parent called replaceCallsWithColumnReferences(). There are cases where this will not have been done because the tree has been re-written to eliminate the window function, e.g. for this query:SELECT * FROM t WHERE EXISTS (SELECT ROW_NUMBER() OVER () FROM t)
true
. This means that the replaceCallsWithColumnReferences will not have been called forthis
, so the returnedgeneratedRef
is null.- Returns:
- the column reference
-
getNewNullResultExpression
ValueNode getNewNullResultExpression() throws StandardException
Get the null result expression column.- Returns:
- the value node
- Throws:
StandardException
- on error
-
-