-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-28552][SQL] Case-insensitive database URLs in JdbcDialect #25287
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
Conversation
|
ok to test |
|
cc @maropu |
|
@teeyog hi, thanks for your first contribution! btw, can you fix this in a more general way? Probably, can we lowercase a prefix in the JdbcDialect side? I think its a bit troublesome to add the logic for lowercases in each dialect... Also, plz add tests in |
|
And, could you please make the PR description clearer as much as possible to make the other reviewers understood easily... we don't have a rigid format for that, but I'ld like you to clearly describe what you propose in this pr? e.g., "This pr proposes to ..." If this pr merged, the description will be included in a commit log, so your kind cooperation makes the commit logs more readable. |
|
Test build #108426 has finished for PR 25287 at commit
|
|
@maropu Thank you very much for your guidance. I will improve this PR description. In addition, you suggest that URL be converted to lowercase only through JdbcDialect without modifying the logic of dialects. I have not thought of a better way to implement it, or to control the incoming url, which is already lowercase, but I don't think that's very good. |
|
Test build #108454 has finished for PR 25287 at commit
|
|
For example, ? |
|
@maropu Thank you for your example, I misunderstood what you mean, I thought you told me not to modify the logic of other dialects. |
|
Test build #108507 has finished for PR 25287 at commit
|
|
Test build #108508 has finished for PR 25287 at commit
|
|
Test build #108510 has finished for PR 25287 at commit
|
|
Test build #108511 has finished for PR 25287 at commit
|
|
@maropu Hi, can you help me find out what caused this error? |
|
Can you update |
|
Test build #108537 has finished for PR 25287 at commit
|
|
|
|
ping @teeyog |
|
Test build #113078 has finished for PR 25287 at commit
|
|
Test build #113079 has finished for PR 25287 at commit
|
srowen
left a comment
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 OK with it. I looked it up and technically URI schemes are meant to be case insensitive, so that's a good argument for this change.
|
|
||
| val testH2DialectTinyInt = new JdbcDialect { | ||
| override def canHandle(url: String): Boolean = url.startsWith("jdbc:h2") | ||
| override def canHandle(url: String) : Boolean = url.startsWith("jdbc:h2") |
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.
nit: revert this.
| "`NONE`, `READ_UNCOMMITTED`, `READ_COMMITTED`, `REPEATABLE_READ` or `SERIALIZABLE`.")) | ||
| } | ||
|
|
||
| test("SPARK-28552: Check whether a dialect instance can be applied on the given jdbc url") { |
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.
You can simplify the tests below;
test("SPARK-28552: Case-insensitive database URLs in JdbcDialect") {
assert(JdbcDialects.get("jdbc:mysql://localhost/db") === MySQLDialect)
assert(JdbcDialects.get("jdbc:MySQL://localhost/db") === MySQLDialect)
assert(JdbcDialects.get("jdbc:postgresql://localhost/db") === PostgresDialect)
assert(JdbcDialects.get("jdbc:postGresql://localhost/db") === PostgresDialect)
assert(JdbcDialects.get("jdbc:db2://localhost/db") === DB2Dialect)
assert(JdbcDialects.get("jdbc:DB2://localhost/db") === DB2Dialect)
assert(JdbcDialects.get("jdbc:sqlserver://localhost/db") === MsSqlServerDialect)
assert(JdbcDialects.get("jdbc:sqlServer://localhost/db") === MsSqlServerDialect)
assert(JdbcDialects.get("jdbc:derby://localhost/db") === DerbyDialect)
assert(JdbcDialects.get("jdbc:derBy://localhost/db") === DerbyDialect)
assert(JdbcDialects.get("jdbc:oracle://localhost/db") === OracleDialect)
assert(JdbcDialects.get("jdbc:Oracle://localhost/db") === OracleDialect)
assert(JdbcDialects.get("jdbc:teradata://localhost/db") === TeradataDialect)
assert(JdbcDialects.get("jdbc:Teradata://localhost/db") === TeradataDialect)
}
maropu
left a comment
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.
Could you check my comments before merging?
ok,thanks |
|
Test build #113195 has finished for PR 25287 at commit
|
|
Test build #113196 has finished for PR 25287 at commit
|
|
Thanks for your first contribution, @teeyog! Merged to master. |
|
FYI: Added @teeyog in the Spark contributor list. |
What changes were proposed in this pull request?
This pr proposes to be case insensitive when matching dialects via jdbc url prefix.
When I use jdbc url such as:
jdbc: MySQL://localhost/dbto query data through sparksql, the result is wrong, but MySQL supports such url writing.because sparksql matches MySQLDialect by prefix
jdbc:mysql, sojdbc: MySQLis not matched with the correct dialect. Therefore, it should be case insensitive when identifying the corresponding dialect through jdbc urlhttps://issues.apache.org/jira/browse/SPARK-28552
How was this patch tested?
UT.