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-19296][SQL] Deduplicate url and table in JdbcUtils #16753
Conversation
Hi @gatorsmile, could you take a look for this one please? (It might not need a JIRA but it happened to be opened by someone). |
It's true, though I wonder if it's still by design, that these methods take url and table as important first-class arguments, and then also other options, even though the options also contain the same arguments. Or, could the other methods like tableExists reasonably also not have to take these arguments? Consistency is probably more important. |
@srowen, I see. Let me maybe give a shot to make them consistent to show if it looks good (otherwise, let me just close my pr and resolve his JIRA). |
Test build #72192 has finished for PR 16753 at commit
|
Test build #72193 has finished for PR 16753 at commit
|
Test build #72194 has finished for PR 16753 at commit
|
cfe258b
to
6b2841a
Compare
Test build #72199 has finished for PR 16753 at commit
|
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 that does look tidier to me. If this is indeed a private API, it seems reasonable to rationalize it in this way. Not sure who else might be a good reviewer here.
@@ -53,33 +53,31 @@ class JdbcRelationProvider extends CreatableRelationProvider | |||
parameters: Map[String, String], | |||
df: DataFrame): BaseRelation = { | |||
val jdbcOptions = new JDBCOptions(parameters) | |||
val url = jdbcOptions.url | |||
val table = jdbcOptions.table |
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.
Maybe, we do not need to have a variable for table
too.
val table = jdbcOptions.table | ||
val createTableOptions = jdbcOptions.createTableOptions | ||
val isTruncate = jdbcOptions.isTruncate |
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 same here.
LGTM except two comments. |
Thank you @srowen and @gatorsmile! |
Test build #72245 has finished for PR 16753 at commit
|
LGTM. Thanks! Merging to master. |
## What changes were proposed in this pull request? This PR deduplicates arguments, `url` and `table` in `JdbcUtils` with `JDBCOptions`. It avoids to use duplicated arguments, for example, as below: from ```scala val jdbcOptions = new JDBCOptions(url, table, map) JdbcUtils.saveTable(ds, url, table, jdbcOptions) ``` to ```scala val jdbcOptions = new JDBCOptions(url, table, map) JdbcUtils.saveTable(ds, jdbcOptions) ``` ## How was this patch tested? Running unit test in `JdbcSuite`/`JDBCWriteSuite` Building with Scala 2.10 as below: ``` ./dev/change-scala-version.sh 2.10 ./build/mvn -Pyarn -Phadoop-2.4 -Dscala-2.10 -DskipTests clean package ``` Author: hyukjinkwon <gurwls223@gmail.com> Closes apache#16753 from HyukjinKwon/SPARK-19296.
What changes were proposed in this pull request?
This PR deduplicates arguments,
url
andtable
inJdbcUtils
withJDBCOptions
.It avoids to use duplicated arguments, for example, as below:
from
to
How was this patch tested?
Running unit test in
JdbcSuite
/JDBCWriteSuite
Building with Scala 2.10 as below: