Source:
<code>public void createEmptyPartition(ConnectorSession session, String schema, String table, List<Object> partitionColumnNames, List<Object> partitionValues) { HiveMetadata hiveMetadata = hiveMetadataFactory.create(); HiveInsertTableHandle hiveInsertTableHandle = hiveMetadata.beginInsert(session, new HiveTableHandle(schema, table)); List<String> actualPartitionColumnNames = hiveInsertTableHandle.getInputColumns().stream() .filter(HiveColumnHandle::isPartitionKey) .map(HiveColumnHandle::getName) .collect(toImmutableList()); checkArgument(Objects.equals(partitionColumnNames, actualPartitionColumnNames), "input partition column names doesn't match actual partition column names"); List<String> partitionStringValues = partitionValues.stream() .map(String.class::cast) .collect(toImmutableList()); if (metastore.getPartition(schema, table, partitionStringValues).isPresent()) { throw new PrestoException(ALREADY_EXISTS, "Partition already exists"); } String partitionName = FileUtils.makePartName(actualPartitionColumnNames, partitionStringValues); WriteInfo writeInfo = locationService.getPartitionWriteInfo(hiveInsertTableHandle.getLocationHandle(), Optional.empty(), partitionName); hiveMetadata.finishInsert( session, hiveInsertTableHandle, ImmutableList.of( <START> Slices.wrappedBuffer( <END> partitionUpdateJsonCodec.toJsonBytes( new PartitionUpdate( partitionName, UpdateMode.NEW, writeInfo.getWritePath(), writeInfo.getTargetPath(), ImmutableList.of(), 0, 0, 0)))), ImmutableList.of()); hiveMetadata.commit(); }</code><technical_language>This is hard read. add a variable</technical_language>

Target:
public void createEmptyPartition(ConnectorSession session, String schema, String table, List<Object> partitionColumnNames, List<Object> partitionValues) { TransactionalMetadata hiveMetadata = hiveMetadataFactory.get(); HiveInsertTableHandle hiveInsertTableHandle = (HiveInsertTableHandle) hiveMetadata.beginInsert(session, new HiveTableHandle(schema, table)); List<String> actualPartitionColumnNames = hiveInsertTableHandle.getInputColumns().stream() .filter(HiveColumnHandle::isPartitionKey) .map(HiveColumnHandle::getName) .collect(toImmutableList()); if (!Objects.equals(partitionColumnNames, actualPartitionColumnNames)) { throw new PrestoException(INVALID_PROCEDURE_ARGUMENT, "input partition column names doesn't match actual partition column names"); } List<String> partitionStringValues = partitionValues.stream() .map(String.class::cast) .collect(toImmutableList()); if (metastore.getPartition(schema, table, partitionStringValues).isPresent()) { throw new PrestoException(ALREADY_EXISTS, "Partition already exists"); } String partitionName = FileUtils.makePartName(actualPartitionColumnNames, partitionStringValues); WriteInfo writeInfo = locationService.getPartitionWriteInfo(hiveInsertTableHandle.getLocationHandle(), Optional.empty(), partitionName); Slice serializedPartitionUpdate = Slices.wrappedBuffer( partitionUpdateJsonCodec.toJsonBytes( new PartitionUpdate( partitionName, UpdateMode.NEW, writeInfo.getWritePath(), writeInfo.getTargetPath(), ImmutableList.of(), 0, 0, 0))); hiveMetadata.finishInsert( session, hiveInsertTableHandle, ImmutableList.of(serializedPartitionUpdate), ImmutableList.of()); hiveMetadata.commit(); }