-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-2678][Core] Added "--" to prevent spark-submit from shadowing application options #1715
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 all commits
2774138
e246367
6c23c52
b8059c0
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 |
|---|---|---|
|
|
@@ -311,6 +311,27 @@ private[spark] class SparkSubmitArguments(args: Seq[String]) { | |
| verbose = true | ||
| parse(tail) | ||
|
|
||
| case ("--primary" | "-p") :: value :: tail => | ||
| primaryResource = if (!SparkSubmit.isShell(value) && !SparkSubmit.isInternal(value)) { | ||
| Utils.resolveURI(value).toString | ||
| } else { | ||
| value | ||
| } | ||
| isPython = SparkSubmit.isPython(value) | ||
| parse(tail) | ||
|
|
||
| case "--" :: tail => | ||
| if (inSparkOpts) { | ||
| // Primary resource is specified with "--primary", "--" is considered as the separator of | ||
| // spark-submit options and user application options. | ||
| childArgs ++= tail | ||
| } else { | ||
| // Primary resource is specified as a positional argument, "--" is passed to the | ||
| // application as a normal argument. | ||
| childArgs += "--" | ||
| parse(tail) | ||
| } | ||
|
|
||
| case value :: tail => | ||
| if (inSparkOpts) { | ||
| value match { | ||
|
|
@@ -322,6 +343,14 @@ private[spark] class SparkSubmitArguments(args: Seq[String]) { | |
| val errMessage = s"Unrecognized option '$value'." | ||
| SparkSubmit.printErrorAndExit(errMessage) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the user attempts to pass a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you indicating cases like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed this locally with current master code.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see. The whole point of this PR is not to make arguments like
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and they only get here if they do |
||
| case v => | ||
| if (primaryResource != null) { | ||
| // Primary resource has already been specified by --primary. It's more likely that | ||
| // user forgot using -- to separate application options from spark-submit options. | ||
| SparkSubmit.printErrorAndExit( | ||
| s"Unrecognized option '$value', " + | ||
| "note that application options must appear after \"--\".") | ||
| } | ||
|
|
||
| primaryResource = | ||
| if (!SparkSubmit.isShell(v) && !SparkSubmit.isInternal(v)) { | ||
| Utils.resolveURI(v).toString | ||
|
|
@@ -349,7 +378,10 @@ private[spark] class SparkSubmitArguments(args: Seq[String]) { | |
| outStream.println("Unknown/unsupported param " + unknownParam) | ||
| } | ||
| outStream.println( | ||
| """Usage: spark-submit [options] <app jar | python file> [app options] | ||
| """Usage: | ||
| | spark-submit [options] <app jar | python file> [app options] | ||
| | spark-submit [options] --primary <app jar | python file> -- [app options] | ||
| | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changes the length of the help output message. Have you verified that all the other scripts (spark-class, spark-submit, pyspark etc.) report the entirety of the help message?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
| |Options: | ||
| | --master MASTER_URL spark://host:port, mesos://host:port, yarn, or local. | ||
| | --deploy-mode DEPLOY_MODE Whether to launch the driver program locally ("client") or | ||
|
|
@@ -377,8 +409,15 @@ private[spark] class SparkSubmitArguments(args: Seq[String]) { | |
| | | ||
| | --executor-memory MEM Memory per executor (e.g. 1000M, 2G) (Default: 1G). | ||
| | | ||
| | --help, -h Show this help message and exit | ||
| | --verbose, -v Print additional debug output | ||
| | --help, -h Show this help message and exit. | ||
| | --verbose, -v Print additional debug output. | ||
| | | ||
| | --primary The primary jar file or Python file of the application. Used | ||
| | in conjunction with "--" to pass arbitrary arguments to the | ||
| | application if any. | ||
| | -- A "--" signals the end of spark-submit options, everything | ||
| | after "--" are passed as command line arguments to the | ||
| | application. Only used in conjunction with "--primary". | ||
| | | ||
| | Spark standalone with cluster deploy mode only: | ||
| | --driver-cores NUM Cores for driver (Default: 1). | ||
|
|
||
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.
These changes seem unrelated. Is there a bug you can mention? Otherwise, could you call them out explicitly in the PR description?
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.
My bad, you're right. I should update the PR description.
While working on #1620, the
beelinescript had once been implemented withspark-submitto avoid duplicatedjavacheck and computing classpath, but then reverted because of the issue this PR is trying to fix (beeline --helpshowsspark-submitusage message).And while working on this PR, I realized that
beelineis only a JDBC client, and unrelated to Spark, I can just start it withspark-class. That's the reason why this change appear here.