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: 

Error Creating Primary Key Constraint

najmead
Contributor

I am trying to add a primary key constraint to an existing table, and I get the following error;

Cannot create or update table because the child column(s) `my_primary_key` of primary key `pk` cannot be set to nullable. Either drop the constraint, or change the column nullability.

This doesn't make sense to me... why would you want a primary key column to be nullable? In any event, I tried to alter the column to allow nulls and still got the same error.

I appreciate that primary keys and foreign keys in data bricks are informational only, but I want to be able to support downstream BI developers with this information if possible.

2 REPLIES 2

Debayan
Esteemed Contributor III
Esteemed Contributor III

Hi, Could you please confirm if you are using the latest databricks-sql-connector ? (https://pypi.org/project/databricks-sql-connector/)

I'm not using databricks-sql-connector. I ran the query from the query editor within databricks itself.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!