use of io.trino.sql.planner.plan.RefreshMaterializedViewNode in project trino by trinodb.
the class LogicalPlanner method createRefreshMaterializedViewPlan.
private RelationPlan createRefreshMaterializedViewPlan(Analysis analysis) {
Optional<QualifiedObjectName> delegatedRefreshMaterializedView = analysis.getDelegatedRefreshMaterializedView();
if (delegatedRefreshMaterializedView.isPresent()) {
return new RelationPlan(new RefreshMaterializedViewNode(idAllocator.getNextId(), delegatedRefreshMaterializedView.get()), analysis.getRootScope(), ImmutableList.of(), Optional.empty());
}
checkState(analysis.getRefreshMaterializedView().isPresent(), "RefreshMaterializedViewAnalysis handle is missing");
Analysis.RefreshMaterializedViewAnalysis viewAnalysis = analysis.getRefreshMaterializedView().get();
TableHandle tableHandle = viewAnalysis.getTarget();
Query query = viewAnalysis.getQuery();
Optional<TableLayout> newTableLayout = metadata.getInsertLayout(session, viewAnalysis.getTarget());
TableWriterNode.RefreshMaterializedViewReference writerTarget = new TableWriterNode.RefreshMaterializedViewReference(viewAnalysis.getTable(), tableHandle, new ArrayList<>(analysis.getTables()));
return getInsertPlan(analysis, viewAnalysis.getTable(), query, tableHandle, viewAnalysis.getColumns(), newTableLayout, Optional.of(writerTarget));
}
Aggregations