Partition ClickHouse table based on unique string hash

I needed to create partitioning of the table based on unique string hash in range of [1...400], to have max 400 of partitions

cast(((arrayReduce('sum', arrayMap(x -> reinterpretAsUInt32(x), arrayConcat(splitByString('', if(isNotNull(jobHash), jobHash, '')), []))) - 100) * (400 - 1) / (3500 - 100) + 1), 'UInt64')

Last updated