How to apply Primary Key constraint in Delta Live Table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2022 06:29 AM
In this blog I can see for dimension and fact tables, the primary key constraint has been applied. Following is the example:
-- Store dimension
CREATE OR REPLACE TABLE dim_store(
store_id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
business_key STRING,
name STRING,
email STRING,
city STRING,
address STRING,
phone_number STRING,
created_date TIMESTAMP,
updated_date TIMESTAMP,
start_at TIMESTAMP,
end_at TIMESTAMP
);
I want to apply the same for Delta Live Tables. Something like this:
CREATE OR REFRESH STREAMING LIVE TABLE dim_store(
store_id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
business_key STRING,
name STRING,
email STRING,
city STRING,
address STRING,
phone_number STRING,
created_date TIMESTAMP,
updated_date TIMESTAMP,
start_at TIMESTAMP,
end_at TIMESTAMP
);
However, when I run the Delta Live Pipeline. It is throwing following error:
Unsupported SQL statement for table 'dim_store': Missing query is not supported.
Can any one please help me and tell me how to apply Primary key constraint for Delta Live Table. I know Databricks does not support enforcement of the PK/FK relationship. However, I want the PK/FK constraints are for informational only.
Kindly help here.