Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/14488#discussion_r73457928
--- 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 --
We really need the 'raw' elements in each of these? I'd think they need to
be parsed. Your tests show this code not parsing escapes. Is that how it
behaved before? then OK.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]