Constraints in Delta tables
Delta tables support constraints to ensure data integrity and quality. When the constraint conditions are not met by the data then InvariantViolationException
is thrown, and data is not added to the table.
The following types of constraints are supported by the Delta table:
- CHECK: Evaluate a given Boolean expression for each input row.
- NOT NULL: Check that the column under constraint does not have a null value.
Getting ready
Before starting we need to ensure that we have a valid subscription with contributor access, a Databricks workspace, and an ADLS Gen2 storage account.
You can follow along by running the steps in the 6_6.Constraints
notebook in the https://github.com/PacktPublishing/Azure-Databricks-Cookbook/blob/main/Chapter06/6_6.Constraints.ipynb. Upload the file to Customer
folder in the rawdata
container in your ADLS Gen-2 account which is mounted.
CustomerwithNullCName.csv
file has 4 rows and one row has C_NAME
as...