{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/131578995","pull_request_review_id":54572010,"id":131578995,"diff_hunk":"@@ -1121,6 +1125,30 @@ class AstBuilder(conf: SQLConf) extends SqlBaseBaseVisitor[AnyRef] with Logging\n   }\n \n   /**\n+   * Create a function name LTRIM for TRIM(Leading), RTRIM for TRIM(Trailing), TRIM for TRIM(BOTH),\n+   * otherwise, return the original function identifier.\n+   */\n+  private def replaceTrimFunction(funcID: FunctionIdentifier, ctx: FunctionCallContext)\n+    : FunctionIdentifier = {","path":"sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala","position":21,"original_position":21,"commit_id":"51ecfc8e4acb0ffd6389726a8fa381dd040925a9","original_commit_id":"51ecfc8e4acb0ffd6389726a8fa381dd040925a9","user":{"login":"kevinyu98","id":7550280,"avatar_url":"https://avatars3.githubusercontent.com/u/7550280?v=4","gravatar_id":"","url":"https://api.github.com/users/kevinyu98","html_url":"https://github.com/kevinyu98","followers_url":"https://api.github.com/users/kevinyu98/followers","following_url":"https://api.github.com/users/kevinyu98/following{/other_user}","gists_url":"https://api.github.com/users/kevinyu98/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinyu98/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinyu98/subscriptions","organizations_url":"https://api.github.com/users/kevinyu98/orgs","repos_url":"https://api.github.com/users/kevinyu98/repos","events_url":"https://api.github.com/users/kevinyu98/events{/privacy}","received_events_url":"https://api.github.com/users/kevinyu98/received_events","type":"User","site_admin":false},"body":"ok.","created_at":"2017-08-07T06:19:20Z","updated_at":"2017-08-07T06:19:20Z","html_url":"https://github.com/apache/spark/pull/12646#discussion_r131578995","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/12646","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/131578995"},"html":{"href":"https://github.com/apache/spark/pull/12646#discussion_r131578995"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/12646"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/12646","id":67622066,"html_url":"https://github.com/apache/spark/pull/12646","diff_url":"https://github.com/apache/spark/pull/12646.diff","patch_url":"https://github.com/apache/spark/pull/12646.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/12646","number":12646,"state":"open","locked":false,"title":"[SPARK-14878][SQL] Trim characters string function support","user":{"login":"kevinyu98","id":7550280,"avatar_url":"https://avatars3.githubusercontent.com/u/7550280?v=4","gravatar_id":"","url":"https://api.github.com/users/kevinyu98","html_url":"https://github.com/kevinyu98","followers_url":"https://api.github.com/users/kevinyu98/followers","following_url":"https://api.github.com/users/kevinyu98/following{/other_user}","gists_url":"https://api.github.com/users/kevinyu98/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinyu98/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinyu98/subscriptions","organizations_url":"https://api.github.com/users/kevinyu98/orgs","repos_url":"https://api.github.com/users/kevinyu98/repos","events_url":"https://api.github.com/users/kevinyu98/events{/privacy}","received_events_url":"https://api.github.com/users/kevinyu98/received_events","type":"User","site_admin":false},"body":"#### What changes were proposed in this pull request?\r\n\r\nThis PR enhances the TRIM function support in Spark SQL by allowing the specification\r\nof trim characters set. Below is the SQL syntax :\r\n\r\n``` SQL\r\n<trim function> ::= TRIM <left paren> <trim operands> <right paren>\r\n<trim operands> ::= [ [ <trim specification> ] [ <trim character set> ] FROM ] <trim source>\r\n<trim source> ::= <character value expression>\r\n<trim specification> ::=\r\n  LEADING\r\n| TRAILING\r\n| BOTH\r\n<trim character set> ::= <characters value expression>    \r\n```\r\nor \r\n``` SQL\r\nLTRIM (source-exp [, trim-exp])\r\nRTRIM (source-exp [, trim-exp])\r\n```\r\n\r\n\r\nHere are the documentation link of support of this feature by other mainstream databases.\r\n- **Oracle:** [TRIM function](http://docs.oracle.com/cd/B28359_01/olap.111/b28126/dml_functions_2126.htm#OLADM704)\r\n- **DB2:** [TRIM scalar function](https://www.ibm.com/support/knowledgecenter/en/SSMKHH_10.0.0/com.ibm.etools.mft.doc/ak05270_.htm)\r\n- **MySQL:** [Trim function](http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_trim)\r\n- **Oracle:** [ltrim](https://docs.oracle.com/cd/B28359_01/olap.111/b28126/dml_functions_2018.htm#OLADM594)\r\n- **DB2:** [ltrim](https://www.ibm.com/support/knowledgecenter/en/SSEPEK_11.0.0/sqlref/src/tpc/db2z_bif_ltrim.html) \r\n\r\n\r\nThis PR is to implement the above enhancement. In the implementation, the design principle is to keep the changes to the minimum. Also, the exiting trim functions (which handles a special case, i.e., trimming space characters) are kept unchanged for performane reasons. \r\n#### How was this patch tested?\r\n\r\nThe unit test cases are added in the following files:\r\n- UTF8StringSuite.java\r\n- StringExpressionsSuite.scala\r\n- sql/SQLQuerySuite.scala\r\n- StringFunctionsSuite.scala\r\n\r\n","created_at":"2016-04-23T23:32:59Z","updated_at":"2017-08-07T06:19:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2a8b43500f52e295758a835610534df5acfbbd7f","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/12646/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/12646/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/12646/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/51ecfc8e4acb0ffd6389726a8fa381dd040925a9","head":{"label":"kevinyu98:spark-14878","ref":"spark-14878","sha":"51ecfc8e4acb0ffd6389726a8fa381dd040925a9","user":{"login":"kevinyu98","id":7550280,"avatar_url":"https://avatars3.githubusercontent.com/u/7550280?v=4","gravatar_id":"","url":"https://api.github.com/users/kevinyu98","html_url":"https://github.com/kevinyu98","followers_url":"https://api.github.com/users/kevinyu98/followers","following_url":"https://api.github.com/users/kevinyu98/following{/other_user}","gists_url":"https://api.github.com/users/kevinyu98/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinyu98/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinyu98/subscriptions","organizations_url":"https://api.github.com/users/kevinyu98/orgs","repos_url":"https://api.github.com/users/kevinyu98/repos","events_url":"https://api.github.com/users/kevinyu98/events{/privacy}","received_events_url":"https://api.github.com/users/kevinyu98/received_events","type":"User","site_admin":false},"repo":{"id":38393679,"name":"spark","full_name":"kevinyu98/spark","owner":{"login":"kevinyu98","id":7550280,"avatar_url":"https://avatars3.githubusercontent.com/u/7550280?v=4","gravatar_id":"","url":"https://api.github.com/users/kevinyu98","html_url":"https://github.com/kevinyu98","followers_url":"https://api.github.com/users/kevinyu98/followers","following_url":"https://api.github.com/users/kevinyu98/following{/other_user}","gists_url":"https://api.github.com/users/kevinyu98/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinyu98/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinyu98/subscriptions","organizations_url":"https://api.github.com/users/kevinyu98/orgs","repos_url":"https://api.github.com/users/kevinyu98/repos","events_url":"https://api.github.com/users/kevinyu98/events{/privacy}","received_events_url":"https://api.github.com/users/kevinyu98/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kevinyu98/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/kevinyu98/spark","forks_url":"https://api.github.com/repos/kevinyu98/spark/forks","keys_url":"https://api.github.com/repos/kevinyu98/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kevinyu98/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kevinyu98/spark/teams","hooks_url":"https://api.github.com/repos/kevinyu98/spark/hooks","issue_events_url":"https://api.github.com/repos/kevinyu98/spark/issues/events{/number}","events_url":"https://api.github.com/repos/kevinyu98/spark/events","assignees_url":"https://api.github.com/repos/kevinyu98/spark/assignees{/user}","branches_url":"https://api.github.com/repos/kevinyu98/spark/branches{/branch}","tags_url":"https://api.github.com/repos/kevinyu98/spark/tags","blobs_url":"https://api.github.com/repos/kevinyu98/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kevinyu98/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kevinyu98/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/kevinyu98/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kevinyu98/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/kevinyu98/spark/languages","stargazers_url":"https://api.github.com/repos/kevinyu98/spark/stargazers","contributors_url":"https://api.github.com/repos/kevinyu98/spark/contributors","subscribers_url":"https://api.github.com/repos/kevinyu98/spark/subscribers","subscription_url":"https://api.github.com/repos/kevinyu98/spark/subscription","commits_url":"https://api.github.com/repos/kevinyu98/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/kevinyu98/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/kevinyu98/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/kevinyu98/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/kevinyu98/spark/contents/{+path}","compare_url":"https://api.github.com/repos/kevinyu98/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kevinyu98/spark/merges","archive_url":"https://api.github.com/repos/kevinyu98/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kevinyu98/spark/downloads","issues_url":"https://api.github.com/repos/kevinyu98/spark/issues{/number}","pulls_url":"https://api.github.com/repos/kevinyu98/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/kevinyu98/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/kevinyu98/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kevinyu98/spark/labels{/name}","releases_url":"https://api.github.com/repos/kevinyu98/spark/releases{/id}","deployments_url":"https://api.github.com/repos/kevinyu98/spark/deployments","created_at":"2015-07-01T20:33:56Z","updated_at":"2016-02-19T21:55:17Z","pushed_at":"2017-07-26T21:05:55Z","git_url":"git://github.com/kevinyu98/spark.git","ssh_url":"git@github.com:kevinyu98/spark.git","clone_url":"https://github.com/kevinyu98/spark.git","svn_url":"https://github.com/kevinyu98/spark","homepage":null,"size":242411,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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":"apache:master","ref":"master","sha":"26cd2ca0402d7d49780116d45a5622a45c79f661","user":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","deployments_url":"https://api.github.com/repos/apache/spark/deployments","created_at":"2014-02-25T08:00:08Z","updated_at":"2017-08-07T05:55:13Z","pushed_at":"2017-08-07T06:03:36Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":257937,"stargazers_count":13818,"watchers_count":13818,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":13011,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":373,"forks":13011,"open_issues":373,"watchers":13818,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/12646"},"html":{"href":"https://github.com/apache/spark/pull/12646"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/12646"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/12646/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/12646/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/12646/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/51ecfc8e4acb0ffd6389726a8fa381dd040925a9"}}}}
{"actor":{"display_login":"kevinyu98"}}