My BigQuery table contains a String column:
WITH
food_thoughts AS (
SELECT 1 as id, 'I want a kebab' AS thought UNION ALL
SELECT 2, 'Pizza is delicious' UNION ALL
SELECT 3, 'All you can eat French fries!'
)
SELECT * FROM food_thoughts
| id | thought |
|---|---|
| 1 | I want a kebab |
| 2 | Pizza is delicious |
| 3 | All you can eat French fries! |
I want to isolate each word of each sentence into a dedicated cell and match it to the other columns. How can I achieve this using a BigQuery command?
The expected output is:
| id | word |
|---|---|
| 1 | I |
| 1 | want |
| 1 | a |
| 1 | kebab |
| 2 | Pizza |
| 2 | is |
| 2 | ... |
| 3 | fries! |
You can try the following BigQuery code:
splitfunctionunnestFROMoperator (documentation here) and an aliasSELECTstatement