Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20611#discussion_r211106063
  
    --- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
    @@ -1976,6 +1976,40 @@ private[spark] object Utils extends Logging {
         }
       }
     
    +  /**
    +   * Returns a qualified path object, API ported from 
org.apache.hadoop.fs.Path class
    +   * @param defaultUri default uri corresponding to the filesystem 
provided.
    +   * @param workingDir the working directory for the particular child path 
wd-relative names.
    +   * @param path Path instance based on the path string specified by the 
user.
    +   * @return Returns a qualified path object
    +   */
    +  def makeQualified(defaultUri: URI, workingDir: Path, path: Path): Path = 
{
    +    val pathUri = if (!path.isAbsolute()) new Path(workingDir, 
path).toUri() else path.toUri()
    +    val newPaths = {
    +      if (pathUri.getScheme == null || pathUri.getAuthority == null &&
    +          defaultUri.getAuthority != null) {
    +        val scheme = if (pathUri.getScheme == null) defaultUri.getScheme 
else pathUri.getScheme
    +        val authority = {
    +          if (pathUri.getAuthority == null) {
    +            if (defaultUri.getAuthority == null) "" else 
defaultUri.getAuthority
    +          } else {
    +            pathUri.getAuthority
    +          }
    +        }
    +        try {
    +          var newUri = new URI(scheme, authority, pathUri.getPath, 
null.asInstanceOf[String],
    +            pathUri.getFragment)
    +          new Path(newUri)
    +        } catch {
    +          case exception: URISyntaxException =>
    +            throw new IllegalArgumentException(exception)
    +        }
    +      }
    +      else path
    --- End diff --
    
    ```
    } else {
      path
    }
    ```


---

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

Reply via email to