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

[CT-2606] [Bug] Contract enforcement checks do not sent SQL header #7714

Closed
2 tasks done
Tracked by #7372
elyobo opened this issue May 26, 2023 · 2 comments · Fixed by #7734 or dbt-labs/dbt-bigquery#750
Closed
2 tasks done
Tracked by #7372
Assignees
Labels
bug Something isn't working model_contracts

Comments

@elyobo
Copy link

elyobo commented May 26, 2023

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

Turning on the contract enforcement sends a where false limit 0 query that does not include the SQL header. This can cause failures, e.g. when the sql header is used to declare a variable or temporary function which is referenced in the model query.

Expected Behavior

The sql header should be sent.

Steps To Reproduce

With dbt 1.5 and dbt-bigquery 1.5.1

A simple model with contract enforcement enabled

version: 2
models:
  - name: demo
    contract:
      enforced: true
    columns:
      - name: demo_text
{% call set_sql_header(config) %}
DECLARE DEMO STRING DEFAULT 'hello world';
{% endcall %}

SELECT DEMO AS demo_text

results in a query being sent like this, which fails because the variable declared in the header does not exist

    select * from (
        

SELECT DEMO AS demo_text
    ) as __dbt_sbq
    where false
    limit 0

The model runs successfully without contract enforcement enabled.

Incidentally, the location of the failed SQL is not reported as with regular model / test failures, but the BQ adapter does drop in a link to the failed job in BQ's UI.

Relevant log output

No response

Environment

- OS: macOS Ventura
- Python: 3.9
- dbt: 1.5
- dbt-bigquery: 1.5.1

Which database adapter are you using with dbt?

bigquery

Additional Context

No response

@elyobo elyobo added bug Something isn't working triage labels May 26, 2023
@github-actions github-actions bot changed the title [Bug] Contract enforcement checks do not sent SQL header [CT-2606] [Bug] Contract enforcement checks do not sent SQL header May 26, 2023
@MichelleArk
Copy link
Contributor

Thank you for opening and providing a reproduction case @elyobo! I've added it to #7372 for tracking.

@elyobo
Copy link
Author

elyobo commented Jun 1, 2023

Thanks @MichelleArk!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working model_contracts
Projects
None yet
2 participants