Skip to content

Commit

Permalink
Test constraint rendering with column quoting (#713)
Browse files Browse the repository at this point in the history
(cherry picked from commit 580ad76)
  • Loading branch information
jtcohen6 authored and MichelleArk committed Jun 14, 2023
1 parent 8183b1a commit 4b0312d
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion tests/functional/adapter/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
BaseConstraintsRuntimeDdlEnforcement,
BaseConstraintsRollback,
BaseIncrementalConstraintsRuntimeDdlEnforcement,
BaseIncrementalConstraintsRollback, BaseModelConstraintsRuntimeEnforcement,
BaseIncrementalConstraintsRollback,
BaseModelConstraintsRuntimeEnforcement,
BaseConstraintQuotedColumn,
)
from dbt.tests.adapter.constraints.fixtures import (
my_model_sql,
Expand All @@ -18,8 +20,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,
model_fk_constraint_schema_yml,
my_model_wrong_order_depends_on_fk_sql,
foreign_key_model_sql,
Expand Down Expand Up @@ -213,3 +217,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 <model_identifier> (
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
);
"""

0 comments on commit 4b0312d

Please sign in to comment.