Ngone51 commented on a change in pull request #26195: [SPARK-29537][SQL] throw 
exception when user defined a wrong base path
URL: https://github.com/apache/spark/pull/26195#discussion_r352590490
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PartitioningAwareFileIndex.scala
 ##########
 @@ -221,7 +221,16 @@ abstract class PartitioningAwareFileIndex(
         if (!fs.isDirectory(userDefinedBasePath)) {
           throw new IllegalArgumentException(s"Option '$BASE_PATH_PARAM' must 
be a directory")
         }
-        Set(fs.makeQualified(userDefinedBasePath))
+        def qualifiedPath(path: Path): String = fs.makeQualified(path).toString
+
+        val qualifiedBasePath = qualifiedPath(userDefinedBasePath)
+        rootPaths
+          .find(p => !qualifiedPath(p).startsWith(qualifiedBasePath))
+          .foreach { rp =>
+            throw new IllegalArgumentException(
+              s"Wrong basePath $userDefinedBasePath for the root path: $rp")
+          }
+        Set(new Path(qualifiedBasePath))
 
 Review comment:
   Ok, I see.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to