diff --git a/dbt/adapters/databricks/__init__.py b/dbt/adapters/databricks/__init__.py index 76392f7f4..2f6161ab3 100644 --- a/dbt/adapters/databricks/__init__.py +++ b/dbt/adapters/databricks/__init__.py @@ -1,9 +1,6 @@ from dbt.adapters.base import AdapterPlugin -from dbt.adapters.databricks.column import DatabricksColumn # noqa -from dbt.adapters.databricks.connections import DatabricksConnectionManager # noqa from dbt.adapters.databricks.credentials import DatabricksCredentials from dbt.adapters.databricks.impl import DatabricksAdapter -from dbt.adapters.databricks.relation import DatabricksRelation # noqa from dbt.include import databricks Plugin = AdapterPlugin( diff --git a/dbt/adapters/databricks/api_client.py b/dbt/adapters/databricks/api_client.py index a821ac9ef..c2dbefb1d 100644 --- a/dbt/adapters/databricks/api_client.py +++ b/dbt/adapters/databricks/api_client.py @@ -1,24 +1,21 @@ import base64 -from collections.abc import Callable +import re import time -from abc import ABC -from abc import abstractmethod +from abc import ABC, abstractmethod +from collections.abc import Callable from dataclasses import dataclass -import re -from typing import Any -from typing import Optional +from typing import Any, Optional + +from dbt_common.exceptions import DbtRuntimeError +from requests import Response, Session +from requests.adapters import HTTPAdapter +from urllib3.util.retry import Retry from dbt.adapters.databricks import utils from dbt.adapters.databricks.__version__ import version from dbt.adapters.databricks.auth import BearerAuth from dbt.adapters.databricks.credentials import DatabricksCredentials from dbt.adapters.databricks.logging import logger -from dbt_common.exceptions import DbtRuntimeError -from requests import Response -from requests import Session -from requests.adapters import HTTPAdapter -from urllib3.util.retry import Retry - DEFAULT_POLLING_INTERVAL = 10 SUBMISSION_LANGUAGE = "python" diff --git a/dbt/adapters/databricks/auth.py b/dbt/adapters/databricks/auth.py index 8662f794d..439fa23fd 100644 --- a/dbt/adapters/databricks/auth.py +++ b/dbt/adapters/databricks/auth.py @@ -1,16 +1,11 @@ -from typing import Any -from typing import Optional - -from databricks.sdk.core import Config -from databricks.sdk.core import credentials_provider -from databricks.sdk.core import CredentialsProvider -from databricks.sdk.core import HeaderFactory -from databricks.sdk.oauth import ClientCredentials -from databricks.sdk.oauth import Token -from databricks.sdk.oauth import TokenSource +from typing import Any, Optional + from requests import PreparedRequest from requests.auth import AuthBase +from databricks.sdk.core import Config, CredentialsProvider, HeaderFactory, credentials_provider +from databricks.sdk.oauth import ClientCredentials, Token, TokenSource + class token_auth(CredentialsProvider): _token: str diff --git a/dbt/adapters/databricks/behaviors/columns.py b/dbt/adapters/databricks/behaviors/columns.py index 91f6c351a..63d80d2d9 100644 --- a/dbt/adapters/databricks/behaviors/columns.py +++ b/dbt/adapters/databricks/behaviors/columns.py @@ -1,9 +1,11 @@ from abc import ABC, abstractmethod -from dbt.adapters.sql import SQLAdapter + +from dbt_common.utils.dict import AttrDict + from dbt.adapters.databricks.column import DatabricksColumn from dbt.adapters.databricks.relation import DatabricksRelation from dbt.adapters.databricks.utils import handle_missing_objects -from dbt_common.utils.dict import AttrDict +from dbt.adapters.sql import SQLAdapter GET_COLUMNS_COMMENTS_MACRO_NAME = "get_columns_comments" diff --git a/dbt/adapters/databricks/column.py b/dbt/adapters/databricks/column.py index f9511201c..4d08ad4d9 100644 --- a/dbt/adapters/databricks/column.py +++ b/dbt/adapters/databricks/column.py @@ -1,6 +1,5 @@ from dataclasses import dataclass -from typing import ClassVar -from typing import Optional +from typing import ClassVar, Optional from dbt.adapters.spark.column import SparkColumn diff --git a/dbt/adapters/databricks/connections.py b/dbt/adapters/databricks/connections.py index 76da3e941..49b1ba82b 100644 --- a/dbt/adapters/databricks/connections.py +++ b/dbt/adapters/databricks/connections.py @@ -1,4 +1,3 @@ -from collections.abc import Callable, Iterator, Sequence import decimal import os import re @@ -6,74 +5,76 @@ import time import uuid import warnings +from collections.abc import Callable, Iterator, Sequence from contextlib import contextmanager from dataclasses import dataclass from multiprocessing.context import SpawnContext from numbers import Number from threading import get_ident -from typing import Any -from typing import cast -from typing import Hashable -from typing import Optional -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Any, Hashable, Optional, cast + +from dbt_common.events.contextvars import get_node_info +from dbt_common.events.functions import fire_event +from dbt_common.exceptions import DbtDatabaseError, DbtInternalError, DbtRuntimeError +from dbt_common.utils import cast_to_str +from requests import Session import databricks.sql as dbsql from databricks.sql.client import Connection as DatabricksSQLConnection from databricks.sql.client import Cursor as DatabricksSQLCursor from databricks.sql.exc import Error from dbt.adapters.base.query_headers import MacroQueryStringSetter -from dbt.adapters.contracts.connection import AdapterRequiredConfig -from dbt.adapters.contracts.connection import AdapterResponse -from dbt.adapters.contracts.connection import Connection -from dbt.adapters.contracts.connection import ConnectionState -from dbt.adapters.contracts.connection import DEFAULT_QUERY_COMMENT -from dbt.adapters.contracts.connection import Identifier -from dbt.adapters.contracts.connection import LazyHandle +from dbt.adapters.contracts.connection import ( + DEFAULT_QUERY_COMMENT, + AdapterRequiredConfig, + AdapterResponse, + Connection, + ConnectionState, + Identifier, + LazyHandle, +) from dbt.adapters.databricks.__version__ import version as __version__ from dbt.adapters.databricks.api_client import DatabricksApiClient from dbt.adapters.databricks.auth import BearerAuth -from dbt.adapters.databricks.credentials import DatabricksCredentials -from dbt.adapters.databricks.credentials import TCredentialProvider -from dbt.adapters.databricks.events.connection_events import ConnectionAcquire -from dbt.adapters.databricks.events.connection_events import ConnectionCancel -from dbt.adapters.databricks.events.connection_events import ConnectionCancelError -from dbt.adapters.databricks.events.connection_events import ConnectionClose -from dbt.adapters.databricks.events.connection_events import ConnectionCloseError -from dbt.adapters.databricks.events.connection_events import ConnectionCreate -from dbt.adapters.databricks.events.connection_events import ConnectionCreated -from dbt.adapters.databricks.events.connection_events import ConnectionCreateError -from dbt.adapters.databricks.events.connection_events import ConnectionIdleCheck -from dbt.adapters.databricks.events.connection_events import ConnectionIdleClose -from dbt.adapters.databricks.events.connection_events import ConnectionRelease -from dbt.adapters.databricks.events.connection_events import ConnectionReset -from dbt.adapters.databricks.events.connection_events import ConnectionRetrieve -from dbt.adapters.databricks.events.connection_events import ConnectionReuse -from dbt.adapters.databricks.events.cursor_events import CursorCancel -from dbt.adapters.databricks.events.cursor_events import CursorCancelError -from dbt.adapters.databricks.events.cursor_events import CursorClose -from dbt.adapters.databricks.events.cursor_events import CursorCloseError -from dbt.adapters.databricks.events.cursor_events import CursorCreate +from dbt.adapters.databricks.credentials import DatabricksCredentials, TCredentialProvider +from dbt.adapters.databricks.events.connection_events import ( + ConnectionAcquire, + ConnectionCancel, + ConnectionCancelError, + ConnectionClose, + ConnectionCloseError, + ConnectionCreate, + ConnectionCreated, + ConnectionCreateError, + ConnectionIdleCheck, + ConnectionIdleClose, + ConnectionRelease, + ConnectionReset, + ConnectionRetrieve, + ConnectionReuse, +) +from dbt.adapters.databricks.events.cursor_events import ( + CursorCancel, + CursorCancelError, + CursorClose, + CursorCloseError, + CursorCreate, +) from dbt.adapters.databricks.events.other_events import QueryError -from dbt.adapters.databricks.events.pipeline_events import PipelineRefresh -from dbt.adapters.databricks.events.pipeline_events import PipelineRefreshError +from dbt.adapters.databricks.events.pipeline_events import PipelineRefresh, PipelineRefreshError from dbt.adapters.databricks.logging import logger from dbt.adapters.databricks.python_models.run_tracking import PythonRunTracker from dbt.adapters.databricks.utils import redact_credentials -from dbt.adapters.events.types import ConnectionClosedInCleanup -from dbt.adapters.events.types import ConnectionLeftOpenInCleanup -from dbt.adapters.events.types import ConnectionReused -from dbt.adapters.events.types import ConnectionUsed -from dbt.adapters.events.types import NewConnection -from dbt.adapters.events.types import SQLQuery -from dbt.adapters.events.types import SQLQueryStatus +from dbt.adapters.events.types import ( + ConnectionClosedInCleanup, + ConnectionLeftOpenInCleanup, + ConnectionReused, + ConnectionUsed, + NewConnection, + SQLQuery, + SQLQueryStatus, +) from dbt.adapters.spark.connections import SparkConnectionManager -from dbt_common.events.contextvars import get_node_info -from dbt_common.events.functions import fire_event -from dbt_common.exceptions import DbtDatabaseError -from dbt_common.exceptions import DbtInternalError -from dbt_common.exceptions import DbtRuntimeError -from dbt_common.utils import cast_to_str -from requests import Session if TYPE_CHECKING: from agate import Table diff --git a/dbt/adapters/databricks/credentials.py b/dbt/adapters/databricks/credentials.py index 8f1a1d89a..0f729a5b1 100644 --- a/dbt/adapters/databricks/credentials.py +++ b/dbt/adapters/databricks/credentials.py @@ -1,28 +1,25 @@ -from collections.abc import Iterable import itertools import json import os import re import threading +from collections.abc import Iterable from dataclasses import dataclass -from typing import Any -from typing import cast -from typing import Optional -from typing import Union +from typing import Any, Optional, Union, cast import keyring +from dbt_common.exceptions import DbtConfigError, DbtValidationError + from databricks.sdk.core import CredentialsProvider -from databricks.sdk.oauth import OAuthClient -from databricks.sdk.oauth import SessionCredentials +from databricks.sdk.oauth import OAuthClient, SessionCredentials from dbt.adapters.contracts.connection import Credentials -from dbt.adapters.databricks.auth import m2m_auth -from dbt.adapters.databricks.auth import token_auth -from dbt.adapters.databricks.events.credential_events import CredentialLoadError -from dbt.adapters.databricks.events.credential_events import CredentialSaveError -from dbt.adapters.databricks.events.credential_events import CredentialShardEvent +from dbt.adapters.databricks.auth import m2m_auth, token_auth +from dbt.adapters.databricks.events.credential_events import ( + CredentialLoadError, + CredentialSaveError, + CredentialShardEvent, +) from dbt.adapters.databricks.logging import logger -from dbt_common.exceptions import DbtConfigError -from dbt_common.exceptions import DbtValidationError CATALOG_KEY_IN_SESSION_PROPERTIES = "databricks.catalog" DBT_DATABRICKS_INVOCATION_ENV = "DBT_DATABRICKS_INVOCATION_ENV" diff --git a/dbt/adapters/databricks/events/connection_events.py b/dbt/adapters/databricks/events/connection_events.py index f2b099940..9f8ec8c1b 100644 --- a/dbt/adapters/databricks/events/connection_events.py +++ b/dbt/adapters/databricks/events/connection_events.py @@ -1,8 +1,8 @@ from abc import ABC -from typing import Any -from typing import Optional +from typing import Any, Optional from databricks.sql.client import Connection + from dbt.adapters.databricks.events.base import SQLErrorEvent diff --git a/dbt/adapters/databricks/events/cursor_events.py b/dbt/adapters/databricks/events/cursor_events.py index 4f87c2dbf..d94a002a2 100644 --- a/dbt/adapters/databricks/events/cursor_events.py +++ b/dbt/adapters/databricks/events/cursor_events.py @@ -2,6 +2,7 @@ from uuid import UUID from databricks.sql.client import Cursor + from dbt.adapters.databricks.events.base import SQLErrorEvent diff --git a/dbt/adapters/databricks/impl.py b/dbt/adapters/databricks/impl.py index e5b0ca481..ce7edae4f 100644 --- a/dbt/adapters/databricks/impl.py +++ b/dbt/adapters/databricks/impl.py @@ -1,62 +1,58 @@ -from collections.abc import Iterable, Iterator -from multiprocessing.context import SpawnContext import os import re -from abc import ABC -from abc import abstractmethod +from abc import ABC, abstractmethod from collections import defaultdict +from collections.abc import Iterable, Iterator from concurrent.futures import Future from contextlib import contextmanager from dataclasses import dataclass -from typing import Any -from typing import cast -from typing import ClassVar -from typing import Generic -from typing import Optional -from typing import TYPE_CHECKING -from typing import Union +from importlib import metadata +from multiprocessing.context import SpawnContext +from typing import TYPE_CHECKING, Any, ClassVar, Generic, Optional, Union, cast from uuid import uuid4 -from dbt.adapters.base import AdapterConfig -from dbt.adapters.base import PythonJobHelper -from dbt.adapters.base.impl import catch_as_completed -from dbt.adapters.base.impl import log_code_execution +from dbt_common.behavior_flags import BehaviorFlag +from dbt_common.contracts.config.base import BaseConfig +from dbt_common.exceptions import CompilationError, DbtConfigError, DbtInternalError +from dbt_common.utils import executor +from dbt_common.utils.dict import AttrDict +from packaging import version + +from dbt.adapters.base import AdapterConfig, PythonJobHelper +from dbt.adapters.base.impl import catch_as_completed, log_code_execution from dbt.adapters.base.meta import available from dbt.adapters.base.relation import BaseRelation -from dbt.adapters.capability import Capability -from dbt.adapters.capability import CapabilityDict -from dbt.adapters.capability import CapabilitySupport -from dbt.adapters.capability import Support -from dbt.adapters.contracts.connection import AdapterResponse -from dbt.adapters.contracts.connection import Connection -from dbt.adapters.contracts.relation import RelationConfig -from dbt.adapters.contracts.relation import RelationType +from dbt.adapters.capability import Capability, CapabilityDict, CapabilitySupport, Support +from dbt.adapters.contracts.connection import AdapterResponse, Connection +from dbt.adapters.contracts.relation import RelationConfig, RelationType from dbt.adapters.databricks.behaviors.columns import ( GetColumnsBehavior, GetColumnsByDescribe, GetColumnsByInformationSchema, ) from dbt.adapters.databricks.column import DatabricksColumn -from dbt.adapters.databricks.connections import DatabricksConnectionManager -from dbt.adapters.databricks.connections import DatabricksDBTConnection -from dbt.adapters.databricks.connections import DatabricksSQLConnectionWrapper -from dbt.adapters.databricks.connections import ExtendedSessionConnectionManager -from dbt.adapters.databricks.connections import USE_LONG_SESSIONS -from dbt.adapters.databricks.python_models.python_submissions import ( - AllPurposeClusterPythonJobHelper, +from dbt.adapters.databricks.connections import ( + USE_LONG_SESSIONS, + DatabricksConnectionManager, + DatabricksDBTConnection, + DatabricksSQLConnectionWrapper, + ExtendedSessionConnectionManager, ) -from dbt.adapters.databricks.python_models.python_submissions import JobClusterPythonJobHelper from dbt.adapters.databricks.python_models.python_submissions import ( + AllPurposeClusterPythonJobHelper, + JobClusterPythonJobHelper, ServerlessClusterPythonJobHelper, -) -from dbt.adapters.databricks.python_models.python_submissions import ( WorkflowPythonJobHelper, ) -from dbt.adapters.databricks.relation import DatabricksRelation -from dbt.adapters.databricks.relation import DatabricksRelationType -from dbt.adapters.databricks.relation import KEY_TABLE_PROVIDER -from dbt.adapters.databricks.relation_configs.base import DatabricksRelationConfig -from dbt.adapters.databricks.relation_configs.base import DatabricksRelationConfigBase +from dbt.adapters.databricks.relation import ( + KEY_TABLE_PROVIDER, + DatabricksRelation, + DatabricksRelationType, +) +from dbt.adapters.databricks.relation_configs.base import ( + DatabricksRelationConfig, + DatabricksRelationConfigBase, +) from dbt.adapters.databricks.relation_configs.incremental import IncrementalTableConfig from dbt.adapters.databricks.relation_configs.materialized_view import ( MaterializedViewConfig, @@ -66,29 +62,19 @@ ) from dbt.adapters.databricks.relation_configs.table_format import TableFormat from dbt.adapters.databricks.relation_configs.tblproperties import TblPropertiesConfig -from dbt.adapters.databricks.utils import get_first_row, handle_missing_objects -from dbt.adapters.databricks.utils import redact_credentials +from dbt.adapters.databricks.utils import get_first_row, handle_missing_objects, redact_credentials from dbt.adapters.relation_configs import RelationResults -from dbt.adapters.spark.impl import DESCRIBE_TABLE_EXTENDED_MACRO_NAME -from dbt.adapters.spark.impl import GET_COLUMNS_IN_RELATION_RAW_MACRO_NAME -from dbt.adapters.spark.impl import KEY_TABLE_OWNER -from dbt.adapters.spark.impl import KEY_TABLE_STATISTICS -from dbt.adapters.spark.impl import LIST_SCHEMAS_MACRO_NAME -from dbt.adapters.spark.impl import SparkAdapter -from dbt_common.behavior_flags import BehaviorFlag -from dbt_common.utils import executor -from dbt_common.utils.dict import AttrDict -from dbt_common.exceptions import CompilationError -from dbt_common.exceptions import DbtConfigError -from dbt_common.exceptions import DbtInternalError -from dbt_common.contracts.config.base import BaseConfig - -from importlib import metadata -from packaging import version +from dbt.adapters.spark.impl import ( + DESCRIBE_TABLE_EXTENDED_MACRO_NAME, + GET_COLUMNS_IN_RELATION_RAW_MACRO_NAME, + KEY_TABLE_OWNER, + KEY_TABLE_STATISTICS, + LIST_SCHEMAS_MACRO_NAME, + SparkAdapter, +) if TYPE_CHECKING: - from agate import Row - from agate import Table + from agate import Row, Table dbt_version = metadata.version("dbt-core") SUPPORT_MICROBATCH = version.parse(dbt_version) >= version.parse("1.9.0b1") diff --git a/dbt/adapters/databricks/python_models/python_config.py b/dbt/adapters/databricks/python_models/python_config.py index 08d06d425..29aa44efa 100644 --- a/dbt/adapters/databricks/python_models/python_config.py +++ b/dbt/adapters/databricks/python_models/python_config.py @@ -1,8 +1,7 @@ -from typing import Any -from typing import Optional import uuid -from pydantic import BaseModel, Field +from typing import Any, Optional +from pydantic import BaseModel, Field DEFAULT_TIMEOUT = 60 * 60 * 24 diff --git a/dbt/adapters/databricks/python_models/python_submissions.py b/dbt/adapters/databricks/python_models/python_submissions.py index 426b9a777..27e4303ce 100644 --- a/dbt/adapters/databricks/python_models/python_submissions.py +++ b/dbt/adapters/databricks/python_models/python_submissions.py @@ -1,17 +1,15 @@ from abc import ABC, abstractmethod -from typing import Any -from typing import Optional +from typing import Any, Optional + from attr import dataclass +from dbt_common.exceptions import DbtRuntimeError from typing_extensions import override from dbt.adapters.base import PythonJobHelper -from dbt.adapters.databricks.api_client import CommandExecution, WorkflowJobApi -from dbt.adapters.databricks.api_client import DatabricksApiClient +from dbt.adapters.databricks.api_client import CommandExecution, DatabricksApiClient, WorkflowJobApi from dbt.adapters.databricks.credentials import DatabricksCredentials from dbt.adapters.databricks.python_models.python_config import ParsedPythonModel from dbt.adapters.databricks.python_models.run_tracking import PythonRunTracker -from dbt_common.exceptions import DbtRuntimeError - DEFAULT_TIMEOUT = 60 * 60 * 24 diff --git a/dbt/adapters/databricks/python_models/run_tracking.py b/dbt/adapters/databricks/python_models/run_tracking.py index e8f95a522..e48dae7d4 100644 --- a/dbt/adapters/databricks/python_models/run_tracking.py +++ b/dbt/adapters/databricks/python_models/run_tracking.py @@ -1,10 +1,10 @@ import threading -from dbt.adapters.databricks.api_client import CommandExecution -from dbt.adapters.databricks.api_client import DatabricksApiClient -from dbt.adapters.databricks.logging import logger from dbt_common.exceptions import DbtRuntimeError +from dbt.adapters.databricks.api_client import CommandExecution, DatabricksApiClient +from dbt.adapters.databricks.logging import logger + class PythonRunTracker(object): _run_ids: set[str] = set() diff --git a/dbt/adapters/databricks/relation.py b/dbt/adapters/databricks/relation.py index efb36a01d..bc1dc991f 100644 --- a/dbt/adapters/databricks/relation.py +++ b/dbt/adapters/databricks/relation.py @@ -1,22 +1,18 @@ from collections.abc import Iterable -from dataclasses import dataclass -from dataclasses import field -from typing import Any, Type -from typing import Optional - -from dbt.adapters.base.relation import BaseRelation -from dbt.adapters.base.relation import InformationSchema -from dbt.adapters.base.relation import Policy +from dataclasses import dataclass, field +from typing import Any, Optional, Type + +from dbt_common.dataclass_schema import StrEnum +from dbt_common.exceptions import DbtRuntimeError +from dbt_common.utils import filter_null_values + +from dbt.adapters.base.relation import BaseRelation, InformationSchema, Policy from dbt.adapters.contracts.relation import ( ComponentName, ) from dbt.adapters.databricks.utils import remove_undefined -from dbt.adapters.spark.impl import KEY_TABLE_OWNER -from dbt.adapters.spark.impl import KEY_TABLE_STATISTICS +from dbt.adapters.spark.impl import KEY_TABLE_OWNER, KEY_TABLE_STATISTICS from dbt.adapters.utils import classproperty -from dbt_common.dataclass_schema import StrEnum -from dbt_common.exceptions import DbtRuntimeError -from dbt_common.utils import filter_null_values KEY_TABLE_PROVIDER = "Provider" diff --git a/dbt/adapters/databricks/relation_configs/base.py b/dbt/adapters/databricks/relation_configs/base.py index 9366226c3..53e5bdb8d 100644 --- a/dbt/adapters/databricks/relation_configs/base.py +++ b/dbt/adapters/databricks/relation_configs/base.py @@ -1,13 +1,7 @@ -from abc import ABC -from abc import abstractmethod -from typing import Any -from typing import ClassVar -from typing import Generic -from typing import Optional -from typing import TypeVar - -from pydantic import BaseModel -from pydantic import ConfigDict +from abc import ABC, abstractmethod +from typing import Any, ClassVar, Generic, Optional, TypeVar + +from pydantic import BaseModel, ConfigDict from typing_extensions import Self from dbt.adapters.contracts.relation import RelationConfig diff --git a/dbt/adapters/databricks/relation_configs/comment.py b/dbt/adapters/databricks/relation_configs/comment.py index 0af362d1a..3dfa07bc1 100644 --- a/dbt/adapters/databricks/relation_configs/comment.py +++ b/dbt/adapters/databricks/relation_configs/comment.py @@ -1,9 +1,10 @@ -from typing import ClassVar -from typing import Optional +from typing import ClassVar, Optional from dbt.adapters.contracts.relation import RelationConfig -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentConfig -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentProcessor +from dbt.adapters.databricks.relation_configs.base import ( + DatabricksComponentConfig, + DatabricksComponentProcessor, +) from dbt.adapters.relation_configs.config_base import RelationResults diff --git a/dbt/adapters/databricks/relation_configs/incremental.py b/dbt/adapters/databricks/relation_configs/incremental.py index f31baf581..156f5bdf7 100644 --- a/dbt/adapters/databricks/relation_configs/incremental.py +++ b/dbt/adapters/databricks/relation_configs/incremental.py @@ -1,8 +1,10 @@ from typing import Optional -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentConfig -from dbt.adapters.databricks.relation_configs.base import DatabricksRelationChangeSet -from dbt.adapters.databricks.relation_configs.base import DatabricksRelationConfigBase +from dbt.adapters.databricks.relation_configs.base import ( + DatabricksComponentConfig, + DatabricksRelationChangeSet, + DatabricksRelationConfigBase, +) from dbt.adapters.databricks.relation_configs.tags import TagsProcessor from dbt.adapters.databricks.relation_configs.tblproperties import TblPropertiesProcessor diff --git a/dbt/adapters/databricks/relation_configs/materialized_view.py b/dbt/adapters/databricks/relation_configs/materialized_view.py index 9a57edd9f..e6a8a47e8 100644 --- a/dbt/adapters/databricks/relation_configs/materialized_view.py +++ b/dbt/adapters/databricks/relation_configs/materialized_view.py @@ -1,8 +1,10 @@ from typing import Optional -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentConfig -from dbt.adapters.databricks.relation_configs.base import DatabricksRelationChangeSet -from dbt.adapters.databricks.relation_configs.base import DatabricksRelationConfigBase +from dbt.adapters.databricks.relation_configs.base import ( + DatabricksComponentConfig, + DatabricksRelationChangeSet, + DatabricksRelationConfigBase, +) from dbt.adapters.databricks.relation_configs.comment import ( CommentProcessor, ) diff --git a/dbt/adapters/databricks/relation_configs/partitioning.py b/dbt/adapters/databricks/relation_configs/partitioning.py index 89120b8ac..bba4b5720 100644 --- a/dbt/adapters/databricks/relation_configs/partitioning.py +++ b/dbt/adapters/databricks/relation_configs/partitioning.py @@ -1,11 +1,12 @@ import itertools -from typing import ClassVar -from typing import Union +from typing import ClassVar, Union from dbt.adapters.contracts.relation import RelationConfig from dbt.adapters.databricks.relation_configs import base -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentConfig -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentProcessor +from dbt.adapters.databricks.relation_configs.base import ( + DatabricksComponentConfig, + DatabricksComponentProcessor, +) from dbt.adapters.relation_configs.config_base import RelationResults diff --git a/dbt/adapters/databricks/relation_configs/query.py b/dbt/adapters/databricks/relation_configs/query.py index 469a117c6..e9b8f73b3 100644 --- a/dbt/adapters/databricks/relation_configs/query.py +++ b/dbt/adapters/databricks/relation_configs/query.py @@ -3,8 +3,10 @@ from dbt_common.exceptions import DbtRuntimeError from dbt.adapters.contracts.relation import RelationConfig -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentConfig -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentProcessor +from dbt.adapters.databricks.relation_configs.base import ( + DatabricksComponentConfig, + DatabricksComponentProcessor, +) from dbt.adapters.relation_configs.config_base import RelationResults diff --git a/dbt/adapters/databricks/relation_configs/refresh.py b/dbt/adapters/databricks/relation_configs/refresh.py index dcb2119f1..bfea49e16 100644 --- a/dbt/adapters/databricks/relation_configs/refresh.py +++ b/dbt/adapters/databricks/relation_configs/refresh.py @@ -1,13 +1,15 @@ import re -from typing import ClassVar -from typing import Optional +from typing import ClassVar, Optional + +from dbt_common.exceptions import DbtRuntimeError from dbt.adapters.contracts.relation import RelationConfig from dbt.adapters.databricks.relation_configs import base -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentConfig -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentProcessor +from dbt.adapters.databricks.relation_configs.base import ( + DatabricksComponentConfig, + DatabricksComponentProcessor, +) from dbt.adapters.relation_configs.config_base import RelationResults -from dbt_common.exceptions import DbtRuntimeError SCHEDULE_REGEX = re.compile(r"CRON '(.*)' AT TIME ZONE '(.*)'") diff --git a/dbt/adapters/databricks/relation_configs/streaming_table.py b/dbt/adapters/databricks/relation_configs/streaming_table.py index d891da13d..f07ed3669 100644 --- a/dbt/adapters/databricks/relation_configs/streaming_table.py +++ b/dbt/adapters/databricks/relation_configs/streaming_table.py @@ -1,16 +1,17 @@ from typing import Optional -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentConfig -from dbt.adapters.databricks.relation_configs.base import DatabricksRelationChangeSet -from dbt.adapters.databricks.relation_configs.base import DatabricksRelationConfigBase +from dbt.adapters.databricks.relation_configs.base import ( + DatabricksComponentConfig, + DatabricksRelationChangeSet, + DatabricksRelationConfigBase, +) from dbt.adapters.databricks.relation_configs.comment import ( CommentProcessor, ) from dbt.adapters.databricks.relation_configs.partitioning import ( PartitionedByProcessor, ) -from dbt.adapters.databricks.relation_configs.refresh import RefreshConfig -from dbt.adapters.databricks.relation_configs.refresh import RefreshProcessor +from dbt.adapters.databricks.relation_configs.refresh import RefreshConfig, RefreshProcessor from dbt.adapters.databricks.relation_configs.tblproperties import ( TblPropertiesProcessor, ) diff --git a/dbt/adapters/databricks/relation_configs/tags.py b/dbt/adapters/databricks/relation_configs/tags.py index a739abe19..461fa77b2 100644 --- a/dbt/adapters/databricks/relation_configs/tags.py +++ b/dbt/adapters/databricks/relation_configs/tags.py @@ -1,12 +1,14 @@ -from typing import ClassVar -from typing import Optional +from typing import ClassVar, Optional + +from dbt_common.exceptions import DbtRuntimeError from dbt.adapters.contracts.relation import RelationConfig from dbt.adapters.databricks.relation_configs import base -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentConfig -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentProcessor +from dbt.adapters.databricks.relation_configs.base import ( + DatabricksComponentConfig, + DatabricksComponentProcessor, +) from dbt.adapters.relation_configs.config_base import RelationResults -from dbt_common.exceptions import DbtRuntimeError class TagsConfig(DatabricksComponentConfig): diff --git a/dbt/adapters/databricks/relation_configs/tblproperties.py b/dbt/adapters/databricks/relation_configs/tblproperties.py index dad00e537..41d18f3fd 100644 --- a/dbt/adapters/databricks/relation_configs/tblproperties.py +++ b/dbt/adapters/databricks/relation_configs/tblproperties.py @@ -1,13 +1,14 @@ -from typing import Any -from typing import ClassVar -from typing import Optional +from typing import Any, ClassVar, Optional + +from dbt_common.exceptions import DbtRuntimeError from dbt.adapters.contracts.relation import RelationConfig from dbt.adapters.databricks.relation_configs import base -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentConfig -from dbt.adapters.databricks.relation_configs.base import DatabricksComponentProcessor +from dbt.adapters.databricks.relation_configs.base import ( + DatabricksComponentConfig, + DatabricksComponentProcessor, +) from dbt.adapters.relation_configs.config_base import RelationResults -from dbt_common.exceptions import DbtRuntimeError class TblPropertiesConfig(DatabricksComponentConfig): diff --git a/dbt/adapters/databricks/utils.py b/dbt/adapters/databricks/utils.py index a48356afc..616e5b368 100644 --- a/dbt/adapters/databricks/utils.py +++ b/dbt/adapters/databricks/utils.py @@ -1,17 +1,15 @@ -from collections.abc import Callable import re -from typing import Any -from typing import TYPE_CHECKING -from typing import TypeVar +from collections.abc import Callable +from typing import TYPE_CHECKING, Any, TypeVar -from dbt.adapters.base import BaseAdapter -from dbt.adapters.spark.impl import TABLE_OR_VIEW_NOT_FOUND_MESSAGES from dbt_common.exceptions import DbtRuntimeError from jinja2 import Undefined +from dbt.adapters.base import BaseAdapter +from dbt.adapters.spark.impl import TABLE_OR_VIEW_NOT_FOUND_MESSAGES + if TYPE_CHECKING: - from agate import Row - from agate import Table + from agate import Row, Table A = TypeVar("A", bound=BaseAdapter) diff --git a/dbt/include/databricks/macros/adapters/catalog.sql b/dbt/include/databricks/macros/adapters/catalog.sql index 9062beb54..171951589 100644 --- a/dbt/include/databricks/macros/adapters/catalog.sql +++ b/dbt/include/databricks/macros/adapters/catalog.sql @@ -12,7 +12,7 @@ {{ databricks__get_catalog_results_sql() }} {%- endset -%} - {{ return(run_query(query)) }} + {{ return(run_query(query)) }} {%- endmacro %} {% macro databricks__get_catalog_relations(information_schema, relations) -%} @@ -29,7 +29,7 @@ {{ databricks__get_catalog_results_sql() }} {%- endset -%} - {{ return(run_query(query)) }} + {{ return(run_query(query)) }} {%- endmacro %} {% macro databricks__get_catalog_tables_sql(information_schema) -%} diff --git a/dev-requirements.txt b/dev-requirements.txt index d72231626..9a1a59119 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,5 +1,4 @@ ruff - freezegun~=1.5.0 ipdb mock>=1.3.0 diff --git a/ruff.toml b/ruff.toml index a544fb732..3bfb09472 100644 --- a/ruff.toml +++ b/ruff.toml @@ -2,5 +2,5 @@ line-length = 100 target-version = 'py39' [lint] -select = ["E", "W", "F"] +select = ["E", "W", "F", "I"] ignore = ["E203"] diff --git a/tests/conftest.py b/tests/conftest.py index b8a0e0775..c2ef51e78 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,7 +2,6 @@ from tests.profiles import get_databricks_cluster_target - pytest_plugins = ["dbt.tests.fixtures.project"] diff --git a/tests/functional/adapter/aliases/test_aliases.py b/tests/functional/adapter/aliases/test_aliases.py index af6682b90..f0f90823d 100644 --- a/tests/functional/adapter/aliases/test_aliases.py +++ b/tests/functional/adapter/aliases/test_aliases.py @@ -1,13 +1,14 @@ import pytest from dbt.tests.adapter.aliases import fixtures as dbt_fixtures -from dbt.tests.adapter.aliases.test_aliases import BaseAliasErrors -from dbt.tests.adapter.aliases.test_aliases import BaseAliases -from dbt.tests.adapter.aliases.test_aliases import BaseSameAliasDifferentDatabases -from dbt.tests.adapter.aliases.test_aliases import BaseSameAliasDifferentSchemas +from dbt.tests.adapter.aliases.test_aliases import ( + BaseAliasErrors, + BaseAliases, + BaseSameAliasDifferentDatabases, + BaseSameAliasDifferentSchemas, +) from tests.functional.adapter.aliases import fixtures as databricks_fixtures - macro_override = { "cast.sql": databricks_fixtures.MACROS__CAST_SQL, "expect_value.sql": dbt_fixtures.MACROS__EXPECT_VALUE_SQL, diff --git a/tests/functional/adapter/basic/test_docs_generate.py b/tests/functional/adapter/basic/test_docs_generate.py index 677879df4..83593eb5b 100644 --- a/tests/functional/adapter/basic/test_docs_generate.py +++ b/tests/functional/adapter/basic/test_docs_generate.py @@ -1,11 +1,9 @@ import pytest from dbt.tests.adapter.basic import expected_catalog -from dbt.tests.adapter.basic.test_docs_generate import BaseDocsGenerate -from dbt.tests.adapter.basic.test_docs_generate import BaseDocsGenReferences +from dbt.tests.adapter.basic.test_docs_generate import BaseDocsGenerate, BaseDocsGenReferences from dbt.tests.util import AnyString -from tests.functional.adapter.basic.typing import AnyLongType -from tests.functional.adapter.basic.typing import StatsLikeDict +from tests.functional.adapter.basic.typing import AnyLongType, StatsLikeDict class TestDocsGenerate(BaseDocsGenerate): diff --git a/tests/functional/adapter/basic/test_incremental.py b/tests/functional/adapter/basic/test_incremental.py index 3958b3304..a353d7802 100644 --- a/tests/functional/adapter/basic/test_incremental.py +++ b/tests/functional/adapter/basic/test_incremental.py @@ -2,8 +2,7 @@ import pytest -from dbt.tests.adapter.basic.test_incremental import BaseIncremental -from dbt.tests.adapter.basic.test_incremental import BaseIncrementalNotSchemaChange +from dbt.tests.adapter.basic.test_incremental import BaseIncremental, BaseIncrementalNotSchemaChange class TestIncrementalDelta(BaseIncremental): diff --git a/tests/functional/adapter/caching/test_caching.py b/tests/functional/adapter/caching/test_caching.py index 206f092f1..d32b3d534 100644 --- a/tests/functional/adapter/caching/test_caching.py +++ b/tests/functional/adapter/caching/test_caching.py @@ -1,7 +1,9 @@ -from dbt.tests.adapter.caching.test_caching import BaseCachingLowercaseModel -from dbt.tests.adapter.caching.test_caching import BaseCachingSelectedSchemaOnly -from dbt.tests.adapter.caching.test_caching import BaseCachingUppercaseModel -from dbt.tests.adapter.caching.test_caching import BaseNoPopulateCache +from dbt.tests.adapter.caching.test_caching import ( + BaseCachingLowercaseModel, + BaseCachingSelectedSchemaOnly, + BaseCachingUppercaseModel, + BaseNoPopulateCache, +) class TestNoPopulateCache(BaseNoPopulateCache): diff --git a/tests/functional/adapter/columns/test_get_columns.py b/tests/functional/adapter/columns/test_get_columns.py index 383dd2c6a..578981989 100644 --- a/tests/functional/adapter/columns/test_get_columns.py +++ b/tests/functional/adapter/columns/test_get_columns.py @@ -2,8 +2,8 @@ from dbt.adapters.databricks.column import DatabricksColumn from dbt.adapters.databricks.relation import DatabricksRelation -from tests.functional.adapter.columns import fixtures from dbt.tests import util +from tests.functional.adapter.columns import fixtures class ColumnsInRelation: diff --git a/tests/functional/adapter/concurrency/test_concurrency.py b/tests/functional/adapter/concurrency/test_concurrency.py index a4e410940..b1b8aded5 100644 --- a/tests/functional/adapter/concurrency/test_concurrency.py +++ b/tests/functional/adapter/concurrency/test_concurrency.py @@ -1,6 +1,5 @@ from dbt.tests import util -from dbt.tests.adapter.concurrency.test_concurrency import BaseConcurrency -from dbt.tests.adapter.concurrency.test_concurrency import seeds__update_csv +from dbt.tests.adapter.concurrency.test_concurrency import BaseConcurrency, seeds__update_csv # Copied from dbt-core diff --git a/tests/functional/adapter/constraints/test_constraints.py b/tests/functional/adapter/constraints/test_constraints.py index d366b3c12..350910d00 100644 --- a/tests/functional/adapter/constraints/test_constraints.py +++ b/tests/functional/adapter/constraints/test_constraints.py @@ -2,24 +2,14 @@ from dbt.tests import util from dbt.tests.adapter.constraints import fixtures -from dbt.tests.adapter.constraints.test_constraints import BaseConstraintQuotedColumn -from dbt.tests.adapter.constraints.test_constraints import BaseConstraintsRollback from dbt.tests.adapter.constraints.test_constraints import ( + BaseConstraintQuotedColumn, + BaseConstraintsRollback, BaseConstraintsRuntimeDdlEnforcement, -) -from dbt.tests.adapter.constraints.test_constraints import ( BaseIncrementalConstraintsColumnsEqual, -) -from dbt.tests.adapter.constraints.test_constraints import ( BaseIncrementalConstraintsRollback, -) -from dbt.tests.adapter.constraints.test_constraints import ( BaseIncrementalConstraintsRuntimeDdlEnforcement, -) -from dbt.tests.adapter.constraints.test_constraints import ( BaseTableConstraintsColumnsEqual, -) -from dbt.tests.adapter.constraints.test_constraints import ( BaseViewConstraintsColumnsEqual, ) from tests.functional.adapter.constraints import fixtures as override_fixtures diff --git a/tests/functional/adapter/dbt_clone/test_dbt_clone.py b/tests/functional/adapter/dbt_clone/test_dbt_clone.py index 291554658..6d619abff 100644 --- a/tests/functional/adapter/dbt_clone/test_dbt_clone.py +++ b/tests/functional/adapter/dbt_clone/test_dbt_clone.py @@ -1,8 +1,7 @@ import pytest from dbt.tests import util -from dbt.tests.adapter.dbt_clone.test_dbt_clone import BaseClone -from dbt.tests.adapter.dbt_clone.test_dbt_clone import BaseClonePossible +from dbt.tests.adapter.dbt_clone.test_dbt_clone import BaseClone, BaseClonePossible from dbt.tests.util import run_dbt from tests.functional.adapter.dbt_clone import fixtures diff --git a/tests/functional/adapter/dbt_show/test_dbt_show.py b/tests/functional/adapter/dbt_show/test_dbt_show.py index 340828c02..98d603154 100644 --- a/tests/functional/adapter/dbt_show/test_dbt_show.py +++ b/tests/functional/adapter/dbt_show/test_dbt_show.py @@ -1,5 +1,4 @@ -from dbt.tests.adapter.dbt_show.test_dbt_show import BaseShowLimit -from dbt.tests.adapter.dbt_show.test_dbt_show import BaseShowSqlHeader +from dbt.tests.adapter.dbt_show.test_dbt_show import BaseShowLimit, BaseShowSqlHeader class TestShowLimit(BaseShowLimit): diff --git a/tests/functional/adapter/ephemeral/test_ephemeral.py b/tests/functional/adapter/ephemeral/test_ephemeral.py index 81a320dbf..c00585b81 100644 --- a/tests/functional/adapter/ephemeral/test_ephemeral.py +++ b/tests/functional/adapter/ephemeral/test_ephemeral.py @@ -5,8 +5,7 @@ from dbt.tests import util from dbt.tests.adapter.ephemeral import test_ephemeral -from dbt.tests.adapter.ephemeral.test_ephemeral import BaseEphemeral -from dbt.tests.adapter.ephemeral.test_ephemeral import BaseEphemeralMulti +from dbt.tests.adapter.ephemeral.test_ephemeral import BaseEphemeral, BaseEphemeralMulti class TestEphemeralMulti(BaseEphemeralMulti): diff --git a/tests/functional/adapter/hooks/test_run_hooks.py b/tests/functional/adapter/hooks/test_run_hooks.py index 91c228437..5c7dd5c2d 100644 --- a/tests/functional/adapter/hooks/test_run_hooks.py +++ b/tests/functional/adapter/hooks/test_run_hooks.py @@ -3,8 +3,7 @@ import pytest from dbt.tests import util -from dbt.tests.adapter.hooks.test_run_hooks import BaseAfterRunHooks -from dbt.tests.adapter.hooks.test_run_hooks import BasePrePostRunHooks +from dbt.tests.adapter.hooks.test_run_hooks import BaseAfterRunHooks, BasePrePostRunHooks from tests.functional.adapter.hooks import fixtures as override_fixtures diff --git a/tests/functional/adapter/iceberg/test_iceberg_support.py b/tests/functional/adapter/iceberg/test_iceberg_support.py index 53ae39994..b25a54af7 100644 --- a/tests/functional/adapter/iceberg/test_iceberg_support.py +++ b/tests/functional/adapter/iceberg/test_iceberg_support.py @@ -1,8 +1,8 @@ import pytest -from tests.functional.adapter.iceberg import fixtures -from dbt.tests import util from dbt.artifacts.schemas.results import RunStatus +from dbt.tests import util +from tests.functional.adapter.iceberg import fixtures # @pytest.mark.skip_profile("databricks_cluster") diff --git a/tests/functional/adapter/incremental/test_incremental_clustering.py b/tests/functional/adapter/incremental/test_incremental_clustering.py index cb867ade3..e3ccd4043 100644 --- a/tests/functional/adapter/incremental/test_incremental_clustering.py +++ b/tests/functional/adapter/incremental/test_incremental_clustering.py @@ -1,4 +1,5 @@ import pytest + from dbt.tests import util from tests.functional.adapter.incremental import fixtures diff --git a/tests/functional/adapter/incremental/test_incremental_replace_table.py b/tests/functional/adapter/incremental/test_incremental_replace_table.py index ec7f351a8..8d24d658d 100644 --- a/tests/functional/adapter/incremental/test_incremental_replace_table.py +++ b/tests/functional/adapter/incremental/test_incremental_replace_table.py @@ -1,4 +1,5 @@ import pytest + from dbt.tests import util from tests.functional.adapter.incremental import fixtures diff --git a/tests/functional/adapter/incremental/test_incremental_tags.py b/tests/functional/adapter/incremental/test_incremental_tags.py index b84e55e1f..b4133b839 100644 --- a/tests/functional/adapter/incremental/test_incremental_tags.py +++ b/tests/functional/adapter/incremental/test_incremental_tags.py @@ -1,4 +1,5 @@ import pytest + from dbt.tests import util from tests.functional.adapter.incremental import fixtures diff --git a/tests/functional/adapter/incremental/test_incremental_tblproperties.py b/tests/functional/adapter/incremental/test_incremental_tblproperties.py index 2893067f7..b141fff41 100644 --- a/tests/functional/adapter/incremental/test_incremental_tblproperties.py +++ b/tests/functional/adapter/incremental/test_incremental_tblproperties.py @@ -1,4 +1,5 @@ import pytest + from dbt.tests import util from tests.functional.adapter.incremental import fixtures diff --git a/tests/functional/adapter/materialized_view_tests/test_changes.py b/tests/functional/adapter/materialized_view_tests/test_changes.py index 9a123638a..1c1fa4c71 100644 --- a/tests/functional/adapter/materialized_view_tests/test_changes.py +++ b/tests/functional/adapter/materialized_view_tests/test_changes.py @@ -8,14 +8,12 @@ ) from dbt.adapters.databricks.relation_configs.tblproperties import TblPropertiesConfig from dbt.tests import util -from dbt.tests.adapter.materialized_view.changes import MaterializedViewChanges from dbt.tests.adapter.materialized_view.changes import ( + MaterializedViewChanges, MaterializedViewChangesApplyMixin, -) -from dbt.tests.adapter.materialized_view.changes import ( MaterializedViewChangesContinueMixin, + MaterializedViewChangesFailMixin, ) -from dbt.tests.adapter.materialized_view.changes import MaterializedViewChangesFailMixin from tests.functional.adapter.materialized_view_tests import fixtures diff --git a/tests/functional/adapter/microbatch/test_microbatch.py b/tests/functional/adapter/microbatch/test_microbatch.py index 89b7f11ef..c51d8ae27 100644 --- a/tests/functional/adapter/microbatch/test_microbatch.py +++ b/tests/functional/adapter/microbatch/test_microbatch.py @@ -1,10 +1,11 @@ -from dbt.tests.adapter.incremental.test_incremental_microbatch import ( - BaseMicrobatch, -) +from importlib import metadata + import pytest from packaging import version -from importlib import metadata +from dbt.tests.adapter.incremental.test_incremental_microbatch import ( + BaseMicrobatch, +) from tests.functional.adapter.microbatch import fixtures dbt_version = metadata.version("dbt-core") diff --git a/tests/functional/adapter/persist_constraints/test_persist_constraints.py b/tests/functional/adapter/persist_constraints/test_persist_constraints.py index 42c9862fa..ac7c50b0a 100644 --- a/tests/functional/adapter/persist_constraints/test_persist_constraints.py +++ b/tests/functional/adapter/persist_constraints/test_persist_constraints.py @@ -1,7 +1,6 @@ import pytest -from dbt.contracts.results import RunResult -from dbt.contracts.results import RunStatus +from dbt.contracts.results import RunResult, RunStatus from dbt.tests import util from tests.functional.adapter.persist_constraints import fixtures diff --git a/tests/functional/adapter/persist_docs/test_persist_docs.py b/tests/functional/adapter/persist_docs/test_persist_docs.py index 2544b1015..e057a837d 100644 --- a/tests/functional/adapter/persist_docs/test_persist_docs.py +++ b/tests/functional/adapter/persist_docs/test_persist_docs.py @@ -2,6 +2,7 @@ import pytest from agate import Table + from dbt.adapters.databricks.impl import DatabricksAdapter from dbt.adapters.databricks.relation import DatabricksRelation from dbt.tests import util diff --git a/tests/functional/adapter/python_model/test_python_model.py b/tests/functional/adapter/python_model/test_python_model.py index e832bbd0f..482674fe9 100644 --- a/tests/functional/adapter/python_model/test_python_model.py +++ b/tests/functional/adapter/python_model/test_python_model.py @@ -4,8 +4,10 @@ from dbt.tests import util from dbt.tests.adapter.python_model import test_python_model as fixtures -from dbt.tests.adapter.python_model.test_python_model import BasePythonIncrementalTests -from dbt.tests.adapter.python_model.test_python_model import BasePythonModelTests +from dbt.tests.adapter.python_model.test_python_model import ( + BasePythonIncrementalTests, + BasePythonModelTests, +) from tests.functional.adapter.python_model import fixtures as override_fixtures diff --git a/tests/functional/adapter/query_comments/test_query_comment.py b/tests/functional/adapter/query_comments/test_query_comment.py index e058668f5..8d64835ba 100644 --- a/tests/functional/adapter/query_comments/test_query_comment.py +++ b/tests/functional/adapter/query_comments/test_query_comment.py @@ -1,15 +1,13 @@ import pytest -from dbt.tests.adapter.query_comment.test_query_comment import BaseEmptyQueryComments from dbt.tests.adapter.query_comment.test_query_comment import ( + BaseEmptyQueryComments, BaseMacroArgsQueryComments, -) -from dbt.tests.adapter.query_comment.test_query_comment import ( BaseMacroInvalidQueryComments, + BaseMacroQueryComments, + BaseNullQueryComments, + BaseQueryComments, ) -from dbt.tests.adapter.query_comment.test_query_comment import BaseMacroQueryComments -from dbt.tests.adapter.query_comment.test_query_comment import BaseNullQueryComments -from dbt.tests.adapter.query_comment.test_query_comment import BaseQueryComments class TestQueryComments(BaseQueryComments): diff --git a/tests/functional/adapter/simple_copy/test_simple_copy.py b/tests/functional/adapter/simple_copy/test_simple_copy.py index feac39bd5..ba65ad15e 100644 --- a/tests/functional/adapter/simple_copy/test_simple_copy.py +++ b/tests/functional/adapter/simple_copy/test_simple_copy.py @@ -1,7 +1,6 @@ import pytest -from dbt.tests.adapter.simple_copy.test_simple_copy import EmptyModelsArentRunBase -from dbt.tests.adapter.simple_copy.test_simple_copy import SimpleCopyBase +from dbt.tests.adapter.simple_copy.test_simple_copy import EmptyModelsArentRunBase, SimpleCopyBase # Tests with materialized_views, which only works for SQL Warehouse diff --git a/tests/functional/adapter/simple_seed/test_seeds.py b/tests/functional/adapter/simple_seed/test_seeds.py index 7e18b61d2..242f79074 100644 --- a/tests/functional/adapter/simple_seed/test_seeds.py +++ b/tests/functional/adapter/simple_seed/test_seeds.py @@ -4,17 +4,19 @@ from dbt.tests import util from dbt.tests.adapter.simple_seed import seeds -from dbt.tests.adapter.simple_seed.test_seed import BaseSeedConfigFullRefreshOff -from dbt.tests.adapter.simple_seed.test_seed import BaseSeedCustomSchema -from dbt.tests.adapter.simple_seed.test_seed import BaseSeedParsing -from dbt.tests.adapter.simple_seed.test_seed import BaseSeedSpecificFormats -from dbt.tests.adapter.simple_seed.test_seed import BaseSeedWithEmptyDelimiter -from dbt.tests.adapter.simple_seed.test_seed import BaseSeedWithUniqueDelimiter -from dbt.tests.adapter.simple_seed.test_seed import BaseSeedWithWrongDelimiter -from dbt.tests.adapter.simple_seed.test_seed import BaseSimpleSeedEnabledViaConfig -from dbt.tests.adapter.simple_seed.test_seed import BaseSimpleSeedWithBOM -from dbt.tests.adapter.simple_seed.test_seed import BaseTestEmptySeed -from dbt.tests.adapter.simple_seed.test_seed import SeedTestBase +from dbt.tests.adapter.simple_seed.test_seed import ( + BaseSeedConfigFullRefreshOff, + BaseSeedCustomSchema, + BaseSeedParsing, + BaseSeedSpecificFormats, + BaseSeedWithEmptyDelimiter, + BaseSeedWithUniqueDelimiter, + BaseSeedWithWrongDelimiter, + BaseSimpleSeedEnabledViaConfig, + BaseSimpleSeedWithBOM, + BaseTestEmptySeed, + SeedTestBase, +) from tests.functional.adapter.simple_seed import fixtures diff --git a/tests/functional/adapter/simple_snapshot/test_snapshot.py b/tests/functional/adapter/simple_snapshot/test_snapshot.py index ef2b873e9..56186e4ef 100644 --- a/tests/functional/adapter/simple_snapshot/test_snapshot.py +++ b/tests/functional/adapter/simple_snapshot/test_snapshot.py @@ -3,8 +3,7 @@ import pytest from dbt.tests import util -from dbt.tests.adapter.simple_snapshot.test_snapshot import BaseSimpleSnapshot -from dbt.tests.adapter.simple_snapshot.test_snapshot import BaseSnapshotCheck +from dbt.tests.adapter.simple_snapshot.test_snapshot import BaseSimpleSnapshot, BaseSnapshotCheck from dbt.tests.util import run_dbt from tests.functional.adapter.simple_snapshot import fixtures diff --git a/tests/functional/adapter/store_test_failures/test_store_failures_as.py b/tests/functional/adapter/store_test_failures/test_store_failures_as.py index ebdb4b2f1..1d830dcb7 100644 --- a/tests/functional/adapter/store_test_failures/test_store_failures_as.py +++ b/tests/functional/adapter/store_test_failures/test_store_failures_as.py @@ -1,17 +1,9 @@ from dbt.tests.adapter.store_test_failures_tests.basic import ( StoreTestFailuresAsExceptions, -) -from dbt.tests.adapter.store_test_failures_tests.basic import StoreTestFailuresAsGeneric -from dbt.tests.adapter.store_test_failures_tests.basic import ( + StoreTestFailuresAsGeneric, StoreTestFailuresAsInteractions, -) -from dbt.tests.adapter.store_test_failures_tests.basic import ( StoreTestFailuresAsProjectLevelEphemeral, -) -from dbt.tests.adapter.store_test_failures_tests.basic import ( StoreTestFailuresAsProjectLevelOff, -) -from dbt.tests.adapter.store_test_failures_tests.basic import ( StoreTestFailuresAsProjectLevelView, ) from dbt.tests.adapter.store_test_failures_tests.test_store_test_failures import ( diff --git a/tests/functional/adapter/streaming_tables/test_st_basic.py b/tests/functional/adapter/streaming_tables/test_st_basic.py index ba95143b2..59f5ea5e7 100644 --- a/tests/functional/adapter/streaming_tables/test_st_basic.py +++ b/tests/functional/adapter/streaming_tables/test_st_basic.py @@ -5,9 +5,7 @@ from dbt.adapters.base.relation import BaseRelation from dbt.adapters.databricks.relation import DatabricksRelationType from dbt.tests import util -from dbt.tests.adapter.materialized_view.files import MY_SEED -from dbt.tests.adapter.materialized_view.files import MY_TABLE -from dbt.tests.adapter.materialized_view.files import MY_VIEW +from dbt.tests.adapter.materialized_view.files import MY_SEED, MY_TABLE, MY_VIEW from tests.functional.adapter.streaming_tables import fixtures diff --git a/tests/functional/adapter/streaming_tables/test_st_changes.py b/tests/functional/adapter/streaming_tables/test_st_changes.py index c0495f359..df343b2e3 100644 --- a/tests/functional/adapter/streaming_tables/test_st_changes.py +++ b/tests/functional/adapter/streaming_tables/test_st_changes.py @@ -1,6 +1,8 @@ from typing import Optional import pytest +from dbt_common.contracts.config.materialization import OnConfigurationChangeOption + from dbt.adapters.base.relation import BaseRelation from dbt.adapters.databricks.relation import DatabricksRelationType from dbt.adapters.databricks.relation_configs.streaming_table import ( @@ -11,7 +13,6 @@ from dbt.tests.adapter.materialized_view.files import ( MY_SEED, ) -from dbt_common.contracts.config.materialization import OnConfigurationChangeOption from tests.functional.adapter.streaming_tables import fixtures diff --git a/tests/functional/adapter/tags/test_databricks_tags.py b/tests/functional/adapter/tags/test_databricks_tags.py index 2221a11b8..7d50f6e79 100644 --- a/tests/functional/adapter/tags/test_databricks_tags.py +++ b/tests/functional/adapter/tags/test_databricks_tags.py @@ -1,4 +1,5 @@ import pytest + from dbt.tests import util from tests.functional.adapter.tags import fixtures diff --git a/tests/functional/adapter/utils/test_source_freshness.py b/tests/functional/adapter/utils/test_source_freshness.py index 5b2024c73..857690b75 100644 --- a/tests/functional/adapter/utils/test_source_freshness.py +++ b/tests/functional/adapter/utils/test_source_freshness.py @@ -2,8 +2,7 @@ import pytest -from dbt.tests.util import get_artifact -from dbt.tests.util import run_dbt +from dbt.tests.util import get_artifact, run_dbt freshness_via_metadata_schema_yml = """ version: 2 diff --git a/tests/functional/adapter/utils/test_utils.py b/tests/functional/adapter/utils/test_utils.py index a6b99634b..06086f25d 100644 --- a/tests/functional/adapter/utils/test_utils.py +++ b/tests/functional/adapter/utils/test_utils.py @@ -20,8 +20,7 @@ from dbt.tests.adapter.utils.test_intersect import BaseIntersect from dbt.tests.adapter.utils.test_last_day import BaseLastDay from dbt.tests.adapter.utils.test_length import BaseLength -from dbt.tests.adapter.utils.test_null_compare import BaseMixedNullCompare -from dbt.tests.adapter.utils.test_null_compare import BaseNullCompare +from dbt.tests.adapter.utils.test_null_compare import BaseMixedNullCompare, BaseNullCompare from dbt.tests.adapter.utils.test_position import BasePosition from dbt.tests.adapter.utils.test_replace import BaseReplace from dbt.tests.adapter.utils.test_right import BaseRight diff --git a/tests/profiles.py b/tests/profiles.py index e34c5073f..e0c88447e 100644 --- a/tests/profiles.py +++ b/tests/profiles.py @@ -1,6 +1,5 @@ import os -from typing import Any -from typing import Optional +from typing import Any, Optional def get_databricks_cluster_target(profile_type: str): diff --git a/tests/unit/api_client/api_test_base.py b/tests/unit/api_client/api_test_base.py index ab0bf183e..f76b54a2c 100644 --- a/tests/unit/api_client/api_test_base.py +++ b/tests/unit/api_client/api_test_base.py @@ -1,5 +1,4 @@ -from typing import Any -from typing import Callable +from typing import Any, Callable import pytest from dbt_common.exceptions import DbtRuntimeError diff --git a/tests/unit/api_client/test_cluster_api.py b/tests/unit/api_client/test_cluster_api.py index 05508f091..3a8efef86 100644 --- a/tests/unit/api_client/test_cluster_api.py +++ b/tests/unit/api_client/test_cluster_api.py @@ -1,8 +1,9 @@ import freezegun import pytest -from dbt.adapters.databricks.api_client import ClusterApi from dbt_common.exceptions import DbtRuntimeError from mock import patch + +from dbt.adapters.databricks.api_client import ClusterApi from tests.unit.api_client.api_test_base import ApiTestBase diff --git a/tests/unit/api_client/test_command_api.py b/tests/unit/api_client/test_command_api.py index 62ec2ce86..880f054e5 100644 --- a/tests/unit/api_client/test_command_api.py +++ b/tests/unit/api_client/test_command_api.py @@ -1,10 +1,9 @@ import freezegun import pytest -from dbt.adapters.databricks.api_client import CommandApi -from dbt.adapters.databricks.api_client import CommandExecution from dbt_common.exceptions import DbtRuntimeError -from mock import Mock -from mock import patch +from mock import Mock, patch + +from dbt.adapters.databricks.api_client import CommandApi, CommandExecution from tests.unit.api_client.api_test_base import ApiTestBase diff --git a/tests/unit/api_client/test_command_context_api.py b/tests/unit/api_client/test_command_context_api.py index 848ae7860..a54e1c060 100644 --- a/tests/unit/api_client/test_command_context_api.py +++ b/tests/unit/api_client/test_command_context_api.py @@ -1,6 +1,7 @@ import pytest -from dbt.adapters.databricks.api_client import CommandContextApi from mock import Mock + +from dbt.adapters.databricks.api_client import CommandContextApi from tests.unit.api_client.api_test_base import ApiTestBase diff --git a/tests/unit/api_client/test_job_runs_api.py b/tests/unit/api_client/test_job_runs_api.py index c1517db05..adc280b5e 100644 --- a/tests/unit/api_client/test_job_runs_api.py +++ b/tests/unit/api_client/test_job_runs_api.py @@ -1,8 +1,9 @@ import freezegun import pytest -from dbt.adapters.databricks.api_client import JobRunsApi from dbt_common.exceptions import DbtRuntimeError from mock import patch + +from dbt.adapters.databricks.api_client import JobRunsApi from tests.unit.api_client.api_test_base import ApiTestBase diff --git a/tests/unit/api_client/test_user_folder_api.py b/tests/unit/api_client/test_user_folder_api.py index 0006c3d11..c0ab4b081 100644 --- a/tests/unit/api_client/test_user_folder_api.py +++ b/tests/unit/api_client/test_user_folder_api.py @@ -1,6 +1,6 @@ import pytest -from dbt.adapters.databricks.api_client import UserFolderApi -from dbt.adapters.databricks.api_client import CurrUserApi + +from dbt.adapters.databricks.api_client import CurrUserApi, UserFolderApi from tests.unit.api_client.api_test_base import ApiTestBase diff --git a/tests/unit/api_client/test_workspace_api.py b/tests/unit/api_client/test_workspace_api.py index 57bb56c1f..d981f6c20 100644 --- a/tests/unit/api_client/test_workspace_api.py +++ b/tests/unit/api_client/test_workspace_api.py @@ -1,8 +1,9 @@ import base64 import pytest -from dbt.adapters.databricks.api_client import WorkspaceApi from mock import Mock + +from dbt.adapters.databricks.api_client import WorkspaceApi from tests.unit.api_client.api_test_base import ApiTestBase diff --git a/tests/unit/events/test_base_events.py b/tests/unit/events/test_base_events.py index 85724eba8..7b480029d 100644 --- a/tests/unit/events/test_base_events.py +++ b/tests/unit/events/test_base_events.py @@ -1,6 +1,6 @@ from databricks.sql.exc import Error -from dbt.adapters.databricks.events.base import ErrorEvent -from dbt.adapters.databricks.events.base import SQLErrorEvent + +from dbt.adapters.databricks.events.base import ErrorEvent, SQLErrorEvent class ErrorTestEvent(ErrorEvent): diff --git a/tests/unit/events/test_connection_events.py b/tests/unit/events/test_connection_events.py index 6e1c8bb34..b0c8af102 100644 --- a/tests/unit/events/test_connection_events.py +++ b/tests/unit/events/test_connection_events.py @@ -1,8 +1,11 @@ -from dbt.adapters.databricks.events.connection_events import ConnectionAcquire -from dbt.adapters.databricks.events.connection_events import ConnectionCloseError -from dbt.adapters.databricks.events.connection_events import ConnectionEvent from mock import Mock +from dbt.adapters.databricks.events.connection_events import ( + ConnectionAcquire, + ConnectionCloseError, + ConnectionEvent, +) + class ConnectionTestEvent(ConnectionEvent): def __init__(self, connection): diff --git a/tests/unit/events/test_cursor_events.py b/tests/unit/events/test_cursor_events.py index 0a767af1d..41248c56c 100644 --- a/tests/unit/events/test_cursor_events.py +++ b/tests/unit/events/test_cursor_events.py @@ -1,7 +1,7 @@ -from dbt.adapters.databricks.events.cursor_events import CursorCloseError -from dbt.adapters.databricks.events.cursor_events import CursorEvent from mock import Mock +from dbt.adapters.databricks.events.cursor_events import CursorCloseError, CursorEvent + class CursorTestEvent(CursorEvent): def __init__(self, cursor): diff --git a/tests/unit/macros/base.py b/tests/unit/macros/base.py index 80912ba0a..db5d6d5c0 100644 --- a/tests/unit/macros/base.py +++ b/tests/unit/macros/base.py @@ -2,10 +2,7 @@ from typing import Any import pytest -from jinja2 import Environment -from jinja2 import FileSystemLoader -from jinja2 import PackageLoader -from jinja2 import Template +from jinja2 import Environment, FileSystemLoader, PackageLoader, Template from mock import Mock from dbt.adapters.databricks.relation import DatabricksRelation diff --git a/tests/unit/macros/relations/test_tags_macros.py b/tests/unit/macros/relations/test_tags_macros.py index 1c5d4f524..e44cb4945 100644 --- a/tests/unit/macros/relations/test_tags_macros.py +++ b/tests/unit/macros/relations/test_tags_macros.py @@ -1,4 +1,5 @@ import pytest + from tests.unit.macros.base import MacroTestBase diff --git a/tests/unit/python/test_python_config.py b/tests/unit/python/test_python_config.py index 853ec7944..3559e044b 100644 --- a/tests/unit/python/test_python_config.py +++ b/tests/unit/python/test_python_config.py @@ -1,5 +1,6 @@ -from pydantic import ValidationError import pytest +from pydantic import ValidationError + from dbt.adapters.databricks.python_models.python_config import ( ParsedPythonModel, PythonJobConfig, diff --git a/tests/unit/python/test_python_helpers.py b/tests/unit/python/test_python_helpers.py index 41cd3441b..8c93bf20e 100644 --- a/tests/unit/python/test_python_helpers.py +++ b/tests/unit/python/test_python_helpers.py @@ -1,4 +1,5 @@ from unittest.mock import Mock + import pytest from dbt.adapters.databricks.python_models.python_submissions import ( diff --git a/tests/unit/python/test_python_job_support.py b/tests/unit/python/test_python_job_support.py index 0d7acb53f..4eec73558 100644 --- a/tests/unit/python/test_python_job_support.py +++ b/tests/unit/python/test_python_job_support.py @@ -1,4 +1,5 @@ from unittest.mock import Mock + import pytest from dbt.adapters.databricks.python_models import python_submissions diff --git a/tests/unit/python/test_python_run_tracker.py b/tests/unit/python/test_python_run_tracker.py index d38d2338d..8b0221709 100644 --- a/tests/unit/python/test_python_run_tracker.py +++ b/tests/unit/python/test_python_run_tracker.py @@ -1,6 +1,7 @@ -from dbt.adapters.databricks.python_models.run_tracking import PythonRunTracker from mock import Mock +from dbt.adapters.databricks.python_models.run_tracking import PythonRunTracker + class TestPythonRunTracker: def test_cancel_runs__from_separate_instance(self): diff --git a/tests/unit/python/test_python_submitters.py b/tests/unit/python/test_python_submitters.py index ad37839d1..334983084 100644 --- a/tests/unit/python/test_python_submitters.py +++ b/tests/unit/python/test_python_submitters.py @@ -1,4 +1,5 @@ from unittest.mock import Mock + import pytest from dbt.adapters.databricks.python_models.python_submissions import ( diff --git a/tests/unit/python/test_python_workflow_support.py b/tests/unit/python/test_python_workflow_support.py index 2e2e09411..595bd90c9 100644 --- a/tests/unit/python/test_python_workflow_support.py +++ b/tests/unit/python/test_python_workflow_support.py @@ -1,4 +1,5 @@ from unittest.mock import Mock + import pytest from dbt.adapters.databricks.python_models.python_submissions import ( diff --git a/tests/unit/relation_configs/test_comment.py b/tests/unit/relation_configs/test_comment.py index 758befb26..1a43ba2fd 100644 --- a/tests/unit/relation_configs/test_comment.py +++ b/tests/unit/relation_configs/test_comment.py @@ -1,8 +1,8 @@ from agate import Table -from dbt.adapters.databricks.relation_configs.comment import CommentConfig -from dbt.adapters.databricks.relation_configs.comment import CommentProcessor from mock import Mock +from dbt.adapters.databricks.relation_configs.comment import CommentConfig, CommentProcessor + class TestCommentProcessor: def test_from_results__no_comment(self): diff --git a/tests/unit/relation_configs/test_materialized_view_config.py b/tests/unit/relation_configs/test_materialized_view_config.py index 79f396017..21fa743d9 100644 --- a/tests/unit/relation_configs/test_materialized_view_config.py +++ b/tests/unit/relation_configs/test_materialized_view_config.py @@ -1,5 +1,6 @@ -from agate import Row -from agate import Table +from agate import Row, Table +from mock import Mock + from dbt.adapters.databricks.relation_configs.comment import CommentConfig from dbt.adapters.databricks.relation_configs.materialized_view import ( MaterializedViewConfig, @@ -8,7 +9,6 @@ from dbt.adapters.databricks.relation_configs.query import QueryConfig from dbt.adapters.databricks.relation_configs.refresh import RefreshConfig from dbt.adapters.databricks.relation_configs.tblproperties import TblPropertiesConfig -from mock import Mock class TestMaterializedViewConfig: diff --git a/tests/unit/relation_configs/test_partitioning.py b/tests/unit/relation_configs/test_partitioning.py index 97abe35eb..8d6fcae4e 100644 --- a/tests/unit/relation_configs/test_partitioning.py +++ b/tests/unit/relation_configs/test_partitioning.py @@ -1,6 +1,9 @@ -from dbt.adapters.databricks.relation_configs.partitioning import PartitionedByConfig -from dbt.adapters.databricks.relation_configs.partitioning import PartitionedByProcessor from mock import Mock + +from dbt.adapters.databricks.relation_configs.partitioning import ( + PartitionedByConfig, + PartitionedByProcessor, +) from tests.unit import fixtures diff --git a/tests/unit/relation_configs/test_query.py b/tests/unit/relation_configs/test_query.py index 20ee9d181..87138c3cc 100644 --- a/tests/unit/relation_configs/test_query.py +++ b/tests/unit/relation_configs/test_query.py @@ -2,8 +2,7 @@ from agate import Row from mock import Mock -from dbt.adapters.databricks.relation_configs.query import QueryConfig -from dbt.adapters.databricks.relation_configs.query import QueryProcessor +from dbt.adapters.databricks.relation_configs.query import QueryConfig, QueryProcessor from dbt.exceptions import DbtRuntimeError sql = "select * from foo" diff --git a/tests/unit/relation_configs/test_refresh.py b/tests/unit/relation_configs/test_refresh.py index 7c2f7c3be..17fdb2c8b 100644 --- a/tests/unit/relation_configs/test_refresh.py +++ b/tests/unit/relation_configs/test_refresh.py @@ -1,8 +1,8 @@ import pytest -from dbt.adapters.databricks.relation_configs.refresh import RefreshConfig -from dbt.adapters.databricks.relation_configs.refresh import RefreshProcessor -from dbt.exceptions import DbtRuntimeError from mock import Mock + +from dbt.adapters.databricks.relation_configs.refresh import RefreshConfig, RefreshProcessor +from dbt.exceptions import DbtRuntimeError from tests.unit import fixtures diff --git a/tests/unit/relation_configs/test_streaming_table_config.py b/tests/unit/relation_configs/test_streaming_table_config.py index 8d69810fc..7681fd685 100644 --- a/tests/unit/relation_configs/test_streaming_table_config.py +++ b/tests/unit/relation_configs/test_streaming_table_config.py @@ -1,3 +1,5 @@ +from mock import Mock + from dbt.adapters.databricks.relation_configs.comment import CommentConfig from dbt.adapters.databricks.relation_configs.partitioning import PartitionedByConfig from dbt.adapters.databricks.relation_configs.refresh import RefreshConfig @@ -5,8 +7,6 @@ StreamingTableConfig, ) from dbt.adapters.databricks.relation_configs.tblproperties import TblPropertiesConfig -from mock import Mock - from tests.unit import fixtures diff --git a/tests/unit/relation_configs/test_tags.py b/tests/unit/relation_configs/test_tags.py index adf5d27fe..bc1ed229d 100644 --- a/tests/unit/relation_configs/test_tags.py +++ b/tests/unit/relation_configs/test_tags.py @@ -1,10 +1,10 @@ import pytest from agate import Table -from dbt.adapters.databricks.relation_configs.tags import TagsConfig -from dbt.adapters.databricks.relation_configs.tags import TagsProcessor -from dbt.exceptions import DbtRuntimeError from mock import Mock +from dbt.adapters.databricks.relation_configs.tags import TagsConfig, TagsProcessor +from dbt.exceptions import DbtRuntimeError + class TestTagsProcessor: def test_from_relation_results__none(self): diff --git a/tests/unit/relation_configs/test_tblproperties.py b/tests/unit/relation_configs/test_tblproperties.py index e4df6b274..9fac55d03 100644 --- a/tests/unit/relation_configs/test_tblproperties.py +++ b/tests/unit/relation_configs/test_tblproperties.py @@ -1,11 +1,11 @@ import pytest -from dbt.adapters.databricks.relation_configs.tblproperties import TblPropertiesConfig +from mock import Mock + from dbt.adapters.databricks.relation_configs.tblproperties import ( + TblPropertiesConfig, TblPropertiesProcessor, ) from dbt.exceptions import DbtRuntimeError -from mock import Mock - from tests.unit import fixtures diff --git a/tests/unit/test_adapter.py b/tests/unit/test_adapter.py index 3dd929bd3..58bd396ee 100644 --- a/tests/unit/test_adapter.py +++ b/tests/unit/test_adapter.py @@ -1,25 +1,24 @@ from multiprocessing import get_context -from typing import Any -from typing import Optional +from typing import Any, Optional -import dbt.flags as flags import mock import pytest from agate import Row -from dbt.adapters.databricks import __version__ -from dbt.adapters.databricks import DatabricksAdapter -from dbt.adapters.databricks import DatabricksRelation +from dbt_common.exceptions import DbtConfigError, DbtValidationError +from mock import Mock + +import dbt.flags as flags +from dbt.adapters.databricks import DatabricksAdapter, __version__ from dbt.adapters.databricks.column import DatabricksColumn -from dbt.adapters.databricks.credentials import CATALOG_KEY_IN_SESSION_PROPERTIES -from dbt.adapters.databricks.credentials import DBT_DATABRICKS_HTTP_SESSION_HEADERS -from dbt.adapters.databricks.credentials import DBT_DATABRICKS_INVOCATION_ENV -from dbt.adapters.databricks.utils import check_not_found_error +from dbt.adapters.databricks.credentials import ( + CATALOG_KEY_IN_SESSION_PROPERTIES, + DBT_DATABRICKS_HTTP_SESSION_HEADERS, + DBT_DATABRICKS_INVOCATION_ENV, +) from dbt.adapters.databricks.impl import get_identifier_list_string -from dbt.adapters.databricks.relation import DatabricksRelationType +from dbt.adapters.databricks.relation import DatabricksRelation, DatabricksRelationType +from dbt.adapters.databricks.utils import check_not_found_error from dbt.config import RuntimeConfig -from dbt_common.exceptions import DbtConfigError -from dbt_common.exceptions import DbtValidationError -from mock import Mock from tests.unit.utils import config_from_parts_or_dicts diff --git a/tests/unit/test_column.py b/tests/unit/test_column.py index 5edbb7b28..47a7fe1e9 100644 --- a/tests/unit/test_column.py +++ b/tests/unit/test_column.py @@ -1,4 +1,4 @@ -from dbt.adapters.databricks import DatabricksColumn +from dbt.adapters.databricks.column import DatabricksColumn class TestSparkColumn: diff --git a/tests/unit/test_compute_config.py b/tests/unit/test_compute_config.py index 7688d9647..c6ad51bde 100644 --- a/tests/unit/test_compute_config.py +++ b/tests/unit/test_compute_config.py @@ -1,9 +1,10 @@ import pytest -from dbt.adapters.databricks import connections -from dbt.adapters.databricks.credentials import DatabricksCredentials from dbt_common.exceptions import DbtRuntimeError from mock import Mock +from dbt.adapters.databricks import connections +from dbt.adapters.databricks.credentials import DatabricksCredentials + class TestDatabricksConnectionHTTPPath: """Test the various cases for determining a specified warehouse.""" diff --git a/tests/unit/test_idle_config.py b/tests/unit/test_idle_config.py index 1e317e2c6..de3545680 100644 --- a/tests/unit/test_idle_config.py +++ b/tests/unit/test_idle_config.py @@ -1,9 +1,9 @@ import pytest +from dbt_common.exceptions import DbtRuntimeError + from dbt.adapters.databricks import connections from dbt.adapters.databricks.credentials import DatabricksCredentials -from dbt.contracts.graph import model_config -from dbt.contracts.graph import nodes -from dbt_common.exceptions import DbtRuntimeError +from dbt.contracts.graph import model_config, nodes class TestDatabricksConnectionMaxIdleTime: diff --git a/tests/unit/test_relation.py b/tests/unit/test_relation.py index a678dcdb5..5bde2fa5e 100644 --- a/tests/unit/test_relation.py +++ b/tests/unit/test_relation.py @@ -1,7 +1,7 @@ import pytest + from dbt.adapters.databricks import relation -from dbt.adapters.databricks.relation import DatabricksQuotePolicy -from dbt.adapters.databricks.relation import DatabricksRelation +from dbt.adapters.databricks.relation import DatabricksQuotePolicy, DatabricksRelation class TestDatabricksRelation: diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index cbe9ed3db..81e772113 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -1,5 +1,4 @@ -from dbt.adapters.databricks.utils import redact_credentials -from dbt.adapters.databricks.utils import remove_ansi +from dbt.adapters.databricks.utils import redact_credentials, remove_ansi class TestDatabricksUtils: diff --git a/tests/unit/utils.py b/tests/unit/utils.py index 894bbd5d1..6fdf86cdf 100644 --- a/tests/unit/utils.py +++ b/tests/unit/utils.py @@ -1,12 +1,9 @@ import os from copy import deepcopy -from dbt.config import Profile -from dbt.config import Project -from dbt.config import RuntimeConfig +from dbt.config import Profile, Project, RuntimeConfig from dbt.config.project import PartialProject -from dbt.config.renderer import DbtProjectYamlRenderer -from dbt.config.renderer import ProfileRenderer +from dbt.config.renderer import DbtProjectYamlRenderer, ProfileRenderer from dbt.config.utils import parse_cli_vars @@ -23,9 +20,10 @@ def profile_from_dict(profile, profile_name, cli_vars="{}"): # in order to call dbt's internal profile rendering, we need to set the # flags global. This is a bit of a hack, but it's the best way to do it. - from dbt.flags import set_from_args from argparse import Namespace + from dbt.flags import set_from_args + set_from_args(Namespace(), None) return Profile.from_raw_profile_info( profile,