Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ class TiBatchWriteTable(
}

def checkUnsupported(): Unit = {
if (tiTableInfo.isCommonHandle) {
throw new TiBatchWriteException(
"tispark currently does not support write data to table with clustered index!")
}

// write to table with auto random column
if (tiTableInfo.hasAutoRandomColumn) {
throw new TiBatchWriteException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class IssueTestSuite extends BaseTiSparkTest {
cancel("currently tidb instance does not support clustered index")
}
spark.sqlContext.setConf(TiConfigConst.USE_INDEX_SCAN_FIRST, "true")
enableClusteredIndex()
tidbStmt.execute("""
|SET tidb_enable_clustered_index = 1;
|drop table if exists `tispark_test`.`clustered0`;
|CREATE TABLE `tispark_test`.`clustered0` (
| `col_bit0` bit(1) not null,
Expand All @@ -60,6 +60,8 @@ class IssueTestSuite extends BaseTiSparkTest {
spark.sql(s"$sql").show(200, false)
runTest(sql, skipJDBC = true)
spark.sqlContext.setConf(TiConfigConst.USE_INDEX_SCAN_FIRST, "false")

disableClusteredIndex()
}

test("partition table with date partition column name") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ trait ClusteredIndexTest extends BaseTiSparkTest with BaseEnumerateDataTypesTest
override def test(): Unit = ???

override def afterAll(): Unit = {
if(supportClusteredIndex) {
executeTiDBSQL("SET tidb_enable_clustered_index = 0;")
if (supportClusteredIndex) {
disableClusteredIndex()
}
super.afterAll()
}
Expand Down Expand Up @@ -88,7 +88,7 @@ trait ClusteredIndexTest extends BaseTiSparkTest with BaseEnumerateDataTypesTest
}

protected def test(schema: Schema): Unit = {
executeTiDBSQL("SET tidb_enable_clustered_index = 1;")
enableClusteredIndex()
executeTiDBSQL(s"drop table if exists `$dbName`.`${schema.tableName}`;")
executeTiDBSQL(schema.toString)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,19 @@ trait SharedSQLContext

protected def initializeStatement(): Unit = {
_statement = _tidbConnection.createStatement()
disableClusteredIndex()
}

protected def enableClusteredIndex(): Unit = {
_statement.execute("SET GLOBAL tidb_enable_clustered_index = 1")
_statement.close()
_statement = _tidbConnection.createStatement()
}

protected def disableClusteredIndex(): Unit = {
_statement.execute("SET GLOBAL tidb_enable_clustered_index = 0")
_statement.close()
_statement = _tidbConnection.createStatement()
}

protected def timeZoneOffset: String = SharedSQLContext.timeZoneOffset
Expand Down