-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-20519][SQL][CORE]Modify to prevent some possible runtime exceptions #17796
Conversation
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.
Don't make JIRAs for these; these are borderline not worth proposing, please.
@@ -916,7 +916,7 @@ private[spark] object Utils extends Logging { | |||
def setCustomHostname(hostname: String) { | |||
// DEBUG code | |||
Utils.checkHost(hostname) | |||
customHostname = Some(hostname) | |||
customHostname = Option(hostname) |
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.
This should be OK, but, it's already being checked for null in the line above.
c5896c7
to
e0eb912
Compare
ok, thanks for review it@srowen |
@@ -723,7 +723,7 @@ class SQLContext private[sql](val sparkSession: SparkSession) | |||
* @since 1.3.0 | |||
*/ | |||
def tables(databaseName: String): DataFrame = { | |||
Dataset.ofRows(sparkSession, ShowTablesCommand(Some(databaseName), None)) | |||
Dataset.ofRows(sparkSession, ShowTablesCommand(Option(databaseName), None)) |
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.
CC maybe @yhuai - OK to let tables(null)
act like tables()
? seems reasonable
@10110346 to be conservative, maybe remove the change to SQLContext. It's not clear to me that you are supposed to be able to call {{tables(null)}} because in this case you should call {{tables()}}. A NullPointerException seems like reasonable behavior. However I think you could also expand the improvement for |
I quite agree with you. |
Test build #3689 has finished for PR 17796 at commit
|
ok to test |
Test build #76482 has started for PR 17796 at commit |
Test FAILed. I don't know why. |
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.
Other than the message change, yes, looks good
def checkHost(host: String, message: String = "") { | ||
assert(host.indexOf(':') == -1, message) | ||
def checkHost(host: String) { | ||
assert(host != null && host.indexOf(':') == -1, "Expected hostname") |
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.
The message should be s"Expected hostname (not IP) but got $host"
def checkHostPort(hostPort: String, message: String = "") { | ||
assert(hostPort.indexOf(':') != -1, message) | ||
def checkHostPort(hostPort: String) { | ||
assert(hostPort != null && hostPort.indexOf(':') != -1, "Expected hostport") |
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.
Likewise here
Test build #76507 has finished for PR 17796 at commit
|
@srowen done, thank you very much. |
def checkHostPort(hostPort: String, message: String = "") { | ||
assert(hostPort.indexOf(':') != -1, message) | ||
def checkHostPort(hostPort: String) { | ||
assert(hostPort != null && hostPort.indexOf(':') != -1, s"Expected hostport but got $hostPort") |
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.
Change "hostport" to "host and port"
Signed-off-by: liuxian <liu.xian3@zte.com.cn>
Test build #76557 has finished for PR 17796 at commit
|
Merged to master |
…ptions Signed-off-by: liuxian <liu.xian3zte.com.cn> ## What changes were proposed in this pull request? When the input parameter is null, may be a runtime exception occurs ## How was this patch tested? Existing unit tests Author: liuxian <liu.xian3@zte.com.cn> Closes apache#17796 from 10110346/wip_lx_0428.
Signed-off-by: liuxian liu.xian3@zte.com.cn
What changes were proposed in this pull request?
When the input parameter is null, may be a runtime exception occurs
How was this patch tested?
Existing unit tests