Question 1
A silver table defines the expectation EXPECT (quantity >= 0) ON VIOLATION DROP ROW. 1,000 rows arrive and 12 violate it. What is the result?
- 988 rows are written and 12 are counted as dropped — Correct
- 12 rows are written to a quarantine table automatically
- No rows are written and the update fails
- 1,000 rows are written with a warning
Correct answer
988 rows are written and 12 are counted as dropped
Explanation
DROP ROW removes violating rows and records them in the data quality metrics.
Question 2
A transformation adds an ingestion timestamp to each row. Which code is correct?
- df.withColumn('ingested_at', current_timestamp()) — Correct
- df.addColumn('ingested_at', current_timestamp())
- df.select('*', lit('current_timestamp').alias('ingested_at'))
- df.select('*', 'current_timestamp')
Correct answer
df.withColumn('ingested_at', current_timestamp())
Explanation
withColumn with current_timestamp() adds a column with the processing timestamp.
Question 3
A data engineer needs to cross join a 12-row months table with a 500-row stores table to build a calendar per store. How many rows will result?
- 12
- 6,000 — Correct
- 512
- 500
Correct answer
6,000
Explanation
A cross join returns every combination: 12 × 500 = 6,000 rows.
Question 4
A silver table must remove duplicate events that share the same event_id. Which PySpark code keeps one row per event_id?
- df.distinct('event_id').orderBy('event_id')
- df.drop('event_id').distinct()
- df.dropDuplicates(['event_id']) — Correct
- df.groupBy('event_id').count()
Correct answer
df.dropDuplicates(['event_id'])
Explanation
dropDuplicates with a subset of columns keeps one row per key. distinct() does not take column arguments, and groupBy().count() returns counts, not rows.
Question 5
An engineer needs average, minimum and maximum order value per country, in one pass. Which code is correct?
- df.select('country', avg('amount'), min('amount'), max('amount'))
- df.groupBy('country').avg('amount').min('amount').max('amount')
- df.groupBy('country').agg(avg('amount'), min('amount'), max('amount')) — Correct
- df.agg(groupBy('country'), avg('amount'), min('amount'), max('amount'))
Correct answer
df.groupBy('country').agg(avg('amount'), min('amount'), max('amount'))
Explanation
groupBy().agg() computes several aggregates at once. Chaining avg().min() fails because avg returns a DataFrame without the original column.
Question 6
A silver table stores customer records with a column email. An engineer must split full_name into first_name and last_name. Which PySpark code is correct?
- df.withColumnRenamed('full_name', 'first_name, last_name')
- df.withColumn('first_name', split('full_name', ' ')[0]).withColumn('last_name', split('full_name', ' ')[1]) — Correct
- df.select(split('full_name').alias('first_name', 'last_name'))
- df.withColumn('first_name', explode(split('full_name', ' '))).withColumn('last_name', explode(split('full_name', ' ')))
Correct answer
df.withColumn('first_name', split('full_name', ' ')[0]).withColumn('last_name', split('full_name', ' ')[1])
Explanation
split returns an array; indexing it gives the parts. explode works on arrays, not strings.
Question 7
Which statement about liquid clustering on Delta tables is correct?
- Liquid clustering is only available for external CSV tables
- Keys can change without a rewrite; OPTIMIZE clusters new data incrementally — Correct
- Liquid clustering requires the table to also be partitioned by the clustering columns
- Liquid clustering is configured with ZORDER BY in the table definition
Correct answer
Keys can change without a rewrite; OPTIMIZE clusters new data incrementally
Explanation
Liquid clustering replaces partitioning and Z-ordering. Keys can be changed with ALTER TABLE ... CLUSTER BY; clustering is applied incrementally by OPTIMIZE.
Question 8
A data engineer must define a gold streaming table in SQL that reads new rows from the silver table orders_silver. Which statement is correct?
- CREATE TABLE gold_orders STREAMING AS orders_silver
- CREATE MATERIALIZED STREAM gold_orders FROM orders_silver
- CREATE STREAMING VIEW gold_orders AS SELECT * FROM orders_silver
- CREATE OR REFRESH STREAMING TABLE gold_orders AS SELECT * FROM STREAM(orders_silver) — Correct
Correct answer
CREATE OR REFRESH STREAMING TABLE gold_orders AS SELECT * FROM STREAM(orders_silver)
Explanation
Streaming tables are created with CREATE OR REFRESH STREAMING TABLE and read incremental input with STREAM().
Question 9
In Lakeflow Declarative Pipelines, a silver table defines the expectation CONSTRAINT valid_amount EXPECT (amount > 0). What happens to rows with amount <= 0?
- They are dropped from the table and recorded in the metrics
- The pipeline update fails immediately
- They are moved to a quarantine table automatically
- They are kept, and the violation is counted in the metrics — Correct
Correct answer
They are kept, and the violation is counted in the metrics
Explanation
Without an ON VIOLATION clause, expectations only warn: invalid rows are kept and counted in data quality metrics. DROP ROW drops them; FAIL UPDATE stops the update.
Question 10
Which statement about expectations in Lakeflow Declarative Pipelines is correct?
- Expectations replace Unity Catalog permissions
- Expectations can only be defined in Python
- Their pass and fail counts are stored in the pipeline event log — Correct
- Expectations are evaluated only when users query the table
Correct answer
Their pass and fail counts are stored in the pipeline event log
Explanation
Expectation metrics are stored in the event log and shown in the pipeline UI, supporting monitoring of data quality over time.