/** * Returns a mapping of the column ordinal in the underlying table to a column * constraint of the modifiable view. * * @param modifiableViewTable The modifiable view which has a constraint * @param targetRowType The target type */ public static Map<Integer, RexNode> getColumnConstraints( ModifiableView modifiableViewTable, RelDataType targetRowType, RelDataTypeFactory typeFactory) { final RexBuilder rexBuilder = new RexBuilder(typeFactory); final RexNode constraint = modifiableViewTable.getConstraint(rexBuilder, targetRowType); final Map<Integer, RexNode> projectMap = new HashMap<>(); final List<RexNode> filters = new ArrayList<>(); RelOptUtil.inferViewPredicates(projectMap, filters, constraint); assert filters.isEmpty(); return projectMap; }
/** 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); }
final ImmutableIntList mapping = modifiableView.getColumnMapping(); assert mapping.size() == targetTable.getRowType().getFieldCount(); modifiableView.getConstraint(rexBuilder, delegateRowType); RelOptUtil.inferViewPredicates(projectMap, filters, constraint); final List<Pair<RexNode, String>> projects = new ArrayList<>();
/** 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); }
final ImmutableIntList mapping = modifiableView.getColumnMapping(); assert mapping.size() == targetTable.getRowType().getFieldCount(); modifiableView.getConstraint(rexBuilder, delegateRowType); RelOptUtil.inferViewPredicates(projectMap, filters, constraint); final List<Pair<RexNode, String>> projects = new ArrayList<>();
/** 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); }
final ImmutableIntList mapping = modifiableView.getColumnMapping(); assert mapping.size() == targetTable.getRowType().getFieldCount(); modifiableView.getConstraint(rexBuilder, delegateRowType); RelOptUtil.inferViewPredicates(projectMap, filters, constraint); final List<Pair<RexNode, String>> projects = new ArrayList<>();
/** * Returns a mapping of the column ordinal in the underlying table to a column * constraint of the modifiable view. * * @param modifiableViewTable The modifiable view which has a constraint * @param targetRowType The target type */ public static Map<Integer, RexNode> getColumnConstraints( ModifiableView modifiableViewTable, RelDataType targetRowType, RelDataTypeFactory typeFactory) { final RexBuilder rexBuilder = new RexBuilder(typeFactory); final RexNode constraint = modifiableViewTable.getConstraint(rexBuilder, targetRowType); final Map<Integer, RexNode> projectMap = new HashMap<>(); final List<RexNode> filters = new ArrayList<>(); RelOptUtil.inferViewPredicates(projectMap, filters, constraint); assert filters.isEmpty(); return projectMap; }
/** 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); }
final ImmutableIntList mapping = modifiableView.getColumnMapping(); assert mapping.size() == targetTable.getRowType().getFieldCount(); modifiableView.getConstraint(rexBuilder, delegateRowType); RelOptUtil.inferViewPredicates(projectMap, filters, constraint); final List<Pair<RexNode, String>> projects = new ArrayList<>();