diff --git a/expression/expression.go b/expression/expression.go index bb38d8544185b..e8f38910c1264 100644 --- a/expression/expression.go +++ b/expression/expression.go @@ -1003,7 +1003,7 @@ func scalarExprSupportedByTiKV(sf *ScalarFunction) bool { ast.JSONType, ast.JSONExtract, ast.JSONObject, ast.JSONArray, ast.JSONMerge, ast.JSONSet, ast.JSONInsert /*ast.JSONReplace,*/, ast.JSONRemove, ast.JSONLength, // FIXME: JSONUnquote is incompatible with Coprocessor - ast.JSONUnquote, + ast.JSONUnquote, ast.JSONContains, // date functions. ast.Date, ast.Week /* ast.YearWeek, ast.ToSeconds */, ast.DateDiff, diff --git a/planner/core/integration_test.go b/planner/core/integration_test.go index 4ee6a4a711395..e716561b114e1 100644 --- a/planner/core/integration_test.go +++ b/planner/core/integration_test.go @@ -3065,7 +3065,7 @@ func TestScalarFunctionPushDown(t *testing.T) { tk := testkit.NewTestKit(t, store) tk.MustExec("use test") tk.MustExec("create table t(id int signed, id2 int unsigned, c varchar(11), d datetime, b double, e bit(10))") - tk.MustExec("insert into t(id, id2, c, d) values (-1, 1, 'abc', '2021-12-12')") + tk.MustExec("insert into t(id, id2, c, d) values (-1, 1, '{\"a\":1}', '2021-12-12')") rows := [][]interface{}{ {"TableReader_7", "root", "data:Selection_6"}, {"└─Selection_6", "cop[tikv]", "right(test.t.c, 1)"}, @@ -3178,6 +3178,10 @@ func TestScalarFunctionPushDown(t *testing.T) { rows[1][2] = "ascii(cast(test.t.e, var_string(2)))" tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where ascii(e);"). CheckAt([]int{0, 3, 6}, rows) + + rows[1][2] = "json_contains(cast(test.t.c, json BINARY), cast(\"1\", json BINARY))" + tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where json_contains(c, '1');"). + CheckAt([]int{0, 3, 6}, rows) } func TestDistinctScalarFunctionPushDown(t *testing.T) {