public TableWriterNode.WriterTarget getTarget(PlanNode node) { if (node instanceof TableWriterNode) { return ((TableWriterNode) node).getTarget(); } if (node instanceof DeleteNode) { return ((DeleteNode) node).getTarget(); } if (node instanceof ExchangeNode || node instanceof UnionNode) { Set<TableWriterNode.WriterTarget> writerTargets = node.getSources().stream() .map(this::getTarget) .collect(toSet()); return Iterables.getOnlyElement(writerTargets); } throw new IllegalArgumentException("Invalid child for TableCommitNode: " + node.getClass().getSimpleName()); }
@Override public PlanNode visitTableFinish(TableFinishNode node, RewriteContext<Void> context) { Optional<DeleteNode> delete = findNode(node.getSource(), DeleteNode.class); if (!delete.isPresent()) { return context.defaultRewrite(node); } Optional<TableScanNode> tableScan = findNode(delete.get().getSource(), TableScanNode.class); if (!tableScan.isPresent()) { return context.defaultRewrite(node); } TableScanNode tableScanNode = tableScan.get(); if (!metadata.supportsMetadataDelete(session, tableScanNode.getTable(), tableScanNode.getLayout().get())) { return context.defaultRewrite(node); } return new MetadataDeleteNode(idAllocator.getNextId(), delete.get().getTarget(), Iterables.getOnlyElement(node.getOutputSymbols()), tableScanNode.getLayout().get()); }
@Override public PlanNode visitDelete(DeleteNode node, RewriteContext<Set<Symbol>> context) { PlanNode source = context.rewrite(node.getSource(), ImmutableSet.of(node.getRowId())); return new DeleteNode(node.getId(), source, node.getTarget(), node.getRowId(), node.getOutputSymbols()); }
@Override public Void visitDelete(DeleteNode node, Integer indent) { print(indent, "- Delete[%s] => [%s]", node.getTarget(), formatOutputs(node.getOutputSymbols())); printPlanNodesStatsAndCost(indent + 2, node); printStats(indent + 2, node.getId()); return processChildren(node, indent + 1); }
private RelationPlan createDeletePlan(Analysis analysis, Delete node) { DeleteNode deleteNode = new QueryPlanner(analysis, symbolAllocator, idAllocator, buildLambdaDeclarationToSymbolMap(analysis, symbolAllocator), metadata, session) .plan(node); TableFinishNode commitNode = new TableFinishNode( idAllocator.getNextId(), deleteNode, deleteNode.getTarget(), symbolAllocator.newSymbol("rows", BIGINT), Optional.empty(), Optional.empty()); return new RelationPlan(commitNode, analysis.getScope(node), commitNode.getOutputSymbols()); }
@Override public PlanNode visitDelete(DeleteNode node, RewriteContext<Context> context) { TableWriterNode.DeleteHandle deleteHandle = (TableWriterNode.DeleteHandle) context.get().getMaterializedHandle(node.getTarget()).get(); return new DeleteNode( node.getId(), rewriteDeleteTableScan(node.getSource(), deleteHandle.getHandle()), deleteHandle, node.getRowId(), node.getOutputSymbols()); }
@Override public PlanNode visitDelete(DeleteNode node, RewriteContext<Void> context) { // For delete queries, the TableScan node that corresponds to the table being deleted must be collocated with the Delete node, // so you can't do a distributed semi-join isDeleteQuery = true; PlanNode rewrittenSource = context.rewrite(node.getSource()); return new DeleteNode( node.getId(), rewrittenSource, node.getTarget(), node.getRowId(), node.getOutputSymbols()); } }
@Override public PlanNode visitDelete(DeleteNode node, RewriteContext<Void> context) { return new DeleteNode(node.getId(), context.rewrite(node.getSource()), node.getTarget(), canonicalize(node.getRowId()), node.getOutputSymbols()); }
public TableWriterNode.WriterTarget getTarget(PlanNode node) { if (node instanceof TableWriterNode) { return ((TableWriterNode) node).getTarget(); } if (node instanceof DeleteNode) { return ((DeleteNode) node).getTarget(); } if (node instanceof ExchangeNode || node instanceof UnionNode) { Set<TableWriterNode.WriterTarget> writerTargets = node.getSources().stream() .map(this::getTarget) .collect(toSet()); return Iterables.getOnlyElement(writerTargets); } throw new IllegalArgumentException("Invalid child for TableCommitNode: " + node.getClass().getSimpleName()); }
@Override public PlanNode visitDelete(DeleteNode node, List<PlanNode> newChildren) { return new DeleteNode(node.getId(), Iterables.getOnlyElement(newChildren), node.getTarget(), node.getRowId(), node.getOutputSymbols()); }
@Override public Void visitDelete(DeleteNode node, Integer indent) { print(indent, "- Delete[%s] => [%s]", node.getTarget(), formatOutputs(node.getOutputSymbols())); return processChildren(node, indent + 1); }
private RelationPlan createDeletePlan(Analysis analysis, Delete node) { QueryPlanner planner = new QueryPlanner(analysis, symbolAllocator, idAllocator, metadata, session, Optional.empty()); DeleteNode deleteNode = planner.planDelete(node); List<Symbol> outputs = ImmutableList.of(symbolAllocator.newSymbol("rows", BIGINT)); TableFinishNode commitNode = new TableFinishNode(idAllocator.getNextId(), deleteNode, deleteNode.getTarget(), outputs); return new RelationPlan(commitNode, analysis.getOutputDescriptor(), commitNode.getOutputSymbols(), Optional.empty()); }
@Override public PlanNode visitTableFinish(TableFinishNode node, RewriteContext<Void> context) { Optional<DeleteNode> delete = findNode(node.getSource(), DeleteNode.class); if (!delete.isPresent()) { return context.defaultRewrite(node); } Optional<TableScanNode> tableScan = findNode(delete.get().getSource(), TableScanNode.class); if (!tableScan.isPresent()) { return context.defaultRewrite(node); } TableScanNode tableScanNode = tableScan.get(); if (!metadata.supportsMetadataDelete(session, tableScanNode.getTable(), tableScanNode.getLayout().get())) { return context.defaultRewrite(node); } return new MetadataDeleteNode(idAllocator.getNextId(), delete.get().getTarget(), Iterables.getOnlyElement(node.getOutputSymbols()), tableScanNode.getLayout().get()); }
@Override public PlanNode visitDelete(DeleteNode node, RewriteContext<Set<Symbol>> context) { PlanNode source = context.rewrite(node.getSource(), ImmutableSet.of(node.getRowId())); return new DeleteNode(node.getId(), source, node.getTarget(), node.getRowId(), node.getOutputSymbols()); }
@Override public PlanNode visitDelete(DeleteNode node, RewriteContext<Context> context) { TableWriterNode.DeleteHandle deleteHandle = (TableWriterNode.DeleteHandle) context.get().getMaterializedHandle(node.getTarget()).get(); return new DeleteNode( node.getId(), rewriteDeleteTableScan(node.getSource(), deleteHandle.getHandle(), context), deleteHandle, node.getRowId(), node.getOutputSymbols()); }
@Override public PlanNode visitDelete(DeleteNode node, RewriteContext<Void> context) { return new DeleteNode(node.getId(), context.rewrite(node.getSource()), node.getTarget(), canonicalize(node.getRowId()), node.getOutputSymbols()); }