Skip to main content
πŸ“˜ Complete PDF

Databricks Certification Practice Test 02

Practice Test 02

Question 1 of 20
πŸ“‹ Multiple Choice
Question 21
A team ingests data from multiple upstream systems. One upstream team adds a new column 'discount_code' to their incoming files. Which Delta Lake capability allows the target Delta table to automatically adapt its schema upon write without failing the pipeline?
A. Partition Pruning
βœ“
B. Schema Evolution
C. Z-Ordering
D. Time Travel
Answer
βœ… B. Schema Evolution
Explanation

1. Direct Confirmation & Core Rule Schema Evolution allows Delta Lake tables to seamlessly incorporate new columns into the table schema during batch or streaming append operations.

2. Why This Answer Is Correct By default, Delta Lake enforces strict schema validation (Schema Enforcement) to prevent data corruption. However, when upstream sources introduce valid new attributes, setting the option `.option("mergeSchema", "true")` (or using `spark.databricks.delta.schema.autoMerge.enabled = true`) activates Schema Evolution. Delta Lake updates the metadata in the transaction log, allowing new fields to be stored while existing rows simply record null values for the new column.

3. Why Other Options Are Incorrect - **A. Partition Pruning**: An optimization technique where the query planner skips reading entire directory partitions based on query filters; it does not modify or adapt table schemas. - **C. Z-Ordering**: A clustering technique that co-locates related information in the same Parquet files to accelerate data skipping during queries. - **D. Time Travel**: The ability to query or restore historical versions of a table using transaction log commits.

4. Architectural & Execution Context When a write with `mergeSchema` executes, Delta Lake verifies that incoming data types are compatible with existing columns. If a column is new, Delta Lake appends a new schema version record to the `_delta_log` atomically. Readers will instantly see the new column without requiring table recreation.

5. Practical Code Example

# Appending new data with automatic schema evolution
(df_with_new_columns.write
  .format("delta")
  .mode("append")
  .option("mergeSchema", "true")
  .save("/mnt/lakehouse/silver_orders"))

6. Real-World Engineering Scenario An e-commerce partner API suddenly introduces a `loyalty_tier` field in their midnight JSON export. Without Schema Evolution, the ingestion pipeline would fail, triggering pager alerts. With `mergeSchema=true`, the pipeline completes successfully, populating `loyalty_tier` for all new rows while backfilling nulls for previous days.

7. Common Exam Trap & Misconception Schema Evolution can add new columns or loosen data types (e.g. Byte to Short to Integer), but it will never automatically rename existing columns or change incompatible types (e.g. String to Timestamp). Incompatible type changes still trigger an error.

8. Best Practice & Production Recommendation Enable Schema Evolution on Bronze ingestion pipelines using Auto Loader (`cloudFiles.schemaLocation`), but restrict Schema Evolution in Gold dimensional tables to prevent accidental schema drift from breaking downstream BI dashboards.

9. Key Concept to Remember Schema Enforcement blocks unexpected writes by default; Schema Evolution (`mergeSchema`) explicitly allows new columns to be added dynamically.

10. Related InsightfulSaga Tutorial πŸ‘‰ [Delta Lake – Foundation of Reliable Data Pipelines](/tutorials/databricks/delta-lake-core)

Answered: 0 / 20
Question Navigator (Test 02)0% Answered