Source:
public PhysicalOperation visitTableWriter(TableWriterNode node, LocalExecutionPlanContext context) { if (node.getPartitioningScheme().isPresent() || stageExecutionDescriptor.isRecoverableGroupedExecution()) { context.setDriverInstanceCount(1); } else { context.setDriverInstanceCount(getTaskWriterCount(session)); } PhysicalOperation source = node.getSource().accept(this, context); ImmutableMap.Builder<VariableReferenceExpression, Integer> outputMapping = ImmutableMap.builder(); outputMapping.put(node.getRowCountVariable(), ROW_COUNT_CHANNEL); outputMapping.put(node.getFragmentVariable(), FRAGMENT_CHANNEL); outputMapping.put(node.getTableCommitContextVariable(), CONTEXT_CHANNEL); OperatorFactory statisticsAggregation = node.getStatisticsAggregation().map(aggregation -> { List<VariableReferenceExpression> groupingVariables = aggregation.getGroupingVariables(); if (groupingVariables.isEmpty()) { return createAggregationOperatorFactory( node.getId(), aggregation.getAggregations(), PARTIAL, STATS_START_CHANNEL, outputMapping, source, context, true); } return createHashAggregationOperatorFactory( node.getId(), aggregation.getAggregations(), ImmutableSet.of(), groupingVariables, PARTIAL, Optional.empty(), Optional.empty(), source, false, false, false, new DataSize(0, BYTE), context, STATS_START_CHANNEL, outputMapping, 200, Optional.empty(), true); }).orElse(new DevNullOperatorFactory(context.getNextOperatorId(), node.getId())); List<Integer> inputChannels = node.getColumns().stream() .map(source::variableToChannel) .collect(toImmutableList()); OperatorFactory operatorFactory = new TableWriterOperatorFactory( context.getNextOperatorId(), node.getId(), pageSinkManager, node.getTarget(), inputChannels, session, statisticsAggregation, getVariableTypes(node.getOutputVariables()), tableCommitContextCodec, stageExecutionDescriptor.isRecoverableGroupedExecution()); return new PhysicalOperation(operatorFactory, outputMapping.build(), context, source); }

Target:
public PhysicalOperation visitTableWriter(TableWriterNode node, LocalExecutionPlanContext context) { if (node.getPartitioningScheme().isPresent()) { context.setDriverInstanceCount(1); } else { context.setDriverInstanceCount(getTaskWriterCount(session)); } PhysicalOperation source = node.getSource().accept(this, context); ImmutableMap.Builder<VariableReferenceExpression, Integer> outputMapping = ImmutableMap.builder(); outputMapping.put(node.getRowCountVariable(), ROW_COUNT_CHANNEL); outputMapping.put(node.getFragmentVariable(), FRAGMENT_CHANNEL); outputMapping.put(node.getTableCommitContextVariable(), CONTEXT_CHANNEL); OperatorFactory statisticsAggregation = node.getStatisticsAggregation().map(aggregation -> { List<VariableReferenceExpression> groupingVariables = aggregation.getGroupingVariables(); if (groupingVariables.isEmpty()) { return createAggregationOperatorFactory( node.getId(), aggregation.getAggregations(), PARTIAL, STATS_START_CHANNEL, outputMapping, source, context, true); } return createHashAggregationOperatorFactory( node.getId(), aggregation.getAggregations(), ImmutableSet.of(), groupingVariables, PARTIAL, Optional.empty(), Optional.empty(), source, false, false, false, new DataSize(0, BYTE), context, STATS_START_CHANNEL, outputMapping, 200, Optional.empty(), true); }).orElse(new DevNullOperatorFactory(context.getNextOperatorId(), node.getId())); List<Integer> inputChannels = node.getColumns().stream() .map(source::variableToChannel) .collect(toImmutableList()); OperatorFactory operatorFactory = new TableWriterOperatorFactory( context.getNextOperatorId(), node.getId(), pageSinkManager, node.getTarget(), inputChannels, session, statisticsAggregation, getVariableTypes(node.getOutputVariables()), tableCommitContextCodec, stageExecutionDescriptor.isRecoverableGroupedExecution()); return new PhysicalOperation(operatorFactory, outputMapping.build(), context, source); }