Source:
<code>private PlanNode rewriteDeleteTableScan(PlanNode node, TableHandle handle) { if (node instanceof TableScanNode) { TableScanNode scan = (TableScanNode) node; TupleDomain<ColumnHandle> originalEnforcedConstraint = scan.getEnforcedConstraint(); Optional<TableLayoutResult> layout = metadata.getLayout( session, handle, new Constraint<>(originalEnforcedConstraint), Optional.of(ImmutableSet.copyOf(scan.getAssignments().values()))); <START> verify(layout.isPresent(), "Expected get a tableLayout for delete"); <END> TableLayoutResult layoutResult = layout.get(); 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()); }</code><technical_language>need alter error message</technical_language>

Target:
private PlanNode rewriteDeleteTableScan(PlanNode node, TableHandle handle) { if (node instanceof TableScanNode) { TableScanNode scan = (TableScanNode) node; TupleDomain<ColumnHandle> originalEnforcedConstraint = scan.getEnforcedConstraint(); TableLayoutResult layoutResult = metadata.getLayout( session, handle, new Constraint<>(originalEnforcedConstraint), Optional.of(ImmutableSet.copyOf(scan.getAssignments().values()))); return new TableScanNode( scan.getId(), layoutResult.getLayout().getNewTableHandle(), scan.getOutputSymbols(), scan.getAssignments(), 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()); }