You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "anuragmantri (via GitHub)" <gi...@apache.org> on 2023/03/04 03:16:31 UTC

[GitHub] [iceberg] anuragmantri commented on a diff in pull request #6913: Core: ReachableFileUtil.versionHintLocation() should not fail for table location with just bucket name

anuragmantri commented on code in PR #6913:
URL: https://github.com/apache/iceberg/pull/6913#discussion_r1125258720


##########
core/src/test/java/org/apache/iceberg/TestPaths.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
+
+import java.net.URISyntaxException;
+import org.apache.hadoop.fs.Path;
+import org.junit.Test;
+
+public class TestPaths {
+
+  @Test
+  public void testPathsWithNoTrailingSlash() {
+    String pathWithoutTrailingSlash = "s3a://bucket1";
+    String metadataLocation = "/metadata";
+    String metadataLocationWithoutLeadingSlash = "metadata";
+
+    String expectedPath = "s3a://bucket1/metadata";
+
+    assertThrows(

Review Comment:
   Done.



##########
core/src/main/java/org/apache/iceberg/ReachableFileUtil.java:
##########
@@ -33,7 +33,7 @@
 public class ReachableFileUtil {
 
   private static final Logger LOG = LoggerFactory.getLogger(ReachableFileUtil.class);
-  private static final String METADATA_FOLDER_NAME = "metadata";
+  private static final String METADATA_FOLDER_NAME = "/metadata";

Review Comment:
   You are right, I changed the place where this path is constructed in `versionHintLocation()` by adding the slash there. 



##########
core/src/test/java/org/apache/iceberg/TestPaths.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
+
+import java.net.URISyntaxException;
+import org.apache.hadoop.fs.Path;
+import org.junit.Test;
+
+public class TestPaths {

Review Comment:
   @nastra this happens only with S3 file paths and not with hadoop file paths. Unfortunately, all our tests use local paths using hadoop Path objects. I could not find integration tests with S3 paths but using hadoop fileIO. Do you have a suggestion on how this can be tested? 



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org