Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyuhang0 committed Mar 21, 2024
1 parent 5aa1618 commit 77b0e96
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
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 like escape") {
val dbTable = "tispark_test.like_escape"
tidbStmt.execute(s"drop table if exists $dbTable")
tidbStmt.execute(
s"CREATE TABLE $dbTable (`name` varchar(64) NOT NULL)")
tidbStmt.execute(s"insert into $dbTable values('ab%H')")
val df = spark.sql("select count(*) from test.t where name like '%\\%H%'")
assert(df.collect().head.get(0) == 1)

}

test("test tiflash overflow in unsigned bigint") {
if (!enableTiFlashTest) {
cancel("tiflash test not enabled")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ public TypedKey getTypedLiteral(int prefixLength) {

@Override
public List<Expression> getChildren() {
// For LIKE statement, an extra ESCAPE parameter is required as the third parameter for
// ScalarFunc.
// However in Spark ESCAPE is not supported so we simply set this value to zero.
return ImmutableList.of(left, reg, Constant.create(0, IntegerType.BIGINT));
// LIKE statement use '\' as escape character because Spark use it as escape character too.
return ImmutableList.of(left, reg, Constant.create(92, IntegerType.BIGINT));
}

@Override
Expand Down

0 comments on commit 77b0e96

Please sign in to comment.