You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/12/02 08:19:14 UTC

[GitHub] [spark] HeartSaVioR commented on a change in pull request #26195: [SPARK-29537][SQL] throw exception when user defined a wrong base path

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


With regards,
Apache Git Services

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