forked from pingcap/tispark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding shard row id bits test (pingcap#938)
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
core/src/test/scala/com/pingcap/tispark/datasource/ShardRowIDBitsSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.pingcap.tispark.datasource | ||
|
||
import org.apache.spark.sql.Row | ||
import org.apache.spark.sql.types.{IntegerType, StructField, StructType} | ||
|
||
class ShardRowIDBitsSuite extends BaseDataSourceTest("test_shard_row_id_bits") { | ||
private val row1 = Row(1) | ||
private val row2 = Row(2) | ||
private val row3 = Row(3) | ||
private val schema = StructType( | ||
List( | ||
StructField("a", IntegerType) | ||
) | ||
) | ||
|
||
test("reading and writing a table with shard_row_id_bits") { | ||
dropTable() | ||
jdbcUpdate( | ||
s"CREATE TABLE $dbtable ( `a` int(11)) SHARD_ROW_ID_BITS = 4" | ||
) | ||
|
||
jdbcUpdate( | ||
s"insert into $dbtable values(null)" | ||
) | ||
|
||
tidbWrite(List(row1, row2, row3), schema) | ||
testTiDBSelect(List(Row(null), row1, row2, row3), sortCol = "a") | ||
} | ||
} |