{"action":"created","comment":{"url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments/36889265","id":36889265,"diff_hunk":"@@ -72,6 +74,75 @@ var builtins = map[string]builtin{\n \t\"upper\": stringBuiltin(func(s string) (Datum, error) {\n \t\treturn DString(strings.ToUpper(s)), nil\n \t}),\n+\n+\t// TODO(XisiHuang): support the substring(str FROM x FOR y) syntax\n+\t\"substring\": {\n+\t\tnArgs: -1,\n+\t\tfn: func(args DTuple) (Datum, error) {\n+\t\t\targsNum := len(args)\n+\t\t\tif argsNum != 2 && argsNum != 3 {\n+\t\t\t\treturn DNull, fmt.Errorf(\"incorrect number of arguments: %d vs %s\",\n+\t\t\t\t\targsNum, \"2 or 3\")\n+\t\t\t}\n+\n+\t\t\tdstr, ok := args[0].(DString)\n+\t\t\tif !ok {\n+\t\t\t\treturn DNull, argTypeError(args[0], \"string\")\n+\t\t\t}\n+\t\t\tstr := string(dstr)\n+\n+\t\t\tstart, ok := args[1].(DInt)\n+\t\t\tif !ok {\n+\t\t\t\treturn DNull, argTypeError(args[1], \"int\")\n+\t\t\t}\n+\n+\t\t\ts := int(start) - 1","path":"sql/parser/builtins.go","position":36,"original_position":36,"commit_id":"35b568121ef5708cf9d72ebe8a04d9cf4b62465e","original_commit_id":"35b568121ef5708cf9d72ebe8a04d9cf4b62465e","user":{"login":"tamird","id":1535036,"avatar_url":"https://avatars.githubusercontent.com/u/1535036?v=3","gravatar_id":"","url":"https://api.github.com/users/tamird","html_url":"https://github.com/tamird","followers_url":"https://api.github.com/users/tamird/followers","following_url":"https://api.github.com/users/tamird/following{/other_user}","gists_url":"https://api.github.com/users/tamird/gists{/gist_id}","starred_url":"https://api.github.com/users/tamird/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamird/subscriptions","organizations_url":"https://api.github.com/users/tamird/orgs","repos_url":"https://api.github.com/users/tamird/repos","events_url":"https://api.github.com/users/tamird/events{/privacy}","received_events_url":"https://api.github.com/users/tamird/received_events","type":"User","site_admin":false},"body":"can you move this `-1` to the very end, where we slice the string? it's much harder to follow when it's all the way up here","created_at":"2015-08-12T17:35:42Z","updated_at":"2015-08-12T17:35:42Z","html_url":"https://github.com/cockroachdb/cockroach/pull/2055#discussion_r36889265","pull_request_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2055","_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments/36889265"},"html":{"href":"https://github.com/cockroachdb/cockroach/pull/2055#discussion_r36889265"},"pull_request":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2055"}}},"pull_request":{"url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2055","id":42138018,"html_url":"https://github.com/cockroachdb/cockroach/pull/2055","diff_url":"https://github.com/cockroachdb/cockroach/pull/2055.diff","patch_url":"https://github.com/cockroachdb/cockroach/pull/2055.patch","issue_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/2055","number":2055,"state":"open","locked":false,"title":"add sql functions concat,substr and test for existing string functions","user":{"login":"XisiHuang","id":13212267,"avatar_url":"https://avatars.githubusercontent.com/u/13212267?v=3","gravatar_id":"","url":"https://api.github.com/users/XisiHuang","html_url":"https://github.com/XisiHuang","followers_url":"https://api.github.com/users/XisiHuang/followers","following_url":"https://api.github.com/users/XisiHuang/following{/other_user}","gists_url":"https://api.github.com/users/XisiHuang/gists{/gist_id}","starred_url":"https://api.github.com/users/XisiHuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XisiHuang/subscriptions","organizations_url":"https://api.github.com/users/XisiHuang/orgs","repos_url":"https://api.github.com/users/XisiHuang/repos","events_url":"https://api.github.com/users/XisiHuang/events{/privacy}","received_events_url":"https://api.github.com/users/XisiHuang/received_events","type":"User","site_admin":false},"body":"see #2042","created_at":"2015-08-11T14:53:10Z","updated_at":"2015-08-12T17:35:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a7458cd31953dbec6c30eeb5cae7853327e541db","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2055/commits","review_comments_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2055/comments","review_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/2055/comments","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/35b568121ef5708cf9d72ebe8a04d9cf4b62465e","head":{"label":"XisiHuang:builtin_function","ref":"builtin_function","sha":"35b568121ef5708cf9d72ebe8a04d9cf4b62465e","user":{"login":"XisiHuang","id":13212267,"avatar_url":"https://avatars.githubusercontent.com/u/13212267?v=3","gravatar_id":"","url":"https://api.github.com/users/XisiHuang","html_url":"https://github.com/XisiHuang","followers_url":"https://api.github.com/users/XisiHuang/followers","following_url":"https://api.github.com/users/XisiHuang/following{/other_user}","gists_url":"https://api.github.com/users/XisiHuang/gists{/gist_id}","starred_url":"https://api.github.com/users/XisiHuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XisiHuang/subscriptions","organizations_url":"https://api.github.com/users/XisiHuang/orgs","repos_url":"https://api.github.com/users/XisiHuang/repos","events_url":"https://api.github.com/users/XisiHuang/events{/privacy}","received_events_url":"https://api.github.com/users/XisiHuang/received_events","type":"User","site_admin":false},"repo":{"id":39671857,"name":"cockroach","full_name":"XisiHuang/cockroach","owner":{"login":"XisiHuang","id":13212267,"avatar_url":"https://avatars.githubusercontent.com/u/13212267?v=3","gravatar_id":"","url":"https://api.github.com/users/XisiHuang","html_url":"https://github.com/XisiHuang","followers_url":"https://api.github.com/users/XisiHuang/followers","following_url":"https://api.github.com/users/XisiHuang/following{/other_user}","gists_url":"https://api.github.com/users/XisiHuang/gists{/gist_id}","starred_url":"https://api.github.com/users/XisiHuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XisiHuang/subscriptions","organizations_url":"https://api.github.com/users/XisiHuang/orgs","repos_url":"https://api.github.com/users/XisiHuang/repos","events_url":"https://api.github.com/users/XisiHuang/events{/privacy}","received_events_url":"https://api.github.com/users/XisiHuang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/XisiHuang/cockroach","description":"A Scalable, Geo-Replicated, Transactional Datastore","fork":true,"url":"https://api.github.com/repos/XisiHuang/cockroach","forks_url":"https://api.github.com/repos/XisiHuang/cockroach/forks","keys_url":"https://api.github.com/repos/XisiHuang/cockroach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/XisiHuang/cockroach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/XisiHuang/cockroach/teams","hooks_url":"https://api.github.com/repos/XisiHuang/cockroach/hooks","issue_events_url":"https://api.github.com/repos/XisiHuang/cockroach/issues/events{/number}","events_url":"https://api.github.com/repos/XisiHuang/cockroach/events","assignees_url":"https://api.github.com/repos/XisiHuang/cockroach/assignees{/user}","branches_url":"https://api.github.com/repos/XisiHuang/cockroach/branches{/branch}","tags_url":"https://api.github.com/repos/XisiHuang/cockroach/tags","blobs_url":"https://api.github.com/repos/XisiHuang/cockroach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/XisiHuang/cockroach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/XisiHuang/cockroach/git/refs{/sha}","trees_url":"https://api.github.com/repos/XisiHuang/cockroach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/XisiHuang/cockroach/statuses/{sha}","languages_url":"https://api.github.com/repos/XisiHuang/cockroach/languages","stargazers_url":"https://api.github.com/repos/XisiHuang/cockroach/stargazers","contributors_url":"https://api.github.com/repos/XisiHuang/cockroach/contributors","subscribers_url":"https://api.github.com/repos/XisiHuang/cockroach/subscribers","subscription_url":"https://api.github.com/repos/XisiHuang/cockroach/subscription","commits_url":"https://api.github.com/repos/XisiHuang/cockroach/commits{/sha}","git_commits_url":"https://api.github.com/repos/XisiHuang/cockroach/git/commits{/sha}","comments_url":"https://api.github.com/repos/XisiHuang/cockroach/comments{/number}","issue_comment_url":"https://api.github.com/repos/XisiHuang/cockroach/issues/comments{/number}","contents_url":"https://api.github.com/repos/XisiHuang/cockroach/contents/{+path}","compare_url":"https://api.github.com/repos/XisiHuang/cockroach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/XisiHuang/cockroach/merges","archive_url":"https://api.github.com/repos/XisiHuang/cockroach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/XisiHuang/cockroach/downloads","issues_url":"https://api.github.com/repos/XisiHuang/cockroach/issues{/number}","pulls_url":"https://api.github.com/repos/XisiHuang/cockroach/pulls{/number}","milestones_url":"https://api.github.com/repos/XisiHuang/cockroach/milestones{/number}","notifications_url":"https://api.github.com/repos/XisiHuang/cockroach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/XisiHuang/cockroach/labels{/name}","releases_url":"https://api.github.com/repos/XisiHuang/cockroach/releases{/id}","created_at":"2015-07-25T03:59:58Z","updated_at":"2015-07-25T04:00:02Z","pushed_at":"2015-08-12T15:33:08Z","git_url":"git://github.com/XisiHuang/cockroach.git","ssh_url":"git@github.com:XisiHuang/cockroach.git","clone_url":"https://github.com/XisiHuang/cockroach.git","svn_url":"https://github.com/XisiHuang/cockroach","homepage":null,"size":27261,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cockroachdb:master","ref":"master","sha":"68ee67e7c4a351cb62d6244ea8c3cd4c43d60720","user":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"repo":{"id":16563587,"name":"cockroach","full_name":"cockroachdb/cockroach","owner":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cockroachdb/cockroach","description":"A Scalable, Geo-Replicated, Transactional Datastore","fork":false,"url":"https://api.github.com/repos/cockroachdb/cockroach","forks_url":"https://api.github.com/repos/cockroachdb/cockroach/forks","keys_url":"https://api.github.com/repos/cockroachdb/cockroach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cockroachdb/cockroach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cockroachdb/cockroach/teams","hooks_url":"https://api.github.com/repos/cockroachdb/cockroach/hooks","issue_events_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/events{/number}","events_url":"https://api.github.com/repos/cockroachdb/cockroach/events","assignees_url":"https://api.github.com/repos/cockroachdb/cockroach/assignees{/user}","branches_url":"https://api.github.com/repos/cockroachdb/cockroach/branches{/branch}","tags_url":"https://api.github.com/repos/cockroachdb/cockroach/tags","blobs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cockroachdb/cockroach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/refs{/sha}","trees_url":"https://api.github.com/repos/cockroachdb/cockroach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/{sha}","languages_url":"https://api.github.com/repos/cockroachdb/cockroach/languages","stargazers_url":"https://api.github.com/repos/cockroachdb/cockroach/stargazers","contributors_url":"https://api.github.com/repos/cockroachdb/cockroach/contributors","subscribers_url":"https://api.github.com/repos/cockroachdb/cockroach/subscribers","subscription_url":"https://api.github.com/repos/cockroachdb/cockroach/subscription","commits_url":"https://api.github.com/repos/cockroachdb/cockroach/commits{/sha}","git_commits_url":"https://api.github.com/repos/cockroachdb/cockroach/git/commits{/sha}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/comments{/number}","issue_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/comments{/number}","contents_url":"https://api.github.com/repos/cockroachdb/cockroach/contents/{+path}","compare_url":"https://api.github.com/repos/cockroachdb/cockroach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cockroachdb/cockroach/merges","archive_url":"https://api.github.com/repos/cockroachdb/cockroach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cockroachdb/cockroach/downloads","issues_url":"https://api.github.com/repos/cockroachdb/cockroach/issues{/number}","pulls_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls{/number}","milestones_url":"https://api.github.com/repos/cockroachdb/cockroach/milestones{/number}","notifications_url":"https://api.github.com/repos/cockroachdb/cockroach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cockroachdb/cockroach/labels{/name}","releases_url":"https://api.github.com/repos/cockroachdb/cockroach/releases{/id}","created_at":"2014-02-06T00:18:47Z","updated_at":"2015-08-12T15:20:56Z","pushed_at":"2015-08-12T17:34:02Z","git_url":"git://github.com/cockroachdb/cockroach.git","ssh_url":"git@github.com:cockroachdb/cockroach.git","clone_url":"https://github.com/cockroachdb/cockroach.git","svn_url":"https://github.com/cockroachdb/cockroach","homepage":null,"size":47211,"stargazers_count":4986,"watchers_count":4986,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":392,"mirror_url":null,"open_issues_count":142,"forks":392,"open_issues":142,"watchers":4986,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2055"},"html":{"href":"https://github.com/cockroachdb/cockroach/pull/2055"},"issue":{"href":"https://api.github.com/repos/cockroachdb/cockroach/issues/2055"},"comments":{"href":"https://api.github.com/repos/cockroachdb/cockroach/issues/2055/comments"},"review_comments":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2055/comments"},"review_comment":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2055/commits"},"statuses":{"href":"https://api.github.com/repos/cockroachdb/cockroach/statuses/35b568121ef5708cf9d72ebe8a04d9cf4b62465e"}}}}