Package org.apache.calcite.sql.fun
Class SqlCase
- java.lang.Object
-
- org.apache.calcite.sql.SqlNode
-
- org.apache.calcite.sql.SqlCall
-
- org.apache.calcite.sql.fun.SqlCase
-
- All Implemented Interfaces:
java.lang.Cloneable
public class SqlCase extends SqlCall
ASqlCase
is a node of a parse tree which represents a case 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
elseExpr
(package private) SqlNodeList
thenList
(package private) SqlNode
value
(package private) SqlNodeList
whenList
-
Fields inherited from class org.apache.calcite.sql.SqlNode
EMPTY_ARRAY, pos
-
-
Constructor Summary
Constructors Constructor Description SqlCase(SqlParserPos pos, SqlNode value, SqlNodeList whenList, SqlNodeList thenList, SqlNode elseExpr)
Creates a SqlCase expression.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SqlCase
createSwitched(SqlParserPos pos, SqlNode value, SqlNodeList whenList, SqlNodeList thenList, SqlNode elseClause)
Creates a call to the switched form of the case operator, viz:CASE value
WHEN whenList[0] THEN thenList[0]
WHEN whenList[1] THEN thenList[1]
...
ELSE elseClause
ENDSqlNode
getElseOperand()
SqlKind
getKind()
Returns the type of node this is, orSqlKind.OTHER
if it's nothing special.java.util.List<SqlNode>
getOperandList()
SqlOperator
getOperator()
SqlNodeList
getThenOperands()
SqlNode
getValueOperand()
SqlNodeList
getWhenOperands()
void
setOperand(int i, SqlNode operand)
Changes the value of an operand.-
Methods inherited from class org.apache.calcite.sql.SqlCall
accept, clone, equalsDeep, findValidOptions, getCallSignature, getFunctionQuantifier, getMonotonicity, isCountStar, isExpanded, operand, operandCount, unparse, validate
-
Methods inherited from class org.apache.calcite.sql.SqlNode
clone, clone, cloneArray, equalDeep, equalDeep, equalsDeep, getParserPosition, isA, toSqlString, toSqlString, toString, validateExpr
-
-
-
-
Field Detail
-
value
SqlNode value
-
whenList
SqlNodeList whenList
-
thenList
SqlNodeList thenList
-
elseExpr
SqlNode elseExpr
-
-
Constructor Detail
-
SqlCase
public SqlCase(SqlParserPos pos, SqlNode value, SqlNodeList whenList, SqlNodeList thenList, SqlNode elseExpr)
Creates a SqlCase expression.- Parameters:
pos
- Parser positionvalue
- The value (null for boolean case)whenList
- List of all WHEN expressionsthenList
- List of all THEN expressionselseExpr
- The implicit or explicit ELSE expression
-
-
Method Detail
-
createSwitched
public static SqlCase createSwitched(SqlParserPos pos, SqlNode value, SqlNodeList whenList, SqlNodeList thenList, SqlNode elseClause)
Creates a call to the switched form of the case operator, viz:CASE value
WHEN whenList[0] THEN thenList[0]
WHEN whenList[1] THEN thenList[1]
...
ELSE elseClause
END
-
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>)
-
getOperator
public SqlOperator getOperator()
- Specified by:
getOperator
in classSqlCall
-
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
-
getValueOperand
public SqlNode getValueOperand()
-
getWhenOperands
public SqlNodeList getWhenOperands()
-
getThenOperands
public SqlNodeList getThenOperands()
-
getElseOperand
public SqlNode getElseOperand()
-
-