Skip to content

Commit

Permalink
expression: push down json_valid to tikv (#38290)
Browse files Browse the repository at this point in the history
close #38289
  • Loading branch information
lizhenhuan authored Nov 17, 2022
1 parent e78ef2c commit b296494
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions expression/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -1071,8 +1071,7 @@ func scalarExprSupportedByTiKV(sf *ScalarFunction) bool {
// json functions.
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.JSONContains,
ast.JSONUnquote, ast.JSONContains, ast.JSONValid,

// date functions.
ast.Date, ast.Week /* ast.YearWeek, ast.ToSeconds */, ast.DateDiff,
Expand Down
4 changes: 4 additions & 0 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3375,6 +3375,10 @@ func TestScalarFunctionPushDown(t *testing.T) {
tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where ascii(e);").
CheckAt([]int{0, 3, 6}, rows)

rows[1][2] = "eq(json_valid(test.t.c), 1)"
tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where json_valid(c)=1;").
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)
Expand Down

0 comments on commit b296494

Please sign in to comment.