use of org.apache.calcite.schema.ModifiableView in project calcite by apache.
the class SqlToRelConverter method createModify.
/**
* 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);
}
Aggregations