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

[ADAP-351] [BigQuery] Generate order-agnostic constraints ddl when contract: true #579

Closed
Tracked by #6747
MichelleArk opened this issue Mar 4, 2023 · 0 comments · Fixed by #606
Closed
Tracked by #6747
Assignees

Comments

@MichelleArk
Copy link
Contributor

Core issue: dbt-labs/dbt-core#7064

Wrap create_table_as user sql in schema-ordered select statement for models with contract: true

{% macro <adapter>__create_table_as(temporary, relation, sql) -%}
    ... 
    {% if config.get('contract', False) %}
      {{ get_assert_columns_equivalent(sql) }}
      {{ get_columns_spec_ddl() }}
      {%- set sql = get_select_subquery(sql) %}
    {% endif %}
  as (
    {{ sql }}
  );
{%- endmacro %}

BigQuery create_table_as: https://github.com/dbt-labs/dbt-bigquery/blob/main/dbt/include/bigquery/macros/adapters.sql#L57

We won't need to do this for view materializations as they don't support constraints.

@github-actions github-actions bot changed the title [BigQuery] Generate order-agnostic constraints ddl when contract: true [ADAP-351] [BigQuery] Generate order-agnostic constraints ddl when contract: true Mar 4, 2023
@MichelleArk MichelleArk assigned MichelleArk and gshank and unassigned MichelleArk Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants