From f44d704801bdeab19ad44c89ecc496b2d5241552 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Wed, 25 Oct 2023 17:05:08 -0400 Subject: [PATCH] move agate_helper into common --- core/dbt/adapters/base/impl.py | 2 +- core/dbt/adapters/sql/connections.py | 6 +++--- core/dbt/common/clients/__init__.py | 0 core/dbt/{ => common}/clients/agate_helper.py | 0 core/dbt/context/providers.py | 2 +- core/dbt/exceptions.py | 2 +- tests/{ => common}/unit/test_agate_helper.py | 2 +- tests/unit/test_postgres_adapter.py | 2 +- tests/unit/utils.py | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 core/dbt/common/clients/__init__.py rename core/dbt/{ => common}/clients/agate_helper.py (100%) rename tests/{ => common}/unit/test_agate_helper.py (99%) diff --git a/core/dbt/adapters/base/impl.py b/core/dbt/adapters/base/impl.py index 4f72248fafe..9f163210323 100644 --- a/core/dbt/adapters/base/impl.py +++ b/core/dbt/adapters/base/impl.py @@ -46,7 +46,7 @@ ) from dbt.adapters.protocol import AdapterConfig -from dbt.clients.agate_helper import ( +from dbt.common.clients.agate_helper import ( empty_table, get_column_value_uncased, merge_tables, diff --git a/core/dbt/adapters/sql/connections.py b/core/dbt/adapters/sql/connections.py index c3836c85dd2..de319e780ad 100644 --- a/core/dbt/adapters/sql/connections.py +++ b/core/dbt/adapters/sql/connections.py @@ -4,7 +4,7 @@ import agate -import dbt.clients.agate_helper +import dbt.common.clients.agate_helper import dbt.exceptions from dbt.adapters.base import BaseConnectionManager from dbt.adapters.contracts.connection import Connection, ConnectionState, AdapterResponse @@ -129,7 +129,7 @@ def get_result_from_cursor(cls, cursor: Any, limit: Optional[int]) -> agate.Tabl rows = cursor.fetchall() data = cls.process_results(column_names, rows) - return dbt.clients.agate_helper.table_from_data_flat(data, column_names) + return dbt.common.clients.agate_helper.table_from_data_flat(data, column_names) def execute( self, sql: str, auto_begin: bool = False, fetch: bool = False, limit: Optional[int] = None @@ -140,7 +140,7 @@ def execute( if fetch: table = self.get_result_from_cursor(cursor, limit) else: - table = dbt.clients.agate_helper.empty_table() + table = dbt.common.clients.agate_helper.empty_table() return response, table def add_begin_query(self): diff --git a/core/dbt/common/clients/__init__.py b/core/dbt/common/clients/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/core/dbt/clients/agate_helper.py b/core/dbt/common/clients/agate_helper.py similarity index 100% rename from core/dbt/clients/agate_helper.py rename to core/dbt/common/clients/agate_helper.py diff --git a/core/dbt/context/providers.py b/core/dbt/context/providers.py index b3e0f67e3df..075ca8b597b 100644 --- a/core/dbt/context/providers.py +++ b/core/dbt/context/providers.py @@ -16,7 +16,7 @@ from dbt.adapters.base.column import Column from dbt.adapters.factory import get_adapter, get_adapter_package_names, get_adapter_type_names -from dbt.clients import agate_helper +from dbt.common.clients import agate_helper from dbt.clients.jinja import get_rendered, MacroGenerator, MacroStack from dbt.config import RuntimeConfig, Project from dbt.constants import SECRET_ENV_PREFIX, DEFAULT_ENV_PLACEHOLDER diff --git a/core/dbt/exceptions.py b/core/dbt/exceptions.py index 335e601a4c8..9e841a0fad1 100644 --- a/core/dbt/exceptions.py +++ b/core/dbt/exceptions.py @@ -2245,7 +2245,7 @@ def __init__(self, yaml_columns, sql_columns): def get_mismatches(self) -> agate.Table: # avoid a circular import - from dbt.clients.agate_helper import table_from_data_flat + from dbt.common.clients.agate_helper import table_from_data_flat column_names = ["column_name", "definition_type", "contract_type", "mismatch_reason"] # list of mismatches diff --git a/tests/unit/test_agate_helper.py b/tests/common/unit/test_agate_helper.py similarity index 99% rename from tests/unit/test_agate_helper.py rename to tests/common/unit/test_agate_helper.py index 476c9514280..9e63aa47346 100644 --- a/tests/unit/test_agate_helper.py +++ b/tests/common/unit/test_agate_helper.py @@ -8,7 +8,7 @@ import os from shutil import rmtree from tempfile import mkdtemp -from dbt.clients import agate_helper +from dbt.common.clients import agate_helper SAMPLE_CSV_DATA = """a,b,c,d,e,f,g 1,n,test,3.2,20180806T11:33:29.320Z,True,NULL diff --git a/tests/unit/test_postgres_adapter.py b/tests/unit/test_postgres_adapter.py index 80b8d61b9b4..c80ae80d8a1 100644 --- a/tests/unit/test_postgres_adapter.py +++ b/tests/unit/test_postgres_adapter.py @@ -10,7 +10,7 @@ from dbt.adapters.postgres import Plugin as PostgresPlugin from dbt.contracts.files import FileHash from dbt.contracts.graph.manifest import ManifestStateCheck -from dbt.clients import agate_helper +from dbt.common.clients import agate_helper from dbt.exceptions import DbtValidationError, DbtConfigError from psycopg2 import extensions as psycopg2_extensions from psycopg2 import DatabaseError diff --git a/tests/unit/utils.py b/tests/unit/utils.py index f38c0f5cabe..c5ee1329293 100644 --- a/tests/unit/utils.py +++ b/tests/unit/utils.py @@ -253,7 +253,7 @@ def generate_name_macros(package): class TestAdapterConversions(TestCase): def _get_tester_for(self, column_type): - from dbt.clients import agate_helper + from dbt.common.clients import agate_helper if column_type is agate.TimeDelta: # dbt never makes this! return agate.TimeDelta()