Explain ARRAYs and STRUCTs in BigQuery and why nested, repeated fields are idiomatic and performant

Quick Overview

Asks what ARRAY and STRUCT types are in BigQuery and why storing one-to-many data as nested, repeated fields is a common design choice. Tests understanding of columnar storage, join and shuffle cost, querying nested data with UNNEST, and the trade-offs of denormalized schemas.

Explain ARRAYs and STRUCTs in BigQuery and why nested, repeated fields are idiomatic and performant

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Other

Explain `ARRAY`s and `STRUCT`s in BigQuery. Why is denormalizing data into nested and repeated fields often considered idiomatic and performant? ```hint Think about the storage format Consider how a columnar engine stores a field nested a few levels deep, and what a query that touches only one sub-field has to read. ``` ```hint Compare with the join Picture the same one-to-many data as two normalized tables, and work out what the engine has to move between workers to answer a question about each parent row. ``` ### What a Strong Answer Covers - What `ARRAY` and `STRUCT` are, and how an array of structs holds a one-to-many relationship inside one row - How nested data is queried (dot notation, `UNNEST`) and how flat tables are turned into nested ones - Why nesting cuts join and shuffle cost, and why columnar storage keeps unused nested fields cheap - When nesting is the wrong choice, including what it costs for updates ### Follow-up Questions - After a `CROSS JOIN UNNEST` over line items, how do you avoid double-counting an order-level column such as shipping cost? - What happens to orders with no line items when you flatten with `UNNEST`, and how do you keep them? - When would you keep a dimension such as a product catalog in its own table instead of nesting it?

Overview: Asks what ARRAY and STRUCT types are in BigQuery and why storing one-to-many data as nested, repeated fields is a common design choice. Tests understanding of columnar storage, join and shuffle cost, querying nested data with UNNEST, and the trade-offs of denormalized schemas.

General logo
General
Nov 25, 2026
mediumData ScientistOtherData Manipulation (SQL/Python)
0
0

Explain ARRAYs and STRUCTs in BigQuery. Why is denormalizing data into nested and repeated fields often considered idiomatic and performant?

What a Strong Answer Covers Guidance

  • What ARRAY and STRUCT are, and how an array of structs holds a one-to-many relationship inside one row
  • How nested data is queried (dot notation, UNNEST ) and how flat tables are turned into nested ones
  • Why nesting cuts join and shuffle cost, and why columnar storage keeps unused nested fields cheap
  • When nesting is the wrong choice, including what it costs for updates

Follow-up Questions Guidance

  • After a CROSS JOIN UNNEST over line items, how do you avoid double-counting an order-level column such as shipping cost?
  • What happens to orders with no line items when you flatten with UNNEST , and how do you keep them?
  • When would you keep a dimension such as a product catalog in its own table instead of nesting it?