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

Adapter Decoupling for 1.8 #237

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion dbt/adapters/dremio/api/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Optional
from abc import abstractmethod

from dbt.events import AdapterLogger
from dbt.adapters.events.logging import AdapterLogger

logger = AdapterLogger("dremio")

Expand Down
4 changes: 2 additions & 2 deletions dbt/adapters/dremio/api/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)
from dbt.adapters.dremio.api.parameters import Parameters

from dbt.events import AdapterLogger
from dbt.adapters.events.logging import AdapterLogger

logger = AdapterLogger("dremio")

Expand Down Expand Up @@ -126,7 +126,7 @@ def _populate_rowcount(self):

while True:
time.sleep(0.2)

if job_status_state != last_job_state:
logger.debug(f"Job State = {job_status_state}")

Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/dremio/api/handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from dbt.adapters.dremio.api.parameters import Parameters
from dbt.adapters.dremio.api.rest.endpoints import login

from dbt.events import AdapterLogger
from dbt.adapters.events.logging import AdapterLogger

logger = AdapterLogger("dremio")

Expand Down
3 changes: 2 additions & 1 deletion dbt/adapters/dremio/api/rest/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
from dbt.adapters.dremio.api.parameters import Parameters
from dbt.adapters.dremio.api.rest.url_builder import UrlBuilder

from dbt.events import AdapterLogger
from dbt.adapters.events.logging import AdapterLogger

logger = AdapterLogger("dremio")

session = requests.Session()


def _get(url, request_headers, details="", ssl_verify=True):
response = session.get(url, headers=request_headers, verify=ssl_verify)
return _check_error(response, details)
Expand Down
22 changes: 12 additions & 10 deletions dbt/adapters/dremio/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
from dbt.adapters.dremio.api.handle import DremioHandle
from dbt.adapters.dremio.api.parameters import ParametersBuilder

from dbt_common.clients import agate_helper

import time
import json

import dbt.exceptions
import dbt_common.exceptions
from dbt.adapters.sql import SQLConnectionManager
from dbt.contracts.connection import AdapterResponse
from dbt.adapters.contracts.connection import AdapterResponse

from dbt.adapters.dremio.api.rest.endpoints import (
delete_catalog,
Expand All @@ -43,7 +45,7 @@
DremioBadRequestException,
)

from dbt.events import AdapterLogger
from dbt.adapters.events.logging import AdapterLogger

logger = AdapterLogger("dremio")

Expand All @@ -61,13 +63,13 @@ def exception_handler(self, sql):
except Exception as e:
logger.debug(f"Error running SQL: {sql}")
self.release()
if isinstance(e, dbt.exceptions.DbtRuntimeError):
if isinstance(e, dbt_common.exceptions.DbtRuntimeError):
# during a sql query, an internal to dbt exception was raised.
# this sounds a lot like a signal handler and probably has
# useful information, so raise it without modification.
raise

raise dbt.exceptions.DbtRuntimeError(e)
raise dbt_common.exceptions.DbtRuntimeError(e)

@classmethod
def open(cls, connection):
Expand Down Expand Up @@ -184,7 +186,7 @@ def execute(
if fetch:
table = cursor.table
else:
table = dbt.clients.agate_helper.empty_table()
table = agate_helper.empty_table()

return response, table

Expand Down Expand Up @@ -254,10 +256,10 @@ def _create_folders(self, database, schema, api_parameters):
except DremioAlreadyExistsException:
logger.debug(f"Folder {folder} already exists.")
except DremioBadRequestException as e:
if "Can not create a folder inside a [SOURCE]" in e.message:
logger.debug(f"Ignoring {e}")
else:
raise e
if "Can not create a folder inside a [SOURCE]" in e.message:
logger.debug(f"Ignoring {e}")
else:
raise e

def _create_path_list(self, database, schema):
path = [database]
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/dremio/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from dbt.adapters.base import Credentials
from dbt.adapters.contracts.connection import Credentials
from dataclasses import dataclass
from typing import Optional
from dbt.adapters.dremio.relation import DremioRelation
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/dremio/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Capability,
)
from dbt.adapters.sql.impl import DROP_RELATION_MACRO_NAME
from dbt.events import AdapterLogger
from dbt.adapters.events.logging import AdapterLogger

logger = AdapterLogger("dremio")

Expand Down
2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Babel==2.12.1
betterproto==1.2.5
certifi==2023.7.22
charset-normalizer==3.1.0
dbt-tests-adapter==1.7.0
dbt-tests-adapter==1.8.0
exceptiongroup==1.1.1
future==0.18.3
grpclib==0.4.3
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

package_name = "dbt-dremio"

package_version = "1.7.0"
package_version = "1.8.0"

description = """The Dremio adapter plugin for dbt"""

Expand All @@ -37,7 +37,8 @@
packages=find_namespace_packages(include=["dbt", "dbt.*"]),
include_package_data=True,
install_requires=[
"dbt-core>=1.2, <=1.7.13",
"dbt-core>=1.8",
"dbt-adapters>=1.0.0, <2.0.0",
"requests>=2.31.0",
],
classifiers=[
Expand Down
1 change: 0 additions & 1 deletion tests/caching/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def unique_schema(request, prefix) -> str:
@pytest.fixture(scope="class")
def dbt_profile_data(unique_schema, dbt_profile_target, profiles_config_update):
profile = {
"config": {"send_anonymous_usage_stats": False},
"test": {
"outputs": {
"default": {},
Expand Down
1 change: 0 additions & 1 deletion tests/fixtures/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def unique_schema(request, prefix) -> str:
@pytest.fixture(scope="class")
def dbt_profile_data(unique_schema, dbt_profile_target, profiles_config_update):
profile = {
"config": {"send_anonymous_usage_stats": False},
"test": {
"outputs": {
"default": {},
Expand Down
1 change: 0 additions & 1 deletion tests/functional/adapter/basic/test_base_mat.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def dbt_profile_data(
self, unique_schema, dbt_profile_target, profiles_config_update
):
profile = {
"config": {"send_anonymous_usage_stats": False},
"test": {
"outputs": {
"default": {},
Expand Down
2 changes: 0 additions & 2 deletions tests/functional/adapter/basic/test_docs_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def dbt_profile_data(
self, unique_schema, dbt_profile_target, profiles_config_update
):
profile = {
"config": {"send_anonymous_usage_stats": False},
"test": {
"outputs": {
"default": {},
Expand Down Expand Up @@ -190,7 +189,6 @@ def dbt_profile_data(
self, unique_schema, dbt_profile_target, profiles_config_update
):
profile = {
"config": {"send_anonymous_usage_stats": False},
"test": {
"outputs": {
"default": {},
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/adapter/basic/test_override.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from dbt.tests.util import run_dbt
from dbt.exceptions import CompilationError
from dbt_common.exceptions import CompilationError
from tests.fixtures.profiles import unique_schema, dbt_profile_data

model_sql = """
Expand Down
2 changes: 0 additions & 2 deletions tests/functional/adapter/basic/test_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def dbt_profile_data(
self, unique_schema, dbt_profile_target, profiles_config_update
):
profile = {
"config": {"send_anonymous_usage_stats": False},
"test": {
"outputs": {
"default": {},
Expand Down Expand Up @@ -77,7 +76,6 @@ def dbt_profile_data(
self, unique_schema, dbt_profile_target, profiles_config_update
):
profile = {
"config": {"send_anonymous_usage_stats": False},
"test": {
"outputs": {
"default": {},
Expand Down
1 change: 0 additions & 1 deletion tests/functional/adapter/dbt_clone/test_dbt_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def dbt_profile_data(
self, unique_schema, dbt_profile_target, profiles_config_update
):
profile = {
"config": {"send_anonymous_usage_stats": False},
"test": {
"outputs": {
"default": {},
Expand Down
1 change: 0 additions & 1 deletion tests/functional/adapter/grants/base_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def dbt_profile_data(
self, unique_schema, dbt_profile_target, profiles_config_update
):
profile = {
"config": {"send_anonymous_usage_stats": False},
"test": {
"outputs": {
"default": {},
Expand Down
1 change: 0 additions & 1 deletion tests/functional/adapter/grants/test_snapshot_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def dbt_profile_data(
self, unique_schema, dbt_profile_target, profiles_config_update
):
profile = {
"config": {"send_anonymous_usage_stats": False},
"test": {
"outputs": {
"default": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def dbt_profile_data(
self, unique_schema, dbt_profile_target, profiles_config_update
):
profile = {
"config": {"send_anonymous_usage_stats": False},
"test": {
"outputs": {
"default": {},
Expand Down
4 changes: 1 addition & 3 deletions tests/hooks/test_model_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pathlib import Path

from dbt.exceptions import CompilationError, ParsingError
from dbt_common.exceptions import CompilationError, ParsingError

from dbt.tests.util import (
run_dbt,
Expand Down Expand Up @@ -51,7 +51,6 @@ def unique_schema(request, prefix) -> str:
@pytest.fixture(scope="class")
def dbt_profile_data(unique_schema, dbt_profile_target, profiles_config_update):
profile = {
"config": {"send_anonymous_usage_stats": False},
"test": {
"outputs": {
"default": {},
Expand Down Expand Up @@ -315,7 +314,6 @@ def dbt_profile_data(
self, unique_schema, dbt_profile_target, profiles_config_update
):
profile = {
"config": {"send_anonymous_usage_stats": False},
"test": {
"outputs": {
"default": {},
Expand Down
1 change: 0 additions & 1 deletion tests/hooks/test_run_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def unique_schema(request, prefix) -> str:
@pytest.fixture(scope="class")
def dbt_profile_data(unique_schema, dbt_profile_target, profiles_config_update):
profile = {
"config": {"send_anonymous_usage_stats": False},
"test": {
"outputs": {
"default": {},
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

import pytest
from unittest.mock import patch
from dbt.exceptions import DbtRuntimeError
from dbt_common.exceptions import DbtRuntimeError
from dbt.adapters.dremio.api.rest.error import DremioRequestTimeoutException
from dbt.adapters.dremio.connections import DremioConnectionManager


class TestRetryConnection:
@patch("dbt.adapters.dremio.api.rest.endpoints._post")
@patch("dbt.contracts.connection.Connection")
@patch("dbt.adapters.contracts.connection.Connection")
# When you nest patch decorators the mocks are passed in to the decorated function in bottom up order.
def test_connection_retry(
self,
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from contextlib import contextmanager
from dbt.tests.util import AnyInteger

from dbt.events import AdapterLogger
from dbt.adapters.events.logging import AdapterLogger

logger = AdapterLogger("dremio")

Expand Down