Snowflake-Labs / dbt_constraints

This package generates database constraints based on the tests in a dbt project
Apache License 2.0
143 stars 28 forks source link

Foreign Key constriants are not created in Snowflake database #58

Closed choudrybabu closed 1 year ago

choudrybabu commented 1 year ago

we have added a test dbt_constraints.foreign_key: in a model yml file under the concerned column , dbt is executing an alter statement but somehow it isnt working in snowflake here is the sql command i see executed by dbt core on snowflake db ALTER TABLE SUPPLY_TEAM ADD CONSTRAINT SUPPLY_TEAM_OFFICE_FK FOREIGN KEY ( OFFICE_ID ) REFERENCES OFFICE ( office_ID ) MATCH SIMPLE RELY the above sql runs without any errors but i dont see it created on table, i checked the DDL and also ran show imported keys on the child table , i dont see FK in db table

choudrybabu commented 1 year ago

i removed the MATCH SIMPLE RELY part of the above alter sql command and ran it manually in the db and it worked as expected

sfc-gh-dflippo commented 1 year ago

I'm going to address this conversation in this thread since the two issues are related:

53