Source:
private PlanNode rewriteDeleteTableScan(PlanNode node, TableHandle handle) { if (node instanceof TableScanNode) { TableScanNode scan = (TableScanNode) node; TupleDomain<ColumnHandle> originalEnforcedConstraint = scan.getEnforcedConstraint(); List<TableLayoutResult> layouts = metadata.getLayouts( session, handle, new Constraint<>(originalEnforcedConstraint), Optional.of(ImmutableSet.copyOf(scan.getAssignments().values()))); verify(layouts.size() == 1, "Expected exactly one layout for delete"); TableLayoutResult layoutResult = Iterables.getOnlyElement(layouts); return new TableScanNode( scan.getId(), handle, scan.getOutputSymbols(), scan.getAssignments(), Optional.of(layoutResult.getLayout().getHandle()), scan.getCurrentConstraint(), computeEnforced(originalEnforcedConstraint, layoutResult.getUnenforcedConstraint())); } if (node instanceof FilterNode) { PlanNode source = rewriteDeleteTableScan(((FilterNode) node).getSource(), handle); return replaceChildren(node, ImmutableList.of(source)); } if (node instanceof ProjectNode) { PlanNode source = rewriteDeleteTableScan(((ProjectNode) node).getSource(), handle); return replaceChildren(node, ImmutableList.of(source)); } if (node instanceof SemiJoinNode) { PlanNode source = rewriteDeleteTableScan(((SemiJoinNode) node).getSource(), handle); return replaceChildren(node, ImmutableList.of(source, ((SemiJoinNode) node).getFilteringSource())); } if (node instanceof JoinNode) { JoinNode joinNode = (JoinNode) node; if (joinNode.getType() == JoinNode.Type.INNER && isAtMostScalar(joinNode.getRight())) { PlanNode source = rewriteDeleteTableScan(joinNode.getLeft(), handle); return replaceChildren(node, ImmutableList.of(source, joinNode.getRight())); } } throw new IllegalArgumentException("Invalid descendant for DeleteNode: " + node.getClass().getName()); }

Target:
private PlanNode rewriteDeleteTableScan(PlanNode node, TableHandle handle) { if (node instanceof TableScanNode) { TableScanNode scan = (TableScanNode) node; TupleDomain<ColumnHandle> originalEnforcedConstraint = scan.getEnforcedConstraint(); List<TableLayoutResult> layouts = metadata.getLayouts( session, handle, new Constraint<>(originalEnforcedConstraint), Optional.of(ImmutableSet.copyOf(scan.getAssignments().values()))); verify(layouts.size() == 1, "Expected exactly one layout for delete"); TableLayoutResult layoutResult = Iterables.getOnlyElement(layouts); return new TableScanNode( scan.getId(), handle, scan.getOutputSymbols(), scan.getAssignments(), Optional.of(layoutResult.getLayout().getHandle()), layoutResult.getLayout().getPredicate(), computeEnforced(originalEnforcedConstraint, layoutResult.getUnenforcedConstraint())); } if (node instanceof FilterNode) { PlanNode source = rewriteDeleteTableScan(((FilterNode) node).getSource(), handle); return replaceChildren(node, ImmutableList.of(source)); } if (node instanceof ProjectNode) { PlanNode source = rewriteDeleteTableScan(((ProjectNode) node).getSource(), handle); return replaceChildren(node, ImmutableList.of(source)); } if (node instanceof SemiJoinNode) { PlanNode source = rewriteDeleteTableScan(((SemiJoinNode) node).getSource(), handle); return replaceChildren(node, ImmutableList.of(source, ((SemiJoinNode) node).getFilteringSource())); } if (node instanceof JoinNode) { JoinNode joinNode = (JoinNode) node; if (joinNode.getType() == JoinNode.Type.INNER && isAtMostScalar(joinNode.getRight())) { PlanNode source = rewriteDeleteTableScan(joinNode.getLeft(), handle); return replaceChildren(node, ImmutableList.of(source, joinNode.getRight())); } } throw new IllegalArgumentException("Invalid descendant for DeleteNode: " + node.getClass().getName()); }