More range partitioned tests

pull/3376/head
Hadi Moshayedi 2020-01-15 15:18:20 -08:00
parent 8635396cea
commit 8b27a9a195
2 changed files with 78 additions and 0 deletions

View File

@ -756,6 +756,61 @@ SELECT max(result) FROM run_command_on_placements('target_table', 'select count(
0
(1 row)
DROP TABLE source_table, target_table;
--
-- Range partitioned target's ranges doesn't cover the whole range
--
SET citus.shard_replication_factor TO 2;
SET citus.replication_model TO 'statement';
SET citus.shard_count TO 4;
CREATE TABLE source_table(a int, b int);
SELECT create_distributed_table('source_table', 'a');
create_distributed_table
---------------------------------------------------------------------
(1 row)
INSERT INTO source_table SELECT i, i * i FROM generate_series(1, 10) i;
SET citus.shard_replication_factor TO 2;
CREATE TABLE target_table(b int not null, a float);
SELECT create_distributed_table('target_table', 'a', 'range');
create_distributed_table
---------------------------------------------------------------------
(1 row)
CALL public.create_range_partitioned_shards('target_table', '{0.0,3.5,6.5,9.5}','{2.9,5.9,8.9,50.0}');
INSERT INTO target_table SELECT b, a+0.6 FROM source_table;
SELECT * FROM target_table ORDER BY a;
b | a
---------------------------------------------------------------------
1 | 1.6
4 | 2.6
9 | 3.6
16 | 4.6
25 | 5.6
36 | 6.6
49 | 7.6
64 | 8.6
81 | 9.6
100 | 10.6
(10 rows)
-- verify that values have been replicated to both replicas, and that each
-- replica has received correct number of rows
SELECT * FROM run_command_on_placements('target_table', 'select count(*) from %s') ORDER BY shardid, nodeport;
nodename | nodeport | shardid | success | result
---------------------------------------------------------------------
localhost | 57637 | 4213625 | t | 2
localhost | 57638 | 4213625 | t | 2
localhost | 57637 | 4213626 | t | 3
localhost | 57638 | 4213626 | t | 3
localhost | 57637 | 4213627 | t | 3
localhost | 57638 | 4213627 | t | 3
localhost | 57637 | 4213628 | t | 2
localhost | 57638 | 4213628 | t | 2
(8 rows)
DROP TABLE source_table, target_table;
SET client_min_messages TO WARNING;
DROP SCHEMA insert_select_repartition CASCADE;

View File

@ -357,7 +357,30 @@ END;
SELECT max(result) FROM run_command_on_placements('target_table', 'select count(*) from %s');
DROP TABLE source_table, target_table;
--
-- Range partitioned target's ranges doesn't cover the whole range
--
SET citus.shard_replication_factor TO 2;
SET citus.replication_model TO 'statement';
SET citus.shard_count TO 4;
CREATE TABLE source_table(a int, b int);
SELECT create_distributed_table('source_table', 'a');
INSERT INTO source_table SELECT i, i * i FROM generate_series(1, 10) i;
SET citus.shard_replication_factor TO 2;
CREATE TABLE target_table(b int not null, a float);
SELECT create_distributed_table('target_table', 'a', 'range');
CALL public.create_range_partitioned_shards('target_table', '{0.0,3.5,6.5,9.5}','{2.9,5.9,8.9,50.0}');
INSERT INTO target_table SELECT b, a+0.6 FROM source_table;
SELECT * FROM target_table ORDER BY a;
-- verify that values have been replicated to both replicas, and that each
-- replica has received correct number of rows
SELECT * FROM run_command_on_placements('target_table', 'select count(*) from %s') ORDER BY shardid, nodeport;
DROP TABLE source_table, target_table;