<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/delta-lake-constraints-and-checks-w7twy2vtp" -->

---
title: Delta Lake Constraints and Checks | daily.dev
description: Delta Lake supports CHECK and NOT NULL constraints that prevent invalid data from being appended to tables, such as blocking negative ages or null values in...
canonical: https://daily.dev/posts/delta-lake-constraints-and-checks-w7twy2vtp
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Delta Lake Constraints and Checks | daily.dev
og:description: Delta Lake supports CHECK and NOT NULL constraints that prevent invalid data from being appended to tables, such as blocking negative ages or null values in...
og:url: https://daily.dev/posts/delta-lake-constraints-and-checks-w7twy2vtp
og:image: https://api.daily.dev/og/posts/W7TWY2vTp.png
og:image:alt: Delta Lake Constraints and Checks
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Delta Lake Constraints and Checks

**[Delta Lake Blog](https://daily.dev/sources/delta-lake)** · 5 min read · 0 upvotes · 0 comments

## Summary

Delta Lake supports CHECK and NOT NULL constraints that prevent invalid data from being appended to tables, such as blocking negative ages or null values in required columns. If any row in an append operation violates a constraint, the entire append is rejected thanks to ACID guarantees, ensuring all-or-nothing writes. The post also clarifies that the DataFrame nullable property is not equivalent to a NOT NULL constraint, since PySpark can silently reset nullable to True when reading CSVs with nulls. It also covers what happens when you try to add a constraint to a table that already contains data violating it: the operation errors out.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://delta.io/blog/2022-11-21-delta-lake-contraints-check>

## Questions this post answers

### Does adding a NOT NULL constraint in Delta Lake work the same as setting nullable=False on a PySpark DataFrame schema?

No, they provide different guarantees. PySpark can silently override a nullable=False setting back to True when reading a CSV file that actually contains null values, so the DataFrame nullable property is not enforced. Only Delta Lake's explicit NOT NULL constraint reliably prevents rows containing nulls from being appended to a table.

_daily.dev surfaces practical Delta Lake data-quality patterns for engineers choosing between schema flags and constraints._

### What happens if I append a batch of rows to a Delta table and only some of them violate a CHECK constraint?

None of the rows get appended. Delta Lake enforces ACID guarantees, so if even one row in the batch fails the constraint check, the entire append operation is rejected and the table remains unchanged; you must filter out the offending rows before retrying the append.

_engineers debugging failed Delta Lake writes can track constraint behavior details on daily.dev._

### Can I add a CHECK constraint to a Delta Lake table that already has existing data?

Yes, but the command fails with an error if any existing row violates the new constraint's boolean condition. Delta Lake validates all current rows against the constraint at the time it's added, so tables with pre-existing bad data (e.g., negative age values) must be cleaned before the constraint can be applied.

_daily.dev helps data engineers stay current on Delta Lake schema and constraint enforcement details._

## Similar posts on daily.dev

- [Delta Lake Explained: Boost Data Reliability in Cloud Storage](https://daily.dev/posts/delta-lake-explained-boost-data-reliability-in-cloud-storage-oechbmvm4) · databricks · 0 upvotes · 0 comments
- [Advancing the Open Lakehouse with Apache Spark, the Delta Kernel, and the new UC Delta APIs](https://daily.dev/posts/advancing-the-open-lakehouse-with-apache-spark-the-delta-kernel-and-the-new-uc-delta-apis-dbaazlwws) · Delta Lake Blog · 0 upvotes · 0 comments
- [Modernizing SQL ETL in Lakehouse with Declarative Patterns](https://daily.dev/posts/modernizing-sql-etl-in-lakehouse-with-declarative-patterns-2bcpe5rx0) · databricks · 1 upvotes · 0 comments

---

Tags: [#data-engineering](https://daily.dev/tags/data-engineering), [#apache-spark](https://daily.dev/tags/apache-spark), [#pyspark](https://daily.dev/tags/pyspark)

[View this post on daily.dev](https://daily.dev/posts/delta-lake-constraints-and-checks-w7twy2vtp)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Delta Lake Constraints and Checks","url":"https://daily.dev/posts/delta-lake-constraints-and-checks-w7twy2vtp","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/delta-lake-constraints-and-checks-w7twy2vtp"},"datePublished":"2026-08-16T08:53:40.803Z","dateModified":"2026-08-16T08:57:06.284Z","description":"Delta Lake supports CHECK and NOT NULL constraints that prevent invalid data from being appended to tables, such as blocking negative ages or null values in...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/caccb37d8d191fe03b4a905aa2a333e2?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/caccb37d8d191fe03b4a905aa2a333e2?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Delta Lake Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Delta Lake Blog","logo":"https://media.daily.dev/image/upload/s--7f2q9Asf--/f_auto,q_auto/v1786870393/logos/delta-lake?_a=BAMAMicg0","url":"https://daily.dev/sources/delta-lake"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/delta-lake-constraints-and-checks-w7twy2vtp","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"data-engineering,apache-spark,pyspark","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Delta Lake Blog","item":"https://daily.dev/sources/delta-lake"},{"@type":"ListItem","position":3,"name":"Delta Lake Constraints and Checks"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/delta-lake-constraints-and-checks-w7twy2vtp#faq","mainEntity":[{"@type":"Question","name":"Does adding a NOT NULL constraint in Delta Lake work the same as setting nullable=False on a PySpark DataFrame schema?","acceptedAnswer":{"@type":"Answer","text":"No, they provide different guarantees. PySpark can silently override a nullable=False setting back to True when reading a CSV file that actually contains null values, so the DataFrame nullable property is not enforced. Only Delta Lake's explicit NOT NULL constraint reliably prevents rows containing nulls from being appended to a table. daily.dev surfaces practical Delta Lake data-quality patterns for engineers choosing between schema flags and constraints."}},{"@type":"Question","name":"What happens if I append a batch of rows to a Delta table and only some of them violate a CHECK constraint?","acceptedAnswer":{"@type":"Answer","text":"None of the rows get appended. Delta Lake enforces ACID guarantees, so if even one row in the batch fails the constraint check, the entire append operation is rejected and the table remains unchanged; you must filter out the offending rows before retrying the append. engineers debugging failed Delta Lake writes can track constraint behavior details on daily.dev."}},{"@type":"Question","name":"Can I add a CHECK constraint to a Delta Lake table that already has existing data?","acceptedAnswer":{"@type":"Answer","text":"Yes, but the command fails with an error if any existing row violates the new constraint's boolean condition. Delta Lake validates all current rows against the constraint at the time it's added, so tables with pre-existing bad data (e.g., negative age values) must be cleaned before the constraint can be applied. daily.dev helps data engineers stay current on Delta Lake schema and constraint enforcement details."}}]}
```

