Source:
public PlanWithProperties visitTableWriter(TableWriterNode originalTableWriterNode, StreamPreferredProperties parentPreferences) { if (getTaskWriterCount(session) == 1) { return planAndEnforceChildren(originalTableWriterNode, singleStream(), defaultParallelism(session)); } if (!isTableWriterMergeOperatorEnabled(session)) { return planAndEnforceChildren(originalTableWriterNode, fixedParallelism(), fixedParallelism()); } Optional<StatisticAggregations.Parts> statisticAggregations = originalTableWriterNode.getStatisticsAggregation() .map(aggregations -> aggregations.splitIntoPartialAndIntermediate(variableAllocator, metadata.getFunctionManager())); PlanWithProperties tableWriter = planAndEnforceChildren( new TableWriterNode( originalTableWriterNode.getId(), originalTableWriterNode.getSource(), originalTableWriterNode.getTarget(), variableAllocator.newVariable("partialrowcount", BIGINT), variableAllocator.newVariable("partialfragments", VARBINARY), variableAllocator.newVariable("partialcontext", VARBINARY), originalTableWriterNode.getColumns(), originalTableWriterNode.getColumnNames(), originalTableWriterNode.getPartitioningScheme(), statisticAggregations.map(StatisticAggregations.Parts::getPartialAggregation)), fixedParallelism(), fixedParallelism()); PlanWithProperties gatheringExchange = deriveProperties( gatheringExchange( idAllocator.getNextId(), LOCAL, tableWriter.getNode()), tableWriter.getProperties()); return deriveProperties( new TableWriterMergeNode( idAllocator.getNextId(), gatheringExchange.getNode(), originalTableWriterNode.getRowCountVariable(), originalTableWriterNode.getFragmentVariable(), originalTableWriterNode.getTableCommitContextVariable(), statisticAggregations.map(StatisticAggregations.Parts::getFinalOrIntermediateAggregation)), gatheringExchange.getProperties()); }

Target:
public PlanWithProperties visitTableWriter(TableWriterNode originalTableWriterNode, StreamPreferredProperties parentPreferences) { if (getTaskWriterCount(session) == 1) { return planAndEnforceChildren(originalTableWriterNode, singleStream(), defaultParallelism(session)); } if (!isTableWriterMergeOperatorEnabled(session)) { return planAndEnforceChildren(originalTableWriterNode, fixedParallelism(), fixedParallelism()); } Optional<StatisticAggregations.Parts> statisticAggregations = originalTableWriterNode .getStatisticsAggregation() .map(aggregations -> aggregations.splitIntoPartialAndIntermediate( variableAllocator, metadata.getFunctionManager())); PlanWithProperties tableWriter = planAndEnforceChildren( new TableWriterNode( originalTableWriterNode.getId(), originalTableWriterNode.getSource(), originalTableWriterNode.getTarget(), variableAllocator.newVariable("partialrowcount", BIGINT), variableAllocator.newVariable("partialfragments", VARBINARY), variableAllocator.newVariable("partialcontext", VARBINARY), originalTableWriterNode.getColumns(), originalTableWriterNode.getColumnNames(), originalTableWriterNode.getPartitioningScheme(), statisticAggregations.map(StatisticAggregations.Parts::getPartialAggregation)), fixedParallelism(), fixedParallelism()); PlanWithProperties gatheringExchange = deriveProperties( gatheringExchange( idAllocator.getNextId(), LOCAL, tableWriter.getNode()), tableWriter.getProperties()); return deriveProperties( new TableWriterMergeNode( idAllocator.getNextId(), gatheringExchange.getNode(), originalTableWriterNode.getRowCountVariable(), originalTableWriterNode.getFragmentVariable(), originalTableWriterNode.getTableCommitContextVariable(), statisticAggregations.map(StatisticAggregations.Parts::getIntermediateAggregation)), gatheringExchange.getProperties()); }