Courseiva

PDE Ingesting and Processing the Data Practice Question

You are building a BigQuery table that contains nested and repeated fields (e.g., order with line items). You need to write a query that counts the number of line items per order. Which TWO SQL functions/techniques can you use?

⚠ Common exam trap

Google often tests the distinction between functions that operate on arrays directly (like ARRAY_LENGTH) versus those that require row-level expansion (like UNNEST), and candidates may mistakenly choose window functions or STRUCT-based aggregation that do not directly count array elements.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

UNNEST with COUNT

UNNEST flattens the repeated line items array into individual rows, allowing COUNT to aggregate the number of line items per order. Option D is correct because ARRAY_LENGTH directly returns the number of elements in the repeated field array, which corresponds to the line item count.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Window function ROW_NUMBER

    Why it's wrong here

    ROW_NUMBER assigns a sequential position within a window partition; it numbers rows rather than counting repeated elements, so it cannot produce a per-order line-item total. It is tempting because it operates over partitions, and it would be correct for ranking or deduplicating rows, not aggregating array length.

  • ✓

    UNNEST with COUNT

    Why this is correct

    UNNEST flattens the repeated line_items array into individual rows, letting COUNT aggregate them per order. This directly satisfies the stem's requirement to count line items within nested, repeated fields, since COUNT alone cannot traverse array elements without first unnesting them into a queryable row set.

  • ✗

    STRUCT with aggregation

    Why it's wrong here

    STRUCT merely groups fields into a record; it holds no counting semantics and cannot tally repeated line items per order. It is tempting because STRUCT defines the nested schema itself, and it would be the right choice when constructing or reshaping nested records, not when aggregating their element counts.

  • ✓

    ARRAY_LENGTH

    Why this is correct

    ARRAY_LENGTH returns the number of elements in an array, so applying it to the repeated line_items field yields the line item count per order directly. This satisfies the nested and repeated field requirement, since repeated fields are represented as arrays in BigQuery's standard SQL.

  • ✗

    SELECT * EXCEPT

    Why it's wrong here

    SELECT * EXCEPT projects columns while excluding named ones; it performs no aggregation and cannot count repeated line items. It is tempting because it handles wide nested schemas conveniently, and it would be correct when trimming unwanted top-level columns from output, not when computing per-order line-item totals.

About these practice questions

One of 747 original PDE practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PDE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PDE exam.