I have a field, called created_by in a bigquery table, with text like this:
created by
"{"name": "Charles Darwin", "email": "[email protected]"}"
The field is a "STRING" type field.
What I need is to extract the name and the email in two sepparated field.
How can I achieve this?
Thanks
2
Answers
You may consider and try below approach using BigQuery’s REGEX_EXTRACT function.
Sample Output:
My sample REGEX is the most basic one since I am not familiar with your complete data. You may enhance or create your own REGEX that can fit your needed validation based on your own analysis on your data.
see below, link to google docs here:
https://cloud.google.com/bigquery/docs/reference/standard-sql/json_functions#json_value
select json_value(json "{"name": "Charles Darwin", "email": "[email protected]"}", ‘$.email’) as getEmail
getemail
select json_value(json "{"name": "Charles Darwin", "email": "[email protected]"}", ‘$.name’) as getName
getName