20 Apr 19 ·  nVector in bigquery ·        Bookmark ·  Report ·  More actions.. Lock comments ·  Pin thread

How to get array length / size of a nested field in big query

Consider the below table in big query, where I have a repeated nested field called author_names.AuN

How can I get the length of the repeated nested field author_names

e.g. for article_id = 2049807276, the length of the author names would be 2.

Solution:

You should use ARRAY_LENGTH() function

#standard SQL
SELECT article_id, ARRAY_LENGTH(author_names) len
FROM `table`

nVector

posted on 20 Apr 19

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds