Skip to content

Commit 6f19550

Browse files
committed
Migrate pieces into core + plugins
1 parent ab54d5d commit 6f19550

9 files changed

+19
-50
lines changed

dev-requirements.txt

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
pytest
22
pytest-dotenv
3-
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core
4-
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter
5-
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-postgres&subdirectory=plugins/postgres
6-
git+https://github.com/dbt-labs/dbt-redshift.git
7-
git+https://github.com/dbt-labs/dbt-snowflake.git
8-
git+https://github.com/dbt-labs/dbt-bigquery.git
3+
git+https://github.com/dbt-labs/dbt-core.git@jerco/data-type-macros#egg=dbt-core&subdirectory=core
4+
git+https://github.com/dbt-labs/dbt-core.git@jerco/data-type-macros#egg=dbt-tests-adapter&subdirectory=tests/adapter
5+
git+https://github.com/dbt-labs/dbt-bigquery.git@jerco/data-type-macros
96
pytest-xdist

macros/cross_db_utils/datatypes.sql

+3-35
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
{# These macros have been moved into dbt-core #}
2+
{# Here for backwards compatibility ONLY #}
3+
14
{# string ------------------------------------------------- #}
25

36
{%- macro type_string() -%}
@@ -8,10 +11,6 @@
811
{{ return(adapter.dispatch('type_string', 'dbt')()) }}
912
{% endmacro %}
1013

11-
-- This will return 'text' by default
12-
-- On Postgres + Snowflake, that's equivalent to varchar (no size)
13-
-- Redshift will treat that as varchar(256)
14-
1514

1615
{# timestamp ------------------------------------------------- #}
1716

@@ -23,34 +22,6 @@
2322
{{ return(adapter.dispatch('type_timestamp', 'dbt')()) }}
2423
{% endmacro %}
2524

26-
<<<<<<< HEAD
27-
=======
28-
/*
29-
POSTGRES
30-
https://www.postgresql.org/docs/current/datatype-datetime.html:
31-
The SQL standard requires that writing just `timestamp`
32-
be equivalent to `timestamp without time zone`, and
33-
PostgreSQL honors that behavior.
34-
`timestamptz` is accepted as an abbreviation for `timestamp with time zone`;
35-
this is a PostgreSQL extension.
36-
37-
SNOWFLAKE
38-
https://docs.snowflake.com/en/sql-reference/data-types-datetime.html#timestamp
39-
The TIMESTAMP_* variation associated with TIMESTAMP is specified by the
40-
TIMESTAMP_TYPE_MAPPING session parameter. The default is TIMESTAMP_NTZ.
41-
42-
BIGQUERY
43-
TIMESTAMP means 'timestamp with time zone'
44-
DATETIME means 'timestamp without time zone'
45-
TODO: shouldn't this return DATETIME instead of TIMESTAMP, for consistency with other databases?
46-
e.g. dateadd returns a DATETIME
47-
48-
/* Snowflake:
49-
https://docs.snowflake.com/en/sql-reference/data-types-datetime.html#timestamp
50-
The TIMESTAMP_* variation associated with TIMESTAMP is specified by the TIMESTAMP_TYPE_MAPPING session parameter. The default is TIMESTAMP_NTZ.
51-
*/
52-
53-
>>>>>>> caf0388 (Refactor tests, passing on BQ)
5425

5526
{# float ------------------------------------------------- #}
5627

@@ -94,6 +65,3 @@ The TIMESTAMP_* variation associated with TIMESTAMP is specified by the TIMESTAM
9465
{% macro default__type_int() %}
9566
{{ return(adapter.dispatch('type_int', 'dbt')()) }}
9667
{% endmacro %}
97-
98-
-- returns 'int' everywhere, except BigQuery, where it returns 'int64'
99-
-- (but BigQuery also now accepts 'int' as a valid alias for 'int64')

tests/functional/data_type/base_data_type.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import os
22
import pytest
33
from dbt.tests.util import run_dbt, check_relations_equal, get_relation_columns
4-
from dbt.tests.adapter.utils.base_utils import BaseUtils
4+
from dbt.tests.adapter.utils.data_types.base_data_type_macro import BaseDataTypeMacro
55

66
class BaseDbtUtilsBackCompat(BaseDataTypeMacro):
7+
# install this repo as a package
78
@pytest.fixture(scope="class")
89
def packages(self):
910
return {"packages": [{"local": os.getcwd()}]}
1011

11-
def assert_columns_equal(self, project, expected_cols, actual_cols):
12-
assert expected_cols == actual_cols, f"Type difference detected: {expected_cols} vs. {actual_cols}"
12+
# call the macros from the 'dbt_utils' namespace
13+
# instead of the unspecified / global namespace
14+
def macro_namespace(self):
15+
return "dbt_utils"
1316

17+
# actual test sequence needs to run 'deps' first
1418
def test_check_types_assert_match(self, project):
1519
run_dbt(['deps'])
1620
super().test_check_types_assert_match(project)

tests/functional/data_type/test_type_bigint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import pytest
3-
from tests.functional.data_type.base_data_type import BaseDbtUtilsLegacyDataTypeMacro
3+
from tests.functional.data_type.base_data_type import BaseDbtUtilsBackCompat, BaseLegacyDataTypeMacro
44
from dbt.tests.adapter.utils.data_types.test_type_bigint import BaseTypeBigInt
55

66

tests/functional/data_type/test_type_float.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import pytest
3-
from tests.functional.data_type.base_data_type import BaseDataTypeMacro, BaseLegacyDataTypeMacro
3+
from tests.functional.data_type.base_data_type import BaseDbtUtilsBackCompat, BaseLegacyDataTypeMacro
44
from dbt.tests.adapter.utils.data_types.test_type_float import BaseTypeFloat
55

66

tests/functional/data_type/test_type_int.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import pytest
3-
from tests.functional.data_type.base_data_type import BaseDataTypeMacro, BaseLegacyDataTypeMacro
3+
from tests.functional.data_type.base_data_type import BaseDbtUtilsBackCompat, BaseLegacyDataTypeMacro
44
from dbt.tests.adapter.utils.data_types.test_type_int import BaseTypeInt
55

66

tests/functional/data_type/test_type_numeric.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import pytest
3-
from tests.functional.data_type.base_data_type import BaseDataTypeMacro, BaseLegacyDataTypeMacro
3+
from tests.functional.data_type.base_data_type import BaseDbtUtilsBackCompat, BaseLegacyDataTypeMacro
44
from dbt.tests.adapter.utils.data_types.test_type_numeric import BaseTypeNumeric
55

66

tests/functional/data_type/test_type_string.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import pytest
3-
from tests.functional.data_type.base_data_type import BaseDataTypeMacro, BaseLegacyDataTypeMacro
3+
from tests.functional.data_type.base_data_type import BaseDbtUtilsBackCompat, BaseLegacyDataTypeMacro
44
from dbt.tests.adapter.utils.data_types.test_type_string import BaseTypeString
55

66

tests/functional/data_type/test_type_timestamp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import pytest
3-
from tests.functional.data_type.base_data_type import BaseDataTypeMacro, BaseLegacyDataTypeMacro
3+
from tests.functional.data_type.base_data_type import BaseDbtUtilsBackCompat, BaseLegacyDataTypeMacro
44
from dbt.tests.adapter.utils.data_types.test_type_timestamp import BaseTypeTimestamp
55

66

0 commit comments

Comments
 (0)