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
Superclass of any window function call.
-
Field Summary
FieldsFields 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
ConstructorsConstructorDescriptionWindowFunctionNode
(ValueNode op, String functionName, WindowNode w, ContextManager cm) -
Method Summary
Modifier and TypeMethodDescription(package private) ValueNode
bindExpression
(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) ValueNode override.(package private) boolean
constantExpression
(PredicateList whereClause) ValueNode override.private WindowDefinitionNode
definedWindow
(WindowList windows, String name) (package private) ColumnReference
Get the generated ColumnReference to this window function after the parent called replaceCallsWithColumnReferences().(package private) ValueNode
Get the null result expression column.(package private) WindowNode
boolean
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
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 Details
-
window
-
generatedRC
-
generatedRef
-
-
Constructor Details
-
WindowFunctionNode
WindowFunctionNode(ValueNode op, 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 Details
-
isConstantExpression
public boolean isConstantExpression()ValueNode override.- Overrides:
isConstantExpression
in classUnaryOperatorNode
- Returns:
- Whether or not this expression tree represents a constant expression.
- See Also:
-
constantExpression
ValueNode override.- Overrides:
constantExpression
in classUnaryOperatorNode
- Returns:
- True means this expression tree represents a constant value.
- See Also:
-
getWindow
WindowNode getWindow()- Returns:
- window associated with this window function
-
setWindow
Set window associated with this window function call.- Parameters:
wdn
- window definition
-
bindExpression
ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, 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:
-
definedWindow
- 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:
-
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
Get the null result expression column.- Returns:
- the value node
- Throws:
StandardException
- on error
-