You have a BigQuery table with nested repeated fields representing user actions. You need to compute a per-user “top action type” while retaining users with no actions. Which approach is most correct?

Answer

Use UNNEST with LEFT JOIN UNNEST (actions) and then aggregate; ensure COALESCE handles NULL top action.

Explanation

A LEFT JOIN with UNNEST preserves users even when actions is empty, allowing you to aggregate with null-safe logic. INNER JOIN/UNNEST would drop users lacking repeated records.

Last reviewed: October 2026

Reviewed by FirstInTest Editorial Team

Report an error
QuestionBack to list