[SPARK-35893][TESTS] Add unit test case for MySQLDialect.getCatalystType

### What changes were proposed in this pull request?
Add unit test case for MySQLDialect.getCatalystType

### Why are the changes needed?
add unit test case

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Unit Test

Closes #33087 from zengruios/SPARK-35893.

Authored-by: zengruios <578395184@qq.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
This commit is contained in:
zengruios 2021-06-26 21:43:52 -07:00 committed by Dongjoon Hyun
parent def29e5075
commit b11b175148

View file

@ -899,6 +899,17 @@ class JDBCSuite extends QueryTest
Option(TimestampType))
}
test("MySQLDialect catalyst type mapping") {
val mySqlDialect = JdbcDialects.get("jdbc:mysql")
val metadata = new MetadataBuilder()
assert(mySqlDialect.getCatalystType(java.sql.Types.VARBINARY, "BIT", 2, metadata) ==
Some(LongType))
assert(metadata.build().contains("binarylong"))
assert(mySqlDialect.getCatalystType(java.sql.Types.VARBINARY, "BIT", 1, metadata) == None)
assert(mySqlDialect.getCatalystType(java.sql.Types.BIT, "TINYINT", 1, metadata) ==
Some(BooleanType))
}
test("SPARK-35446: MySQLDialect type mapping of float") {
val mySqlDialect = JdbcDialects.get("jdbc:mysql://127.0.0.1/db")
assert(mySqlDialect.getJDBCType(FloatType).map(_.databaseTypeDefinition).get == "FLOAT")