use of io.trino.sql.planner.plan.TableWriterNode.CreateTarget in project trino by trinodb.
the class LocalExecutionPlanner method createTableFinisher.
private static TableFinisher createTableFinisher(Session session, TableFinishNode node, Metadata metadata) {
WriterTarget target = node.getTarget();
return (fragments, statistics, tableExecuteContext) -> {
if (target instanceof CreateTarget) {
return metadata.finishCreateTable(session, ((CreateTarget) target).getHandle(), fragments, statistics);
} else if (target instanceof InsertTarget) {
return metadata.finishInsert(session, ((InsertTarget) target).getHandle(), fragments, statistics);
} else if (target instanceof TableWriterNode.RefreshMaterializedViewTarget) {
TableWriterNode.RefreshMaterializedViewTarget refreshTarget = (TableWriterNode.RefreshMaterializedViewTarget) target;
return metadata.finishRefreshMaterializedView(session, refreshTarget.getTableHandle(), refreshTarget.getInsertHandle(), fragments, statistics, refreshTarget.getSourceTableHandles());
} else if (target instanceof DeleteTarget) {
metadata.finishDelete(session, ((DeleteTarget) target).getHandleOrElseThrow(), fragments);
return Optional.empty();
} else if (target instanceof UpdateTarget) {
metadata.finishUpdate(session, ((UpdateTarget) target).getHandleOrElseThrow(), fragments);
return Optional.empty();
} else if (target instanceof TableExecuteTarget) {
TableExecuteHandle tableExecuteHandle = ((TableExecuteTarget) target).getExecuteHandle();
metadata.finishTableExecute(session, tableExecuteHandle, fragments, tableExecuteContext.getSplitsInfo());
return Optional.empty();
} else {
throw new AssertionError("Unhandled target type: " + target.getClass().getName());
}
};
}
use of io.trino.sql.planner.plan.TableWriterNode.CreateTarget in project trino by trinodb.
the class TestTableWriterOperator method createTableWriterOperator.
private Operator createTableWriterOperator(PageSinkManager pageSinkManager, OperatorFactory statisticsAggregation, List<Type> outputTypes, Session session, DriverContext driverContext) {
List<String> notNullColumnNames = new ArrayList<>(1);
notNullColumnNames.add(null);
TableWriterOperatorFactory factory = new TableWriterOperatorFactory(0, new PlanNodeId("test"), pageSinkManager, new CreateTarget(new OutputTableHandle(CONNECTOR_ID, new ConnectorTransactionHandle() {
}, new ConnectorOutputTableHandle() {
}), new SchemaTableName("testSchema", "testTable")), ImmutableList.of(0), notNullColumnNames, session, statisticsAggregation, outputTypes);
return factory.createOperator(driverContext);
}
Aggregations