nerdexam
Databricks

CERTIFIED-DATA-ENGINEER-PROFESSIONAL · Question #38

The downstream consumers of a Delta Lake table have been complaining about data quality issues impacting performance in their applications. Specifically, they have complained that invalid latitude…

The correct answer is C. The activity details table already contains records that violate the constraints; all existing data. Delta Lake enforces CHECK constraints not just on future writes, but also validates them against existing data in the table at the time the constraint is added. If any existing row in activity_details contains a latitude or longitude value outside the valid range, the ALTER…

Data Management and Quality

Question

The downstream consumers of a Delta Lake table have been complaining about data quality issues impacting performance in their applications. Specifically, they have complained that invalid latitude and longitude values in the activity_details table have been breaking their ability to use other geolocation processes. A junior engineer has written the following code to add CHECK constraints to the Delta Lake table:

A senior engineer has confirmed the above logic is correct and the valid ranges for latitude and longitude are provided, but the code fails when executed. Which statement explains the cause of this failure?

Options

  • ABecause another team uses this table to support a frequently running application, two-phase
  • BThe activity details table already exists; CHECK constraints can only be added during initial table
  • CThe activity details table already contains records that violate the constraints; all existing data
  • DThe activity details table already contains records; CHECK constraints can only be added prior to
  • EThe current table schema does not contain the field valid coordinates; schema evolution will need

How the community answered

(36 responses)
  • A
    3% (1)
  • B
    3% (1)
  • C
    83% (30)
  • D
    3% (1)
  • E
    8% (3)

Explanation

Delta Lake enforces CHECK constraints not just on future writes, but also validates them against existing data in the table at the time the constraint is added. If any existing row in activity_details contains a latitude or longitude value outside the valid range, the ALTER TABLE ADD CONSTRAINT command will fail immediately and the constraint will not be applied. This is a safety mechanism to ensure the constraint accurately reflects the actual state of the table. To resolve this, the team must first identify and either correct or remove the offending rows, then re-execute the ALTER TABLE statement. CHECK constraints are not restricted to table creation time (B, D are false), and the constraint does not require a new column (E is false).

Topics

#Delta Lake#CHECK Constraints#Data Quality#Table Alteration

Community Discussion

No community discussion yet for this question.

Full CERTIFIED-DATA-ENGINEER-PROFESSIONAL Practice