diff --git a/core/src/test/scala/org/apache/spark/sql/IssueTestSuite.scala b/core/src/test/scala/org/apache/spark/sql/IssueTestSuite.scala index 270a2dab04..d8cb9efb98 100644 --- a/core/src/test/scala/org/apache/spark/sql/IssueTestSuite.scala +++ b/core/src/test/scala/org/apache/spark/sql/IssueTestSuite.scala @@ -22,6 +22,29 @@ import org.apache.spark.sql.functions.{col, sum} class IssueTestSuite extends BaseTiSparkTest { + test("test read tiflash not null error") { + if (!enableTiFlashTest) { + cancel("tiflash test not enabled") + } + val dbTable = "test.tiflash_not_null" + tidbStmt.execute(s"drop table if exists $dbTable") + tidbStmt.execute(s"CREATE TABLE $dbTable (`a` int NOT NULL)") + tidbStmt.execute(s"ALTER TABLE $dbTable SET TIFLASH REPLICA 1") + + Thread.sleep(5 * 1000) + + val prev = spark.conf.getOption(TiConfigConst.ISOLATION_READ_ENGINES) + try { + spark.conf + .set(TiConfigConst.ISOLATION_READ_ENGINES, TiConfigConst.TIFLASH_STORAGE_ENGINE) + spark.sql(s"select max(a) from tidb_catalog.$dbTable").show() + } finally { + spark.conf.set( + TiConfigConst.ISOLATION_READ_ENGINES, + prev.getOrElse(TiConfigConst.DEFAULT_STORAGE_ENGINES)) + } + } + test("test column mismatch, issue 2750") { val dbTable = "tispark_test.column_mismatch" tidbStmt.execute(s"drop table if exists $dbTable") diff --git a/tikv-client/scripts/proto.sh b/tikv-client/scripts/proto.sh index e8195e6e34..c47884b5ea 100755 --- a/tikv-client/scripts/proto.sh +++ b/tikv-client/scripts/proto.sh @@ -22,7 +22,7 @@ kvproto_hash=4d69c6f95e683dfb5859277563bf896aca06ec34 raft_rs_hash=b9891b673573fad77ebcf9bbe0969cf945841926 -tipb_hash=45e60c77588fefe421d0f6f29426a36b5b15171d +tipb_hash=29e23c62eeace5912f696d1b184b63d5dc3edcce if [ -d "kvproto" ]; then cd kvproto; git fetch -p; git checkout ${kvproto_hash}; cd .. diff --git a/tikv-client/src/main/java/com/pingcap/tikv/expression/visitor/ProtoConverter.java b/tikv-client/src/main/java/com/pingcap/tikv/expression/visitor/ProtoConverter.java index 353b8dc0c5..7cbc0421db 100644 --- a/tikv-client/src/main/java/com/pingcap/tikv/expression/visitor/ProtoConverter.java +++ b/tikv-client/src/main/java/com/pingcap/tikv/expression/visitor/ProtoConverter.java @@ -16,6 +16,7 @@ package com.pingcap.tikv.expression.visitor; +import static com.pingcap.tidb.tipb.AggFunctionMode.Partial1Mode; import static java.util.Objects.requireNonNull; import com.google.common.collect.ImmutableMap; @@ -350,6 +351,7 @@ protected Expr visit(AggregateFunction node, Object context) { } builder.setFieldType(toPBFieldType(getType(node))); + builder.setAggFuncMode(Partial1Mode); return builder.build(); }