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. 

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