From 3d87870818c45b05d18598a2fe3f2db8d840c158 Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Thu, 11 May 2023 15:54:43 -0400 Subject: [PATCH 1/2] Test core 7537 --- dev-requirements.txt | 4 +-- tests/functional/adapter/test_constraints.py | 32 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 7d6994a6c..2bc887e5b 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ # install latest changes in dbt-core # TODO: how to automate switching from develop to version branches? -git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter +git+https://github.com/dbt-labs/dbt-core.git@jerco/7370-model-contracts-respect-quoting#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git@jerco/7370-model-contracts-respect-quoting#egg=dbt-tests-adapter&subdirectory=tests/adapter # if version 1.x or greater -> pin to major version # if version 0.x -> pin to minor diff --git a/tests/functional/adapter/test_constraints.py b/tests/functional/adapter/test_constraints.py index 6b6189092..667b9c204 100644 --- a/tests/functional/adapter/test_constraints.py +++ b/tests/functional/adapter/test_constraints.py @@ -8,6 +8,7 @@ BaseIncrementalConstraintsRuntimeDdlEnforcement, BaseIncrementalConstraintsRollback, BaseModelConstraintsRuntimeEnforcement, + BaseConstraintQuotedColumn, ) from dbt.tests.adapter.constraints.fixtures import ( my_model_sql, @@ -18,8 +19,10 @@ my_model_wrong_name_sql, my_model_view_wrong_name_sql, my_model_incremental_wrong_name_sql, + my_model_with_quoted_column_name_sql, model_schema_yml, constrained_model_schema_yml, + model_quoted_column_schema_yml, ) _expected_sql_bigquery = """ @@ -196,3 +199,32 @@ def expected_sql(self): ) as model_subq ); """ + + +class TestBigQueryConstraintQuotedColumn(BaseConstraintQuotedColumn): + @pytest.fixture(scope="class") + def models(self): + return { + "my_model.sql": my_model_with_quoted_column_name_sql, + "constraints_schema.yml": model_quoted_column_schema_yml.replace("text", "string"), + } + + @pytest.fixture(scope="class") + def expected_sql(self): + return """ +create or replace table ( + id integer not null, + `from` string not null, + date_day string +) +options() +as ( + select id, `from`, date_day + from ( + select + 'blue' as `from`, + 1 as id, + '2019-01-01' as date_day + ) as model_subq +); +""" From 476537819c7a2084d518cefb21ecbfedd8d39c4b Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Tue, 13 Jun 2023 15:41:39 -0400 Subject: [PATCH 2/2] revert dev-requirements.txt changes --- dev-requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index a7454fe62..0d914bd7e 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ # install latest changes in dbt-core # TODO: how to automate switching from develop to version branches? -git+https://github.com/dbt-labs/dbt-core.git@jerco/7370-model-contracts-respect-quoting#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt-core.git@jerco/7370-model-contracts-respect-quoting#egg=dbt-tests-adapter&subdirectory=tests/adapter +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter # if version 1.x or greater -> pin to major version # if version 0.x -> pin to minor