diff --git a/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java b/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java index 94238e41b72f..56f5fff51852 100644 --- a/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java +++ b/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java @@ -1075,10 +1075,7 @@ public Optional finishCreateTable(ConnectorSession sess { HiveOutputTableHandle handle = (HiveOutputTableHandle) tableHandle; - List partitionUpdates = fragments.stream() - .map(Slice::getBytes) - .map(partitionUpdateCodec::fromJson) - .collect(toList()); + List partitionUpdates = getPartitionUpdates(fragments); WriteInfo writeInfo = locationService.getQueryWriteInfo(handle.getLocationHandle()); Table table = buildTableObject( @@ -1297,10 +1294,7 @@ public Optional finishInsert(ConnectorSession session, { HiveInsertTableHandle handle = (HiveInsertTableHandle) insertHandle; - List partitionUpdates = fragments.stream() - .map(Slice::getBytes) - .map(partitionUpdateCodec::fromJson) - .collect(toList()); + List partitionUpdates = getPartitionUpdates(fragments); HiveStorageFormat tableStorageFormat = handle.getTableStorageFormat(); partitionUpdates = PartitionUpdate.mergePartitionUpdates(partitionUpdates); @@ -2044,6 +2038,14 @@ private static boolean hasAdminRole(Set roles) return roles.stream().anyMatch(principal -> principal.getName().equalsIgnoreCase(ADMIN_ROLE_NAME)); } + private List getPartitionUpdates(Collection fragments) + { + return fragments.stream() + .map(Slice::getBytes) + .map(partitionUpdateCodec::fromJson) + .collect(toList()); + } + private void verifyJvmTimeZone() { if (!allowCorruptWritesForTesting && !timeZone.equals(DateTimeZone.getDefault())) {