Redshift equivalent Hash function.

0

I am looking to convert hash function to Redshift, below is the link for the definition of the function.

https://www.ibm.com/support/knowledgecenter/en/SSULQD_7.1.0/com.ibm.nz.sqltk.doc/r_sqlext_hash8.html

This hash8 function produces 64 bit integer(based on Jenkins algorithm) for input string and looks like the equivalent hash algorithm is not present in Redshift.

As a workaround we are re-creating hash values using FNV_HASH but due to large number of impacted tables and size wanted to confirm on the availability of equivalent function in Redshift.

https://docs.aws.amazon.com/redshift/latest/dg/r_FNV_HASH.html

AWS
已提問 3 年前檢視次數 890 次
1 個回答
0
已接受的答案

Not inbuilt, but i wrote something similar:

create function hash8 (varchar) returns bigint immutable as $$ select strtol(to_hex(strtol(substr(md5($1), 1, 1), 16) & 7) || substr(md5($1), 2, 15), 16) $$ language sql;

profile pictureAWS
專家
Rajiv_G
已回答 3 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南