|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.sql.SqlOperator org.eigenbase.sql.SqlWindowOperator
public class SqlWindowOperator
An operator describing a window specification.
Operands are as follows:
SqlIdentifier
)SqlNodeList
)SqlNodeList
)SqlLiteral
)SqlNode
)SqlNode
)
Nested Class Summary | |
---|---|
(package private) static class |
SqlWindowOperator.Bound
An enumeration of types of bounds in a window: CURRENT ROW ,
UNBOUNDED PRECEDING , and UNBOUNDED FOLLOWING . |
static class |
SqlWindowOperator.OffsetRange
|
private static class |
SqlWindowOperator.ValSign
|
Field Summary | |
---|---|
(package private) static SqlPostfixOperator |
followingOperator
The FOLLOWING operator used exclusively in a window specification. |
(package private) static SqlPostfixOperator |
precedingOperator
The PRECEDING operator used exclusively in a window specification. |
Fields inherited from class org.eigenbase.sql.SqlOperator |
---|
MaxPrec, NL |
Constructor Summary | |
---|---|
SqlWindowOperator()
|
Method Summary | ||
---|---|---|
|
acceptCall(SqlVisitor<R> visitor,
SqlCall call,
boolean onlyExpressions,
SqlBasicVisitor.ArgHandler<R> argHandler)
Accepts a SqlVisitor , directing an SqlBasicVisitor.ArgHandler to visit operand of a
call. |
|
private static void |
checkSpecialLiterals(SqlWindow window,
SqlValidator validator)
|
|
static SqlNode |
createBound(SqlLiteral range)
|
|
SqlWindow |
createCall(SqlIdentifier declName,
SqlIdentifier refName,
SqlNodeList partitionList,
SqlNodeList orderList,
SqlLiteral isRows,
SqlNode lowerBound,
SqlNode upperBound,
SqlLiteral allowPartial,
SqlParserPos pos)
|
|
SqlCall |
createCall(SqlLiteral functionQualifier,
SqlParserPos pos,
SqlNode... operands)
Creates a call to this operand with an array of operands. |
|
static SqlNode |
createCurrentRow(SqlParserPos pos)
|
|
SqlWindow |
createCurrentRowWindow(String columnName)
Creates a window (RANGE columnName CURRENT ROW) . |
|
static SqlNode |
createFollowing(SqlLiteral literal,
SqlParserPos pos)
|
|
static SqlNode |
createPreceding(SqlLiteral literal,
SqlParserPos pos)
|
|
static SqlNode |
createUnboundedFollowing(SqlParserPos pos)
|
|
static SqlNode |
createUnboundedPreceding(SqlParserPos pos)
|
|
SqlWindow |
createUnboundedPrecedingWindow(String columnName)
Creates a window (RANGE columnName UNBOUNDED
PRECEDING) . |
|
static SqlWindowOperator.OffsetRange |
getOffsetAndRange(SqlNode lowerBound,
SqlNode upperBound,
boolean physical)
Converts a pair of bounds into a (range, offset) pair. |
|
private static SqlWindowOperator.ValSign |
getRangeOffset(SqlNode node,
SqlPostfixOperator op)
Decodes a node, representing an upper or lower bound to a window, into a range offset. |
|
SqlSyntax |
getSyntax()
Returns the syntactic type of this operator. |
|
static boolean |
isCurrentRow(SqlNode node)
Returns whether an expression represents the "CURRENT ROW" bound. |
|
private static boolean |
isTableSorted(SqlValidatorScope scope)
This method retrieves the list of columns for the current table then walks through the list looking for a column that is monotonic (sorted) |
|
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. |
|
void |
unparse(SqlWriter writer,
SqlNode[] operands,
int leftPrec,
int rightPrec)
Writes a SQL representation of a call to this operator to a writer, including parentheses if the operators on either side are of greater precedence. |
|
void |
validateCall(SqlCall call,
SqlValidator validator,
SqlValidatorScope scope,
SqlValidatorScope operandScope)
Validates a call to this operator. |
|
private void |
validateFrameBoundary(SqlNode bound,
boolean isRows,
SqlTypeFamily orderTypeFam,
SqlValidator validator,
SqlValidatorScope scope)
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
static final SqlPostfixOperator followingOperator
static final SqlPostfixOperator precedingOperator
Constructor Detail |
---|
public SqlWindowOperator()
Method Detail |
---|
public SqlSyntax getSyntax()
SqlOperator
getSyntax
in class SqlOperator
public SqlCall createCall(SqlLiteral functionQualifier, SqlParserPos pos, SqlNode... operands)
SqlOperator
The position of the resulting call is the union of the
pos
and the positions of all of the operands.
createCall
in class SqlOperator
functionQualifier
- function qualifier (e.g. "DISTINCT"), may bepos
- parser position of the identifier of the calloperands
- array of operandspublic SqlWindow createCall(SqlIdentifier declName, SqlIdentifier refName, SqlNodeList partitionList, SqlNodeList orderList, SqlLiteral isRows, SqlNode lowerBound, SqlNode upperBound, SqlLiteral allowPartial, SqlParserPos pos)
public <R> void acceptCall(SqlVisitor<R> visitor, SqlCall call, boolean onlyExpressions, SqlBasicVisitor.ArgHandler<R> argHandler)
SqlOperator
SqlVisitor
, directing an SqlBasicVisitor.ArgHandler
to visit operand of a
call. The argument handler allows fine control about how the operands are
visited, and how the results are combined.
acceptCall
in class SqlOperator
visitor
- Visitorcall
- Call to visitonlyExpressions
- If true, ignores operands which are not
expressions. For example, in the call to the AS
operatorargHandler
- Called for each operandpublic void unparse(SqlWriter writer, SqlNode[] operands, int leftPrec, int rightPrec)
SqlOperator
The default implementation of this method delegates to SqlSyntax.unparse(org.eigenbase.sql.SqlWriter, org.eigenbase.sql.SqlOperator, org.eigenbase.sql.SqlNode[], int, int)
.
unparse
in class SqlOperator
public void validateCall(SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope)
SqlOperator
This method should not perform type-derivation or perform validation
related related to types. That is done later, by SqlOperator.deriveType(SqlValidator, SqlValidatorScope, SqlCall)
. This method
should focus on structural validation.
A typical implementation of this method first validates the operands, then performs some operator-specific logic. The default implementation just validates the operands.
This method is the default implementation of SqlCall.validate(org.eigenbase.sql.validate.SqlValidator, org.eigenbase.sql.validate.SqlValidatorScope)
;
but note that some sub-classes of SqlCall
never call this method.
validateCall
in class SqlOperator
call
- the call to this operatorvalidator
- the active validatorscope
- validator scopeoperandScope
- validator scope in which to validate operands to this
call; usually equal to scope, but not always because some operators
introduce new scopesSqlNode.validateExpr(SqlValidator, SqlValidatorScope)
,
SqlOperator.deriveType(SqlValidator, SqlValidatorScope, SqlCall)
private void validateFrameBoundary(SqlNode bound, boolean isRows, SqlTypeFamily orderTypeFam, SqlValidator validator, SqlValidatorScope scope)
private static void checkSpecialLiterals(SqlWindow window, SqlValidator validator)
private static boolean isTableSorted(SqlValidatorScope scope)
public SqlWindow createCurrentRowWindow(String columnName)
(RANGE columnName CURRENT ROW)
.
columnName
- Order columnpublic SqlWindow createUnboundedPrecedingWindow(String columnName)
(RANGE columnName UNBOUNDED
PRECEDING)
.
columnName
- Order columnpublic static SqlNode createCurrentRow(SqlParserPos pos)
public static SqlNode createUnboundedFollowing(SqlParserPos pos)
public static SqlNode createUnboundedPreceding(SqlParserPos pos)
public static SqlNode createFollowing(SqlLiteral literal, SqlParserPos pos)
public static SqlNode createPreceding(SqlLiteral literal, 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 static SqlWindowOperator.OffsetRange getOffsetAndRange(SqlNode lowerBound, SqlNode upperBound, boolean physical)
If the upper bound is unbounded, returns null, since that cannot be represented as a (range, offset) pair. (The offset would be +infinity, but what would the range be?)
lowerBound
- Lower boundupperBound
- Upper boundphysical
- Whether interval is physical (rows), as opposed to
logical (values)
private static SqlWindowOperator.ValSign getRangeOffset(SqlNode node, SqlPostfixOperator op)
node
- Node representing window boundop
- Either precedingOperator
or followingOperator
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |