nerdexam
Snowflake

DEA-C02 · Question #134

A Data Engineer needs to share customer data using an API with a partner application. The API will accept the JSON payload using this structure: All information can be found in table, CUSTOMER. There

The correct answer is B. with customerSummary as ( select object_construct( 'email', email, 'address', object_construct( 'City', city_name, 'Street', street_name, 'House_no', house_no, 'ZIP', zip_code ) ) contacts, username from CUSTOMER ) select object_construct( 'username', username, 'contactDetails', array_agg(contacts) over (partition by username) ) as API_PAYLOAD from customerSummary;. Because a single customer can have multiple rows with different contact details, the payload's contactDetails field must be a JSON array. Option B correctly uses a CTE to first build individual contact objects (combining email and nested address object), then applies ARRAY_AGG as

Data Transformation

Question

A Data Engineer needs to share customer data using an API with a partner application. The API will accept the JSON payload using this structure:

All information can be found in table, CUSTOMER. There may be multiple rows for a single customer with different contact details. Which query will prepare the JSON payload in the required format? A. B. C. D.

Exhibits

DEA-C02 question #134 exhibit 1
DEA-C02 question #134 exhibit 2
DEA-C02 question #134 exhibit 3
DEA-C02 question #134 exhibit 4
DEA-C02 question #134 exhibit 5

Options

  • Aselect object_construct( 'username', username, 'contactDetails', object_construct( 'email', email, 'address', object_construct( 'City', city_name, 'Street', street_name, 'House_no', house_no, 'ZIP', zip_code ) ) ) ) as API_PAYLOAD from CUSTOMER;
  • Bwith customerSummary as ( select object_construct( 'email', email, 'address', object_construct( 'City', city_name, 'Street', street_name, 'House_no', house_no, 'ZIP', zip_code ) ) contacts, username from CUSTOMER ) select object_construct( 'username', username, 'contactDetails', array_agg(contacts) over (partition by username) ) as API_PAYLOAD from customerSummary;
  • Cselect array_agg(object_construct( 'email', email, 'address', object_construct( 'City', city_name, 'Street', street_name, 'House_no', house_no, 'ZIP', zip_code ) )) over (partition by username) as ContactDetails, username from CUSTOMER;

How the community answered

(20 responses)
  • A
    10% (2)
  • B
    70% (14)
  • C
    20% (4)

Explanation

Because a single customer can have multiple rows with different contact details, the payload's contactDetails field must be a JSON array. Option B correctly uses a CTE to first build individual contact objects (combining email and nested address object), then applies ARRAY_AGG as a window function partitioned by username to collect all contacts per customer into an array, and finally wraps everything in OBJECT_CONSTRUCT. Option A builds a single OBJECT_CONSTRUCT per row without aggregating across rows, so customers with multiple contacts would produce duplicate top-level objects instead of one object with an array. Option C returns an array of contacts and the username as separate columns rather than a single nested JSON payload object - it does not produce the required structure.

Topics

#JSON#SQL Functions#Data Transformation#API Data Preparation

Community Discussion

No community discussion yet for this question.

Full DEA-C02 Practice