Source:
private TableScanNode createTemporaryTableScan( TableHandle tableHandle, List<Symbol> outputSymbols, Map<Symbol, ColumnMetadata> temporaryTableColumns, PartitioningMetadata expectedPartitioningMetadata) { Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle); Map<Symbol, ColumnMetadata> outputColumns = outputSymbols.stream() .collect(toImmutableMap(identity(), temporaryTableColumns::get)); Set<ColumnHandle> outputColumnHandles = outputColumns.values().stream() .map(ColumnMetadata::getName) .map(columnHandles::get) .collect(toImmutableSet()); List<TableLayoutResult> layouts = metadata.getLayouts(session, tableHandle, Constraint.alwaysTrue(), Optional.of(outputColumnHandles)); checkArgument(layouts.size() == 1, "temporary table is expected to have exactly one layout"); TableLayoutResult selectedLayout = getOnlyElement(layouts); 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"); TableLayoutHandle layoutHandle = selectedLayout.getLayout().getHandle(); Map<Symbol, ColumnHandle> assignments = outputSymbols.stream() .collect(toImmutableMap(identity(), symbol -> columnHandles.get(outputColumns.get(symbol).getName()))); return new TableScanNode( idAllocator.getNextId(), tableHandle, outputSymbols, assignments, Optional.of(layoutHandle), TupleDomain.all(), TupleDomain.all()); }

Target:
private TableScanNode createTemporaryTableScan( TableHandle tableHandle, List<Symbol> outputSymbols, Map<Symbol, ColumnMetadata> temporaryTableColumns, PartitioningMetadata expectedPartitioningMetadata) { Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle); Map<Symbol, ColumnMetadata> outputColumns = outputSymbols.stream() .collect(toImmutableMap(identity(), temporaryTableColumns::get)); Set<ColumnHandle> outputColumnHandles = outputColumns.values().stream() .map(ColumnMetadata::getName) .map(columnHandles::get) .collect(toImmutableSet()); List<TableLayoutResult> layouts = metadata.getLayouts(session, tableHandle, Constraint.alwaysTrue(), Optional.of(outputColumnHandles)); checkArgument(layouts.size() == 1, "temporary table is expected to have exactly one layout"); TableLayoutResult selectedLayout = getOnlyElement(layouts); 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"); TableLayoutHandle layoutHandle = selectedLayout.getLayout().getHandle(); Map<Symbol, ColumnHandle> assignments = outputSymbols.stream() .collect(toImmutableMap(identity(), symbol -> columnHandles.get(outputColumns.get(symbol).getName()))); return new TableScanNode( idAllocator.getNextId(), tableHandle, outputSymbols, assignments, Optional.of(layoutHandle), TupleDomain.all(), TupleDomain.all(), true); }