HeartSaVioR 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_r352462320
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PartitioningAwareFileIndex.scala
 ##########
 @@ -221,6 +221,15 @@ abstract class PartitioningAwareFileIndex(
         if (!fs.isDirectory(userDefinedBasePath)) {
           throw new IllegalArgumentException(s"Option '$BASE_PATH_PARAM' must 
be a directory")
         }
+        def qualifiedPath(path: Path): Path = path.makeQualified(fs.getUri, 
fs.getWorkingDirectory)
+
+        val qualifiedBasePath = qualifiedPath(userDefinedBasePath)
+        rootPaths
+          .find(p => 
!qualifiedPath(p).toString.startsWith(qualifiedBasePath.toString))
+          .foreach { rp =>
+            throw new IllegalArgumentException(
+              s"Wrong basePath $userDefinedBasePath for the root path: $rp")
+          }
         Set(fs.makeQualified(userDefinedBasePath))
 
 Review comment:
   Can be simply `Set(qualifiedBasePath)` as we now calculated it before; if we 
want to change `qualifiedPath()` to return String, `Set(new 
Path(qualifiedBasePath))`.

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