Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contract Enforcement Error with PK #494

Open
jckardos opened this issue Mar 26, 2024 · 2 comments
Open

Contract Enforcement Error with PK #494

jckardos opened this issue Mar 26, 2024 · 2 comments

Comments

@jckardos
Copy link

models:

  • name: apprenticeship_history
    description: cust_apprenticeships
    config:
    unique_key: apprenticeship_history_hk
    contract:
    enforced: true
    constraints:
    • type: primary_key
      columns:
      • apprenticeship_history_hk
        name: pk_apprenticeship_history

generates the following error on build/run

'fabric__table_columns_and_constraints' is undefined

in macro create_table_as (macros\relations\table\create.sql)
called by macro default__get_create_table_as_sql (macros\relations\table\create.sql)
called by macro get_create_table_as_sql (macros\relations\table\create.sql)
called by macro statement (macros\etc\statement.sql)
called by macro materialization_table_fabric (macros\materializations\models\table\table.sql)
called by model apprenticeship_history (models\silver\success_factors\apprenticeship_history.sql)

@stephan-meier
Copy link

stephan-meier commented May 6, 2024

I get the same error message with every contract I try on Azure SQL DB, even with zero constraints.
dbt-core 1.7.12, dbt-sqlserver 1.7.4

@mmc00
Copy link

mmc00 commented May 8, 2024

Sorry previous pull request wasn't test it. It's related with the changes in fabric #500

ataft added a commit to flexanalytics/dbt-business-intelligence that referenced this issue Jun 17, 2024
Initial work on dbt constraints using contracts. Items to note:
* contracts do not appear to be enforced if model schema.yml is namespaced with dbt_business_intelligence
* main fix here is addition of fabric__table_columns_and_constraints macro, which is a redirect to get around this issue: dbt-msft/dbt-sqlserver#494
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants