hudi-agent commented on code in PR #19747:
URL: https://github.com/apache/hudi/pull/19747#discussion_r3865318545


##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/TestSparkClientFunctionalTestHarness.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.hudi.testutils;
+
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.testutils.HoodieTestTable;
+import org.apache.hudi.storage.StoragePath;
+
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Covers the path contract of {@link SparkClientFunctionalTestHarness} 
(HUDI-6042).
+ */
+public class TestSparkClientFunctionalTestHarness extends 
SparkClientFunctionalTestHarness {
+
+  @Test
+  public void basePathHasNoSchemeAndBaseUriDoes() {
+    assertFalse(basePath().startsWith("file:"),
+        "basePath() must be unqualified so java.nio.file.Paths can consume it, 
but was " + basePath());
+    assertTrue(Paths.get(basePath()).isAbsolute(),
+        "basePath() must resolve to an absolute path, but was " + basePath());
+    assertEquals("file", baseUri().getScheme(), "baseUri() must keep the 
scheme");
+    assertEquals(basePath(), Paths.get(baseUri()).toString(),
+        "baseUri() and basePath() must point at the same directory");
+  }
+
+  @Test
+  public void nioResolvesPartitionsUnderTheTableDirectory() {
+    // A scheme-qualified basePath() silently yields a relative path here, 
placing partitions under
+    // the working directory rather than the table. This is the failure mode 
FileCreateUtils hits.
+    java.nio.file.Path partition = Paths.get(basePath(), "2016/03/15");
+    assertTrue(partition.isAbsolute(), "partition path must be absolute, but 
was " + partition);
+    assertTrue(partition.startsWith(Paths.get(basePath())),
+        "partition path must sit under the table directory, but was " + 
partition);
+  }
+
+  @Test

Review Comment:
   🤖 nit: since there's no competing `Path` type imported here, could you add 
`import java.nio.file.Path;` and drop the fully-qualified name for readability?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to