create_distributed_table distributes non-empty table with append/range distribution
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
create_distributed_table waits concurrent COPY to append/range distributed table, then it distributed the table(without COPYing local data to shards). We should error out if local table is not empty for append/range distributions
Example test case to reproduce the issue;
```sql
CREATE TABLE append_copy(id integer, data text, int_data int);
```
Session 1;
```sql
BEGIN;
COPY append_copy FROM PROGRAM 'echo 5, f, 5\\n6, g, 6\\n7, h, 7\\n8, i, 8\\n9, j, 9' WITH CSV;
```
Session 2;
```sql
SELECT create_distributed_table('append_copy', 'id', 'append');
```
Session 1;
```sql
COMMIT;
```
Result;
```sql
SELECT * FROM append_copy;
id | data | int_data
----+------+----------
(0 rows)
DELETE FROM pg_dist_partition WHERE logicalrelid = 'append_copy'::regclass;
DELETE 1
SELECT * FROM append_copy;
id | data | int_data
----+------+----------
5 | f | 5
6 | g | 6
7 | h | 7
8 | i | 8
9 | j | 9
(5 rows)
```
Contributor guide
Assessment
This issue has not been assessed yet.