{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/presto/pulls/comments/29375940","id":29375940,"diff_hunk":"@@ -0,0 +1,149 @@\n+/*\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package com.facebook.presto.operator.scalar;\n+\n+import com.facebook.presto.metadata.FunctionInfo;\n+import com.facebook.presto.metadata.FunctionRegistry;\n+import com.facebook.presto.metadata.ParametricScalar;\n+import com.facebook.presto.metadata.Signature;\n+import com.facebook.presto.spi.ConnectorSession;\n+import com.facebook.presto.spi.PrestoException;\n+import com.facebook.presto.spi.block.Block;\n+import com.facebook.presto.spi.type.StandardTypes;\n+import com.facebook.presto.spi.type.Type;\n+import com.facebook.presto.spi.type.TypeManager;\n+import com.facebook.presto.spi.type.TypeSignature;\n+import com.facebook.presto.type.ArrayType;\n+import com.facebook.presto.type.MapType;\n+import com.facebook.presto.type.RowType;\n+import com.google.common.collect.ImmutableList;\n+import io.airlift.slice.DynamicSliceOutput;\n+import io.airlift.slice.Slice;\n+\n+import java.lang.invoke.MethodHandle;\n+import java.util.Map;\n+\n+import static com.facebook.presto.metadata.OperatorType.CAST;\n+import static com.facebook.presto.metadata.Signature.internalOperator;\n+import static com.facebook.presto.metadata.Signature.typeParameter;\n+import static com.facebook.presto.spi.StandardErrorCode.INVALID_FUNCTION_ARGUMENT;\n+import static com.facebook.presto.spi.type.TimestampType.TIMESTAMP;\n+import static com.facebook.presto.spi.type.TypeSignature.parseTypeSignature;\n+import static com.facebook.presto.type.TypeUtils.parameterizedTypeName;\n+import static com.facebook.presto.type.TypeUtils.readStructuralBlock;\n+import static com.facebook.presto.util.Reflection.methodHandle;\n+import static java.lang.String.format;\n+\n+public final class ArrayJoin\n+        extends ParametricScalar\n+{\n+    public static final ArrayJoin ARRAY_JOIN = new ArrayJoin();\n+    private static final TypeSignature VARCHAR_TYPE_SIGNATURE = parseTypeSignature(StandardTypes.VARCHAR);\n+    private static final String FUNCTION_NAME = \"array_join\";\n+    private static final Signature SIGNATURE = new Signature(FUNCTION_NAME, ImmutableList.of(typeParameter(\"T\")), StandardTypes.VARCHAR,\n+            ImmutableList.of(\"array<T>\", StandardTypes.VARCHAR, StandardTypes.VARCHAR),\n+            false, false);\n+\n+    @Override\n+    public Signature getSignature()\n+    {\n+        return SIGNATURE;\n+    }\n+\n+    @Override\n+    public boolean isHidden()\n+    {\n+        return false;\n+    }\n+\n+    @Override\n+    public boolean isDeterministic()\n+    {\n+        return true;\n+    }\n+\n+    @Override\n+    public String getDescription()\n+    {\n+        return \"Concatenates the elements of the given array using a delimiter and an optional string to replace nulls\";\n+    }\n+\n+    @Override\n+    public FunctionInfo specialize(Map<String, Type> types, int arity, TypeManager typeManager, FunctionRegistry functionRegistry)\n+    {\n+        Type type = types.get(\"T\");\n+        TypeSignature valueType = type.getTypeSignature();\n+        TypeSignature arrayType = parameterizedTypeName(StandardTypes.ARRAY, valueType);\n+        Signature signature = new Signature(FUNCTION_NAME, VARCHAR_TYPE_SIGNATURE, arrayType, VARCHAR_TYPE_SIGNATURE, VARCHAR_TYPE_SIGNATURE);\n+\n+        MethodHandle methodHandle = methodHandle(ArrayJoin.class, \"arrayJoin\", FunctionInfo.class, Type.class, ConnectorSession.class, Slice.class, Slice.class, Slice.class);\n+        FunctionInfo castFunction = functionRegistry.getExactFunction(internalOperator(CAST.name(), VARCHAR_TYPE_SIGNATURE, ImmutableList.of(valueType)));","path":"presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayJoin.java","position":91,"original_position":91,"commit_id":"8aef5b8e3b30e825e480ee425764d3582a6f3c08","original_commit_id":"8aef5b8e3b30e825e480ee425764d3582a6f3c08","user":{"login":"nezihyigitbasi","id":1223839,"avatar_url":"https://avatars.githubusercontent.com/u/1223839?v=3","gravatar_id":"","url":"https://api.github.com/users/nezihyigitbasi","html_url":"https://github.com/nezihyigitbasi","followers_url":"https://api.github.com/users/nezihyigitbasi/followers","following_url":"https://api.github.com/users/nezihyigitbasi/following{/other_user}","gists_url":"https://api.github.com/users/nezihyigitbasi/gists{/gist_id}","starred_url":"https://api.github.com/users/nezihyigitbasi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nezihyigitbasi/subscriptions","organizations_url":"https://api.github.com/users/nezihyigitbasi/orgs","repos_url":"https://api.github.com/users/nezihyigitbasi/repos","events_url":"https://api.github.com/users/nezihyigitbasi/events{/privacy}","received_events_url":"https://api.github.com/users/nezihyigitbasi/received_events","type":"User","site_admin":false},"body":"``castFunction`` can be null for ``ARRAY_JOIN(ARRAY [null, null, null, null], 'X', null)``.  ","created_at":"2015-04-29T20:16:45Z","updated_at":"2015-04-29T20:16:45Z","html_url":"https://github.com/facebook/presto/pull/2600#discussion_r29375940","pull_request_url":"https://api.github.com/repos/facebook/presto/pulls/2600","_links":{"self":{"href":"https://api.github.com/repos/facebook/presto/pulls/comments/29375940"},"html":{"href":"https://github.com/facebook/presto/pull/2600#discussion_r29375940"},"pull_request":{"href":"https://api.github.com/repos/facebook/presto/pulls/2600"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/presto/pulls/2600","id":32070706,"html_url":"https://github.com/facebook/presto/pull/2600","diff_url":"https://github.com/facebook/presto/pull/2600.diff","patch_url":"https://github.com/facebook/presto/pull/2600.patch","issue_url":"https://api.github.com/repos/facebook/presto/issues/2600","number":2600,"state":"open","locked":false,"title":"Add array_to_string function","user":{"login":"nezihyigitbasi","id":1223839,"avatar_url":"https://avatars.githubusercontent.com/u/1223839?v=3","gravatar_id":"","url":"https://api.github.com/users/nezihyigitbasi","html_url":"https://github.com/nezihyigitbasi","followers_url":"https://api.github.com/users/nezihyigitbasi/followers","following_url":"https://api.github.com/users/nezihyigitbasi/following{/other_user}","gists_url":"https://api.github.com/users/nezihyigitbasi/gists{/gist_id}","starred_url":"https://api.github.com/users/nezihyigitbasi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nezihyigitbasi/subscriptions","organizations_url":"https://api.github.com/users/nezihyigitbasi/orgs","repos_url":"https://api.github.com/users/nezihyigitbasi/repos","events_url":"https://api.github.com/users/nezihyigitbasi/events{/privacy}","received_events_url":"https://api.github.com/users/nezihyigitbasi/received_events","type":"User","site_admin":false},"body":"This PR addresses #2539","created_at":"2015-03-26T23:13:57Z","updated_at":"2015-04-29T20:16:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1fdf55f0b876a743321b4303cca356b26be1c764","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/facebook/presto/pulls/2600/commits","review_comments_url":"https://api.github.com/repos/facebook/presto/pulls/2600/comments","review_comment_url":"https://api.github.com/repos/facebook/presto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/presto/issues/2600/comments","statuses_url":"https://api.github.com/repos/facebook/presto/statuses/8aef5b8e3b30e825e480ee425764d3582a6f3c08","head":{"label":"nezihyigitbasi:array_to_string","ref":"array_to_string","sha":"8aef5b8e3b30e825e480ee425764d3582a6f3c08","user":{"login":"nezihyigitbasi","id":1223839,"avatar_url":"https://avatars.githubusercontent.com/u/1223839?v=3","gravatar_id":"","url":"https://api.github.com/users/nezihyigitbasi","html_url":"https://github.com/nezihyigitbasi","followers_url":"https://api.github.com/users/nezihyigitbasi/followers","following_url":"https://api.github.com/users/nezihyigitbasi/following{/other_user}","gists_url":"https://api.github.com/users/nezihyigitbasi/gists{/gist_id}","starred_url":"https://api.github.com/users/nezihyigitbasi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nezihyigitbasi/subscriptions","organizations_url":"https://api.github.com/users/nezihyigitbasi/orgs","repos_url":"https://api.github.com/users/nezihyigitbasi/repos","events_url":"https://api.github.com/users/nezihyigitbasi/events{/privacy}","received_events_url":"https://api.github.com/users/nezihyigitbasi/received_events","type":"User","site_admin":false},"repo":{"id":20698188,"name":"presto","full_name":"nezihyigitbasi/presto","owner":{"login":"nezihyigitbasi","id":1223839,"avatar_url":"https://avatars.githubusercontent.com/u/1223839?v=3","gravatar_id":"","url":"https://api.github.com/users/nezihyigitbasi","html_url":"https://github.com/nezihyigitbasi","followers_url":"https://api.github.com/users/nezihyigitbasi/followers","following_url":"https://api.github.com/users/nezihyigitbasi/following{/other_user}","gists_url":"https://api.github.com/users/nezihyigitbasi/gists{/gist_id}","starred_url":"https://api.github.com/users/nezihyigitbasi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nezihyigitbasi/subscriptions","organizations_url":"https://api.github.com/users/nezihyigitbasi/orgs","repos_url":"https://api.github.com/users/nezihyigitbasi/repos","events_url":"https://api.github.com/users/nezihyigitbasi/events{/privacy}","received_events_url":"https://api.github.com/users/nezihyigitbasi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nezihyigitbasi/presto","description":"Distributed SQL query engine for big data","fork":true,"url":"https://api.github.com/repos/nezihyigitbasi/presto","forks_url":"https://api.github.com/repos/nezihyigitbasi/presto/forks","keys_url":"https://api.github.com/repos/nezihyigitbasi/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nezihyigitbasi/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nezihyigitbasi/presto/teams","hooks_url":"https://api.github.com/repos/nezihyigitbasi/presto/hooks","issue_events_url":"https://api.github.com/repos/nezihyigitbasi/presto/issues/events{/number}","events_url":"https://api.github.com/repos/nezihyigitbasi/presto/events","assignees_url":"https://api.github.com/repos/nezihyigitbasi/presto/assignees{/user}","branches_url":"https://api.github.com/repos/nezihyigitbasi/presto/branches{/branch}","tags_url":"https://api.github.com/repos/nezihyigitbasi/presto/tags","blobs_url":"https://api.github.com/repos/nezihyigitbasi/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nezihyigitbasi/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nezihyigitbasi/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/nezihyigitbasi/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nezihyigitbasi/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/nezihyigitbasi/presto/languages","stargazers_url":"https://api.github.com/repos/nezihyigitbasi/presto/stargazers","contributors_url":"https://api.github.com/repos/nezihyigitbasi/presto/contributors","subscribers_url":"https://api.github.com/repos/nezihyigitbasi/presto/subscribers","subscription_url":"https://api.github.com/repos/nezihyigitbasi/presto/subscription","commits_url":"https://api.github.com/repos/nezihyigitbasi/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/nezihyigitbasi/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/nezihyigitbasi/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/nezihyigitbasi/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/nezihyigitbasi/presto/contents/{+path}","compare_url":"https://api.github.com/repos/nezihyigitbasi/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nezihyigitbasi/presto/merges","archive_url":"https://api.github.com/repos/nezihyigitbasi/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nezihyigitbasi/presto/downloads","issues_url":"https://api.github.com/repos/nezihyigitbasi/presto/issues{/number}","pulls_url":"https://api.github.com/repos/nezihyigitbasi/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/nezihyigitbasi/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/nezihyigitbasi/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nezihyigitbasi/presto/labels{/name}","releases_url":"https://api.github.com/repos/nezihyigitbasi/presto/releases{/id}","created_at":"2014-06-10T19:14:21Z","updated_at":"2015-04-29T19:05:10Z","pushed_at":"2015-04-29T19:05:09Z","git_url":"git://github.com/nezihyigitbasi/presto.git","ssh_url":"git@github.com:nezihyigitbasi/presto.git","clone_url":"https://github.com/nezihyigitbasi/presto.git","svn_url":"https://github.com/nezihyigitbasi/presto","homepage":"http://prestodb.io/","size":38957,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"816e19dc269f6dd36ff9eb8784e1afd6be52eb30","user":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":5349565,"name":"presto","full_name":"facebook/presto","owner":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/presto","description":"Distributed SQL query engine for running interactive analytic queries against big data sources.","fork":false,"url":"https://api.github.com/repos/facebook/presto","forks_url":"https://api.github.com/repos/facebook/presto/forks","keys_url":"https://api.github.com/repos/facebook/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/presto/teams","hooks_url":"https://api.github.com/repos/facebook/presto/hooks","issue_events_url":"https://api.github.com/repos/facebook/presto/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/presto/events","assignees_url":"https://api.github.com/repos/facebook/presto/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/presto/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/presto/tags","blobs_url":"https://api.github.com/repos/facebook/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/presto/languages","stargazers_url":"https://api.github.com/repos/facebook/presto/stargazers","contributors_url":"https://api.github.com/repos/facebook/presto/contributors","subscribers_url":"https://api.github.com/repos/facebook/presto/subscribers","subscription_url":"https://api.github.com/repos/facebook/presto/subscription","commits_url":"https://api.github.com/repos/facebook/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/presto/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/presto/merges","archive_url":"https://api.github.com/repos/facebook/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/presto/downloads","issues_url":"https://api.github.com/repos/facebook/presto/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/presto/labels{/name}","releases_url":"https://api.github.com/repos/facebook/presto/releases{/id}","created_at":"2012-08-09T01:03:37Z","updated_at":"2015-04-29T19:45:42Z","pushed_at":"2015-04-29T20:04:40Z","git_url":"git://github.com/facebook/presto.git","ssh_url":"git@github.com:facebook/presto.git","clone_url":"https://github.com/facebook/presto.git","svn_url":"https://github.com/facebook/presto","homepage":"https://prestodb.io","size":85571,"stargazers_count":3384,"watchers_count":3384,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":774,"mirror_url":null,"open_issues_count":213,"forks":774,"open_issues":213,"watchers":3384,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/presto/pulls/2600"},"html":{"href":"https://github.com/facebook/presto/pull/2600"},"issue":{"href":"https://api.github.com/repos/facebook/presto/issues/2600"},"comments":{"href":"https://api.github.com/repos/facebook/presto/issues/2600/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/presto/pulls/2600/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/presto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/presto/pulls/2600/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/presto/statuses/8aef5b8e3b30e825e480ee425764d3582a6f3c08"}}}}