Skip to content

Instantly share code, notes, and snippets.

@coderfi
Created March 23, 2018 18:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderfi/93e1b8f6e7210504b6ea3381c5e1e902 to your computer and use it in GitHub Desktop.
Save coderfi/93e1b8f6e7210504b6ea3381c5e1e902 to your computer and use it in GitHub Desktop.
HIVE/SPARK SQL convert md5 to bigint
-- takes the leftmost 16 hex-characters of the md5 hash of foo, converts it to base-10, and casts it to a 64-bit number
-- Note: this decreases the possible space of hashes!
SELECT CAST(conv(substring(md5("foo"), 0, 16), 16, 10) AS BIGINT)");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment