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 UnaryOperatorNode
K_BASE, K_XMLPARSE, K_XMLSERIALIZE, kind, methodName, operand, operator, receiverInterfaceType, resultInterfaceType, UnaryArgTypes, UnaryMethodNames, UnaryOperators, UnaryResultTypesFields inherited from class ValueNode
transformedFields inherited from class 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) ValueNodebindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) ValueNode override.(package private) booleanconstantExpression(PredicateList whereClause) ValueNode override.private WindowDefinitionNodedefinedWindow(WindowList windows, String name) (package private) ColumnReferenceGet the generated ColumnReference to this window function after the parent called replaceCallsWithColumnReferences().(package private) ValueNodeGet the null result expression column.(package private) WindowNodebooleanValueNode override.voidprintSubNodes(int depth) QueryTreeNode override.(package private) ValueNodereplaceCallsWithColumnReferences(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) voidSet window associated with this window function call.Methods inherited from class UnaryOperatorNode
acceptChildren, addXmlOpMethodParams, bindOperand, bindParameter, categorize, generateExpression, getOperand, getOperatorString, getOrderableVariantType, getParameterOperand, getReceiverInterfaceName, isEquivalent, isSameNodeKind, preprocess, remapColumnReferencesToExpressions, setMethodName, setOperator, toStringMethods inherited from class OperatorNode
pushSqlXmlUtilMethods inherited from class 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, verifyPutAndsOnTopMethods inherited from class 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:
isConstantExpressionin classUnaryOperatorNode- Returns:
- Whether or not this expression tree represents a constant expression.
- See Also:
-
constantExpression
ValueNode override.- Overrides:
constantExpressionin 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:
bindExpressionin 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:
printSubNodesin 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:in which case the top PRN of the subquery sitting over a WindowResultSetNode just contains a RC which is boolean constantSELECT * FROM t WHERE EXISTS (SELECT ROW_NUMBER() OVER () FROM t)true. This means that the replaceCallsWithColumnReferences will not have been called forthis, so the returnedgeneratedRefis null.- Returns:
- the column reference
-
getNewNullResultExpression
Get the null result expression column.- Returns:
- the value node
- Throws:
StandardException- on error
-