Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test branch #916

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
25636de
bump python sdk version
eric-wang-1990 Aug 14, 2024
12c077b
update
eric-wang-1990 Aug 14, 2024
5b8d938
Merge branch '1.9.latest' of github.com-ghec:databricks/dbt-databrick…
eric-wang-1990 Oct 14, 2024
403e496
update
eric-wang-1990 Oct 31, 2024
5a8f9c0
Merge branch '1.9.latest' of github.com-ghec:databricks/dbt-databrick…
eric-wang-1990 Oct 31, 2024
41092ba
update
eric-wang-1990 Oct 31, 2024
737f021
fix token test
eric-wang-1990 Oct 31, 2024
8c8417c
test
eric-wang-1990 Nov 14, 2024
c4aa1a3
fix test, add lock
eric-wang-1990 Nov 15, 2024
8dcba15
update
eric-wang-1990 Nov 16, 2024
bfe05a9
Merge branch 'main' of github.com-ghec:databricks/dbt-databricks into…
eric-wang-1990 Nov 16, 2024
55de168
update
eric-wang-1990 Nov 16, 2024
19b9f4d
fix test
eric-wang-1990 Nov 19, 2024
c4096e7
Merge branch '1.10.latest' into bump_python_sdk_version
benc-db Nov 26, 2024
e34a7c8
remove unneeded files
benc-db Nov 26, 2024
1368151
remove unexpected files
benc-db Nov 26, 2024
4e9edb7
lint
benc-db Nov 26, 2024
6ca087a
update
eric-wang-1990 Jan 28, 2025
ee46aae
update
eric-wang-1990 Oct 31, 2024
8562a21
test
eric-wang-1990 Nov 14, 2024
7790ea8
update
eric-wang-1990 Nov 16, 2024
d688c6f
Switch to render for safest relation str substitution (#903)
benc-db Jan 15, 2025
fd385d2
Adding missing 1.9 Snapshot behavior (#904)
benc-db Jan 17, 2025
6548b4d
Enforce retry defaults to ensure sufficient retries regardless of PyS…
benc-db Jan 17, 2025
b280157
Compress to one connection manager (#910)
benc-db Jan 23, 2025
6213ef8
bump version to 0.41.0
eric-wang-1990 Jan 28, 2025
9e2f105
fix wrong merge
eric-wang-1990 Jan 28, 2025
a287d60
Revert "fix wrong merge"
eric-wang-1990 Jan 28, 2025
e68d4d8
Revert "Revert "fix wrong merge""
eric-wang-1990 Jan 28, 2025
1529e17
Merge branch '1.10.latest' of https://github.com/databricks/dbt-datab…
eric-wang-1990 Jan 28, 2025
61f1e37
update
eric-wang-1990 Jan 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions dbt/adapters/databricks/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

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.credentials import BearerAuth, DatabricksCredentials
from dbt.adapters.databricks.logging import logger

DEFAULT_POLLING_INTERVAL = 10
Expand Down Expand Up @@ -557,8 +556,7 @@ def create(
http_headers = credentials.get_all_http_headers(
connection_parameters.pop("http_headers", {})
)
credentials_provider = credentials.authenticate(None)
header_factory = credentials_provider(None) # type: ignore
header_factory = credentials.authenticate().credentials_provider() # type: ignore
session.auth = BearerAuth(header_factory)

session.headers.update({"User-Agent": user_agent, **http_headers})
Expand Down
100 changes: 0 additions & 100 deletions dbt/adapters/databricks/auth.py

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ classifiers = [
"Programming Language :: Python :: 3.12",
]
dependencies = [
"databricks-sdk==0.17.0",
"databricks-sdk==0.41.0",
"databricks-sql-connector>=3.5.0, <4.0.0",
"dbt-adapters>=1.10.3, <2.0",
"dbt-common>=1.13.0, <2.0",
Expand Down
2 changes: 2 additions & 0 deletions tests/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def _build_databricks_cluster_target(
"token": os.getenv("DBT_DATABRICKS_TOKEN"),
"client_id": os.getenv("DBT_DATABRICKS_CLIENT_ID"),
"client_secret": os.getenv("DBT_DATABRICKS_CLIENT_SECRET"),
"azure_client_id": os.getenv("DBT_DATABRICKS_AZURE_CLIENT_ID"),
"azure_client_secret": os.getenv("DBT_DATABRICKS_AZURE_CLIENT_SECRET"),
"connect_retries": 3,
"connect_timeout": 5,
"retry_all": True,
Expand Down
7 changes: 5 additions & 2 deletions tests/unit/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,12 @@ def connect(
):
assert server_hostname == "yourorg.databricks.com"
assert http_path == "sql/protocolv1/o/1234567890123456/1234-567890-test123"
if not (expected_no_token or expected_client_creds):
assert credentials_provider._token == "dapiXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

if not (expected_no_token or expected_client_creds):
assert (
credentials_provider()().get("Authorization")
== "Bearer dapiXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
)
if expected_client_creds:
assert kwargs.get("client_id") == "foo"
assert kwargs.get("client_secret") == "bar"
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,21 @@ def test_token(self):
http_path="http://foo",
schema="dbt",
)
provider = creds.authenticate(None)
credentialManager = creds.authenticate()
provider = credentialManager.credentials_provider()
assert provider is not None

headers_fn = provider()
headers_fn = provider
headers = headers_fn()
assert headers is not None

raw = provider.as_dict()
raw = credentialManager._config.as_dict()
assert raw is not None

provider_b = creds._provider_from_dict()
headers_fn2 = provider_b()
headers2 = headers_fn2()
assert headers == headers2
assert headers == {"Authorization": "Bearer foo"}


@pytest.mark.skip(reason="Cache moved to databricks sdk TokenCache")
class TestShardedPassword:
def test_store_and_delete_short_password(self):
# set the keyring to mock class
Expand Down Expand Up @@ -133,6 +132,7 @@ def test_store_and_delete_long_password(self):
assert retrieved_password is None


@pytest.mark.skip(reason="Cache moved to databricks sdk TokenCache")
class MockKeyring(keyring.backend.KeyringBackend):
def __init__(self):
self.file_location = self._generate_test_root_dir()
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_compute_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from unittest.mock import Mock
from unittest.mock import Mock, patch

import pytest
from dbt_common.exceptions import DbtRuntimeError
Expand All @@ -23,7 +23,8 @@ def path(self):

@pytest.fixture
def creds(self, path):
return DatabricksCredentials(http_path=path)
with patch("dbt.adapters.databricks.credentials.Config"):
return DatabricksCredentials(http_path=path)

@pytest.fixture
def node(self):
Expand Down
13 changes: 8 additions & 5 deletions tests/unit/test_idle_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest.mock import patch

import pytest
from dbt_common.exceptions import DbtRuntimeError

Expand All @@ -6,14 +8,15 @@
from dbt.contracts.graph import model_config, nodes


@patch("dbt.adapters.databricks.credentials.Config")
class TestDatabricksConnectionMaxIdleTime:
"""Test the various cases for determining a specified warehouse."""

errMsg = (
"Compute resource foo does not exist or does not specify http_path, " "relation: a_relation"
)

def test_get_max_idle_default(self):
def test_get_max_idle_default(self, _):
creds = DatabricksCredentials()

# No node and nothing specified in creds
Expand Down Expand Up @@ -72,7 +75,7 @@ def test_get_max_idle_default(self):
# path = connections._get_http_path(node, creds)
# self.assertEqual("alternate_path", path)

def test_get_max_idle_creds(self):
def test_get_max_idle_creds(self, _):
creds_idle_time = 77
creds = DatabricksCredentials(connect_max_idle=creds_idle_time)

Expand Down Expand Up @@ -123,7 +126,7 @@ def test_get_max_idle_creds(self):
time = connections._get_max_idle_time(node, creds)
assert creds_idle_time == time

def test_get_max_idle_compute(self):
def test_get_max_idle_compute(self, _):
creds_idle_time = 88
compute_idle_time = 77
creds = DatabricksCredentials(connect_max_idle=creds_idle_time)
Expand Down Expand Up @@ -151,7 +154,7 @@ def test_get_max_idle_compute(self):
time = connections._get_max_idle_time(node, creds)
assert compute_idle_time == time

def test_get_max_idle_invalid(self):
def test_get_max_idle_invalid(self, _):
creds_idle_time = "foo"
compute_idle_time = "bar"
creds = DatabricksCredentials(connect_max_idle=creds_idle_time)
Expand Down Expand Up @@ -204,7 +207,7 @@ def test_get_max_idle_invalid(self):
"1,002.3 is not a valid value for connect_max_idle. " "Must be a number of seconds."
) in str(info.value)

def test_get_max_idle_simple_string_conversion(self):
def test_get_max_idle_simple_string_conversion(self, _):
creds_idle_time = "12"
compute_idle_time = "34"
creds = DatabricksCredentials(connect_max_idle=creds_idle_time)
Expand Down
Loading