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

Data type macros #214

Merged
merged 3 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## dbt-bigquery 1.2.0rc1 (Release TBD)

### Under the hood
- Modify `BigQueryColumn.numeric_type` to always exclude precision + scale, since the functionality of ["parametrized data types on BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#parameterized_data_types) is highly constrained ([#214](https://github.com/dbt-labs/dbt-bigquery/pull/214))

## dbt-bigquery 1.2.0b1 (June 24, 2022)

### Fixes
Expand Down
8 changes: 7 additions & 1 deletion dbt/adapters/bigquery/column.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Optional, List, TypeVar, Iterable, Type
from typing import Optional, List, TypeVar, Iterable, Type, Any

from dbt.adapters.base.column import Column

Expand Down Expand Up @@ -92,6 +92,12 @@ def data_type(self) -> str:
else:
return field_type

@classmethod
def numeric_type(cls, dtype: str, precision: Any, scale: Any) -> str:
# BigQuery makes life much harder if precision + scale are specified
# even if they're fed in here, just return the data type by itself
return dtype

def is_string(self) -> bool:
return self.dtype.lower() == "string"

Expand Down
34 changes: 34 additions & 0 deletions tests/functional/adapter/utils/test_data_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pytest
from dbt.tests.adapter.utils.data_types.test_type_bigint import BaseTypeBigInt
from dbt.tests.adapter.utils.data_types.test_type_float import BaseTypeFloat
from dbt.tests.adapter.utils.data_types.test_type_int import BaseTypeInt
from dbt.tests.adapter.utils.data_types.test_type_numeric import BaseTypeNumeric
from dbt.tests.adapter.utils.data_types.test_type_string import BaseTypeString
from dbt.tests.adapter.utils.data_types.test_type_timestamp import BaseTypeTimestamp


class TestTypeBigInt(BaseTypeBigInt):
pass


class TestTypeFloat(BaseTypeFloat):
pass


class TestTypeInt(BaseTypeInt):
pass


class TestTypeNumeric(BaseTypeNumeric):
def numeric_fixture_type(self):
return "numeric"


class TestTypeString(BaseTypeString):
pass


class TestTypeTimestamp(BaseTypeTimestamp):
pass