{"action":"created","comment":{"url":"https://api.github.com/repos/citusdata/citus/pulls/comments/61048813","id":61048813,"diff_hunk":"@@ -299,20 +409,41 @@ ProcessCopyStmt(CopyStmt *copyStatement, char *completionTag)\n \t */\n \tif (copyStatement->relation != NULL)\n \t{\n-\t\tRelation copiedRelation = NULL;\n-\t\tbool isDistributedRelation = false;\n+\t\tbool isDistributedTable = false;\n+\t\tbool workerCopy = WorkerCopy(copyStatement);\n+\n+\t\tif (workerCopy)\n+\t\t{\n+\t\t\tNodeAddress *masterNodeAddress = MasterNodeAddress(copyStatement);\n+\t\t\tchar *relationName = copyStatement->relation->relname;\n+\t\t\tchar *nodeName = masterNodeAddress->nodeName;\n+\t\t\tint32 nodePort = masterNodeAddress->nodePort;\n+\n+\t\t\tisDistributedTable = IsRemoteDistributedTable(relationName, nodeName,\n+\t\t\t\t\t\t\t\t\t\t\t\t\t\t  nodePort);\n+\t\t\tif (!isDistributedTable)\n+\t\t\t{\n+\t\t\t\tereport(ERROR, (errmsg(\"relation \\\"%s\\\" on the master node is not a \"\n+\t\t\t\t\t\t\t\t\t   \"distributed table\", relationName)));\n+\t\t\t}\n \n-\t\tcopiedRelation = heap_openrv(copyStatement->relation, AccessShareLock);\n+\t\t\tCreateLocalTable(relationName, nodeName, nodePort);","path":"src/backend/distributed/executor/multi_utility.c","position":163,"original_position":163,"commit_id":"b00a19c757fdb231387180411729429d5293cb1e","original_commit_id":"b00a19c757fdb231387180411729429d5293cb1e","user":{"login":"metdos","id":149191,"avatar_url":"https://avatars.githubusercontent.com/u/149191?v=3","gravatar_id":"","url":"https://api.github.com/users/metdos","html_url":"https://github.com/metdos","followers_url":"https://api.github.com/users/metdos/followers","following_url":"https://api.github.com/users/metdos/following{/other_user}","gists_url":"https://api.github.com/users/metdos/gists{/gist_id}","starred_url":"https://api.github.com/users/metdos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metdos/subscriptions","organizations_url":"https://api.github.com/users/metdos/orgs","repos_url":"https://api.github.com/users/metdos/repos","events_url":"https://api.github.com/users/metdos/events{/privacy}","received_events_url":"https://api.github.com/users/metdos/received_events","type":"User","site_admin":false},"body":"> What happens if the table exists?\r\n\r\nThis is not a problem because we create new tables as temporary and\r\ntemporary tables exist in a special schema. Though, I need to think about\r\nschema support a bit more and test it well.","created_at":"2016-04-26T08:47:10Z","updated_at":"2016-04-26T08:47:10Z","html_url":"https://github.com/citusdata/citus/pull/468#discussion_r61048813","pull_request_url":"https://api.github.com/repos/citusdata/citus/pulls/468","_links":{"self":{"href":"https://api.github.com/repos/citusdata/citus/pulls/comments/61048813"},"html":{"href":"https://github.com/citusdata/citus/pull/468#discussion_r61048813"},"pull_request":{"href":"https://api.github.com/repos/citusdata/citus/pulls/468"}}},"pull_request":{"url":"https://api.github.com/repos/citusdata/citus/pulls/468","id":67734817,"html_url":"https://github.com/citusdata/citus/pull/468","diff_url":"https://github.com/citusdata/citus/pull/468.diff","patch_url":"https://github.com/citusdata/citus/pull/468.patch","issue_url":"https://api.github.com/repos/citusdata/citus/issues/468","number":468,"state":"open","locked":false,"title":"Add COPY support on worker nodes for append partitioned relations","user":{"login":"metdos","id":149191,"avatar_url":"https://avatars.githubusercontent.com/u/149191?v=3","gravatar_id":"","url":"https://api.github.com/users/metdos","html_url":"https://github.com/metdos","followers_url":"https://api.github.com/users/metdos/followers","following_url":"https://api.github.com/users/metdos/following{/other_user}","gists_url":"https://api.github.com/users/metdos/gists{/gist_id}","starred_url":"https://api.github.com/users/metdos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metdos/subscriptions","organizations_url":"https://api.github.com/users/metdos/orgs","repos_url":"https://api.github.com/users/metdos/repos","events_url":"https://api.github.com/users/metdos/events{/privacy}","received_events_url":"https://api.github.com/users/metdos/received_events","type":"User","site_admin":false},"body":"Hey @marcocitus, this PR is not completely ready. I will continue refactoring, adding comments and testing. In the meantime, if you have time, you can check the high-level approach. I will let you know when I'm completely done.\r\n\r\nHere how it works on the worker node;\r\nCOPY lineitem FROM '/path_to_file/lineitem.tbl' WITH (DELIMITER '|', MASTER_HOSTNAME 'localhost', MASTER_PORT 5432);","created_at":"2016-04-25T15:01:40Z","updated_at":"2016-04-26T08:47:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e8b0ae9cd9ef3fc6941d06950e7c6c4ab10418ff","assignee":{"login":"marcocitus","id":7127240,"avatar_url":"https://avatars.githubusercontent.com/u/7127240?v=3","gravatar_id":"","url":"https://api.github.com/users/marcocitus","html_url":"https://github.com/marcocitus","followers_url":"https://api.github.com/users/marcocitus/followers","following_url":"https://api.github.com/users/marcocitus/following{/other_user}","gists_url":"https://api.github.com/users/marcocitus/gists{/gist_id}","starred_url":"https://api.github.com/users/marcocitus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcocitus/subscriptions","organizations_url":"https://api.github.com/users/marcocitus/orgs","repos_url":"https://api.github.com/users/marcocitus/repos","events_url":"https://api.github.com/users/marcocitus/events{/privacy}","received_events_url":"https://api.github.com/users/marcocitus/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/citusdata/citus/pulls/468/commits","review_comments_url":"https://api.github.com/repos/citusdata/citus/pulls/468/comments","review_comment_url":"https://api.github.com/repos/citusdata/citus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/citusdata/citus/issues/468/comments","statuses_url":"https://api.github.com/repos/citusdata/citus/statuses/b00a19c757fdb231387180411729429d5293cb1e","head":{"label":"citusdata:feature/worker-copy-for-append-partitioning","ref":"feature/worker-copy-for-append-partitioning","sha":"b00a19c757fdb231387180411729429d5293cb1e","user":{"login":"citusdata","id":2545424,"avatar_url":"https://avatars.githubusercontent.com/u/2545424?v=3","gravatar_id":"","url":"https://api.github.com/users/citusdata","html_url":"https://github.com/citusdata","followers_url":"https://api.github.com/users/citusdata/followers","following_url":"https://api.github.com/users/citusdata/following{/other_user}","gists_url":"https://api.github.com/users/citusdata/gists{/gist_id}","starred_url":"https://api.github.com/users/citusdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/citusdata/subscriptions","organizations_url":"https://api.github.com/users/citusdata/orgs","repos_url":"https://api.github.com/users/citusdata/repos","events_url":"https://api.github.com/users/citusdata/events{/privacy}","received_events_url":"https://api.github.com/users/citusdata/received_events","type":"Organization","site_admin":false},"repo":{"id":50874442,"name":"citus","full_name":"citusdata/citus","owner":{"login":"citusdata","id":2545424,"avatar_url":"https://avatars.githubusercontent.com/u/2545424?v=3","gravatar_id":"","url":"https://api.github.com/users/citusdata","html_url":"https://github.com/citusdata","followers_url":"https://api.github.com/users/citusdata/followers","following_url":"https://api.github.com/users/citusdata/following{/other_user}","gists_url":"https://api.github.com/users/citusdata/gists{/gist_id}","starred_url":"https://api.github.com/users/citusdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/citusdata/subscriptions","organizations_url":"https://api.github.com/users/citusdata/orgs","repos_url":"https://api.github.com/users/citusdata/repos","events_url":"https://api.github.com/users/citusdata/events{/privacy}","received_events_url":"https://api.github.com/users/citusdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/citusdata/citus","description":"Scalable PostgreSQL for real-time workloads","fork":false,"url":"https://api.github.com/repos/citusdata/citus","forks_url":"https://api.github.com/repos/citusdata/citus/forks","keys_url":"https://api.github.com/repos/citusdata/citus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/citusdata/citus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/citusdata/citus/teams","hooks_url":"https://api.github.com/repos/citusdata/citus/hooks","issue_events_url":"https://api.github.com/repos/citusdata/citus/issues/events{/number}","events_url":"https://api.github.com/repos/citusdata/citus/events","assignees_url":"https://api.github.com/repos/citusdata/citus/assignees{/user}","branches_url":"https://api.github.com/repos/citusdata/citus/branches{/branch}","tags_url":"https://api.github.com/repos/citusdata/citus/tags","blobs_url":"https://api.github.com/repos/citusdata/citus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/citusdata/citus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/citusdata/citus/git/refs{/sha}","trees_url":"https://api.github.com/repos/citusdata/citus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/citusdata/citus/statuses/{sha}","languages_url":"https://api.github.com/repos/citusdata/citus/languages","stargazers_url":"https://api.github.com/repos/citusdata/citus/stargazers","contributors_url":"https://api.github.com/repos/citusdata/citus/contributors","subscribers_url":"https://api.github.com/repos/citusdata/citus/subscribers","subscription_url":"https://api.github.com/repos/citusdata/citus/subscription","commits_url":"https://api.github.com/repos/citusdata/citus/commits{/sha}","git_commits_url":"https://api.github.com/repos/citusdata/citus/git/commits{/sha}","comments_url":"https://api.github.com/repos/citusdata/citus/comments{/number}","issue_comment_url":"https://api.github.com/repos/citusdata/citus/issues/comments{/number}","contents_url":"https://api.github.com/repos/citusdata/citus/contents/{+path}","compare_url":"https://api.github.com/repos/citusdata/citus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/citusdata/citus/merges","archive_url":"https://api.github.com/repos/citusdata/citus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/citusdata/citus/downloads","issues_url":"https://api.github.com/repos/citusdata/citus/issues{/number}","pulls_url":"https://api.github.com/repos/citusdata/citus/pulls{/number}","milestones_url":"https://api.github.com/repos/citusdata/citus/milestones{/number}","notifications_url":"https://api.github.com/repos/citusdata/citus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/citusdata/citus/labels{/name}","releases_url":"https://api.github.com/repos/citusdata/citus/releases{/id}","deployments_url":"https://api.github.com/repos/citusdata/citus/deployments","created_at":"2016-02-01T21:58:39Z","updated_at":"2016-04-25T18:11:50Z","pushed_at":"2016-04-26T08:21:39Z","git_url":"git://github.com/citusdata/citus.git","ssh_url":"git@github.com:citusdata/citus.git","clone_url":"https://github.com/citusdata/citus.git","svn_url":"https://github.com/citusdata/citus","homepage":"https://www.citusdata.com","size":2356,"stargazers_count":1246,"watchers_count":1246,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":63,"mirror_url":null,"open_issues_count":329,"forks":63,"open_issues":329,"watchers":1246,"default_branch":"master"}},"base":{"label":"citusdata:master","ref":"master","sha":"996e56f62318ecc008c7b8caa53aea5ff74d9356","user":{"login":"citusdata","id":2545424,"avatar_url":"https://avatars.githubusercontent.com/u/2545424?v=3","gravatar_id":"","url":"https://api.github.com/users/citusdata","html_url":"https://github.com/citusdata","followers_url":"https://api.github.com/users/citusdata/followers","following_url":"https://api.github.com/users/citusdata/following{/other_user}","gists_url":"https://api.github.com/users/citusdata/gists{/gist_id}","starred_url":"https://api.github.com/users/citusdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/citusdata/subscriptions","organizations_url":"https://api.github.com/users/citusdata/orgs","repos_url":"https://api.github.com/users/citusdata/repos","events_url":"https://api.github.com/users/citusdata/events{/privacy}","received_events_url":"https://api.github.com/users/citusdata/received_events","type":"Organization","site_admin":false},"repo":{"id":50874442,"name":"citus","full_name":"citusdata/citus","owner":{"login":"citusdata","id":2545424,"avatar_url":"https://avatars.githubusercontent.com/u/2545424?v=3","gravatar_id":"","url":"https://api.github.com/users/citusdata","html_url":"https://github.com/citusdata","followers_url":"https://api.github.com/users/citusdata/followers","following_url":"https://api.github.com/users/citusdata/following{/other_user}","gists_url":"https://api.github.com/users/citusdata/gists{/gist_id}","starred_url":"https://api.github.com/users/citusdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/citusdata/subscriptions","organizations_url":"https://api.github.com/users/citusdata/orgs","repos_url":"https://api.github.com/users/citusdata/repos","events_url":"https://api.github.com/users/citusdata/events{/privacy}","received_events_url":"https://api.github.com/users/citusdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/citusdata/citus","description":"Scalable PostgreSQL for real-time workloads","fork":false,"url":"https://api.github.com/repos/citusdata/citus","forks_url":"https://api.github.com/repos/citusdata/citus/forks","keys_url":"https://api.github.com/repos/citusdata/citus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/citusdata/citus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/citusdata/citus/teams","hooks_url":"https://api.github.com/repos/citusdata/citus/hooks","issue_events_url":"https://api.github.com/repos/citusdata/citus/issues/events{/number}","events_url":"https://api.github.com/repos/citusdata/citus/events","assignees_url":"https://api.github.com/repos/citusdata/citus/assignees{/user}","branches_url":"https://api.github.com/repos/citusdata/citus/branches{/branch}","tags_url":"https://api.github.com/repos/citusdata/citus/tags","blobs_url":"https://api.github.com/repos/citusdata/citus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/citusdata/citus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/citusdata/citus/git/refs{/sha}","trees_url":"https://api.github.com/repos/citusdata/citus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/citusdata/citus/statuses/{sha}","languages_url":"https://api.github.com/repos/citusdata/citus/languages","stargazers_url":"https://api.github.com/repos/citusdata/citus/stargazers","contributors_url":"https://api.github.com/repos/citusdata/citus/contributors","subscribers_url":"https://api.github.com/repos/citusdata/citus/subscribers","subscription_url":"https://api.github.com/repos/citusdata/citus/subscription","commits_url":"https://api.github.com/repos/citusdata/citus/commits{/sha}","git_commits_url":"https://api.github.com/repos/citusdata/citus/git/commits{/sha}","comments_url":"https://api.github.com/repos/citusdata/citus/comments{/number}","issue_comment_url":"https://api.github.com/repos/citusdata/citus/issues/comments{/number}","contents_url":"https://api.github.com/repos/citusdata/citus/contents/{+path}","compare_url":"https://api.github.com/repos/citusdata/citus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/citusdata/citus/merges","archive_url":"https://api.github.com/repos/citusdata/citus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/citusdata/citus/downloads","issues_url":"https://api.github.com/repos/citusdata/citus/issues{/number}","pulls_url":"https://api.github.com/repos/citusdata/citus/pulls{/number}","milestones_url":"https://api.github.com/repos/citusdata/citus/milestones{/number}","notifications_url":"https://api.github.com/repos/citusdata/citus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/citusdata/citus/labels{/name}","releases_url":"https://api.github.com/repos/citusdata/citus/releases{/id}","deployments_url":"https://api.github.com/repos/citusdata/citus/deployments","created_at":"2016-02-01T21:58:39Z","updated_at":"2016-04-25T18:11:50Z","pushed_at":"2016-04-26T08:21:39Z","git_url":"git://github.com/citusdata/citus.git","ssh_url":"git@github.com:citusdata/citus.git","clone_url":"https://github.com/citusdata/citus.git","svn_url":"https://github.com/citusdata/citus","homepage":"https://www.citusdata.com","size":2356,"stargazers_count":1246,"watchers_count":1246,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":63,"mirror_url":null,"open_issues_count":329,"forks":63,"open_issues":329,"watchers":1246,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/citusdata/citus/pulls/468"},"html":{"href":"https://github.com/citusdata/citus/pull/468"},"issue":{"href":"https://api.github.com/repos/citusdata/citus/issues/468"},"comments":{"href":"https://api.github.com/repos/citusdata/citus/issues/468/comments"},"review_comments":{"href":"https://api.github.com/repos/citusdata/citus/pulls/468/comments"},"review_comment":{"href":"https://api.github.com/repos/citusdata/citus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/citusdata/citus/pulls/468/commits"},"statuses":{"href":"https://api.github.com/repos/citusdata/citus/statuses/b00a19c757fdb231387180411729429d5293cb1e"}}}}