-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract_email_domain.sql
22 lines (18 loc) · 1.03 KB
/
extract_email_domain.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{% macro extract_email_domain(email) -%}
{{ adapter.dispatch('extract_email_domain', 'census_utils') (email) }}
{%- endmacro %}
{% macro default__extract_email_domain(email) -%}
case when contains_substr(regexp_substr(lower(replace(rtrim({{ email }},'.'),' ','')), '@(.*)', 1, 1),'.') = true
then regexp_substr(lower(replace(rtrim({{ email }},'.'),' ','')), '@(.*)', 1, 1)
end
{%- endmacro %}
{%- macro snowflake__extract_email_domain(email) %}
case when contains(regexp_substr(lower(replace(rtrim({{ email }},'.'),' ','')), '@(.*)', 1, 1, 'e',1),'.') = true
then regexp_substr(lower(replace(rtrim({{ email }},'.'),' ','')), '@(.*)', 1, 1, 'e',1)
end
{%- endmacro -%}
{%- macro redshift__extract_email_domain(email) %}
case when regexp_instr(regexp_substr(lower(replace(rtrim({{ email }},'.'),' ','')), '@(.*)', 1, 1),'\\.') > 0
then regexp_substr(lower(replace(rtrim({{ email }},'.'),' ','')), '@(.*)', 1, 1, 'e')
end
{%- endmacro -%}