skip to Main Content

I am trying to select domain name from an email address using Athena but my noob glasses cant find the translation that works.

As per my understanding the following should work but the required functions are missing in Athena

(SUBSTRING_INDEX(SUBSTR(sd_ccode, strpos(sd_ccode, '@') + 1),'.',1)) as Domain

would you know how these functions translate in Athena ?

2

Answers


  1. You can use the split_part function, as in:

    select emailaddress , split_part(emailaddress,'@',2)
    from table1
    
    Login or Signup to reply.
  2. One more method using regexp_extract function:

    regexp_extract(emailaddress ,'@(.*)',1)
    

    Regex '@(.*)' here is a capturing group after @ containing any number of characters

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search