Skip to content

Instantly share code, notes, and snippets.

@vithalsamp
Created February 25, 2018 16:32
Show Gist options
  • Select an option

  • Save vithalsamp/4bcd03e7fda4643e7bd0baf45d94380c to your computer and use it in GitHub Desktop.

Select an option

Save vithalsamp/4bcd03e7fda4643e7bd0baf45d94380c to your computer and use it in GitHub Desktop.
create or replace function udf_domain (email varchar(max))
returns varchar(max)
stable as $$
if not email:
return None
return email.split('@')[-1]
$$ language plpythonu;
--Call User defined function
training=# Select udf_domain ('user@dwgeek.com');
udf_domain
------------
dwgeek.com
(1 row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment