diff --git a/mr/src/main/java/org/apache/iceberg/mr/mapreduce/IcebergSplit.java b/mr/src/main/java/org/apache/iceberg/mr/mapreduce/IcebergSplit.java index 7c95fbe20599..0d6c44074539 100644 --- a/mr/src/main/java/org/apache/iceberg/mr/mapreduce/IcebergSplit.java +++ b/mr/src/main/java/org/apache/iceberg/mr/mapreduce/IcebergSplit.java @@ -74,9 +74,13 @@ public long getLength() { @Override public String[] getLocations() { - if (locations == null) { + // The implementation of getLocations() is only meant to be used during split computation + // getLocations() won't be accurate when called on worker nodes and will always return "*" + if (locations == null && conf != null) { boolean localityPreferred = conf.getBoolean(InputFormatConfig.LOCALITY, false); locations = localityPreferred ? Util.blockLocations(task, conf) : ANYWHERE; + } else { + locations = ANYWHERE; } return locations;