Package org.apache.calcite.rel.core
Class TableModify
java.lang.Object
org.apache.calcite.rel.AbstractRelNode
org.apache.calcite.rel.SingleRel
org.apache.calcite.rel.core.TableModify
- All Implemented Interfaces:
Cloneable,RelOptNode,RelNode
- Direct Known Subclasses:
EnumerableTableModify,JdbcRules.JdbcTableModify,LogicalTableModify
Relational expression that modifies a table.
It is similar to TableScan,
but represents a request to modify a table rather than read from it.
It takes one child which produces the modified rows. Those rows are:
- For
INSERT, those rows are the new values; - for
DELETE, the old values; - for
UPDATE, all old values plus updated new values; - for
MERGE, the rows may contain fields for bothINSERTandUPDATEoperations, depending on the clauses specified:- If only `WHEN MATCHED THEN UPDATE` is specified, the row contains all old values plus
updated new values (like
UPDATE). - If only `WHEN NOT MATCHED THEN INSERT` is specified, the row contains new values to be
inserted (like
INSERT). - If both `WHEN MATCHED THEN UPDATE` and `WHEN NOT MATCHED THEN INSERT` are specified, the row contains: new values to be inserted, all old values, updated new values.
- If only `WHEN MATCHED THEN UPDATE` is specified, the row contains all old values plus
updated new values (like
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration of supported modification operations.Nested classes/interfaces inherited from interface org.apache.calcite.rel.RelNode
RelNode.Context -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Prepare.CatalogReaderThe connection to the optimizing session.protected final RelOptTableThe table definition.Fields inherited from class org.apache.calcite.rel.AbstractRelNode
digest, id, rowType, traitSet -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTableModify(RelOptCluster cluster, RelTraitSet traitSet, RelOptTable table, Prepare.CatalogReader catalogReader, RelNode input, TableModify.Operation operation, @Nullable List<String> updateColumnList, @Nullable List<RexNode> sourceExpressionList, boolean flattened) Creates aTableModify.protectedTableModify(RelInput input) Creates a TableModify by parsing serialized output. -
Method Summary
Modifier and TypeMethodDescription@Nullable RelOptCostcomputeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) Returns the cost of this plan (not including children).Describes the inputs and attributes of this relational expression.getExpectedInputRowType(int ordinalInParent) Returns the type of the rows expected for an input.getTable()If this relational expression represents an access to a table, returns that table, otherwise returns null.booleanisDelete()booleanbooleanisInsert()booleanisMerge()booleanisUpdate()Methods inherited from class org.apache.calcite.rel.SingleRel
childrenAccept, estimateRowCount, getInput, getInputs, replaceInputMethods inherited from class org.apache.calcite.rel.AbstractRelNode
accept, accept, collectVariablesSet, collectVariablesUsed, copy, deepEquals, deepHashCode, equals, explain, getCluster, getConvention, getCorrelVariable, getDescription, getDigest, getId, getInput, getRelDigest, getRelTypeName, getRowType, getTraitSet, getVariablesSet, hashCode, isEnforcer, isValid, metadata, onRegister, recomputeDigest, register, sole, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.calcite.rel.RelNode
explain, fieldIsNullable, stripped
-
Field Details
-
catalogReader
The connection to the optimizing session. -
table
The table definition.
-
-
Constructor Details
-
TableModify
protected TableModify(RelOptCluster cluster, RelTraitSet traitSet, RelOptTable table, Prepare.CatalogReader catalogReader, RelNode input, TableModify.Operation operation, @Nullable List<String> updateColumnList, @Nullable List<RexNode> sourceExpressionList, boolean flattened) Creates aTableModify.The UPDATE operation has format like this:
UPDATE table SET iden1 = exp1, ident2 = exp2 WHERE condition
- Parameters:
cluster- Cluster this relational expression belongs totraitSet- Traits of this relational expressiontable- Target table to modifycatalogReader- accessor to the table metadata.input- Sub-query or filter conditionoperation- Modify operation (INSERT, UPDATE, DELETE)updateColumnList- List of column identifiers to be updated (e.g. ident1, ident2); null if not UPDATEsourceExpressionList- List of value expressions to be set (e.g. exp1, exp2); null if not UPDATEflattened- Whether set flattens the input row type
-
TableModify
Creates a TableModify by parsing serialized output.
-
-
Method Details
-
getCatalogReader
-
getTable
Description copied from interface:RelNodeIf this relational expression represents an access to a table, returns that table, otherwise returns null.- Specified by:
getTablein interfaceRelNode- Overrides:
getTablein classAbstractRelNode- Returns:
- If this relational expression represents an access to a table, returns that table, otherwise returns null
-
getUpdateColumnList
-
getSourceExpressionList
-
isFlattened
public boolean isFlattened() -
getOperation
-
isInsert
public boolean isInsert() -
isUpdate
public boolean isUpdate() -
isDelete
public boolean isDelete() -
isMerge
public boolean isMerge() -
deriveRowType
- Overrides:
deriveRowTypein classSingleRel
-
getExpectedInputRowType
Description copied from interface:RelNodeReturns the type of the rows expected for an input. Defaults toRelNode.getRowType().- Specified by:
getExpectedInputRowTypein interfaceRelNode- Overrides:
getExpectedInputRowTypein classAbstractRelNode- Parameters:
ordinalInParent- input's 0-based ordinal with respect to this parent rel- Returns:
- expected row type
-
explainTerms
Description copied from class:AbstractRelNodeDescribes the inputs and attributes of this relational expression. Each node should callsuper.explainTerms, then call theRelWriter.input(String, RelNode)andRelWriter.item(String, Object)methods for each input and attribute.- Overrides:
explainTermsin classSingleRel- Parameters:
pw- Plan writer- Returns:
- Plan writer for fluent-explain pattern
-
computeSelfCost
Description copied from interface:RelNodeReturns the cost of this plan (not including children). The base implementation throws an error; derived classes should override.NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use
RelMetadataQuery.getNonCumulativeCost(org.apache.calcite.rel.RelNode), which gives plugins a chance to override the rel's default ideas about cost.- Specified by:
computeSelfCostin interfaceRelNode- Overrides:
computeSelfCostin classAbstractRelNode- Parameters:
planner- Planner for cost calculationmq- Metadata query- Returns:
- Cost of this plan (not including children)
-