Delta live table generate unique integer value (kind of surrogate key) for combination of columns

NathanSundarara
Valued Contributor

Hi,

we are in process of moving our Datawarehouse from sql server to databricks. we are in process of testing our Dimension Product table which has identity column for referencing in fact table as surrogate key.

In Databricks Apply changes SCD type 2 we were recommended to generate since apply changes don't allow identity column. I tried hash() function using combination of two columns using concat_ws() and passing result of concat_ws to hash function. It generated big int but it also generates negative values.

Functions like MD5 , SHA1, SHA2 all generates string function. There is xxhash64 which generates BIG INT not sure if it also generates negative numbers.

My questions is does any one know kind of hash function which will generate same hash like numeric number (positive) ones? If not we might end up using SHA1, or SHA2 function. I asked in Databricks American office hours the guy recommended posting in Community forum so trying here.