cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How can I check that column on a delta table has a "NOT NULL" constraint or not?

Lon_Fortes
New Contributor III

Title pretty much says it all -

I'm trying to determine whether or not a column on my existing delta table was defined as NOT NULL or not. It does not show up in any of the metadata (describe detail, describe history, show tblproperties).

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions

Lon_Fortes
New Contributor III

I've found a solution, the following scala serves my needs:

val table = spark.table("<database>.<tablename>")

val schema = table.printSchema

View solution in original post

2 REPLIES 2

Lon_Fortes
New Contributor III

I've found a solution, the following scala serves my needs:

val table = spark.table("<database>.<tablename>")

val schema = table.printSchema

Matthew8
New Contributor II

walgreenslistens Wrote:

A UNIQUE constraint defines a set of columns that uniquely identify rows in a table only if all the key values are not NULL. If one or more key parts are NULL, duplicate keys are allowed.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group