Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

public abstract Class WindowFunctionNode

extends UnaryOperatorNode
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.sql.compile.AggregateWindowFunctionNode, org.apache.derby.impl.sql.compile.RowNumberFunctionNode
Imports
java.util.List, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.CompilerContext

Superclass of any window function call.

Field Summary

Modifier and TypeField and Description
private ResultColumn
private ColumnReference
private WindowNode
Inherited from org.apache.derby.impl.sql.compile.UnaryOperatorNode:
K_BASEK_XMLPARSEK_XMLSERIALIZEkindmethodNameoperandoperatorreceiverInterfaceTyperesultInterfaceTypeUnaryArgTypesUnaryMethodNamesUnaryOperatorsUnaryResultTypes

Constructor Summary

AccessConstructor and Description
pack-priv
WindowFunctionNode(ValueNode
operand (null for now)
op
,
String
operator
functionName
,
WindowNode
window node (definition or reference)
w
,
ContextManager
context manager
cm
)

Method Summary

Modifier and TypeMethod and Description
pack-priv ValueNode
bindExpression(FromList
The FROM list for the query this expression is in, for binding columns.
fromList
,
SubqueryList
The subquery list being built as we find SubqueryNodes
subqueryList
,
List<AggregateNode>
The aggregate list being built as we find AggregateNodes
aggregates
)

Overrides org.apache.derby.impl.sql.compile.UnaryOperatorNode.bindExpression.

ValueNode override.

pack-priv boolean
private WindowDefinitionNode

Returns:

if name matches a defined window (in windows), return the definition of that window, else null.
definedWindow
(WindowList windows, String name)

pack-priv ColumnReference

Returns:

the column reference
getGeneratedRef
()

Get the generated ColumnReference to this window function after the parent called replaceCallsWithColumnReferences().

pack-priv ValueNode

Returns:

the value node
getNewNullResultExpression
()

Get the null result expression column.

pack-priv WindowNode

Returns:

window associated with this window function
getWindow
()

public boolean
public void
printSubNodes(int
The depth of this node in the tree
depth
)

Overrides org.apache.derby.impl.sql.compile.UnaryOperatorNode.printSubNodes.

QueryTreeNode override.

pack-priv ValueNode

Returns:

ValueNode The (potentially) modified tree.
replaceCallsWithColumnReferences
(ResultColumnList
The RCL to append to.
rcl
,
int
The tableNumber for the new ColumnReference
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.

pack-priv void
setWindow(WindowDefinitionNode
window definition
wdn
)

Set window associated with this window function call.

Inherited from org.apache.derby.impl.sql.compile.UnaryOperatorNode:
acceptChildrenaddXmlOpMethodParamsbindOperandbindParametercategorizegenerateExpressiongetOperandgetOperatorStringgetOrderableVariantTypegetParameterOperandgetReceiverInterfaceNameisEquivalentisSameNodeKindpreprocessremapColumnReferencesToExpressionssetMethodNamesetOperatortoString

Field Detail

generatedRCback to summary
private ResultColumn generatedRC
generatedRefback to summary
private ColumnReference generatedRef
windowback to summary
private WindowNode window

Constructor Detail

WindowFunctionNodeback to summary
pack-priv WindowFunctionNode(ValueNode op, String functionName, WindowNode w, ContextManager cm) throws StandardException
Parameters
op:ValueNode

operand (null for now)

functionName:String

operator

w:WindowNode

window node (definition or reference)

cm:ContextManager

context manager

Method Detail

bindExpressionback to summary
pack-priv ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) throws StandardException

Overrides org.apache.derby.impl.sql.compile.UnaryOperatorNode.bindExpression.

ValueNode override.

Parameters
fromList:FromList

Doc from org.apache.derby.impl.sql.compile.UnaryOperatorNode.bindExpression.

The FROM list for the query this expression is in, for binding columns.

subqueryList:SubqueryList

Doc from org.apache.derby.impl.sql.compile.UnaryOperatorNode.bindExpression.

The subquery list being built as we find SubqueryNodes

aggregates:List<AggregateNode>

Doc from org.apache.derby.impl.sql.compile.UnaryOperatorNode.bindExpression.

The aggregate list being built as we find AggregateNodes

Returns:ValueNode

Doc from org.apache.derby.impl.sql.compile.UnaryOperatorNode.bindExpression.

The new top of the expression tree.

Annotations
@Override
Exceptions
StandardException:

Doc from org.apache.derby.impl.sql.compile.UnaryOperatorNode.bindExpression.

Thrown on error

See Also
ValueNode#bindExpression
constantExpressionback to summary
pack-priv boolean constantExpression(PredicateList whereClause)

Overrides org.apache.derby.impl.sql.compile.UnaryOperatorNode.constantExpression.

ValueNode override.

Returns:boolean

Doc from org.apache.derby.impl.sql.compile.ValueNode.constantExpression.

True means this expression tree represents a constant value.

Annotations
@Override
See Also
ValueNode#isConstantExpression
definedWindowback to summary
private WindowDefinitionNode definedWindow(WindowList windows, String name)
Returns:WindowDefinitionNode

if name matches a defined window (in windows), return the definition of that window, else null.

getGeneratedRefback to summary
pack-priv 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)

in which case the top PRN of the subquery sitting over a WindowResultSetNode just contains a RC which is boolean constant true. This means that the replaceCallsWithColumnReferences will not have been called for this, so the returned generatedRef is null.

Returns:ColumnReference

the column reference

getNewNullResultExpressionback to summary
pack-priv ValueNode getNewNullResultExpression() throws StandardException

Get the null result expression column.

Returns:ValueNode

the value node

Exceptions
StandardException:
on error
getWindowback to summary
pack-priv WindowNode getWindow()
Returns:WindowNode

window associated with this window function

isConstantExpressionback to summary
public boolean isConstantExpression()

Overrides org.apache.derby.impl.sql.compile.UnaryOperatorNode.isConstantExpression.

ValueNode override.

Returns:boolean

Doc from org.apache.derby.impl.sql.compile.UnaryOperatorNode.isConstantExpression.

Whether or not this expression tree represents a constant expression.

Annotations
@Override
See Also
ValueNode#isConstantExpression
printSubNodesback to summary
public void printSubNodes(int depth)

Overrides org.apache.derby.impl.sql.compile.UnaryOperatorNode.printSubNodes.

QueryTreeNode override.

Parameters
depth:int

Doc from org.apache.derby.impl.sql.compile.UnaryOperatorNode.printSubNodes.

The depth of this node in the tree

Annotations
@Override
See Also
QueryTreeNode#printSubNodes
replaceCallsWithColumnReferencesback to summary
pack-priv 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:ResultColumnList

The RCL to append to.

tableNumber:int

The tableNumber for the new ColumnReference

Returns:ValueNode

ValueNode The (potentially) modified tree.

Exceptions
StandardException:
Thrown on error
setWindowback to summary
pack-priv void setWindow(WindowDefinitionNode wdn)

Set window associated with this window function call.

Parameters
wdn:WindowDefinitionNode

window definition