Skip to content

Commit

Permalink
fix bug: ci SpecialTiDBTypeTestSuite failed with tidb-3.0.1 (#984)
Browse files Browse the repository at this point in the history
  • Loading branch information
marsishandsome authored Aug 5, 2019
1 parent 1973d53 commit 1a95291
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,26 @@ import org.apache.spark.sql.BaseTiSparkTest

class SpecialTiDBTypeTestSuite extends BaseTiSparkTest {
test("adding time type index test") {
val query = "select * from t_t"

tidbStmt.execute("drop table if exists t_t")
tidbStmt.execute("CREATE TABLE `t_t` (`t` time(3), index `idx_t`(t))")
// NOTE: jdbc only allows time in day range whereas mysql time has much
// larger range.
tidbStmt.execute("INSERT INTO t_t (t) VALUES('18:59:59'),('17:59:59'),('12:59:59')")
refreshConnections()
val df = spark.sql("select * from t_t")
val df = spark.sql(query)
val data = dfData(df, df.schema.fields)
assert(data(0)(0) === Converter.convertStrToDuration("18:59:59"))
assert(data(1)(0) === Converter.convertStrToDuration("17:59:59"))
assert(data(2)(0) === Converter.convertStrToDuration("12:59:59"))
runTest(
query,
rSpark = data,
rTiDB = List(
List(Converter.convertStrToDuration("18:59:59")),
List(Converter.convertStrToDuration("17:59:59")),
List(Converter.convertStrToDuration("12:59:59"))
),
skipJDBC = true
)

val where = spark.sql("select * from t_t where t = 46799000000000")
val whereData = dfData(where, where.schema.fields)
Expand Down

0 comments on commit 1a95291

Please sign in to comment.