public class SqlSelect extends SqlCall
SqlSelect
is a node of a parse tree which represents a select
statement. It warrants its own node type just because we have a lot of
methods to put somewhere.Modifier and Type | Field and Description |
---|---|
(package private) SqlNode |
fetch |
(package private) SqlNode |
from |
static int |
FROM_OPERAND |
(package private) SqlNodeList |
groupBy |
(package private) SqlNode |
having |
static int |
HAVING_OPERAND |
(package private) SqlNodeList |
keywordList |
(package private) SqlNode |
offset |
(package private) SqlNodeList |
orderBy |
(package private) SqlNodeList |
selectList |
(package private) SqlNode |
where |
static int |
WHERE_OPERAND |
(package private) SqlNodeList |
windowDecls |
EMPTY_ARRAY, pos
Constructor and Description |
---|
SqlSelect(SqlParserPos pos,
SqlNodeList keywordList,
SqlNodeList selectList,
SqlNode from,
SqlNode where,
SqlNodeList groupBy,
SqlNode having,
SqlNodeList windowDecls,
SqlNodeList orderBy,
SqlNode offset,
SqlNode fetch) |
Modifier and Type | Method and Description |
---|---|
SqlNode |
getFetch() |
SqlNode |
getFrom() |
SqlNodeList |
getGroup() |
SqlNode |
getHaving() |
SqlKind |
getKind()
Returns the type of node this is, or
SqlKind.OTHER if it's nothing special. |
SqlNode |
getModifierNode(SqlSelectKeyword modifier) |
SqlNode |
getOffset() |
java.util.List<SqlNode> |
getOperandList() |
SqlOperator |
getOperator() |
SqlNodeList |
getOrderList() |
SqlNodeList |
getSelectList() |
SqlNode |
getWhere() |
SqlNodeList |
getWindowList() |
boolean |
hasOrderBy() |
boolean |
hasWhere() |
boolean |
isDistinct() |
boolean |
isKeywordPresent(SqlSelectKeyword targetKeyWord) |
void |
setFetch(SqlNode fetch) |
void |
setFrom(SqlNode from) |
void |
setGroupBy(SqlNodeList groupBy) |
void |
setHaving(SqlNode having) |
void |
setOffset(SqlNode offset) |
void |
setOperand(int i,
SqlNode operand)
Changes the value of an operand.
|
void |
setOrderBy(SqlNodeList orderBy) |
void |
setSelectList(SqlNodeList selectList) |
void |
setWhere(SqlNode whereClause) |
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, equalsDeep, findValidOptions, getCallSignature, getFunctionQuantifier, getMonotonicity, isCountStar, isExpanded, operand, operandCount
clone, clone, cloneArray, equalDeep, equalDeep, equalsDeep, getParserPosition, isA, toSqlString, toSqlString, toString, validateExpr
public static final int FROM_OPERAND
public static final int WHERE_OPERAND
public static final int HAVING_OPERAND
SqlNodeList keywordList
SqlNodeList selectList
SqlNode from
SqlNode where
SqlNodeList groupBy
SqlNode having
SqlNodeList windowDecls
SqlNodeList orderBy
SqlNode offset
SqlNode fetch
public SqlSelect(SqlParserPos pos, SqlNodeList keywordList, SqlNodeList selectList, SqlNode from, SqlNode where, SqlNodeList groupBy, SqlNode having, SqlNodeList windowDecls, SqlNodeList orderBy, SqlNode offset, SqlNode fetch)
public SqlOperator getOperator()
getOperator
in class SqlCall
public SqlKind getKind()
SqlNode
SqlKind.OTHER
if it's nothing special.getKind
in class SqlCall
SqlKind
value, never nullSqlNode.isA(java.util.Set<org.apache.calcite.sql.SqlKind>)
public java.util.List<SqlNode> getOperandList()
getOperandList
in class SqlCall
public void setOperand(int i, SqlNode operand)
SqlCall
SqlValidator
; use sparingly.setOperand
in class SqlCall
i
- Operand indexoperand
- Operand valuepublic final boolean isDistinct()
public final SqlNode getModifierNode(SqlSelectKeyword modifier)
public final SqlNode getFrom()
public void setFrom(SqlNode from)
public final SqlNodeList getGroup()
public void setGroupBy(SqlNodeList groupBy)
public final SqlNode getHaving()
public void setHaving(SqlNode having)
public final SqlNodeList getSelectList()
public void setSelectList(SqlNodeList selectList)
public final SqlNode getWhere()
public void setWhere(SqlNode whereClause)
@Nonnull public final SqlNodeList getWindowList()
public final SqlNodeList getOrderList()
public void setOrderBy(SqlNodeList orderBy)
public final SqlNode getOffset()
public void setOffset(SqlNode offset)
public final SqlNode getFetch()
public void setFetch(SqlNode fetch)
public void validate(SqlValidator validator, SqlValidatorScope scope)
SqlCall
The 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 void unparse(SqlWriter writer, int leftPrec, int rightPrec)
SqlNode
The 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 boolean hasOrderBy()
public boolean hasWhere()
public boolean isKeywordPresent(SqlSelectKeyword targetKeyWord)
Copyright © 2012–2019 The Apache Software Foundation. All rights reserved.