databricks Data Engineer Professional · Practice questions

Section 3: Data Manipulation Practice Questions

Review 10 sample questions with their correct answers and explanations. Sign up free to continue with the full topic quiz.

Sign up free for the full quiz

Question 1

A gold metric requires a running total per customer. Which SQL is correct?

  1. SUM(amount) OVER (PARTITION BY customer_id ORDER BY order_ts ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) — Correct
  2. CUMULATIVE(amount, customer_id)
  3. SUM(amount) GROUP BY customer_id, order_ts
  4. SUM(amount) OVER (PARTITION BY order_ts ORDER BY customer_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)

Correct answer

SUM(amount) OVER (PARTITION BY customer_id ORDER BY order_ts ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)

Explanation

Window frames define running totals per partition.

Question 2

Which statement about schema evolution for Delta writes is correct?

  1. mergeSchema adds new columns; type changes need other mechanisms — Correct
  2. Schema evolution removes columns that are missing from the incoming DataFrame
  3. Schema evolution is enabled by default for every write and cannot be turned off
  4. mergeSchema changes existing column types automatically, for example from STRING to INT, on every append

Correct answer

mergeSchema adds new columns; type changes need other mechanisms

Explanation

mergeSchema adds columns; widening types uses type widening or explicit table changes.

Question 3

A MERGE with WHEN NOT MATCHED BY SOURCE THEN DELETE runs with a source containing only today's partition of data. What is the risk?

  1. Only duplicates are deleted
  2. Unscoped deletion of older target rows — Correct
  3. Nothing; the clause only applies to today's rows automatically
  4. The MERGE will fail

Correct answer

Unscoped deletion of older target rows

Explanation

Add a condition (for example AND tgt.date = current_date()) to limit deletions to the scope of the source.

Question 4

A JSON field arrives as an integer in some messages and as a string in others. Silver must store it as BIGINT without losing bad values. Which approach fits?

  1. Store the field as BINARY so that both representations fit in the same column
  2. try_cast to BIGINT and keep the raw value in a quarantine column — Correct
  3. CAST to BIGINT under ANSI mode, which converts every string to a number without raising errors
  4. Drop the field entirely, because mixed types cannot be stored in Delta tables in any form

Correct answer

try_cast to BIGINT and keep the raw value in a quarantine column

Explanation

try_cast avoids failures while preserving the original for investigation.

Question 5

Which statement about MERGE schema evolution is correct?

  1. With schema evolution on, new source columns are added — Correct
  2. MERGE cannot handle schema differences under any setting
  3. Schema evolution removes target columns not in the source
  4. MERGE always adds new columns automatically

Correct answer

With schema evolution on, new source columns are added

Explanation

Schema evolution in MERGE adds new columns; it does not drop existing ones.

Question 6

A downstream silver table must also delete rows when the bronze source deletes them for GDPR. Which approach handles this?

  1. skipChangeCommits
  2. A daily full refresh
  3. Rely on VACUUM in bronze, which also removes the matching rows from every downstream table automatically
  4. Read bronze's Change Data Feed and apply deletes with AUTO CDC or MERGE — Correct

Correct answer

Read bronze's Change Data Feed and apply deletes with AUTO CDC or MERGE

Explanation

Propagating deletes requires processing change records, not ignoring them.

Question 7

A pipeline must apply the same set of 12 expectations to several tables. What is the most maintainable approach?

  1. A shared rule dictionary with expect_all_or_drop — Correct
  2. Copy the 12 decorators to each table
  3. Apply the rules in a dashboard
  4. Use VACUUM

Correct answer

A shared rule dictionary with expect_all_or_drop

Explanation

expect_all variants accept a dictionary of rules, which can be loaded from shared configuration.

Question 8

Which Delta feature allows changing a column from INT to BIGINT without rewriting data files?

  1. Type widening — Correct
  2. Shallow clone, which copies the schema with a different column type
  3. Change Data Feed, which writes the new type into the change log only
  4. Deletion vectors, which store the new type alongside the deleted rows

Correct answer

Type widening

Explanation

Type widening supports certain type changes as metadata-only operations.

Question 9

Which command renames a column in a Delta table without rewriting data files?

  1. VACUUM t RENAME a
  2. CREATE OR REPLACE TABLE with the new name
  3. ALTER TABLE t CHANGE a b with overwriteSchema
  4. RENAME COLUMN with column mapping enabled — Correct

Correct answer

RENAME COLUMN with column mapping enabled

Explanation

Column mapping (name mode) allows renaming and dropping columns as metadata-only operations.

Question 10

A source system sends CDC records (insert, update, delete) with a sequence column seq. The target silver table must reflect only the latest state of each key, handling out-of-order arrival, in a Lakeflow declarative pipeline. Which approach is correct?

  1. Append all CDC records to silver and let consumers filter the latest version
  2. AUTO CDC with keys, SEQUENCE BY seq and APPLY AS DELETE WHEN op = 'DELETE' — Correct
  3. Use a streaming table with dropDuplicates on the key, which keeps the first record seen per key
  4. Use a materialized view that selects MAX(seq) per key from the CDC feed

Correct answer

AUTO CDC with keys, SEQUENCE BY seq and APPLY AS DELETE WHEN op = 'DELETE'

Explanation

AUTO CDC handles ordering with SEQUENCE BY, applies deletes, and manages late or out-of-order events. dropDuplicates keeps the first record, not the latest.

Ready for the full quiz?

Create a free QuizAnalyst account to practice the complete question set and save your progress.

Sign up free for the full quiz