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

    https://github.com/apache/spark/pull/14488#discussion_r73458498
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
 ---
    @@ -749,25 +749,44 @@ case class ParseUrl(children: Seq[Expression])
         Pattern.compile(REGEXPREFIX + key.toString + REGEXSUBFIX)
       }
     
    -  private def getUrl(url: UTF8String): URL = {
    +  private def getUrl(url: UTF8String): URI = {
         try {
    -      new URL(url.toString)
    +      new URI(url.toString)
         } catch {
    -      case e: MalformedURLException => null
    +      case e: URISyntaxException => null
         }
       }
     
    -  private def getExtractPartFunc(partToExtract: UTF8String): URL => String 
= {
    +  private def getExtractPartFunc(partToExtract: UTF8String): URI => String 
= {
    +
    +    // partToExtract match {
    +    //   case HOST => _.toURL().getHost
    +    //   case PATH => _.toURL().getPath
    +    //   case QUERY => _.toURL().getQuery
    +    //   case REF => _.toURL().getRef
    +    //   case PROTOCOL => _.toURL().getProtocol
    +    //   case FILE => _.toURL().getFile
    +    //   case AUTHORITY => _.toURL().getAuthority
    +    //   case USERINFO => _.toURL().getUserInfo
    +    //   case _ => (url: URI) => null
    +    // }
    +
         partToExtract match {
           case HOST => _.getHost
    -      case PATH => _.getPath
    -      case QUERY => _.getQuery
    -      case REF => _.getRef
    -      case PROTOCOL => _.getProtocol
    -      case FILE => _.getFile
    -      case AUTHORITY => _.getAuthority
    -      case USERINFO => _.getUserInfo
    -      case _ => (url: URL) => null
    +      case PATH => _.getRawPath
    +      case QUERY => _.getRawQuery
    +      case REF => _.getRawFragment
    +      case PROTOCOL => _.getScheme
    +      case FILE =>
    +        (url: URI) =>
    +          if (url.getRawQuery ne null) {
    --- End diff --
    
    It does seem so:
    ```
    scala> new URL("http://example.com/path%20?query=x%20#hash%20";).getQuery()
    res1: String = query=x%20
    
    scala> new URL("http://example.com/path%20?query=x%20#hash%20";).getRef()
    res2: String = hash%20
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to