public SubPlanBuilder visitMaterializedViewWriter(MaterializedViewWriterNode node, Void context)
{
SubPlanBuilder subPlanBuilder = node.getSource().accept(this, context);
if (createSingleNodePlan) {
subPlanBuilder.setRoot(new MaterializedViewWriterNode(node.getId(),
subPlanBuilder.getRoot(),
node.getTable(),
node.getColumns(),
node.getOutput()));
}
else {
// rewrite the sub-plan builder to use the source id of the table writer node
subPlanBuilder = createSubPlan(subPlanBuilder.getRoot(), subPlanBuilder.getDistribution(), node.getId());
// Put a simple SUM(<output symbol>) on top of the table writer node
FunctionInfo sum = metadata.getFunction(QualifiedName.of("sum"), ImmutableList.of(Type.BIGINT), false);
Symbol intermediateOutput = allocator.newSymbol(node.getOutput().toString(), sum.getReturnType());
MaterializedViewWriterNode writer = new MaterializedViewWriterNode(node.getId(),
subPlanBuilder.getRoot(),
node.getTable(),
node.getColumns(),
intermediateOutput);
subPlanBuilder.setRoot(writer);