public class SqlWindow extends SqlCall
For example, the query
SELECT sum(a) OVER (w ROWS 3 PRECEDING)
FROM t
WINDOW w AS (PARTITION BY x, y ORDER BY z),
w1 AS (w ROWS 5 PRECEDING UNBOUNDED FOLLOWING)
declares windows w and w1, and uses a window in an OVER clause. It thus
contains 3 SqlWindow objects.
EMPTY_ARRAY, pos| Constructor and Description |
|---|
SqlWindow(SqlParserPos pos,
SqlIdentifier declName,
SqlIdentifier refName,
SqlNodeList partitionList,
SqlNodeList orderList,
SqlLiteral isRows,
SqlNode lowerBound,
SqlNode upperBound,
SqlLiteral allowPartial)
Creates a window.
|
| Modifier and Type | Method and Description |
|---|---|
static SqlWindow |
create(SqlIdentifier declName,
SqlIdentifier refName,
SqlNodeList partitionList,
SqlNodeList orderList,
SqlLiteral isRows,
SqlNode lowerBound,
SqlNode upperBound,
SqlLiteral allowPartial,
SqlParserPos pos) |
static SqlNode |
createBound(SqlLiteral range) |
static SqlNode |
createCurrentRow(SqlParserPos pos) |
SqlWindow |
createCurrentRowWindow(String columnName)
Creates a window
(RANGE columnName CURRENT ROW). |
static SqlNode |
createFollowing(SqlNode e,
SqlParserPos pos) |
static SqlNode |
createPreceding(SqlNode e,
SqlParserPos pos) |
static SqlNode |
createUnboundedFollowing(SqlParserPos pos) |
static SqlNode |
createUnboundedPreceding(SqlParserPos pos) |
SqlWindow |
createUnboundedPrecedingWindow(String columnName)
Creates a window
(RANGE columnName UNBOUNDED
PRECEDING). |
boolean |
equalsDeep(SqlNode node,
boolean fail)
Overridden method to specifically check only the right subtree of a window
definition.
|
SqlIdentifier |
getDeclName() |
SqlKind |
getKind()
Returns the type of node this is, or
SqlKind.OTHER if it's nothing special. |
SqlNode |
getLowerBound() |
List<SqlNode> |
getOperandList() |
SqlOperator |
getOperator() |
SqlNodeList |
getOrderList() |
SqlNodeList |
getPartitionList() |
SqlIdentifier |
getRefName() |
SqlNode |
getUpperBound() |
SqlCall |
getWindowCall() |
boolean |
isAllowPartial()
Returns whether partial windows are allowed.
|
boolean |
isAlwaysNonEmpty()
Returns if the window is guaranteed to have rows.
|
static boolean |
isCurrentRow(SqlNode node)
Returns whether an expression represents the "CURRENT ROW" bound.
|
boolean |
isRows() |
static boolean |
isUnboundedFollowing(SqlNode node)
Returns whether an expression represents the "UNBOUNDED FOLLOWING" bound.
|
static boolean |
isUnboundedPreceding(SqlNode node)
Returns whether an expression represents the "UNBOUNDED PRECEDING" bound.
|
SqlWindow |
overlay(SqlWindow that,
SqlValidator validator)
Creates a new window by combining this one with another.
|
void |
populateBounds()
Fill in missing bounds.
|
void |
setDeclName(SqlIdentifier declName) |
void |
setLowerBound(SqlNode lowerBound) |
void |
setOperand(int i,
SqlNode operand)
Changes the value of an operand.
|
void |
setUpperBound(SqlNode upperBound) |
void |
setWindowCall(SqlCall windowCall) |
void |
unparse(SqlWriter writer,
int leftPrec,
int rightPrec)
Writes a SQL representation of this node to a writer.
|
void |
validate(SqlValidator validator,
SqlValidatorScope scope)
Validates this call.
|
accept, clone, findValidOptions, getCallSignature, getFunctionQuantifier, getMonotonicity, isCountStar, isExpanded, operand, operandCountclone, cloneArray, equalDeep, equalDeep, getParserPosition, isA, toSqlString, toSqlString, toString, validateExprpublic SqlWindow(SqlParserPos pos, SqlIdentifier declName, SqlIdentifier refName, SqlNodeList partitionList, SqlNodeList orderList, SqlLiteral isRows, SqlNode lowerBound, SqlNode upperBound, SqlLiteral allowPartial)
public static SqlWindow create(SqlIdentifier declName, SqlIdentifier refName, SqlNodeList partitionList, SqlNodeList orderList, SqlLiteral isRows, SqlNode lowerBound, SqlNode upperBound, SqlLiteral allowPartial, SqlParserPos pos)
public SqlOperator getOperator()
getOperator in class SqlCallpublic SqlKind getKind()
SqlNodeSqlKind.OTHER if it's nothing special.getKind in class SqlNodeSqlKind value, never nullSqlNode.isA(java.util.Set<org.apache.calcite.sql.SqlKind>)public List<SqlNode> getOperandList()
getOperandList in class SqlCallpublic void setOperand(int i,
SqlNode operand)
SqlCallSqlValidator; use sparingly.setOperand in class SqlCalli - Operand indexoperand - Operand valuepublic void unparse(SqlWriter writer, int leftPrec, int rightPrec)
SqlNodeThe leftPrec and rightPrec parameters give
us enough context to decide whether we need to enclose the expression in
parentheses. For example, we need parentheses around "2 + 3" if preceded
by "5 *". This is because the precedence of the "*" operator is greater
than the precedence of the "+" operator.
The algorithm handles left- and right-associative operators by giving them slightly different left- and right-precedence.
If SqlWriter.isAlwaysUseParentheses() is true, we use
parentheses even when they are not required by the precedence rules.
For the details of this algorithm, see SqlCall.unparse(org.apache.calcite.sql.SqlWriter, int, int).
public SqlIdentifier getDeclName()
public void setDeclName(SqlIdentifier declName)
public SqlNode getLowerBound()
public void setLowerBound(SqlNode lowerBound)
public SqlNode getUpperBound()
public void setUpperBound(SqlNode upperBound)
public boolean isAlwaysNonEmpty()
Window.Group.isAlwaysNonEmpty(),
SqlOperatorBinding.getGroupCount(),
SqlValidatorImpl.resolveWindow(SqlNode, org.apache.calcite.sql.validate.SqlValidatorScope, boolean)public boolean isRows()
public SqlNodeList getOrderList()
public SqlNodeList getPartitionList()
public SqlIdentifier getRefName()
public void setWindowCall(SqlCall windowCall)
public SqlCall getWindowCall()
public static SqlNode createCurrentRow(SqlParserPos pos)
public static SqlNode createUnboundedFollowing(SqlParserPos pos)
public static SqlNode createUnboundedPreceding(SqlParserPos pos)
public static SqlNode createFollowing(SqlNode e, SqlParserPos pos)
public static SqlNode createPreceding(SqlNode e, SqlParserPos pos)
public static SqlNode createBound(SqlLiteral range)
public static boolean isCurrentRow(SqlNode node)
public static boolean isUnboundedPreceding(SqlNode node)
public static boolean isUnboundedFollowing(SqlNode node)
public SqlWindow overlay(SqlWindow that, SqlValidator validator)
For example,
WINDOW (w PARTITION BY x ORDER BY y) overlay WINDOW w AS (PARTITION BY z)yields
WINDOW (PARTITION BY z ORDER BY y)
Does not alter this or the other window.
public boolean equalsDeep(SqlNode node, boolean fail)
equalsDeep in class SqlCallnode - The SqlWindow to compare to "this" windowfail - Whether to throw if not equalpublic boolean isAllowPartial()
public void validate(SqlValidator validator, SqlValidatorScope scope)
SqlCallThe default implementation delegates the validation to the operator's
SqlOperator.validateCall(org.apache.calcite.sql.SqlCall, org.apache.calcite.sql.validate.SqlValidator, org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.validate.SqlValidatorScope). Derived classes may override (as do,
for example SqlSelect and SqlUpdate).
public SqlWindow createCurrentRowWindow(String columnName)
(RANGE columnName CURRENT ROW).columnName - Order columnpublic SqlWindow createUnboundedPrecedingWindow(String columnName)
(RANGE columnName UNBOUNDED
PRECEDING).columnName - Order columnpublic void populateBounds()
Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.