Source:
private TableScanNode createTemporaryTableScan( TableHandle tableHandle, List<VariableReferenceExpression> outputVariables, Map<VariableReferenceExpression, ColumnMetadata> variableToColumnMap, PartitioningMetadata expectedPartitioningMetadata) { Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle); Map<VariableReferenceExpression, ColumnMetadata> outputColumns = outputVariables.stream() .collect(toImmutableMap(identity(), variableToColumnMap::get)); Set<ColumnHandle> outputColumnHandles = outputColumns.values().stream() .map(ColumnMetadata::getName) .map(columnHandles::get) .collect(toImmutableSet()); TableLayoutResult selectedLayout = metadata.getLayout(session, tableHandle, Constraint.alwaysTrue(), Optional.of(outputColumnHandles)); verify(selectedLayout.getUnenforcedConstraint().equals(TupleDomain.all()), "temporary table layout shouldn't enforce any constraints"); verify(!selectedLayout.getLayout().getColumns().isPresent(), "temporary table layout must provide all the columns"); List<ColumnHandle> expectedPartitioningColumns = expectedPartitioningMetadata.getPartitionColumns().stream() .map(columnHandles::get) .collect(toImmutableList()); verify(selectedLayout.getLayout().getTablePartitioning().get().getPartitioningColumns() .equals(expectedPartitioningColumns), "invalid temporary table partition columns"); Map<VariableReferenceExpression, ColumnHandle> assignments = outputVariables.stream() .collect(toImmutableMap(identity(), variable -> columnHandles.get(outputColumns.get(variable).getName()))); return new TableScanNode( idAllocator.getNextId(), selectedLayout.getLayout().getNewTableHandle(), outputVariables, assignments, TupleDomain.all(), TupleDomain.all()); }

Target:
private TableScanNode createTemporaryTableScan( TableHandle tableHandle, List<VariableReferenceExpression> outputVariables, Map<VariableReferenceExpression, ColumnMetadata> variableToColumnMap, PartitioningMetadata expectedPartitioningMetadata) { Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle); Map<VariableReferenceExpression, ColumnMetadata> outputColumns = outputVariables.stream() .collect(toImmutableMap(identity(), variableToColumnMap::get)); Set<ColumnHandle> outputColumnHandles = outputColumns.values().stream() .map(ColumnMetadata::getName) .map(columnHandles::get) .collect(toImmutableSet()); TableLayoutResult selectedLayout = metadata.getLayout(session, tableHandle, Constraint.alwaysTrue(), Optional.of(outputColumnHandles)); verify(selectedLayout.getUnenforcedConstraint().equals(TupleDomain.all()), "temporary table layout shouldn't enforce any constraints"); verify(!selectedLayout.getLayout().getColumns().isPresent(), "temporary table layout must provide all the columns"); TablePartitioning expectedPartitioning = new TablePartitioning( expectedPartitioningMetadata.getPartitioningHandle(), expectedPartitioningMetadata.getPartitionColumns().stream() .map(columnHandles::get) .collect(toImmutableList())); verify(selectedLayout.getLayout().getTablePartitioning().equals(Optional.of(expectedPartitioning)), "invalid temporary table partitioning"); Map<VariableReferenceExpression, ColumnHandle> assignments = outputVariables.stream() .collect(toImmutableMap(identity(), variable -> columnHandles.get(outputColumns.get(variable).getName()))); return new TableScanNode( idAllocator.getNextId(), selectedLayout.getLayout().getNewTableHandle(), outputVariables, assignments, TupleDomain.all(), TupleDomain.all()); }