nay2Y
nay2Y

Reputation: 11

unnest() used, but still cannot access field text on a value with type ARRAY<STRUCT<text STRING, language STRING>>, big query

I'm using bigquery to search for patents that contain the word 'metal' in the title. My query: My query

Then I got the following error message: Error message

I checked the data structure for title_localized: The title_localized array

What I'm doing wrong?

Upvotes: 0

Views: 2680

Answers (1)

Juta
Juta

Reputation: 411

You can use UNNEST this way to query nested fields:

SELECT
  DISTINCT country_code
FROM
  `patents-public-data.patents.publications`,
  UNNEST(title_localized) AS t
WHERE
  t.text LIKE '%metal%'

Upvotes: 4

Related Questions