Skip to content
Merged
Prev Previous commit
Next Next commit
Change date_day in test_constraints.py from a date to a string
  • Loading branch information
gshank committed Mar 15, 2023
commit bdd555fd3dcbfbff9019285ea07a5670bc140adc
24 changes: 12 additions & 12 deletions tests/adapter/dbt/tests/adapter/constraints/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
select
'blue' as color,
1 as id,
cast('2019-01-01' as date) as date_day
'2019-01-01' as date_day
"""

my_model_wrong_order_sql = """
Expand All @@ -21,7 +21,7 @@
select
'blue' as color,
1 as id,
cast('2019-01-01' as date) as date_day
'2019-01-01' as date_day
"""

my_model_wrong_name_sql = """
Expand All @@ -34,7 +34,7 @@
select
'blue' as color,
1 as error,
cast('2019-01-01' as date) as date_day
'2019-01-01' as date_day
"""

my_model_data_type_sql = """
Expand All @@ -60,7 +60,7 @@
cast(null as {{ dbt.type_int() }}) as id,
-- change the color as well (to test rollback)
'red' as color,
cast('2019-01-01' as date) as date_day
'2019-01-01' as date_day
"""

model_schema_yml = """
Expand All @@ -81,7 +81,7 @@
- name: color
data_type: text
- name: date_day
data_type: date
data_type: text
- name: my_model_error
config:
contract: true
Expand All @@ -96,7 +96,7 @@
- name: color
data_type: text
- name: date_day
data_type: date
data_type: text
- name: my_model_wrong_order
config:
contract: true
Expand All @@ -111,7 +111,7 @@
- name: color
data_type: text
- name: date_day
data_type: date
data_type: text
- name: my_model_wrong_name
config:
contract: true
Expand All @@ -126,7 +126,7 @@
- name: color
data_type: text
- name: date_day
data_type: date
data_type: text
"""

model_data_type_schema_yml = """
Expand All @@ -150,7 +150,7 @@
select
1 as id,
'blue' as color,
cast('2019-01-01' as date) as date_day
'2019-01-01' as date_day
"""

my_model_view_wrong_order_sql = """
Expand All @@ -163,7 +163,7 @@
select
'blue' as color,
1 as id,
cast('2019-01-01' as date) as date_day
'2019-01-01' as date_day
"""

my_model_view_wrong_name_sql = """
Expand All @@ -176,7 +176,7 @@
select
'blue' as color,
1 as error,
cast('2019-01-01' as date) as date_day
'2019-01-01' as date_day
"""

my_model_view_with_nulls_sql = """
Expand All @@ -191,5 +191,5 @@
cast(null as {{ dbt.type_int() }}) as id,
-- change the color as well (to test rollback)
'red' as color,
cast('2019-01-01' as date) as date_day
'2019-01-01' as date_day
"""
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def data_types(self, schema_int_type, int_type, string_type):
return [
["1", schema_int_type, int_type],
["'1'", string_type, string_type],
["cast('2019-01-01' as date)", "date", "DATE"],
["true", "bool", "BOOL"],
["'2013-11-03 00:00:00-07'::timestamptz", "timestamptz", "DATETIMETZ"],
["'2013-11-03 00:00:00-07'::timestamp", "timestamp", "DATETIME"],
Expand Down Expand Up @@ -89,10 +88,10 @@ def test__constraints_wrong_column_names(self, project, string_type, int_type):

expected_compile_error = "Please ensure the name, data_type, and number of columns in your `yml` file match the columns in your SQL file."
expected_schema_file_columns = (
f"Schema File Columns: id {int_type}, color {string_type}, date_day DATE"
f"Schema File Columns: id {int_type}, color {string_type}, date_day TEXT"
)
expected_sql_file_columns = (
f"SQL File Columns: color {string_type}, error {int_type}, date_day DATE"
f"SQL File Columns: color {string_type}, error {int_type}, date_day TEXT"
)

assert expected_compile_error in log_output
Expand Down Expand Up @@ -179,7 +178,7 @@ def test__constraints_correct_column_data_types(self, project, data_types):
create table {0} (
id integer not null primary key check (id > 0) ,
color text ,
date_day date
date_day text
) ;
insert into {0} (
id ,
Expand All @@ -196,7 +195,7 @@ def test__constraints_correct_column_data_types(self, project, data_types):
select
'blue' as color,
1 as id,
cast('2019-01-01' as date) as date_day
'2019-01-01' as date_day
) as model_subq
);
"""
Expand Down