cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

ParseException: mismatched input 'PRIMARY'

Hongbo
New Contributor III

I got parseException issue and I have no idea what cause the problem:

ParseException: mismatched input 'PRIMARY' expecting {')', ',', 'CONSTRAINT'}(line 2, pos 44)

== SQL ==

CREATE TABLE persons(first_name STRING NOT NULL, last_name STRING NOT NULL, nickname STRING, CONSTRAINT person_pk PRIMARY KEY (first_name, last_name)

--------------------------------------------^^^

)

1 ACCEPTED SOLUTION

Accepted Solutions

erigaud
Honored Contributor

You can only declare Primary and foreign keys on fields on Unity Catalog

You also need Databricks Runtime 11.1+

Otherwise only NOT NULL and CHECK constraints are supported.

More info : https://docs.databricks.com/tables/constraints.html

View solution in original post

3 REPLIES 3

Hongbo
New Contributor III

I think the issue is Only CHECK constraints are currently supported

erigaud
Honored Contributor

You can only declare Primary and foreign keys on fields on Unity Catalog

You also need Databricks Runtime 11.1+

Otherwise only NOT NULL and CHECK constraints are supported.

More info : https://docs.databricks.com/tables/constraints.html

Hello erigaud, 

Thanks for your answer, had the same issue. 

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.