Data Transformation and Modeling
Drill 20 practice questions focused entirely on Data Transformation and Modeling for the Databricks Databricks Data Engineer Associate exam. Tap an answer for instant feedback and a full explanation — no sign-up, always free.
A data engineer is joining a large fact table (billions of rows) with a small dimension table (about 20 MB) in a Spark SQL query. The job is running slowly because of heavy shuffling during the join. Which technique should the engineer use to eliminate the shuffle and improve performance?
A data engineer is building a Silver-layer transformation from a Bronze customer table. The column `preferred_contact` frequently contains NULL values, and the business rule states that when it is NULL, the pipeline should fall back to the value in `secondary_contact`, and if that is also NULL, use the literal string 'unknown'. Which Spark SQL expression correctly implements this rule in a single column definition?
A data engineer has a Silver table 'order_items' with one row per line item, containing columns 'order_id', 'product_name', and 'quantity'. For a reporting requirement, they must produce a Gold table with exactly one row per 'order_id' where a new column 'products' holds an array of all 'product_name' values for that order. Which Spark SQL approach produces the correct result?
A data engineer is building a Gold-layer table that reports the number of unique customers who placed at least one order on each calendar day. The Silver table `orders` has columns `order_date`, `customer_id`, and `order_amount`. Which Spark SQL query correctly produces one row per day with the count of distinct customers?
A data engineer runs `CREATE TABLE sales_summary AS SELECT region, SUM(amount) AS total FROM silver.orders GROUP BY region` in a Databricks SQL notebook without specifying a LOCATION. The catalog and schema are configured with default settings. Where will the underlying data files for sales_summary be stored, and what happens if the table is later dropped?
A data engineer needs to build a complete availability matrix for a Gold-layer report. Each of the 500 store locations must appear once for every date in a 365-row date dimension table, regardless of whether any sales occurred. Both tables share no common join key. Which Spark SQL join produces all 182,500 store-date combinations?
A data engineer is designing a Silver Delta table for e-commerce events. Queries almost always filter on the event date, but the source only provides an event_timestamp column of type TIMESTAMP. The engineer wants the table to be physically partitioned by date without requiring downstream writers to manually compute and populate a separate date column on every insert. Which approach best satisfies this requirement?
A data engineer runs a MERGE INTO command to upsert a batch of customer updates into a Delta target table. The source DataFrame contains multiple rows with the same customer_id (the merge key) because the daily extract captured several updates per customer. The MERGE fails with an error stating that a matched target row was matched by more than one source row. What is the correct approach to resolve this while keeping only the most recent update per customer?
A data engineer maintains a Silver customer table in Delta Lake. Each night a source extract arrives that contains both existing customers (already loaded) and brand-new customers. The business rule is strict: existing customer rows must NEVER be modified, but any customer not yet in the table must be inserted. Which MERGE statement correctly implements this requirement?
A data engineer is writing a MERGE statement to update a Delta table of customer accounts. Business rules require that when a matched record has a status of 'CLOSED' in the source, the target row should be deleted; for all other matched records, the target row should be updated with the new balance. Which MERGE clause construction correctly implements both behaviors?
A data engineer maintains a Silver dimension table `dim_customer` and receives a daily batch of updated customer records in a staging view `stg_customer`. Both tables share the key `customer_id`. The requirement is: update existing customers with new attribute values, and insert customers that do not yet exist. Which single Spark SQL statement correctly implements this upsert?
A data engineer maintains a Silver Delta table 'customers' that must be fully synchronized with a daily full snapshot loaded into a staging view 'stg_customers'. The requirement is: insert new customers, update changed customers, and delete customers that no longer exist in the daily snapshot. Which single MERGE statement clause correctly handles the deletion of records that are present in the target but absent from the source?
A data engineer maintains a Silver Delta table `customers` and receives a daily source batch `updates` containing both new and existing customer records, keyed by `customer_id`. The requirement is: when a `customer_id` already exists in the target, update its `email` and `status` columns; when a `customer_id` does not exist in the target, insert the full new row. Which single Spark SQL statement correctly implements this in one pass?
A data engineer is creating a Silver Delta table for web clickstream events. The table will hold billions of rows, and analysts almost always filter queries by event_date. A colleague suggests partitioning the table by user_id because most joins reference that column. What is the best partitioning strategy, and why?
A data engineer needs to add a column to a Spark DataFrame of sales transactions that shows, for each row, the total number of transactions made by that customer — while still keeping every individual transaction row in the output. Which approach produces the correct result without collapsing rows?
A data engineer is building a Silver-layer table from ingested event records. Each row has columns event_id, user_id, event_type, and ingest_timestamp. Duplicate events can arrive with the same event_id but slightly different ingest_timestamp values. The engineer wants to keep only one row per unique event_id, regardless of the timestamp. Which PySpark approach correctly deduplicates the DataFrame based on event_id alone?
A data engineer is transforming a bronze Delta table where each row represents an order with a column `items` containing an array of struct values (each struct has `product_id` and `qty`). The goal for the silver layer is to produce one row per individual item, keeping the parent `order_id`. Which PySpark transformation correctly flattens this structure?
A data engineer is reconciling two daily snapshots: a 'crm_customers' table and a 'billing_customers' table, both keyed on customer_id. The goal is to produce a single result that includes every customer_id present in either table, showing NULLs for columns from whichever side is missing so that mismatches can be flagged. Which join type should be used?
A data engineer is building a Silver table that combines an 'orders' DataFrame with a 'customers' DataFrame on customer_id. The business requirement is that every order must appear in the result, even if the order references a customer_id that does not exist in the customers table (so those customer columns should be null). Which join type should the engineer use?
A data engineer maintains two Delta tables: `active_customers` and `orders`. They need to produce a result set containing only the rows from `orders` whose `customer_id` does NOT exist in the `active_customers` table, so the marketing team can identify orphaned orders. Which single join operation produces exactly this result most efficiently?
More Databricks Data Engineer Associate practice
Keep going with the other Databricks Certified Data Engineer Associate domains, or take a full timed mock exam.
← Back to Databricks Data Engineer Associate overview