SELECT `justfunctions.eu.detect_department_email`("[email protected]")
/*--Output--
1
*/
CREATE OR REPLACE FUNCTION `your_project_id.your_dataset_id.detect_department_email`(`email` STRING)
RETURNS INT AS (((
WITH A AS (SELECT SPLIT(email,"@")[offset(0)] email_part)
SELECT
CASE
WHEN email_part IN (
'info', 'test', 'hello', 'hey', 'help',
'press', 'support', 'sales', 'dev', 'developers', 'marketing',
'admin', 'hq', 'finance', 'operations', 'home', 'headquarters',
'jobs', 'main', 'here', 'one', 'hr', 'tech', 'billing',
'accounts', 'partnerships', 'team', 'contact',
'feedback', 'legal', 'solutions', 'services', 'training',
'products', 'careers', 'service', 'management', 'events',
'subscriptions', 'media', 'research', 'security', 'investor',
'relations', 'customerservice', 'bookings', 'reservations',
'licensing', 'advertising', 'affiliates',
'design', 'editor', 'collaborations', 'solutions', 'analytics',
'client', 'membership', 'strategy', 'businessdev', 'feedback',
'office', 'customer', 'cs', 'outreach')
OR REGEXP_CONTAINS(email_part,'support')
THEN 1 ELSE 0 END is_department_email
FROM A
)))
OPTIONS ( description = '''Detects if an <email> belongs to a business department (e.g., sales, HR, support).''')
SQL User Defined Function (SQL UDF)
See something wrong? Contact us or report an issue on Github.