Search in sources :

Example 1 with DeleteNode

use of io.trino.sql.planner.plan.DeleteNode in project trino by trinodb.

the class LogicalPlanner method createDeletePlan.

private RelationPlan createDeletePlan(Analysis analysis, Delete node) {
    DeleteNode deleteNode = new QueryPlanner(analysis, symbolAllocator, idAllocator, buildLambdaDeclarationToSymbolMap(analysis, symbolAllocator), plannerContext, Optional.empty(), session, ImmutableMap.of()).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(), Optional.empty());
}
Also used : DeleteNode(io.trino.sql.planner.plan.DeleteNode) TableFinishNode(io.trino.sql.planner.plan.TableFinishNode)

Example 2 with DeleteNode

use of io.trino.sql.planner.plan.DeleteNode in project trino by trinodb.

the class QueryPlanner method plan.

public DeleteNode plan(Delete node) {
    Table table = node.getTable();
    TableHandle handle = analysis.getTableHandle(table);
    // create table scan
    RelationPlan relationPlan = new RelationPlanner(analysis, symbolAllocator, idAllocator, lambdaDeclarationToSymbolMap, plannerContext, outerContext, session, recursiveSubqueries).process(table, null);
    PlanBuilder builder = newPlanBuilder(relationPlan, analysis, lambdaDeclarationToSymbolMap);
    if (node.getWhere().isPresent()) {
        builder = filter(builder, node.getWhere().get(), node);
    }
    // create delete node
    Symbol rowId = builder.translate(analysis.getRowIdField(table));
    List<Symbol> outputs = ImmutableList.of(symbolAllocator.newSymbol("partialrows", BIGINT), symbolAllocator.newSymbol("fragment", VARBINARY));
    return new DeleteNode(idAllocator.getNextId(), builder.getRoot(), new DeleteTarget(Optional.empty(), plannerContext.getMetadata().getTableMetadata(session, handle).getTable()), rowId, outputs);
}
Also used : DeleteNode(io.trino.sql.planner.plan.DeleteNode) Table(io.trino.sql.tree.Table) TableHandle(io.trino.metadata.TableHandle) DeleteTarget(io.trino.sql.planner.plan.TableWriterNode.DeleteTarget) PlanBuilder.newPlanBuilder(io.trino.sql.planner.PlanBuilder.newPlanBuilder)

Aggregations

DeleteNode (io.trino.sql.planner.plan.DeleteNode)2 TableHandle (io.trino.metadata.TableHandle)1 PlanBuilder.newPlanBuilder (io.trino.sql.planner.PlanBuilder.newPlanBuilder)1 TableFinishNode (io.trino.sql.planner.plan.TableFinishNode)1 DeleteTarget (io.trino.sql.planner.plan.TableWriterNode.DeleteTarget)1 Table (io.trino.sql.tree.Table)1