-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-33912][SQL] Refactor DependencyUtils ivy property parameter #30928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
83686af
978e994
23d4451
7da53f2
e09d8e0
c7d1aee
de0eee1
de1225d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,11 +29,11 @@ import org.apache.spark.deploy.SparkSubmitUtils | |
| import org.apache.spark.internal.Logging | ||
|
|
||
| case class IvyProperties( | ||
| packagesExclusions: String, | ||
| packages: String, | ||
| repositories: String, | ||
| ivyRepoPath: String, | ||
| ivySettingsPath: String) | ||
| packagesExclusions: Option[String], | ||
| packages: Option[String], | ||
| repositories: Option[String], | ||
| ivyRepoPath: Option[String], | ||
| ivySettingsPath: Option[String]) | ||
|
|
||
| private[spark] object DependencyUtils extends Logging { | ||
|
|
||
|
|
@@ -44,7 +44,7 @@ private[spark] object DependencyUtils extends Logging { | |
| "spark.jars.repositories", | ||
| "spark.jars.ivy", | ||
| "spark.jars.ivySettings" | ||
| ).map(sys.props.get(_).orNull) | ||
| ).map(sys.props.get(_)) | ||
| IvyProperties(packagesExclusions, packages, repositories, ivyRepoPath, ivySettingsPath) | ||
| } | ||
|
|
||
|
|
@@ -69,10 +69,10 @@ private[spark] object DependencyUtils extends Logging { | |
| * Example: Input: excludeorg.mortbay.jetty:jetty,org.eclipse.jetty:jetty-http | ||
| * Output: [org.mortbay.jetty:jetty,org.eclipse.jetty:jetty-http] | ||
| */ | ||
| private def parseQueryParams(uri: URI): (Boolean, String) = { | ||
| private def parseQueryParams(uri: URI): (Boolean, Option[String]) = { | ||
| val uriQuery = uri.getQuery | ||
| if (uriQuery == null) { | ||
| (false, "") | ||
| (false, None) | ||
| } else { | ||
| val mapTokens = uriQuery.split("&").map(_.split("=")) | ||
| if (mapTokens.exists(isInvalidQueryString)) { | ||
|
|
@@ -103,7 +103,7 @@ private[spark] object DependencyUtils extends Logging { | |
| } | ||
| excludes | ||
| }.mkString(",") | ||
| }.getOrElse("") | ||
| } | ||
|
|
||
| val validParams = Set("transitive", "exclude") | ||
| val invalidParams = groupedParams.keys.filterNot(validParams.contains).toSeq | ||
|
|
@@ -150,36 +150,36 @@ private[spark] object DependencyUtils extends Logging { | |
| resolveMavenDependencies( | ||
| transitive, | ||
| exclusionList, | ||
| authority, | ||
| Some(authority), | ||
| ivyProperties.repositories, | ||
| ivyProperties.ivyRepoPath, | ||
| Option(ivyProperties.ivySettingsPath) | ||
| ivyProperties.ivySettingsPath | ||
| ).split(",") | ||
| } | ||
|
|
||
| def resolveMavenDependencies( | ||
| packagesTransitive: Boolean, | ||
| packagesExclusions: String, | ||
| packages: String, | ||
| repositories: String, | ||
| ivyRepoPath: String, | ||
| packagesExclusions: Option[String], | ||
| packages: Option[String], | ||
| repositories: Option[String], | ||
| ivyRepoPath: Option[String], | ||
| ivySettingsPath: Option[String]): String = { | ||
| val exclusions: Seq[String] = | ||
| if (!StringUtils.isBlank(packagesExclusions)) { | ||
| packagesExclusions.split(",") | ||
| if (packagesExclusions.nonEmpty) { | ||
| packagesExclusions.map(_.split(",")).get | ||
| } else { | ||
| Nil | ||
| } | ||
|
||
| // Create the IvySettings, either load from file or build defaults | ||
| val ivySettings = ivySettingsPath match { | ||
| case Some(path) => | ||
| SparkSubmitUtils.loadIvySettings(path, Option(repositories), Option(ivyRepoPath)) | ||
| SparkSubmitUtils.loadIvySettings(path, repositories, ivyRepoPath) | ||
|
|
||
| case None => | ||
| SparkSubmitUtils.buildIvySettings(Option(repositories), Option(ivyRepoPath)) | ||
| SparkSubmitUtils.buildIvySettings(repositories, ivyRepoPath) | ||
| } | ||
|
|
||
| SparkSubmitUtils.resolveMavenCoordinates(packages, ivySettings, | ||
| SparkSubmitUtils.resolveMavenCoordinates(packages.get, ivySettings, | ||
|
||
| transitive = packagesTransitive, exclusions = exclusions) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but why do we bother change this? Looks like there are a lot of
nulls above too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, that's why I asked about #30928 (comment)
Since want to refactor parameter to use
Option[String], but here are justString, so change this place .There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stringvsnullis a valid way probably in Java context.Optionmight be preferred since we're in Scala but I wouldn't change it just for this reason. The gain is small compared to the size of change and potential maintenance overhead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So would you prefer to keep current or revert this change and just make it as Option when use method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I wouldn't particularly mind when I read these codes. If you still prefer, feel free to wait for other committers' approval or review. I don't mind if any committer prefers and wants to merge it in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, wait for other committer's review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be neutral on it - but if we're just changing a few instances? not sure it's worth the inconsistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decide to change this since there is already a Option[String]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm neutral on this change, too. I find
xxx: String = nullin many places of thecorepackage and I'm not sure that this partial fix can make any benefit.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, revert this change. about this.How about current