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
11 changes: 11 additions & 0 deletions core/src/test/scala/org/apache/spark/sql/IssueTestSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ import org.apache.spark.sql.functions.{col, sum}

class IssueTestSuite extends BaseTiSparkTest {

test("test issue 2649") {
val dbTable = "tispark_test.mutil_uniq"
tidbStmt.execute(s"drop table if exists $dbTable")
tidbStmt.execute(
s"CREATE TABLE $dbTable (`a` int(5) NOT NULL,`b` int(5) NOT NULL,UNIQUE KEY `idx_ab` (`a`,`b`))")
tidbStmt.execute(s"insert into $dbTable values(0, 0),(1,1)")
val df = spark.sql(s"select * from $dbTable where a=1")
val row1 = Row(1, 1)
checkAnswer(df, Seq(row1))
}

//https://github.com/pingcap/tispark/issues/2268
test("show rowid in commonhandle") {
spark.sqlContext.setConf(TiConfigConst.SHOW_ROWID, "true")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,10 @@ private void addIndexReaderIndexRangeScanExecutorCols(

private void addIndexColsToScanBuilder(
IndexScan.Builder indexScanBuilder, Map<String, Integer> colOffsetInFieldMap) {
if (indexInfo.isUnique()) {
indexScanBuilder.setUnique(true);
}
for (TiIndexColumn indexColumn : indexInfo.getIndexColumns()) {
// We can optimize performance by pass unique into index scan.
// Refer to
// https://github.com/pingcap/tidb/blob/4ae5be190b0017675deedd9af8b80d8868e03f0e/planner/core/plan_to_pb.go#L271 to see if we can pass unique into index scan.
TiColumnInfo tableInfoColumn = tableInfo.getColumn(indexColumn.getName());
// already add this col before.
ColumnInfo.Builder colBuild = ColumnInfo.newBuilder(tableInfoColumn.toProto(tableInfo));
Expand Down