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:ย 

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. 

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now