Source:
public ConnectorTableHandle createTemporaryTable(ConnectorSession session, List<ColumnMetadata> columns, Optional<ConnectorPartitioningMetadata> partitioningMetadata) { String schemaName = getTemporaryTableSchema(session); String tableName = PRESTO_TEMPORARY_TABLE_NAME_PREFIX + randomUUID().toString().replaceAll("-", "_"); HiveStorageFormat storageFormat = getTemporaryTableStorageFormat(session); Optional<HiveBucketProperty> bucketProperty = partitioningMetadata.map(partitioning -> { Set<String> allColumns = columns.stream() .map(ColumnMetadata::getName) .collect(toImmutableSet()); if (!allColumns.containsAll(partitioning.getPartitionColumns())) { throw new PrestoException(INVALID_TABLE_PROPERTY, format( "Bucketing columns %s not present in schema", Sets.difference(ImmutableSet.copyOf(partitioning.getPartitionColumns()), allColumns))); } HivePartitioningHandle partitioningHandle = (HivePartitioningHandle) partitioning.getPartitioningHandle(); return new HiveBucketProperty(partitioning.getPartitionColumns(), partitioningHandle.getBucketCount(), ImmutableList.of()); }); List<HiveColumnHandle> columnHandles = getColumnHandles( translateHiveUnsupportedTypesForTemporaryTable(columns, typeManager), ImmutableSet.of(), typeTranslator, getDefaultHiveTypeForTemporaryTable(storageFormat)); validateColumns(storageFormat, columnHandles); Table table = Table.builder() .setDatabaseName(schemaName) .setTableName(tableName) .setOwner(session.getUser()) .setTableType(TEMPORARY_TABLE) .setDataColumns(columnHandles.stream() .map(handle -> new Column(handle.getName(), handle.getHiveType(), handle.getComment())) .collect(toImmutableList())) .withStorage(storage -> storage .setStorageFormat(fromHiveStorageFormat(storageFormat)) .setBucketProperty(bucketProperty) .setLocation("")) .build(); metastore.createTable( session, table, buildInitialPrivilegeSet(table.getOwner()), Optional.empty(), false, new PartitionStatistics(createEmptyStatistics(), ImmutableMap.of())); return new HiveTableHandle(schemaName, tableName); }

Target:
public ConnectorTableHandle createTemporaryTable(ConnectorSession session, List<ColumnMetadata> columns, Optional<ConnectorPartitioningMetadata> partitioningMetadata) { String schemaName = getTemporaryTableSchema(session); String tableName = PRESTO_TEMPORARY_TABLE_NAME_PREFIX + randomUUID().toString().replaceAll("-", "_"); HiveStorageFormat storageFormat = getTemporaryTableStorageFormat(session); Optional<HiveBucketProperty> bucketProperty = partitioningMetadata.map(partitioning -> { Set<String> allColumns = columns.stream() .map(ColumnMetadata::getName) .collect(toImmutableSet()); if (!allColumns.containsAll(partitioning.getPartitionColumns())) { throw new PrestoException(INVALID_TABLE_PROPERTY, format( "Bucketing columns %s not present in schema", Sets.difference(ImmutableSet.copyOf(partitioning.getPartitionColumns()), allColumns))); } HivePartitioningHandle partitioningHandle = (HivePartitioningHandle) partitioning.getPartitioningHandle(); return new HiveBucketProperty(partitioning.getPartitionColumns(), partitioningHandle.getBucketCount(), ImmutableList.of()); }); Optional<HiveType> defaultHiveType = storageFormat == PAGEFILE ? Optional.of(HIVE_BINARY) : Optional.empty(); List<HiveColumnHandle> columnHandles = getColumnHandles( translateHiveUnsupportedTypesForTemporaryTable(columns, typeManager), ImmutableSet.of(), typeTranslator, defaultHiveType); validateColumns(storageFormat, columnHandles); Table table = Table.builder() .setDatabaseName(schemaName) .setTableName(tableName) .setOwner(session.getUser()) .setTableType(TEMPORARY_TABLE) .setDataColumns(columnHandles.stream() .map(handle -> new Column(handle.getName(), handle.getHiveType(), handle.getComment())) .collect(toImmutableList())) .withStorage(storage -> storage .setStorageFormat(fromHiveStorageFormat(storageFormat)) .setBucketProperty(bucketProperty) .setLocation("")) .build(); metastore.createTable( session, table, buildInitialPrivilegeSet(table.getOwner()), Optional.empty(), false, new PartitionStatistics(createEmptyStatistics(), ImmutableMap.of())); return new HiveTableHandle(schemaName, tableName); }