Skip to content

Instantly share code, notes, and snippets.

@begriffs
Created August 17, 2017 20:08
Show Gist options
  • Save begriffs/bfe21194b96f5d9c0306b55632204945 to your computer and use it in GitHub Desktop.
Save begriffs/bfe21194b96f5d9c0306b55632204945 to your computer and use it in GitHub Desktop.
No error from this view
CREATE TYPE prio AS ENUM ('low', 'med', 'high');
SELECT run_command_on_workers ($cmd$
CREATE TYPE prio AS ENUM ('low', 'med', 'high');
$cmd$);
CREATE TABLE todos (
id serial,
project_id int,
priority prio DEFAULT 'med',
what text NOT NULL,
PRIMARY KEY (id, project_id)
);
INSERT INTO todos (project_id, what)
SELECT random() * 4, 'usual thing'
FROM generate_series(1, 100);
INSERT INTO todos (project_id, what, priority)
SELECT random() * 4, 'important thing', 'high'
FROM generate_series(1, 10);
SELECT create_distributed_table ('todos', 'project_id');
CREATE VIEW important_todos AS
SELECT *
FROM todos
WHERE priority >= 'high';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment