Skip to content

Commit

Permalink
Fix request partitions from Glue logic
Browse files Browse the repository at this point in the history
In case requested partition are not found in Glue API can return empty partitions and empty unprocessed keys.
  • Loading branch information
pajaks committed Feb 15, 2024
1 parent eac7b9f commit af2cd84
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.base.Verify.verify;
import static com.google.common.collect.Comparators.lexicographical;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.ImmutableMap.toImmutableMap;
Expand Down Expand Up @@ -1058,8 +1057,8 @@ private List<Partition> batchGetPartition(Table table, Collection<String> partit
List<PartitionValueList> unprocessedKeys = batchGetPartitionResult.getUnprocessedKeys();

// In the unlikely scenario where batchGetPartition call cannot make progress on retrieving partitions, avoid infinite loop
if (partitions.isEmpty()) {
verify(!unprocessedKeys.isEmpty(), "Empty unprocessedKeys for non-empty BatchGetPartitionRequest and empty partitions result");
// We fail only in case there are still unprocessedKeys. Case with empty partitions and empty unprocessedKeys is correct in case partitions from request are not found.
if (partitions.isEmpty() && !unprocessedKeys.isEmpty()) {
throw new TrinoException(HIVE_METASTORE_ERROR, "Cannot make progress retrieving partitions. Unable to retrieve partitions: " + unprocessedKeys);
}

Expand Down

0 comments on commit af2cd84

Please sign in to comment.