aboutsummaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorVolodymyr Lyubinets <vlyubin@gmail.com>2015-04-06 18:00:51 -0700
committerAaron Davidson <aaron@databricks.com>2015-04-06 18:00:51 -0700
commite40ea8742a8771ecd46b182f45b5fcd8bd6dd725 (patch)
treee654bf33a085ae1849445e5a61056fc082ca0891 /sql
parent30363ede8635f2548e444697dbcf60a795b61a84 (diff)
downloadspark-e40ea8742a8771ecd46b182f45b5fcd8bd6dd725.tar.gz
spark-e40ea8742a8771ecd46b182f45b5fcd8bd6dd725.tar.bz2
spark-e40ea8742a8771ecd46b182f45b5fcd8bd6dd725.zip
[Minor] [SQL] [SPARK-6729] Minor fix for DriverQuirks get
The function uses .substring(0, X), which will trigger OutOfBoundsException if string length is less than X. A better way to do this is to use startsWith, which won't error out in this case. Author: Volodymyr Lyubinets <vlyubin@gmail.com> Closes #5378 from vlyubin/quirks and squashes the following commits: 504e8e0 [Volodymyr Lyubinets] Minor fix for DriverQuirks get
Diffstat (limited to 'sql')
-rw-r--r--sql/core/src/main/scala/org/apache/spark/sql/jdbc/DriverQuirks.scala4
1 files changed, 2 insertions, 2 deletions
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/DriverQuirks.scala b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/DriverQuirks.scala
index 1704be7fcb..0feabc4282 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/DriverQuirks.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/DriverQuirks.scala
@@ -49,9 +49,9 @@ private[sql] object DriverQuirks {
* Fetch the DriverQuirks class corresponding to a given database url.
*/
def get(url: String): DriverQuirks = {
- if (url.substring(0, 10).equals("jdbc:mysql")) {
+ if (url.startsWith("jdbc:mysql")) {
new MySQLQuirks()
- } else if (url.substring(0, 15).equals("jdbc:postgresql")) {
+ } else if (url.startsWith("jdbc:postgresql")) {
new PostgresQuirks()
} else {
new NoQuirks()