Search code examples
sqlgoogle-bigquerydelimiter

How to split column by delimiter on Google BigQuery


I've a column of emails and I'd like to split it into two columns using @ as a delimiter.

Table:

enter image description here

Expected outcome

enter image description here


Solution

  • Try SPLIT with subsequent OFFSET:

    SELECT SPLIT(email, '@')[OFFSET(0)] as email1, SPLIT(email, '@')[OFFSET(1)] as email2
    FROM mytable