org.eigenbase.sql
Class SqlSelect

java.lang.Object
  extended by org.eigenbase.sql.SqlNode
      extended by org.eigenbase.sql.SqlCall
          extended by org.eigenbase.sql.SqlSelect
All Implemented Interfaces:
Cloneable

public class SqlSelect
extends SqlCall

A 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.


Field Summary
static int FROM_OPERAND
           
static int GROUP_OPERAND
           
static int HAVING_OPERAND
           
static int KEYWORDS_OPERAND
           
static int OPERAND_COUNT
           
static int ORDER_OPERAND
           
static int SELECT_OPERAND
           
static int WHERE_OPERAND
           
static int WINDOW_OPERAND
           
 
Fields inherited from class org.eigenbase.sql.SqlCall
operands
 
Fields inherited from class org.eigenbase.sql.SqlNode
emptyArray
 
Constructor Summary
SqlSelect(SqlSelectOperator operator, SqlNode[] operands, SqlParserPos pos)
           
 
Method Summary
 void addFrom(SqlIdentifier tableId)
           
 void addWhere(SqlNode condition)
           
 SqlNode getFrom()
           
 SqlNodeList getGroup()
           
 SqlNode getHaving()
           
 SqlNode getModifierNode(SqlSelectKeyword modifier)
           
 SqlNodeList getOrderList()
           
 SqlNodeList getSelectList()
           
 SqlNode getWhere()
           
 SqlNodeList getWindowList()
           
 boolean hasOrderBy()
           
 boolean hasWhere()
           
 boolean isDistinct()
           
 boolean isKeywordPresent(SqlSelectKeyword targetKeyWord)
           
 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.eigenbase.sql.SqlCall
accept, clone, equalsDeep, findValidOptions, getCallSignature, getFunctionQuantifier, getKind, getMonotonicity, getOperands, getOperator, isA, isCountStar, isExpanded, isName, setOperand, setOperator
 
Methods inherited from class org.eigenbase.sql.SqlNode
clone, cloneArray, equalDeep, getParserPosition, toSqlString, toSqlString, toString, validateExpr
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEYWORDS_OPERAND

public static final int KEYWORDS_OPERAND
See Also:
Constant Field Values

SELECT_OPERAND

public static final int SELECT_OPERAND
See Also:
Constant Field Values

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

GROUP_OPERAND

public static final int GROUP_OPERAND
See Also:
Constant Field Values

HAVING_OPERAND

public static final int HAVING_OPERAND
See Also:
Constant Field Values

WINDOW_OPERAND

public static final int WINDOW_OPERAND
See Also:
Constant Field Values

ORDER_OPERAND

public static final int ORDER_OPERAND
See Also:
Constant Field Values

OPERAND_COUNT

public static final int OPERAND_COUNT
See Also:
Constant Field Values
Constructor Detail

SqlSelect

SqlSelect(SqlSelectOperator operator,
          SqlNode[] operands,
          SqlParserPos pos)
Method Detail

isDistinct

public final boolean isDistinct()

getModifierNode

public final SqlNode getModifierNode(SqlSelectKeyword modifier)

getFrom

public final SqlNode getFrom()

getGroup

public final SqlNodeList getGroup()

getHaving

public final SqlNode getHaving()

getSelectList

public final SqlNodeList getSelectList()

getWhere

public final SqlNode getWhere()

getWindowList

public final SqlNodeList getWindowList()

getOrderList

public final SqlNodeList getOrderList()

addFrom

public void addFrom(SqlIdentifier tableId)

addWhere

public void addWhere(SqlNode condition)

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.eigenbase.sql.SqlCall, org.eigenbase.sql.validate.SqlValidator, org.eigenbase.sql.validate.SqlValidatorScope, org.eigenbase.sql.validate.SqlValidatorScope). Derived classes may override (as do, for example SqlSelect and SqlUpdate).

Overrides:
validate in class SqlCall
scope - Validator

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 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.eigenbase.sql.SqlWriter, int, int).

Overrides:
unparse in class SqlCall
Parameters:
writer - Target writer
leftPrec - The precedence of the SqlNode immediately preceding this node in a depth-first scan of the parse tree
rightPrec - The precedence of the SqlNode immediately

hasOrderBy

public boolean hasOrderBy()

hasWhere

public boolean hasWhere()

isKeywordPresent

public boolean isKeywordPresent(SqlSelectKeyword targetKeyWord)