{"action":"created","issue":{"url":"https://api.github.com/repos/citusdata/citus/issues/687","repository_url":"https://api.github.com/repos/citusdata/citus","labels_url":"https://api.github.com/repos/citusdata/citus/issues/687/labels{/name}","comments_url":"https://api.github.com/repos/citusdata/citus/issues/687/comments","events_url":"https://api.github.com/repos/citusdata/citus/issues/687/events","html_url":"https://github.com/citusdata/citus/issues/687","id":168191440,"number":687,"title":"Support evaluating functions on master to determine partition column value","user":{"login":"lfittl","id":7227,"avatar_url":"https://avatars.githubusercontent.com/u/7227?v=3","gravatar_id":"","url":"https://api.github.com/users/lfittl","html_url":"https://github.com/lfittl","followers_url":"https://api.github.com/users/lfittl/followers","following_url":"https://api.github.com/users/lfittl/following{/other_user}","gists_url":"https://api.github.com/users/lfittl/gists{/gist_id}","starred_url":"https://api.github.com/users/lfittl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lfittl/subscriptions","organizations_url":"https://api.github.com/users/lfittl/orgs","repos_url":"https://api.github.com/users/lfittl/repos","events_url":"https://api.github.com/users/lfittl/events{/privacy}","received_events_url":"https://api.github.com/users/lfittl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-28T20:41:08Z","updated_at":"2016-08-03T08:37:05Z","closed_at":null,"body":"**Use case:** I have a distributed `customers` table with a `customer_id` column as SERIAL/UUID. `customer_id` is also my partition column.\r\n\r\nMy intention is for Citus to generate the `customer_id` (using a sequence or `uuid_generate_v4()`) and return it back to me using `RETURNING` on insertion.\r\n\r\nRight now we're failing with `ERROR:  values given for the partition column must be constants or constant expressions`.\r\n\r\nThe current workaround is to have the client generate the ID, which works easy enough for UUIDs, but is rather cumbersome for sequences/SERIAL.\r\n\r\nFull example for SERIAL:\r\n\r\n```sql\r\nCREATE TABLE example_serial(id serial, name text, created_at timestamp);\r\nSELECT master_create_distributed_table('example_serial', 'id', 'hash');\r\nSELECT master_create_worker_shards('example_serial', 16, 1);\r\n\r\nINSERT INTO example_serial (name, created_at) VALUES ('My test', now());\r\n-- ERROR:  values given for the partition column must be constants or constant expressions\r\n\r\nINSERT INTO example_serial (id, name, created_at) VALUES (nextval('example_serial_id_seq'::regclass), 'My test', now());\r\n-- ERROR:  values given for the partition column must be constants or constant expressions\r\n\r\nINSERT INTO example_serial (id, name, created_at) VALUES (1, 'My test', now());\r\n-- INSERT 0 1\r\n```\r\n\r\nFull example for uuid:\r\n\r\n```sql\r\nCREATE TABLE example_uuid(id uuid default uuid_generate_v4(), name text, created_at timestamp);\r\nSELECT master_create_distributed_table('example_uuid', 'id', 'hash');\r\nSELECT master_create_worker_shards('example_uuid', 16, 1);\r\n\r\nINSERT INTO example_uuid (name, created_at) VALUES ('My test', now());\r\n-- ERROR:  values given for the partition column must be constants or constant expressions\r\n\r\nINSERT INTO example_uuid (id, name, created_at) VALUES (uuid_generate_v4(), 'My test', now());\r\n-- ERROR:  values given for the partition column must be constants or constant expressions\r\n\r\nINSERT INTO example_uuid (id, name, created_at) VALUES ('fa5f4b4b-6c97-47ee-9f84-fa702e01c98c', 'My test', now());\r\n-- INSERT 0 1\r\n```"},"comment":{"url":"https://api.github.com/repos/citusdata/citus/issues/comments/237177552","html_url":"https://github.com/citusdata/citus/issues/687#issuecomment-237177552","issue_url":"https://api.github.com/repos/citusdata/citus/issues/687","id":237177552,"user":{"login":"lithp","id":466333,"avatar_url":"https://avatars.githubusercontent.com/u/466333?v=3","gravatar_id":"","url":"https://api.github.com/users/lithp","html_url":"https://github.com/lithp","followers_url":"https://api.github.com/users/lithp/followers","following_url":"https://api.github.com/users/lithp/following{/other_user}","gists_url":"https://api.github.com/users/lithp/gists{/gist_id}","starred_url":"https://api.github.com/users/lithp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lithp/subscriptions","organizations_url":"https://api.github.com/users/lithp/orgs","repos_url":"https://api.github.com/users/lithp/repos","events_url":"https://api.github.com/users/lithp/events{/privacy}","received_events_url":"https://api.github.com/users/lithp/received_events","type":"User","site_admin":false},"created_at":"2016-08-03T08:37:05Z","updated_at":"2016-08-03T08:37:05Z","body":"This is potentially related to #681, we probably have to fix it by moving shard pruning into the executor, which might fix #681 at the same time."}}
{"actor":{"display_login":"lithp"}}