Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
This commit adds regression test for partition column which tests
partition columns which is not eligible for distribution.
  • Loading branch information
onderkalaci committed Feb 6, 2015
1 parent e17fbbd commit 20b17d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion expected/create_shards.out.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ CREATE FUNCTION create_table_then_fail(cstring, integer)
-- ===================================================================
CREATE TABLE table_to_distribute (
name text,
id bigint PRIMARY KEY
id bigint PRIMARY KEY,
data json
);
-- use an index instead of table name
SELECT master_create_distributed_table('table_to_distribute_pkey', 'id');
Expand All @@ -26,6 +27,11 @@ ERROR: could not find column: bad_column
-- use unsupported partition type
SELECT master_create_distributed_table('table_to_distribute', 'name', 'r');
ERROR: unsupported partition method: r
-- use unsupported partition column
SELECT master_create_distributed_table('table_to_distribute', 'data');
ERROR: cannot distribute relation: "table_to_distribute"
DETAIL: Column "data" is not eligible to be the distribution column.
HINT: Try another column as the distribution column.
-- distribute table and inspect side effects
SELECT master_create_distributed_table('table_to_distribute', 'name');
master_create_distributed_table
Expand Down
6 changes: 5 additions & 1 deletion sql/create_shards.sql.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ CREATE FUNCTION create_table_then_fail(cstring, integer)

CREATE TABLE table_to_distribute (
name text,
id bigint PRIMARY KEY
id bigint PRIMARY KEY,
data json
);

-- use an index instead of table name
Expand All @@ -30,6 +31,9 @@ SELECT master_create_distributed_table('table_to_distribute', 'bad_column');
-- use unsupported partition type
SELECT master_create_distributed_table('table_to_distribute', 'name', 'r');

-- use unsupported partition column
SELECT master_create_distributed_table('table_to_distribute', 'data');

-- distribute table and inspect side effects
SELECT master_create_distributed_table('table_to_distribute', 'name');
SELECT partition_method, key FROM pgs_distribution_metadata.partition
Expand Down

0 comments on commit 20b17d6

Please sign in to comment.