Package org.apache.calcite.sql
Class SqlSelectOperator
- java.lang.Object
-
- org.apache.calcite.sql.SqlOperator
-
- org.apache.calcite.sql.SqlSelectOperator
-
public class SqlSelectOperator extends SqlOperator
An operator describing a query. (Not a query itself.)Operands are:
- 0: distinct (
SqlLiteral
) - 1: selectClause (
SqlNodeList
) - 2: fromClause (
SqlCall
to "join" operator) - 3: whereClause (
SqlNode
) - 4: havingClause (
SqlNode
) - 5: groupClause (
SqlNode
) - 6: windowClause (
SqlNodeList
) - 7: orderClause (
SqlNode
)
- 0: distinct (
-
-
Field Summary
Fields Modifier and Type Field Description static SqlSelectOperator
INSTANCE
-
Fields inherited from class org.apache.calcite.sql.SqlOperator
kind, MDX_PRECEDENCE, NL
-
-
Constructor Summary
Constructors Modifier Constructor Description private
SqlSelectOperator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> void
acceptCall(SqlVisitor<R> visitor, SqlCall call, boolean onlyExpressions, SqlBasicVisitor.ArgHandler<R> argHandler)
Accepts aSqlVisitor
, directing anSqlBasicVisitor.ArgHandler
to visit an operand of a call.boolean
argumentMustBeScalar(int ordinal)
Returns whether theordinal
th argument to this operator must be scalar (as opposed to a query).SqlCall
createCall(SqlLiteral functionQualifier, SqlParserPos pos, SqlNode... operands)
Creates a call to this operand with an array of operands.SqlSelect
createCall(SqlNodeList keywordList, SqlNodeList selectList, SqlNode fromClause, SqlNode whereClause, SqlNodeList groupBy, SqlNode having, SqlNodeList windowDecls, SqlNodeList orderBy, SqlNode offset, SqlNode fetch, SqlParserPos pos)
Creates a call to theSELECT
operator.SqlSyntax
getSyntax()
Returns the syntactic type of this operator, never null.void
unparse(SqlWriter writer, SqlCall call, 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.-
Methods inherited from class org.apache.calcite.sql.SqlOperator
acceptCall, adjustType, allowsFraming, checkOperandCount, checkOperandTypes, constructArgNameList, constructArgTypeList, constructOperandList, createCall, createCall, createCall, deriveType, equals, getAllowedSignatures, getAllowedSignatures, getKind, getLeftPrec, getMonotonicity, getMonotonicity, getName, getNameAsId, getOperandCountRange, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, getSignatureTemplate, hashCode, inferReturnType, inferReturnType, isAggregator, isDeterministic, isDynamicFunction, isGroup, isGroupAuxiliary, isName, leftPrec, needsSpace, preValidateCall, requiresDecimalExpansion, requiresOrder, requiresOver, rewriteCall, rightPrec, toString, unparseListClause, unparseListClause, validateCall, validateOperands, validRexOperands
-
-
-
-
Field Detail
-
INSTANCE
public static final SqlSelectOperator INSTANCE
-
-
Method Detail
-
getSyntax
public SqlSyntax getSyntax()
Description copied from class:SqlOperator
Returns the syntactic type of this operator, never null.- Specified by:
getSyntax
in classSqlOperator
-
createCall
public SqlCall createCall(SqlLiteral functionQualifier, SqlParserPos pos, SqlNode... operands)
Description copied from class:SqlOperator
Creates a call to this operand with an array of operands.The position of the resulting call is the union of the
pos
and the positions of all of the operands.- Overrides:
createCall
in classSqlOperator
- Parameters:
functionQualifier
- function qualifier (e.g. "DISTINCT"), may bepos
- parser position of the identifier of the calloperands
- array of operands
-
createCall
public SqlSelect createCall(SqlNodeList keywordList, SqlNodeList selectList, SqlNode fromClause, SqlNode whereClause, SqlNodeList groupBy, SqlNode having, SqlNodeList windowDecls, SqlNodeList orderBy, SqlNode offset, SqlNode fetch, SqlParserPos pos)
Creates a call to theSELECT
operator.- Parameters:
keywordList
- List of keywords such DISTINCT and ALL, or nullselectList
- The SELECT clause, or null if emptyfromClause
- The FROM clausewhereClause
- The WHERE clause, or null if not presentgroupBy
- The GROUP BY clause, or null if not presenthaving
- The HAVING clause, or null if not presentwindowDecls
- The WINDOW clause, or null if not presentorderBy
- The ORDER BY clause, or null if not presentoffset
- Expression for number of rows to discard before returning first rowfetch
- Expression for number of rows to fetchpos
- The parser position, orSqlParserPos.ZERO
if not specified; must not be null.- Returns:
- A
SqlSelect
, never null
-
acceptCall
public <R> void acceptCall(SqlVisitor<R> visitor, SqlCall call, boolean onlyExpressions, SqlBasicVisitor.ArgHandler<R> argHandler)
Description copied from class:SqlOperator
Accepts aSqlVisitor
, directing anSqlBasicVisitor.ArgHandler
to visit an operand of a call.The argument handler allows fine control about how the operands are visited, and how the results are combined.
- Overrides:
acceptCall
in classSqlOperator
- Parameters:
visitor
- Visitorcall
- Call to visitonlyExpressions
- If true, ignores operands which are not expressions. For example, in the call to theAS
operatorargHandler
- Called for each operand
-
unparse
public void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec)
Description copied from class:SqlOperator
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.The default implementation of this method delegates to
SqlSyntax.unparse(org.apache.calcite.sql.SqlWriter, org.apache.calcite.sql.SqlOperator, org.apache.calcite.sql.SqlCall, int, int)
.- Overrides:
unparse
in classSqlOperator
-
argumentMustBeScalar
public boolean argumentMustBeScalar(int ordinal)
Description copied from class:SqlOperator
Returns whether theordinal
th argument to this operator must be scalar (as opposed to a query).If true (the default), the validator will attempt to convert the argument into a scalar sub-query, which must have one column and return at most one row.
Operators such as
SELECT
andEXISTS
override this method.- Overrides:
argumentMustBeScalar
in classSqlOperator
-
-