Class SqlSelect
- java.lang.Object
-
- org.apache.calcite.sql.SqlNode
-
- org.apache.calcite.sql.SqlCall
-
- org.apache.calcite.sql.SqlSelect
-
- All Implemented Interfaces:
java.lang.Cloneable
public class SqlSelect extends SqlCall
ASqlSelect
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.
-
-
Field Summary
Fields Modifier and Type Field 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
-
Fields inherited from class org.apache.calcite.sql.SqlNode
EMPTY_ARRAY, pos
-
-
Constructor Summary
Constructors Constructor Description SqlSelect(SqlParserPos pos, SqlNodeList keywordList, SqlNodeList selectList, SqlNode from, SqlNode where, SqlNodeList groupBy, SqlNode having, SqlNodeList windowDecls, SqlNodeList orderBy, SqlNode offset, SqlNode fetch)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SqlNode
getFetch()
SqlNode
getFrom()
SqlNodeList
getGroup()
SqlNode
getHaving()
SqlKind
getKind()
Returns the type of node this is, orSqlKind.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.-
Methods inherited from class org.apache.calcite.sql.SqlCall
accept, clone, equalsDeep, findValidOptions, getCallSignature, getFunctionQuantifier, getMonotonicity, isCountStar, isExpanded, operand, operandCount
-
Methods inherited from class org.apache.calcite.sql.SqlNode
clone, clone, cloneArray, equalDeep, equalDeep, equalsDeep, getParserPosition, isA, toSqlString, toSqlString, toString, validateExpr
-
-
-
-
Field Detail
-
FROM_OPERAND
public static final int FROM_OPERAND
- See Also:
- Constant Field Values
-
WHERE_OPERAND
public static final int WHERE_OPERAND
- See Also:
- Constant Field Values
-
HAVING_OPERAND
public static final int HAVING_OPERAND
- See Also:
- Constant Field Values
-
keywordList
SqlNodeList keywordList
-
selectList
SqlNodeList selectList
-
from
SqlNode from
-
where
SqlNode where
-
groupBy
SqlNodeList groupBy
-
having
SqlNode having
-
windowDecls
SqlNodeList windowDecls
-
orderBy
SqlNodeList orderBy
-
offset
SqlNode offset
-
fetch
SqlNode fetch
-
-
Constructor Detail
-
SqlSelect
public SqlSelect(SqlParserPos pos, SqlNodeList keywordList, SqlNodeList selectList, SqlNode from, SqlNode where, SqlNodeList groupBy, SqlNode having, SqlNodeList windowDecls, SqlNodeList orderBy, SqlNode offset, SqlNode fetch)
-
-
Method Detail
-
getOperator
public SqlOperator getOperator()
- Specified by:
getOperator
in classSqlCall
-
getKind
public SqlKind getKind()
Description copied from class:SqlNode
Returns the type of node this is, orSqlKind.OTHER
if it's nothing special.- Overrides:
getKind
in classSqlCall
- Returns:
- a
SqlKind
value, never null - See Also:
SqlNode.isA(java.util.Set<org.apache.calcite.sql.SqlKind>)
-
getOperandList
public java.util.List<SqlNode> getOperandList()
- Specified by:
getOperandList
in classSqlCall
-
setOperand
public void setOperand(int i, SqlNode operand)
Description copied from class:SqlCall
Changes the value of an operand. Allows some rewrite bySqlValidator
; use sparingly.- Overrides:
setOperand
in classSqlCall
- Parameters:
i
- Operand indexoperand
- Operand value
-
isDistinct
public final boolean isDistinct()
-
getModifierNode
public final SqlNode getModifierNode(SqlSelectKeyword modifier)
-
getFrom
public final SqlNode getFrom()
-
setFrom
public void setFrom(SqlNode from)
-
getGroup
public final SqlNodeList getGroup()
-
setGroupBy
public void setGroupBy(SqlNodeList groupBy)
-
getHaving
public final SqlNode getHaving()
-
setHaving
public void setHaving(SqlNode having)
-
getSelectList
public final SqlNodeList getSelectList()
-
setSelectList
public void setSelectList(SqlNodeList selectList)
-
getWhere
public final SqlNode getWhere()
-
setWhere
public void setWhere(SqlNode whereClause)
-
getWindowList
@Nonnull public final SqlNodeList getWindowList()
-
getOrderList
public final SqlNodeList getOrderList()
-
setOrderBy
public void setOrderBy(SqlNodeList orderBy)
-
getOffset
public final SqlNode getOffset()
-
setOffset
public void setOffset(SqlNode offset)
-
getFetch
public final SqlNode getFetch()
-
setFetch
public void setFetch(SqlNode fetch)
-
validate
public void validate(SqlValidator validator, SqlValidatorScope scope)
Description copied from class:SqlCall
Validates this call.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 exampleSqlSelect
andSqlUpdate
).
-
unparse
public void unparse(SqlWriter writer, int leftPrec, int rightPrec)
Description copied from class:SqlNode
Writes a SQL representation of this node to a writer.The
leftPrec
andrightPrec
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)
.
-
hasOrderBy
public boolean hasOrderBy()
-
hasWhere
public boolean hasWhere()
-
isKeywordPresent
public boolean isKeywordPresent(SqlSelectKeyword targetKeyWord)
-
-