Skip to content

Commit

Permalink
Merge branch 'main' into 1.9.latest
Browse files Browse the repository at this point in the history
  • Loading branch information
benc-db committed Nov 20, 2024
2 parents f193c4b + 8fc6973 commit 4e3e3f8
Show file tree
Hide file tree
Showing 99 changed files with 377 additions and 484 deletions.
20 changes: 0 additions & 20 deletions .pre-commit-config.yaml

This file was deleted.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- Prepare for python typing deprecations ([837](https://github.com/databricks/dbt-databricks/pull/837))
- Fix behavior flag use in init of DatabricksAdapter (thanks @VersusFacit!) ([836](https://github.com/databricks/dbt-databricks/pull/836))
- Restrict pydantic to V1 per dbt Labs' request ([843](https://github.com/databricks/dbt-databricks/pull/843))
- Switching to Ruff for formatting and linting ([847](https://github.com/databricks/dbt-databricks/pull/847))

## dbt-databricks 1.8.7 (October 10, 2024)

Expand Down
4 changes: 0 additions & 4 deletions black.ini

This file was deleted.

3 changes: 0 additions & 3 deletions dbt/adapters/databricks/__init__.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
23 changes: 9 additions & 14 deletions dbt/adapters/databricks/api_client.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -142,7 +139,6 @@ def get_folder(self, _: str, schema: str) -> str:


class CurrUserApi(DatabricksApi):

def __init__(self, session: Session, host: str):
super().__init__(session, host, "/api/2.0/preview/scim/v2")
self._user = ""
Expand Down Expand Up @@ -401,7 +397,6 @@ def get(self, job_id: str) -> dict[str, Any]:


class WorkflowJobApi(DatabricksApi):

def __init__(self, session: Session, host: str):
super().__init__(session, host, "/api/2.1/jobs")

Expand Down
15 changes: 5 additions & 10 deletions dbt/adapters/databricks/auth.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions dbt/adapters/databricks/behaviors/columns.py
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
3 changes: 1 addition & 2 deletions dbt/adapters/databricks/column.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
102 changes: 51 additions & 51 deletions dbt/adapters/databricks/connections.py
Original file line number Diff line number Diff line change
@@ -1,79 +1,80 @@
from collections.abc import Callable, Iterator, Sequence
import decimal
import os
import re
import sys
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
Expand Down Expand Up @@ -868,7 +869,6 @@ def cleanup_all(self) -> None:
def _update_compute_connection(
self, conn: DatabricksDBTConnection, new_name: str
) -> DatabricksDBTConnection:

if conn.name == new_name and conn.state == ConnectionState.OPEN:
# Found a connection and nothing to do, so just return it
return conn
Expand Down
25 changes: 11 additions & 14 deletions dbt/adapters/databricks/credentials.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions dbt/adapters/databricks/events/connection_events.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
1 change: 1 addition & 0 deletions dbt/adapters/databricks/events/cursor_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from uuid import UUID

from databricks.sql.client import Cursor

from dbt.adapters.databricks.events.base import SQLErrorEvent


Expand Down
Loading

0 comments on commit 4e3e3f8

Please sign in to comment.