Translate value to partition_ident

Hi,

I’m wondering if there is a SQL function that will perform the consistent hashing to determine the partition_ident that’s used for table partitioning (or the reverse).

Example: I have partitioned my table using the day column I’d like to somehow be able to translate 2023-03-03' to 04732dhn6ss30c9m60o30c1gto avoid having to look this up on the CrateDB Admin UI for a script that works off thepartition_ident`.

greetings Daniel

there is no exposed function, but you can look up the values in information_schema.table_partitions

e.g.

SELECT partition_ident, values['day']
FROM information_schema.table_partitions
WHERE table_name = 'test' and partition_ident = '04732dhn6ss30c9m60o30c1g'

and the other way around

SELECT partition_ident, values['day']
FROM information_schema.table_partitions
WHERE table_name = 'test' and values['day']= '2023-03-03'::TIMESTAMPTZ
1 Like