jackye1995 commented on a change in pull request #1863:
URL: https://github.com/apache/iceberg/pull/1863#discussion_r534559328
##########
File path: aws/src/main/java/org/apache/iceberg/aws/s3/BaseS3File.java
##########
@@ -75,13 +76,14 @@ public boolean exists() {
}
}
- protected HeadObjectResponse getObjectMetadata() throws S3Exception {
+ protected S3Object getObjectMetadata() throws S3Exception {
if (metadata == null) {
- HeadObjectRequest.Builder requestBuilder = HeadObjectRequest.builder()
+ ListObjectsV2Response response =
client().listObjectsV2(ListObjectsV2Request.builder()
.bucket(uri().bucket())
- .key(uri().key());
- S3RequestUtil.configureEncryption(awsProperties, requestBuilder);
- metadata = client().headObject(requestBuilder.build());
+ .prefix(uri().key())
+ .maxKeys(1)
+ .build());
+ metadata = response.hasContents() ? response.contents().get(0) : null;
Review comment:
Yeah I was going to ask, I saw in `HadoopInputFile` it simply throws a
`RuntimeIOException` when asking for length of a file not exist. Probably
better to check existence and throw `NotFoundException` in this case.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]