0

We use json_extract to extract fields for data in BigQuery I can easily filter by event_type, but how can I filter by title extracted from the JSON? for example: only titles that contain the word "facebook"

if I query by operation it works perfectly:

SELECT timestamp,
operation as event_type,
json_extract(data, '$.title') as title,
json_extract(data, '$.duration') as duration,
FROM `videos` 
WHERE (operation = "CREATE") ORDER BY timestamp ASC
user515766
  • 349
  • 2
  • 5
  • 7

1 Answers1

3

Dose this work?

SELECT timestamp,
operation as event_type,
json_extract(data, '$.title') as title,
json_extract(data, '$.duration') as duration,
FROM `videos` 
WHERE operation = "CREATE"
  and json_value(data, '$.title') like '%facebook%'
ORDER BY timestamp ASC
Sergey Geron
  • 9,098
  • 2
  • 22
  • 29