cockroachdb / cockroachdb/cockroach
sql: not possible to cast to enum UDT in partition values list
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
When we create a table with an enum user-defined type, we can cast various constants in the table definition to the type:
```sql
CREATE TYPE e AS ENUM ('e1', 'e2');
CREATE TABLE ab (
a e PRIMARY KEY DEFAULT 'e1'::e,
b e AS ('e2'::e) VIRTUAL
) PARTITION BY LIST (a) (PARTITION p VALUES IN (('e1')));
```
But when we try to cast the constants in the partition values list to the type, it fails with "type does not exist":
```sql
CREATE TYPE f AS ENUM ('f1', 'f2');
CREATE TABLE cd (
c f PRIMARY KEY DEFAULT 'f1'::f,
d f AS ('f2'::f) VIRTUAL
) PARTITION BY LIST (c) (PARTITION p VALUES IN (('f1'::f)));
-- fails with
-- ERROR: PARTITION p: type "f" does not exist
-- SQLSTATE: 42704
```
Jira issue: CRDB-46392
Contributor guide
Assessment
This issue has not been assessed yet.