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)

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

)

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

View solution in original post

Hello erigaud, 

Thanks for your answer, had the same issue.