本文整理汇总了Java中org.apache.calcite.rel.logical.LogicalTableModify类的典型用法代码示例。如果您正苦于以下问题:Java LogicalTableModify类的具体用法?Java LogicalTableModify怎么用?Java LogicalTableModify使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LogicalTableModify类属于org.apache.calcite.rel.logical包,在下文中一共展示了LogicalTableModify类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: insertCopying
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
public JdbcRelBuilder insertCopying(
LogicalTableModify original,
Table table
) {
List<String> name = JdbcTableUtils.getQualifiedName(original.getTable(), table);
push(new LogicalTableModify(
cluster,
original.getTraitSet(),
relOptSchema.getTableForMember(name),
original.getCatalogReader(),
peek(),
TableModify.Operation.INSERT,
null,
null,
original.isFlattened()
));
return this;
}
开发者ID:tzolov,项目名称:calcite-sql-rewriter,代码行数:20,代码来源:JdbcRelBuilder.java
示例2: apply
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
@Override
public RelNode apply(RelNode originalRel, JdbcRelBuilderFactory relBuilderFactory) {
if (!(originalRel instanceof LogicalTableModify)) {
return null;
}
LogicalTableModify tableModify = (LogicalTableModify) originalRel;
if (tableModify.getOperation() != operation) {
return null;
}
Table baseTable = JdbcTableUtils.getJdbcTable(tableModify);
if (!(baseTable instanceof JournalledJdbcTable)) {
// Not a journal table; nothing to do
return null;
}
JournalledJdbcTable journalTable = (JournalledJdbcTable) baseTable;
return doApply(tableModify, journalTable, relBuilderFactory);
}
开发者ID:tzolov,项目名称:calcite-sql-rewriter,代码行数:23,代码来源:AbstractForcedRule.java
示例3: createModify
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
/** Creates a relational expression to modify a table or modifiable view. */
private RelNode createModify(RelOptTable targetTable, RelNode source) {
final ModifiableTable modifiableTable =
targetTable.unwrap(ModifiableTable.class);
if (modifiableTable != null) {
return modifiableTable.toModificationRel(cluster, targetTable,
catalogReader, source, LogicalTableModify.Operation.INSERT, null,
null, false);
}
final ModifiableView modifiableView =
targetTable.unwrap(ModifiableView.class);
if (modifiableView != null) {
final Table delegateTable = modifiableView.getTable();
final RelDataType delegateRowType = delegateTable.getRowType(typeFactory);
final RelOptTable delegateRelOptTable =
RelOptTableImpl.create(null, delegateRowType, delegateTable,
modifiableView.getTablePath());
final RelNode newSource =
createSource(targetTable, source, modifiableView, delegateRowType);
return createModify(delegateRelOptTable, newSource);
}
return LogicalTableModify.create(targetTable, catalogReader, source,
LogicalTableModify.Operation.INSERT, null, null, false);
}
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:SqlToRelConverter.java
示例4: convert
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
@Override
public RelNode convert(RelNode rel) {
final LogicalTableModify modify =
(LogicalTableModify) rel;
final ModifiableTable modifiableTable =
modify.getTable().unwrap(ModifiableTable.class);
if (modifiableTable == null
/* || modifiableTable.getExpression(tableInSchema) == null */) {
return null;
}
final RelTraitSet traitSet =
modify.getTraitSet().replace(getOut());
return new JdbcTableModify(
modify.getCluster(), traitSet,
modify.getTable(),
modify.getCatalogReader(),
convert(modify.getInput(), traitSet),
modify.getOperation(),
modify.getUpdateColumnList(),
modify.isFlattened());
}
开发者ID:bitnine-oss,项目名称:octopus,代码行数:22,代码来源:JdbcRules.java
示例5: createModify
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
/** Creates a relational expression to modify a table or modifiable view. */
private RelNode createModify(RelOptTable targetTable, RelNode source) {
final ModifiableTable modifiableTable =
targetTable.unwrap(ModifiableTable.class);
if (modifiableTable != null) {
return modifiableTable.toModificationRel(cluster, targetTable,
catalogReader, source, LogicalTableModify.Operation.INSERT, null,
null, false);
}
final ModifiableView modifiableView =
targetTable.unwrap(ModifiableView.class);
if (modifiableView != null) {
final Table delegateTable = modifiableView.getTable();
final RelDataType delegateRowType = delegateTable.getRowType(typeFactory);
final RelOptTable delegateRelOptTable =
RelOptTableImpl.create(null, delegateRowType, delegateTable,
modifiableView.getTablePath());
final RelNode newSource =
createSource(targetTable, source, modifiableView, delegateRowType);
return createModify(delegateRelOptTable, newSource);
}
return LogicalTableModify.create(targetTable, catalogReader, source,
LogicalTableModify.Operation.INSERT, null, null, false);
}
开发者ID:apache,项目名称:kylin,代码行数:25,代码来源:SqlToRelConverter.java
示例6: mapTableModOp
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
protected LogicalTableModify.Operation mapTableModOp(
boolean isDml, SqlKind sqlKind) {
if (!isDml) {
return null;
}
switch (sqlKind) {
case INSERT:
return LogicalTableModify.Operation.INSERT;
case DELETE:
return LogicalTableModify.Operation.DELETE;
case MERGE:
return LogicalTableModify.Operation.MERGE;
case UPDATE:
return LogicalTableModify.Operation.UPDATE;
default:
return null;
}
}
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:Prepare.java
示例7: PreparedResultImpl
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
public PreparedResultImpl(
RelDataType rowType,
RelDataType parameterRowType,
List<List<String>> fieldOrigins,
List<RelCollation> collations,
RelNode rootRel,
LogicalTableModify.Operation tableModOp,
boolean isDml) {
this.rowType = Preconditions.checkNotNull(rowType);
this.parameterRowType = Preconditions.checkNotNull(parameterRowType);
this.fieldOrigins = Preconditions.checkNotNull(fieldOrigins);
this.collations = ImmutableList.copyOf(collations);
this.rootRel = Preconditions.checkNotNull(rootRel);
this.tableModOp = tableModOp;
this.isDml = isDml;
}
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:Prepare.java
示例8: convert
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
@Override public RelNode convert(RelNode rel) {
final LogicalTableModify modify =
(LogicalTableModify) rel;
final ModifiableTable modifiableTable =
modify.getTable().unwrap(ModifiableTable.class);
if (modifiableTable == null
/* || modifiableTable.getExpression(tableInSchema) == null */) {
return null;
}
final RelTraitSet traitSet =
modify.getTraitSet().replace(out);
return new JdbcTableModify(
modify.getCluster(), traitSet,
modify.getTable(),
modify.getCatalogReader(),
convert(modify.getInput(), traitSet),
modify.getOperation(),
modify.getUpdateColumnList(),
modify.getSourceExpressionList(),
modify.isFlattened());
}
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:JdbcRules.java
示例9: convert
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
@Override public RelNode convert(RelNode rel) {
final LogicalTableModify modify =
(LogicalTableModify) rel;
final ModifiableTable modifiableTable =
modify.getTable().unwrap(ModifiableTable.class);
if (modifiableTable == null) {
return null;
}
final RelTraitSet traitSet =
modify.getTraitSet().replace(EnumerableConvention.INSTANCE);
return new EnumerableTableModify(
modify.getCluster(), traitSet,
modify.getTable(),
modify.getCatalogReader(),
convert(modify.getInput(), traitSet),
modify.getOperation(),
modify.getUpdateColumnList(),
modify.getSourceExpressionList(),
modify.isFlattened());
}
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:EnumerableTableModifyRule.java
示例10: createModify
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
/** Creates a relational expression to modify a table or modifiable view. */
private RelNode createModify(RelOptTable targetTable, RelNode source) {
final ModifiableTable modifiableTable =
targetTable.unwrap(ModifiableTable.class);
if (modifiableTable != null
&& modifiableTable == targetTable.unwrap(Table.class)) {
return modifiableTable.toModificationRel(cluster, targetTable,
catalogReader, source, LogicalTableModify.Operation.INSERT, null,
null, false);
}
final ModifiableView modifiableView =
targetTable.unwrap(ModifiableView.class);
if (modifiableView != null) {
final Table delegateTable = modifiableView.getTable();
final RelDataType delegateRowType = delegateTable.getRowType(typeFactory);
final RelOptTable delegateRelOptTable =
RelOptTableImpl.create(null, delegateRowType, delegateTable,
modifiableView.getTablePath());
final RelNode newSource =
createSource(targetTable, source, modifiableView, delegateRowType);
return createModify(delegateRelOptTable, newSource);
}
return LogicalTableModify.create(targetTable, catalogReader, source,
LogicalTableModify.Operation.INSERT, null, null, false);
}
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:SqlToRelConverter.java
示例11: testReduceCastsNullable
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
@Ignore // Calcite does not support INSERT yet
@Test public void testReduceCastsNullable() throws Exception {
HepProgram program = new HepProgramBuilder()
// Simulate the way INSERT will insert casts to the target types
.addRuleInstance(
new CoerceInputsRule(LogicalTableModify.class, false,
RelFactories.LOGICAL_BUILDER))
// Convert projects to calcs, merge two calcs, and then
// reduce redundant casts in merged calc.
.addRuleInstance(ProjectToCalcRule.INSTANCE)
.addRuleInstance(CalcMergeRule.INSTANCE)
.addRuleInstance(ReduceExpressionsRule.CALC_INSTANCE)
.build();
checkPlanning(program,
"insert into sales.depts(name) "
+ "select cast(gender as varchar(128)) from sales.emps");
}
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:RelOptRulesTest.java
示例12: JdbcTableModificationRule
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
private JdbcTableModificationRule(JdbcConvention out) {
super(
LogicalTableModify.class,
Convention.NONE,
out,
"JdbcTableModificationRule");
}
开发者ID:bitnine-oss,项目名称:octopus,代码行数:8,代码来源:JdbcRules.java
示例13: toModificationRel
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
public TableModify toModificationRel(
RelOptCluster cluster,
RelOptTable table,
Prepare.CatalogReader catalogReader,
RelNode child,
TableModify.Operation operation,
List<String> updateColumnList,
List<RexNode> sourceExpressionList,
boolean flattened) {
return LogicalTableModify.create(table, catalogReader, child, operation,
updateColumnList, sourceExpressionList, flattened);
}
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:SqlCreateTable.java
示例14: JdbcTableModificationRule
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
private JdbcTableModificationRule(JdbcConvention out) {
super(
LogicalTableModify.class,
Convention.NONE,
out,
"JdbcTableModificationRule");
}
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:JdbcRules.java
示例15: toModificationRel
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
@Override public TableModify toModificationRel(RelOptCluster cluster,
RelOptTable table, CatalogReader catalogReader, RelNode input,
Operation operation, List<String> updateColumnList,
List<RexNode> sourceExpressionList, boolean flattened) {
jdbcSchema.convention.register(cluster.getPlanner());
return new LogicalTableModify(cluster, cluster.traitSetOf(Convention.NONE),
table, catalogReader, input, operation, updateColumnList,
sourceExpressionList, flattened);
}
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:JdbcTable.java
示例16: rewriteRel
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
public void rewriteRel(LogicalTableModify rel) {
LogicalTableModify newRel =
LogicalTableModify.create(
rel.getTable(),
rel.getCatalogReader(),
getNewForOldRel(rel.getInput()),
rel.getOperation(),
rel.getUpdateColumnList(),
rel.getSourceExpressionList(),
true);
setNewForOldRel(rel, newRel);
}
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:RelStructuredTypeFlattener.java
示例17: toModificationRel
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
public TableModify toModificationRel(RelOptCluster cluster,
RelOptTable table, Prepare.CatalogReader catalogReader, RelNode child,
TableModify.Operation operation, List<String> updateColumnList,
List<RexNode> sourceExpressionList, boolean flattened) {
return LogicalTableModify.create(table, catalogReader, child, operation,
updateColumnList, sourceExpressionList, flattened);
}
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:FrameworksTest.java
示例18: doApply
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
@Override
public RelNode doApply(LogicalTableModify tableModify, JournalledJdbcTable journalTable,
JdbcRelBuilderFactory relBuilderFactory) {
String versionField = journalTable.getVersionField();
String subsequentVersionField = journalTable.getSubsequentVersionField();
JdbcRelBuilder relBuilder = relBuilderFactory.create(
tableModify.getCluster(),
tableModify.getTable().getRelOptSchema()
);
RelNode input = tableModify.getInput();
// Bypass projection which removes version columns
if (!(input instanceof LogicalProject)) {
throw new IllegalStateException("Unknown Calcite DELETE structure");
}
relBuilder.push(input.getInput(0));
JournalVersionType versionType = journalTable.getVersionType();
if (!versionType.isValidSqlType(relBuilder.field(versionField).getType().getSqlTypeName())) {
throw new IllegalStateException("Incorrect journalVersionType! Column 'version_number' is of type: "
+ relBuilder.field(versionField).getType().getSqlTypeName()
+ " but the journalVersionType is " + versionType);
}
RexNode newVersion = journalTable.getVersionType().incrementVersion(relBuilder, relBuilder.field(versionField));
List<String> columnNames = new ArrayList<>();
List<RexNode> sources = new ArrayList<>();
sources.addAll(((LogicalProject) input).getProjects());
columnNames.addAll(input.getRowType().getFieldNames());
sources.add(newVersion);
sources.add(newVersion);
columnNames.add(versionField);
columnNames.add(subsequentVersionField);
relBuilder.project(sources, columnNames);
relBuilder.insertCopying(
tableModify,
journalTable.getJournalTable()
);
return relBuilder.build();
}
开发者ID:tzolov,项目名称:calcite-sql-rewriter,代码行数:47,代码来源:JournalledDeleteRule.java
示例19: doApply
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
@Override
public RelNode doApply(LogicalTableModify tableModify, JournalledJdbcTable journalTable,
JdbcRelBuilderFactory relBuilderFactory) {
JdbcRelBuilder relBuilder = relBuilderFactory.create(
tableModify.getCluster(),
tableModify.getTable().getRelOptSchema()
);
RelNode input = tableModify.getInput();
if (input instanceof LogicalValues) {
// TODO: do we need to do anything here?
relBuilder.push(input);
}
else if (input instanceof LogicalProject) {
LogicalProject project = (LogicalProject) input;
List<RexNode> desiredFields = new ArrayList<>();
List<String> desiredNames = new ArrayList<>();
for (Pair<RexNode, String> field : project.getNamedProjects()) {
if (field.getKey() instanceof RexInputRef) {
desiredFields.add(field.getKey());
desiredNames.add(field.getValue());
}
}
relBuilder.push(project.getInput());
relBuilder.project(desiredFields, desiredNames);
}
else {
throw new IllegalStateException("Unknown Calcite INSERT structure");
}
relBuilder.insertCopying(
tableModify,
journalTable.getJournalTable()
);
return relBuilder.build();
}
开发者ID:tzolov,项目名称:calcite-sql-rewriter,代码行数:45,代码来源:JournalledInsertRule.java
示例20: doApply
import org.apache.calcite.rel.logical.LogicalTableModify; //导入依赖的package包/类
@Override
public RelNode doApply(LogicalTableModify tableModify, JournalledJdbcTable journalTable,
JdbcRelBuilderFactory relBuilderFactory) {
if (!(tableModify.getInput() instanceof LogicalProject)) {
throw new IllegalStateException("Unknown Calcite UPDATE structure");
}
String versionField = journalTable.getVersionField();
// Merge the Update's update column expression into the target INSERT
LogicalProject project = (LogicalProject) tableModify.getInput();
List<RexNode> desiredFields = new ArrayList<>();
List<String> desiredNames = new ArrayList<>();
for (Pair<RexNode, String> field : project.getNamedProjects()) {
if (field.getKey() instanceof RexInputRef) {
int index = tableModify.getUpdateColumnList().indexOf(field.getValue());
if (index != -1) {
desiredFields.add(tableModify.getSourceExpressionList().get(index));
}
else {
desiredFields.add(field.getKey());
}
desiredNames.add(field.getValue());
}
}
JdbcRelBuilder relBuilder = relBuilderFactory.create(
tableModify.getCluster(),
tableModify.getTable().getRelOptSchema()
);
relBuilder.push(project.getInput());
JournalVersionType versionType = journalTable.getVersionType();
if (!versionType.isValidSqlType(relBuilder.field(versionField).getType().getSqlTypeName())) {
throw new IllegalStateException("Incorrect journalVersionType! Column 'version_number' is of type: "
+ relBuilder.field(versionField).getType().getSqlTypeName()
+ " but the journalVersionType is " + versionType);
}
if (versionType.updateRequiresExplicitVersion()) {
RexNode newVersion = versionType.incrementVersion(relBuilder, relBuilder.field(versionField));
desiredFields.add(newVersion);
desiredNames.add(versionField);
}
relBuilder.project(desiredFields, desiredNames);
// Convert the UPDATE into INSERT TableModify operations
relBuilder.insertCopying(
tableModify,
journalTable.getJournalTable()
);
return relBuilder.build();
}
开发者ID:tzolov,项目名称:calcite-sql-rewriter,代码行数:58,代码来源:JournalledUpdateRule.java
注:本文中的org.apache.calcite.rel.logical.LogicalTableModify类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论