cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.