Skip to content

Commit

Permalink
*: support substr. (pingcap#2422)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanfei1991 authored Jan 9, 2017
1 parent 677a85b commit b2ce51a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions ast/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ const (
Space = "space"
Strcmp = "strcmp"
Substring = "substring"
Substr = "substr"
SubstringIndex = "substring_index"
Trim = "trim"
Upper = "upper"
Expand Down
1 change: 1 addition & 0 deletions expression/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ var Funcs = map[string]Func{
ast.Space: {builtinSpace, 1, 1},
ast.Strcmp: {builtinStrcmp, 2, 2},
ast.Substring: {builtinSubstring, 2, 3},
ast.Substr: {builtinSubstring, 2, 3},
ast.SubstringIndex: {builtinSubstringIndex, 3, 3},
ast.Trim: {builtinTrim, 1, 3},
ast.Upper: {builtinUpper, 1, 1},
Expand Down
4 changes: 4 additions & 0 deletions plan/logical_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,10 @@ func (s *testPlanSuite) TestPlanBuilder(c *C) {
sql: "do sleep(5)",
plan: "*plan.TableDual->Projection",
},
{
sql: "select substr(\"abc\", 1)",
plan: "*plan.TableDual->Projection",
},
}
for _, ca := range cases {
comment := Commentf("for %s", ca.sql)
Expand Down

0 comments on commit b2ce51a

Please sign in to comment.