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:
java.lang.Cloneable
,RelOptNode
,RelNode
- Direct Known Subclasses:
EnumerableTableModify
,JdbcRules.JdbcTableModify
,LogicalTableModify
public abstract class TableModify extends SingleRel
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TableModify.Operation
Enumeration of supported modification operations.-
Nested classes/interfaces inherited from interface org.apache.calcite.rel.RelNode
RelNode.Context
-
-
Field Summary
Fields Modifier and Type Field Description protected Prepare.CatalogReader
catalogReader
The connection to the optimizing session.private boolean
flattened
private RelDataType
inputRowType
private TableModify.Operation
operation
private java.util.List<RexNode>
sourceExpressionList
protected RelOptTable
table
The table definition.private java.util.List<java.lang.String>
updateColumnList
-
Fields inherited from class org.apache.calcite.rel.AbstractRelNode
digest, id, rowType, traitSet
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TableModify(RelOptCluster cluster, RelTraitSet traitSet, RelOptTable table, Prepare.CatalogReader catalogReader, RelNode input, TableModify.Operation operation, java.util.List<java.lang.String> updateColumnList, java.util.List<RexNode> sourceExpressionList, boolean flattened)
Creates aTableModify
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RelOptCost
computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
Returns the cost of this plan (not including children).RelDataType
deriveRowType()
RelWriter
explainTerms(RelWriter pw)
Describes the inputs and attributes of this relational expression.Prepare.CatalogReader
getCatalogReader()
RelDataType
getExpectedInputRowType(int ordinalInParent)
Returns the type of the rows expected for an input.TableModify.Operation
getOperation()
java.util.List<RexNode>
getSourceExpressionList()
RelOptTable
getTable()
If this relational expression represents an access to a table, returns that table, otherwise returns null.java.util.List<java.lang.String>
getUpdateColumnList()
boolean
isDelete()
boolean
isFlattened()
boolean
isInsert()
boolean
isMerge()
boolean
isUpdate()
-
Methods inherited from class org.apache.calcite.rel.SingleRel
childrenAccept, estimateRowCount, getInput, getInputs, replaceInput
-
Methods inherited from class org.apache.calcite.rel.AbstractRelNode
accept, accept, collectVariablesSet, collectVariablesUsed, computeDigest, computeSelfCost, copy, explain, getChildExps, getCluster, getCollationList, getConvention, getCorrelVariable, getDescription, getDigest, getId, getInput, getQuery, getRelTypeName, getRows, getRowType, getTraitSet, getVariablesSet, getVariablesStopped, isDistinct, isKey, isValid, isValid, metadata, onRegister, recomputeDigest, register, sole, toString
-
-
-
-
Field Detail
-
catalogReader
protected Prepare.CatalogReader catalogReader
The connection to the optimizing session.
-
table
protected final RelOptTable table
The table definition.
-
operation
private final TableModify.Operation operation
-
updateColumnList
private final java.util.List<java.lang.String> updateColumnList
-
sourceExpressionList
private final java.util.List<RexNode> sourceExpressionList
-
inputRowType
private RelDataType inputRowType
-
flattened
private final boolean flattened
-
-
Constructor Detail
-
TableModify
protected TableModify(RelOptCluster cluster, RelTraitSet traitSet, RelOptTable table, Prepare.CatalogReader catalogReader, RelNode input, TableModify.Operation operation, java.util.List<java.lang.String> updateColumnList, java.util.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
-
-
Method Detail
-
getCatalogReader
public Prepare.CatalogReader getCatalogReader()
-
getTable
public RelOptTable getTable()
Description copied from interface:RelNode
If this relational expression represents an access to a table, returns that table, otherwise returns null.- Specified by:
getTable
in interfaceRelNode
- Overrides:
getTable
in classAbstractRelNode
- Returns:
- If this relational expression represents an access to a table, returns that table, otherwise returns null
-
getUpdateColumnList
public java.util.List<java.lang.String> getUpdateColumnList()
-
getSourceExpressionList
public java.util.List<RexNode> getSourceExpressionList()
-
isFlattened
public boolean isFlattened()
-
getOperation
public TableModify.Operation getOperation()
-
isInsert
public boolean isInsert()
-
isUpdate
public boolean isUpdate()
-
isDelete
public boolean isDelete()
-
isMerge
public boolean isMerge()
-
deriveRowType
public RelDataType deriveRowType()
- Overrides:
deriveRowType
in classSingleRel
-
getExpectedInputRowType
public RelDataType getExpectedInputRowType(int ordinalInParent)
Description copied from interface:RelNode
Returns the type of the rows expected for an input. Defaults toRelNode.getRowType()
.- Specified by:
getExpectedInputRowType
in interfaceRelNode
- Overrides:
getExpectedInputRowType
in classAbstractRelNode
- Parameters:
ordinalInParent
- input's 0-based ordinal with respect to this parent rel- Returns:
- expected row type
-
explainTerms
public RelWriter explainTerms(RelWriter pw)
Description copied from class:AbstractRelNode
Describes the inputs and attributes of this relational expression. Each node should callsuper.explainTerms
, then call theRelWriterImpl.input(String, RelNode)
andRelWriterImpl.item(String, Object)
methods for each input and attribute.- Overrides:
explainTerms
in classSingleRel
- Parameters:
pw
- Plan writer- Returns:
- Plan writer for fluent-explain pattern
-
computeSelfCost
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
Description copied from interface:RelNode
Returns 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:
computeSelfCost
in interfaceRelNode
- Overrides:
computeSelfCost
in classAbstractRelNode
- Parameters:
planner
- Planner for cost calculationmq
- Metadata query- Returns:
- Cost of this plan (not including children)
-
-