org.eigenbase.sql
Class SqlMerge
java.lang.Object
org.eigenbase.sql.SqlNode
org.eigenbase.sql.SqlCall
org.eigenbase.sql.SqlMerge
- All Implemented Interfaces:
- Cloneable
public class SqlMerge
- extends SqlCall
A SqlMerge
is a node of a parse tree which represents a MERGE
statement.
Methods inherited from class org.eigenbase.sql.SqlCall |
accept, clone, equalsDeep, findValidOptions, getCallSignature, getFunctionQuantifier, getKind, getMonotonicity, getOperands, getOperator, isA, isCountStar, isExpanded, isName, setOperand, setOperator |
TARGET_TABLE_OPERAND
public static final int TARGET_TABLE_OPERAND
- See Also:
- Constant Field Values
SOURCE_TABLEREF_OPERAND
public static final int SOURCE_TABLEREF_OPERAND
- See Also:
- Constant Field Values
CONDITION_OPERAND
public static final int CONDITION_OPERAND
- See Also:
- Constant Field Values
UPDATE_OPERAND
public static final int UPDATE_OPERAND
- See Also:
- Constant Field Values
INSERT_OPERAND
public static final int INSERT_OPERAND
- See Also:
- Constant Field Values
SOURCE_SELECT_OPERAND
public static final int SOURCE_SELECT_OPERAND
- See Also:
- Constant Field Values
ALIAS_OPERAND
public static final int ALIAS_OPERAND
- See Also:
- Constant Field Values
OPERAND_COUNT
public static final int OPERAND_COUNT
- See Also:
- Constant Field Values
SqlMerge
public SqlMerge(SqlSpecialOperator operator,
SqlIdentifier targetTable,
SqlNode condition,
SqlNode source,
SqlNode updateCall,
SqlNode insertCall,
SqlIdentifier alias,
SqlParserPos pos)
getTargetTable
public SqlIdentifier getTargetTable()
- Returns:
- the identifier for the target table of the merge
getAlias
public SqlIdentifier getAlias()
- Returns:
- the alias for the target table of the merge
getSourceTableRef
public SqlNode getSourceTableRef()
- Returns:
- the source for the merge
setSourceTableRef
public void setSourceTableRef(SqlNode tableRef)
getUpdateCall
public SqlUpdate getUpdateCall()
- Returns:
- the update statement for the merge
getInsertCall
public SqlInsert getInsertCall()
- Returns:
- the insert statement for the merge
getCondition
public SqlNode getCondition()
- Returns:
- the condition expression to determine whether to update or insert
getSourceSelect
public SqlSelect getSourceSelect()
- Gets the source SELECT expression for the data to be updated/inserted.
Returns null before the statement has been expanded by
SqlValidator.performUnconditionalRewrites.
- Returns:
- the source SELECT for the data to be updated
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 writerleftPrec
- The precedence of the SqlNode
immediately
preceding this node in a depth-first scan of the parse treerightPrec
- The precedence of the SqlNode
immediately
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