Skip to content

Instantly share code, notes, and snippets.

@jriquelme
Created April 23, 2020 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jriquelme/5d7e1a215ebf5fba41528ca6da06f68c to your computer and use it in GitHub Desktop.
Save jriquelme/5d7e1a215ebf5fba41528ca6da06f68c to your computer and use it in GitHub Desktop.
Redshift UDF in Python to get an UUID v5
-- Use:
-- select f_py_uuid5('30fb0513-dddf-4801-ac98-dacc8b7953e5', 'jorge@larix.cl');
-- > d6d2210e-b94c-5a26-95b7-ccf97f29ad1f
create or replace function f_py_uuid5(namespace varchar, name varchar)
returns varchar
immutable
as $$
import uuid
return uuid.uuid5(uuid.UUID(namespace), name).__str__()
$$ language plpythonu;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment