I am trying to find a method in SQL world (specifically Trino/Presto) where I can reproduce the following Input / Output combination.
Input - s (type String)
Output - o Int where o = hashCode(s)
E.g.
String x = "plaintext";
System.out.println(x.hashCode());
The above java code snippet prints 1973234167. I want a method in Presto/Trino that does the same thing
somemethod("plaintext") = 1973234167
What's the quickest way to reproduce this in Presto/Trino world?
My attempts:
- I have tried
xxhash64. But it doesn't return the same value. - I can write a
udf/functionin Java and call in Trino environment. But that's going to take a longer path given the production environment I am working on.
It was easier to write my own scaler function using Trino SPI.
I had to generate my jar and deploy it to all Trino instances via EMR bootstrap actions.