From 6c71f7c470e92596a965351cba4cb140bc679aca Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Tue, 7 Nov 2023 14:11:43 -0500 Subject: [PATCH] Support agate Integer type, test with empty seed (#1004) (cherry picked from commit 548d532052d356a6f4600b01ba2af5b132eb1560) --- .changes/unreleased/Fixes-20231107-100905.yaml | 6 ++++++ dbt/adapters/bigquery/impl.py | 4 ++++ tests/functional/adapter/test_simple_seed.py | 5 +++++ tests/unit/mock_adapter.py | 3 +++ 4 files changed, 18 insertions(+) create mode 100644 .changes/unreleased/Fixes-20231107-100905.yaml diff --git a/.changes/unreleased/Fixes-20231107-100905.yaml b/.changes/unreleased/Fixes-20231107-100905.yaml new file mode 100644 index 000000000..942298ed9 --- /dev/null +++ b/.changes/unreleased/Fixes-20231107-100905.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Support agate Integer type, test with empty seed +time: 2023-11-07T10:09:05.723451-05:00 +custom: + Author: gshank + Issue: "1003" diff --git a/dbt/adapters/bigquery/impl.py b/dbt/adapters/bigquery/impl.py index 3f8351861..e89d9e4e8 100644 --- a/dbt/adapters/bigquery/impl.py +++ b/dbt/adapters/bigquery/impl.py @@ -426,6 +426,10 @@ def convert_number_type(cls, agate_table: agate.Table, col_idx: int) -> str: decimals = agate_table.aggregate(agate.MaxPrecision(col_idx)) # type: ignore[attr-defined] return "float64" if decimals else "int64" + @classmethod + def convert_integer_type(cls, agate_table: agate.Table, col_idx: int) -> str: + return "int64" + @classmethod def convert_boolean_type(cls, agate_table: agate.Table, col_idx: int) -> str: return "bool" diff --git a/tests/functional/adapter/test_simple_seed.py b/tests/functional/adapter/test_simple_seed.py index c8b178467..b01f99346 100644 --- a/tests/functional/adapter/test_simple_seed.py +++ b/tests/functional/adapter/test_simple_seed.py @@ -2,6 +2,7 @@ from dbt.tests.adapter.simple_seed.fixtures import macros__schema_test from dbt.tests.adapter.simple_seed.seeds import seeds__enabled_in_config_csv, seeds__tricky_csv from dbt.tests.adapter.simple_seed.test_seed import SeedConfigBase +from dbt.tests.adapter.simple_seed.test_seed import BaseTestEmptySeed from dbt.tests.adapter.utils.base_utils import run_dbt @@ -151,3 +152,7 @@ def test__bigquery_seed_table_with_labels_config_bigquery(self, project): assert bq_table.labels assert bq_table.labels == self.table_labels() assert bq_table.expires + + +class TestBigQueryEmptySeed(BaseTestEmptySeed): + pass diff --git a/tests/unit/mock_adapter.py b/tests/unit/mock_adapter.py index d3bdf87b2..885854261 100644 --- a/tests/unit/mock_adapter.py +++ b/tests/unit/mock_adapter.py @@ -55,6 +55,9 @@ def convert_text_type(self, *args, **kwargs): def convert_number_type(self, *args, **kwargs): return self.responder.convert_number_type(*args, **kwargs) + def convert_integer_type(self, *args, **kwargs): + return self.responder.convert_integer_type(*args, **kwargs) + def convert_boolean_type(self, *args, **kwargs): return self.responder.convert_boolean_type(*args, **kwargs)