CertKeen

Databricks Data Engineer Associate · Free practice question 4 of 12

collect_set vs collect_list aggregation

For each customer, an analyst at Wicklow Grocers needs an array of the distinct store IDs where the customer shopped, with no repeated values. Which aggregate function should be used with GROUP BY customer_id?

  1. A.collect_set(store_id)
  2. B.collect_list(store_id)
  3. C.array(store_id)
  4. D.explode(store_id)
Show answer and explanation

Correct answer: A. collect_set(store_id)

Why: collect_set aggregates values into an array without duplicates. collect_list keeps every value, including repeats. array builds an array from its arguments within a single row, and explode turns array elements into rows instead of aggregating.

More free Databricks Data Engineer Associate questions