Source:
public PhysicalOperation visitTableFinish(TableFinishNode node, LocalExecutionPlanContext context) { PhysicalOperation source = node.getSource().accept(this, context); ImmutableMap.Builder<VariableReferenceExpression, Integer> outputMapping = ImmutableMap.builder(); OperatorFactory statisticsAggregation = node.getStatisticsAggregation().map(aggregation -> { List<VariableReferenceExpression> groupingVariables = aggregation.getGroupingVariables(); if (groupingVariables.isEmpty()) { return createAggregationOperatorFactory( node.getId(), aggregation.getAggregations(), FINAL, 0, outputMapping, source, context, true); } return createHashAggregationOperatorFactory( node.getId(), aggregation.getAggregations(), ImmutableSet.of(), groupingVariables, FINAL, Optional.empty(), Optional.empty(), source, false, false, false, new DataSize(0, BYTE), context, 0, outputMapping, 200, Optional.empty(), true); }).orElse(new DevNullOperatorFactory(context.getNextOperatorId(), node.getId())); Map<VariableReferenceExpression, Integer> aggregationOutput = outputMapping.build(); StatisticAggregationsDescriptor<Integer> descriptor = node.getStatisticsAggregationDescriptor() .map(desc -> desc.map(aggregationOutput::get)) .orElse(StatisticAggregationsDescriptor.empty()); ExecutionWriterTarget writerTarget = context.tableWriteInfo.getWriterTarget().orElseThrow(() -> new IllegalStateException("writerTarget is absent")); OperatorFactory operatorFactory = new TableFinishOperatorFactory( context.getNextOperatorId(), node.getId(), createTableFinisher(session, metadata, writerTarget), createLifespanCommitter(session, metadata, writerTarget), statisticsAggregation, descriptor, session, tableCommitContextCodec); Map<VariableReferenceExpression, Integer> layout = ImmutableMap.of(node.getOutputVariables().get(0), 0); return new PhysicalOperation(operatorFactory, layout, context, source); }

Target:
public PhysicalOperation visitTableFinish(TableFinishNode node, LocalExecutionPlanContext context) { PhysicalOperation source = node.getSource().accept(this, context); ImmutableMap.Builder<VariableReferenceExpression, Integer> outputMapping = ImmutableMap.builder(); OperatorFactory statisticsAggregation = node.getStatisticsAggregation().map(aggregation -> { List<VariableReferenceExpression> groupingVariables = aggregation.getGroupingVariables(); if (groupingVariables.isEmpty()) { return createAggregationOperatorFactory( node.getId(), aggregation.getAggregations(), FINAL, 0, outputMapping, source, context, true); } return createHashAggregationOperatorFactory( node.getId(), aggregation.getAggregations(), ImmutableSet.of(), groupingVariables, FINAL, Optional.empty(), Optional.empty(), source, false, false, false, new DataSize(0, BYTE), context, 0, outputMapping, 200, Optional.empty(), true); }).orElse(new DevNullOperatorFactory(context.getNextOperatorId(), node.getId())); Map<VariableReferenceExpression, Integer> aggregationOutput = outputMapping.build(); StatisticAggregationsDescriptor<Integer> descriptor = node.getStatisticsAggregationDescriptor() .map(desc -> desc.map(aggregationOutput::get)) .orElse(StatisticAggregationsDescriptor.empty()); ExecutionWriterTarget writerTarget = context.getTableWriteInfo().getWriterTarget().orElseThrow(() -> new VerifyException("writerTarget is absent")); OperatorFactory operatorFactory = new TableFinishOperatorFactory( context.getNextOperatorId(), node.getId(), createTableFinisher(session, metadata, writerTarget), createLifespanCommitter(session, metadata, writerTarget), statisticsAggregation, descriptor, session, tableCommitContextCodec); Map<VariableReferenceExpression, Integer> layout = ImmutableMap.of(node.getOutputVariables().get(0), 0); return new PhysicalOperation(operatorFactory, layout, context, source); }