citusdata / pg_shard

ATTENTION: pg_shard is superseded by Citus, its more powerful replacement
https://github.com/citusdata/citus
GNU Lesser General Public License v3.0
1.06k stars 63 forks source link

Support enumeration types for partition columns #80

Closed jasonmp85 closed 9 years ago

jasonmp85 commented 9 years ago

This is similar to #79 except maybe more surprising that it doesn't Just Work™:

CREATE TYPE bug_status AS ENUM ('new', 'open', 'closed');
# CREATE TYPE
# Time: 6.044 ms

CREATE TABLE bugs (
    id integer,
    status bug_status
);
# CREATE TABLE
# Time: 3.599 ms

SELECT master_create_distributed_table('bugs', 'status');
# ERROR:  42883: could not identify a hash function for type bug_status
# DETAIL:  Partition column types must have a hash function defined to use hash partitioning.
# LOCATION:  master_create_distributed_table, create_shards.c:109
# Time: 3.202 ms

Kinda weird that enum types don't have a built-in hash function defined, given they're basically glorified integers.

jasonmp85 commented 9 years ago

Strangely, while hash_array fails to hash an array of a custom composite type (could not identify a hash function for type…), it can hash an array of an enumerated type. So perhaps we should look at it to see whether we're looking up hash functions in the best way possible.

onderkalaci commented 9 years ago

@jasonmp85 So, this might be related to the patch applied to citus very recently (Composite Type bug fix (New version)).

So, I'll check this too, missed that while checking for #79 .

jasonmp85 commented 9 years ago

Oh, I think I misled. I said that hash_array could find a function for composite types (#79), but I think I was confusing that with this (enumeration types). So we're on our own for composite types, but as I said above, it's kinda weird that we don't find the right function for an enumeration type.