Skip to content
Advertisement

Spliting Name in Google BigQuery

Split FullName into firstName and lastName.

I want to split the full name based on “,” into firstName and LastName. anything before “,” should be selected as firstName and anything “,” should be the lastName. I used split(fullName) function and used offset to grab the firstName and the lastName but ran into an error when there were 2 “,” in the fullName. I used this code :

IS THERE A BETTER WAY TO DO IT? HOW DO I RESOLVE THE DOUBLE “,” ISSUE? if i use OFFSET(2) I get an OffBound error.

Advertisement

Answer

Below is for BigQuery Standard SQL

You can test, play with above using dummy data as in below example

with output

In case if comma is missing at all – you can use below

with result

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement