-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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-48385][SQL] Migrate the jdbc driver of mariadb from 2.x
to 3.x
#46655
Changes from 7 commits
78519b4
0b38cec
e32a4ed
e284137
68ade95
94334aa
e30e5ed
91a3d08
25f1742
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 |
---|---|---|
|
@@ -154,30 +154,43 @@ class MySQLIntegrationSuite extends DockerJDBCIntegrationSuite { | |
test("SPARK-47462: Unsigned numeric types") { | ||
val df = sqlContext.read.jdbc(jdbcUrl, "unsigned_numbers", new Properties) | ||
val rows = df.head() | ||
assert(rows.get(0).isInstanceOf[Short]) | ||
assert(rows.get(1).isInstanceOf[Integer]) | ||
assert(rows.get(2).isInstanceOf[Integer]) | ||
assert(rows.get(3).isInstanceOf[Long]) | ||
assert(rows.get(4).isInstanceOf[BigDecimal]) | ||
assert(rows.get(5).isInstanceOf[BigDecimal]) | ||
assert(rows.get(6).isInstanceOf[Double]) | ||
// Unlike MySQL, MariaDB seems not to distinguish signed and unsigned tinyint(1). | ||
val isMaria = jdbcUrl.indexOf("disableMariaDbDriver") == -1 | ||
if (isMaria) { | ||
assert(rows.get(0).isInstanceOf[Integer]) | ||
assert(rows.get(1).isInstanceOf[Long]) | ||
assert(rows.get(2).isInstanceOf[Integer]) | ||
assert(rows.get(3).isInstanceOf[BigDecimal]) | ||
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. Could you describe the root cause of this change, @panbingkun ? For me, this looks suspicious like a breaking change. - assert(rows.get(3).isInstanceOf[Long])
+ assert(rows.get(3).isInstanceOf[BigDecimal]) 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. 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. We can also add compatible logic in 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. 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.
These mariadb SQL Data Type <-> JDBC Data Type mapping rules seem incorrect, do they have a statement why they made such change 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. Let me try to find it. |
||
assert(rows.get(4).isInstanceOf[BigDecimal]) | ||
assert(rows.get(5).isInstanceOf[BigDecimal]) | ||
assert(rows.get(6).isInstanceOf[Double]) | ||
// Unlike MySQL, MariaDB seems not to distinguish signed and unsigned tinyint(1). | ||
assert(rows.get(7).isInstanceOf[Boolean]) | ||
} else { | ||
assert(rows.get(7).isInstanceOf[Short]) | ||
} | ||
assert(rows.getShort(0) === 255) | ||
assert(rows.getInt(1) === 65535) | ||
assert(rows.getInt(2) === 16777215) | ||
assert(rows.getLong(3) === 4294967295L) | ||
assert(rows.getAs[BigDecimal](4).equals(new BigDecimal("9223372036854775808"))) | ||
assert(rows.getAs[BigDecimal](5).equals(new BigDecimal("123456789012345.123456789012345000"))) | ||
assert(rows.getDouble(6) === 1.0000000000000002) | ||
if (isMaria) { | ||
|
||
assert(rows.getInt(0) === 255) | ||
assert(rows.getLong(1) === 65535L) | ||
assert(rows.getInt(2) === 16777215) | ||
assert(rows.getAs[BigDecimal](3).equals(new BigDecimal("4294967295"))) | ||
assert(rows.getAs[BigDecimal](4).equals(new BigDecimal("9223372036854775808"))) | ||
assert(rows.getAs[BigDecimal](5).equals(new BigDecimal("123456789012345.123456789012345000"))) | ||
assert(rows.getDouble(6) === 1.0000000000000002) | ||
assert(rows.getBoolean(7) === false) | ||
} else { | ||
assert(rows.get(0).isInstanceOf[Short]) | ||
assert(rows.get(1).isInstanceOf[Integer]) | ||
assert(rows.get(2).isInstanceOf[Integer]) | ||
assert(rows.get(3).isInstanceOf[Long]) | ||
assert(rows.get(4).isInstanceOf[BigDecimal]) | ||
assert(rows.get(5).isInstanceOf[BigDecimal]) | ||
assert(rows.get(6).isInstanceOf[Double]) | ||
assert(rows.get(7).isInstanceOf[Short]) | ||
|
||
assert(rows.getShort(0) === 255) | ||
assert(rows.getInt(1) === 65535) | ||
assert(rows.getInt(2) === 16777215) | ||
assert(rows.getLong(3) === 4294967295L) | ||
assert(rows.getAs[BigDecimal](4).equals(new BigDecimal("9223372036854775808"))) | ||
assert(rows.getAs[BigDecimal](5).equals(new BigDecimal("123456789012345.123456789012345000"))) | ||
assert(rows.getDouble(6) === 1.0000000000000002) | ||
assert(rows.getShort(7) === 0) | ||
} | ||
} | ||
|
@@ -367,13 +380,13 @@ class MySQLOverMariaConnectorIntegrationSuite extends MySQLIntegrationSuite { | |
|
||
override val db = new MySQLDatabaseOnDocker { | ||
override def getJdbcUrl(ip: String, port: Int): String = | ||
s"jdbc:mysql://$ip:$port/mysql?user=root&password=rootpass&allowPublicKeyRetrieval=true" + | ||
s"&useSSL=false" | ||
s"jdbc:mysql://$ip:$port/mysql?permitMysqlScheme&user=root&password=rootpass" + | ||
s"&allowPublicKeyRetrieval=true&useSSL=false" | ||
} | ||
|
||
override def testConnection(): Unit = { | ||
Using.resource(getConnection()) { conn => | ||
assert(conn.getClass.getName === "org.mariadb.jdbc.MariaDbConnection") | ||
assert(conn.getClass.getName === "org.mariadb.jdbc.Connection") | ||
} | ||
} | ||
} |
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.
permitMysqlScheme:
https://mariadb.com/kb/en/mariadb-connector-j-303-release-notes/#jdbcmariadb-scheme