{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/32701290","id":32701290,"diff_hunk":"@@ -313,3 +313,131 @@ case class StringLength(child: Expression) extends UnaryExpression with ExpectsI\n     defineCodeGen(ctx, ev, c => s\"($c).length()\")\n   }\n }\n+\n+/**\n+ * Returns the numeric value of the first character of str.\n+ */\n+case class Ascii(child: Expression) extends UnaryExpression with ExpectsInputTypes {\n+  override def dataType: DataType = IntegerType\n+  override def expectedChildTypes: Seq[DataType] = Seq(StringType)\n+\n+  override def eval(input: InternalRow): Any = {\n+    val string = child.eval(input)\n+    if (string == null) {\n+      null\n+    } else {\n+      val bytes = string.asInstanceOf[UTF8String].getBytes\n+      if (bytes.length > 0) {","path":"sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringOperations.scala","position":18,"original_position":18,"commit_id":"6a714814ff0176a6fca72493b90cc46da69b0065","original_commit_id":"6a714814ff0176a6fca72493b90cc46da69b0065","user":{"login":"rxin","id":323388,"avatar_url":"https://avatars.githubusercontent.com/u/323388?v=3","gravatar_id":"","url":"https://api.github.com/users/rxin","html_url":"https://github.com/rxin","followers_url":"https://api.github.com/users/rxin/followers","following_url":"https://api.github.com/users/rxin/following{/other_user}","gists_url":"https://api.github.com/users/rxin/gists{/gist_id}","starred_url":"https://api.github.com/users/rxin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rxin/subscriptions","organizations_url":"https://api.github.com/users/rxin/orgs","repos_url":"https://api.github.com/users/rxin/repos","events_url":"https://api.github.com/users/rxin/events{/privacy}","received_events_url":"https://api.github.com/users/rxin/received_events","type":"User","site_admin":false},"body":"what should the behavior be if it is a non-ascii utf8 string?","created_at":"2015-06-18T06:07:56Z","updated_at":"2015-06-18T06:07:56Z","html_url":"https://github.com/apache/spark/pull/6843#discussion_r32701290","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/6843","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/32701290"},"html":{"href":"https://github.com/apache/spark/pull/6843#discussion_r32701290"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/6843"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/6843","id":37801677,"html_url":"https://github.com/apache/spark/pull/6843","diff_url":"https://github.com/apache/spark/pull/6843.diff","patch_url":"https://github.com/apache/spark/pull/6843.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/6843","number":6843,"state":"open","locked":false,"title":"[SPARK-8238][SPARK-8239][SPARK-8242][SPARK-8243][SPARK-8268][SQL][WIP] Add ascii/base64/unbase64/encode/decode functions","user":{"login":"chenghao-intel","id":2367031,"avatar_url":"https://avatars.githubusercontent.com/u/2367031?v=3","gravatar_id":"","url":"https://api.github.com/users/chenghao-intel","html_url":"https://github.com/chenghao-intel","followers_url":"https://api.github.com/users/chenghao-intel/followers","following_url":"https://api.github.com/users/chenghao-intel/following{/other_user}","gists_url":"https://api.github.com/users/chenghao-intel/gists{/gist_id}","starred_url":"https://api.github.com/users/chenghao-intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenghao-intel/subscriptions","organizations_url":"https://api.github.com/users/chenghao-intel/orgs","repos_url":"https://api.github.com/users/chenghao-intel/repos","events_url":"https://api.github.com/users/chenghao-intel/events{/privacy}","received_events_url":"https://api.github.com/users/chenghao-intel/received_events","type":"User","site_admin":false},"body":"Add `ascii`,`base64`,`unbase64`,`encode` and `decode` expressions.","created_at":"2015-06-16T14:36:42Z","updated_at":"2015-06-18T06:07:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"693fcf667969219e2eddfe92c4c7a1e7a4fab906","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/6843/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/6843/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/6843/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/6a714814ff0176a6fca72493b90cc46da69b0065","head":{"label":"chenghao-intel:str_funcs2","ref":"str_funcs2","sha":"6a714814ff0176a6fca72493b90cc46da69b0065","user":{"login":"chenghao-intel","id":2367031,"avatar_url":"https://avatars.githubusercontent.com/u/2367031?v=3","gravatar_id":"","url":"https://api.github.com/users/chenghao-intel","html_url":"https://github.com/chenghao-intel","followers_url":"https://api.github.com/users/chenghao-intel/followers","following_url":"https://api.github.com/users/chenghao-intel/following{/other_user}","gists_url":"https://api.github.com/users/chenghao-intel/gists{/gist_id}","starred_url":"https://api.github.com/users/chenghao-intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenghao-intel/subscriptions","organizations_url":"https://api.github.com/users/chenghao-intel/orgs","repos_url":"https://api.github.com/users/chenghao-intel/repos","events_url":"https://api.github.com/users/chenghao-intel/events{/privacy}","received_events_url":"https://api.github.com/users/chenghao-intel/received_events","type":"User","site_admin":false},"repo":{"id":18098468,"name":"spark","full_name":"chenghao-intel/spark","owner":{"login":"chenghao-intel","id":2367031,"avatar_url":"https://avatars.githubusercontent.com/u/2367031?v=3","gravatar_id":"","url":"https://api.github.com/users/chenghao-intel","html_url":"https://github.com/chenghao-intel","followers_url":"https://api.github.com/users/chenghao-intel/followers","following_url":"https://api.github.com/users/chenghao-intel/following{/other_user}","gists_url":"https://api.github.com/users/chenghao-intel/gists{/gist_id}","starred_url":"https://api.github.com/users/chenghao-intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenghao-intel/subscriptions","organizations_url":"https://api.github.com/users/chenghao-intel/orgs","repos_url":"https://api.github.com/users/chenghao-intel/repos","events_url":"https://api.github.com/users/chenghao-intel/events{/privacy}","received_events_url":"https://api.github.com/users/chenghao-intel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chenghao-intel/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/chenghao-intel/spark","forks_url":"https://api.github.com/repos/chenghao-intel/spark/forks","keys_url":"https://api.github.com/repos/chenghao-intel/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chenghao-intel/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chenghao-intel/spark/teams","hooks_url":"https://api.github.com/repos/chenghao-intel/spark/hooks","issue_events_url":"https://api.github.com/repos/chenghao-intel/spark/issues/events{/number}","events_url":"https://api.github.com/repos/chenghao-intel/spark/events","assignees_url":"https://api.github.com/repos/chenghao-intel/spark/assignees{/user}","branches_url":"https://api.github.com/repos/chenghao-intel/spark/branches{/branch}","tags_url":"https://api.github.com/repos/chenghao-intel/spark/tags","blobs_url":"https://api.github.com/repos/chenghao-intel/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chenghao-intel/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chenghao-intel/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/chenghao-intel/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chenghao-intel/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/chenghao-intel/spark/languages","stargazers_url":"https://api.github.com/repos/chenghao-intel/spark/stargazers","contributors_url":"https://api.github.com/repos/chenghao-intel/spark/contributors","subscribers_url":"https://api.github.com/repos/chenghao-intel/spark/subscribers","subscription_url":"https://api.github.com/repos/chenghao-intel/spark/subscription","commits_url":"https://api.github.com/repos/chenghao-intel/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/chenghao-intel/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/chenghao-intel/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/chenghao-intel/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/chenghao-intel/spark/contents/{+path}","compare_url":"https://api.github.com/repos/chenghao-intel/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chenghao-intel/spark/merges","archive_url":"https://api.github.com/repos/chenghao-intel/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chenghao-intel/spark/downloads","issues_url":"https://api.github.com/repos/chenghao-intel/spark/issues{/number}","pulls_url":"https://api.github.com/repos/chenghao-intel/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/chenghao-intel/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/chenghao-intel/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chenghao-intel/spark/labels{/name}","releases_url":"https://api.github.com/repos/chenghao-intel/spark/releases{/id}","created_at":"2014-03-25T11:52:04Z","updated_at":"2015-03-05T08:13:37Z","pushed_at":"2015-06-17T08:56:22Z","git_url":"git://github.com/chenghao-intel/spark.git","ssh_url":"git@github.com:chenghao-intel/spark.git","clone_url":"https://github.com/chenghao-intel/spark.git","svn_url":"https://github.com/chenghao-intel/spark","homepage":null,"size":118032,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"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":"658814c898bec04c31a8e57f8da0103497aac6ec","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","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://avatars.githubusercontent.com/u/47359?v=3","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}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-06-18T05:42:49Z","pushed_at":"2015-06-18T05:53:15Z","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":1481944,"stargazers_count":4419,"watchers_count":4419,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3891,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":358,"forks":3891,"open_issues":358,"watchers":4419,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/6843"},"html":{"href":"https://github.com/apache/spark/pull/6843"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/6843"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/6843/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/6843/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/6843/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/6a714814ff0176a6fca72493b90cc46da69b0065"}}}}