20 April 2019 · n-pacha ·       Add to Favorites   Report

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`

n-pacha

posted on 20 April 2019

Read great educational content like this and a lot more !

Members get free exclusive access to content, new courses, and discounts. Signup for a free account to write a post / comment / upvote posts. Creating an account takes less than 5 seconds and you can start earning badges & points too

Copied