Skip to content

Commit

Permalink
Merge pull request #39 from codeforkjeff/dbt-1-4-0-compat
Browse files Browse the repository at this point in the history
dbt 1.4.0 compatibility
  • Loading branch information
codeforkjeff authored Feb 1, 2023
2 parents 10c7969 + 8e0657d commit ba845bb
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apt-get update && apt-get -y install git python3 python3-pip python3-venv sq
WORKDIR /opt/dbt-sqlite

RUN python3 -m pip install --upgrade pip \
&& python3 -m pip install pytest pytest-dotenv dbt-core~=1.3.0 dbt-tests-adapter~=1.3.0
&& python3 -m pip install pytest pytest-dotenv dbt-core~=1.4.0 dbt-tests-adapter~=1.4.0

RUN wget -q https://github.com/nalgeon/sqlean/releases/download/0.15.2/crypto.so
RUN wget -q https://github.com/nalgeon/sqlean/releases/download/0.15.2/math.so
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Use the right version. Starting with the release of dbt-core 1.0.0,
versions of dbt-sqlite are aligned to the same major+minor
[version](https://semver.org/) of dbt-core.

- versions 1.4.x of this adapter work with dbt-core 1.4.x
- versions 1.3.x of this adapter work with dbt-core 1.3.x
- versions 1.2.x of this adapter work with dbt-core 1.2.x
- versions 1.1.x of this adapter work with dbt-core 1.1.x
- versions 1.0.x of this adapter work with dbt-core 1.0.x
Expand Down
16 changes: 8 additions & 8 deletions dbt/adapters/sqlite/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from dbt.contracts.connection import AdapterResponse
from dbt.contracts.connection import Connection
from dbt.exceptions import (
DatabaseException,
FailedToConnectException,
RuntimeException
DbtDatabaseError,
FailedToConnectError,
DbtRuntimeError
)
from dbt.logger import GLOBAL_LOGGER as logger

Expand Down Expand Up @@ -66,7 +66,7 @@ def open(cls, connection: Connection):
handle: sqlite3.Connection = sqlite3.connect(schemas_and_paths['main'])
attached.append(schemas_and_paths['main'])
else:
raise FailedToConnectException("at least one schema must be called 'main'")
raise FailedToConnectError("at least one schema must be called 'main'")

if len(credentials.extensions) > 0:
handle.enable_load_extension(True)
Expand All @@ -92,7 +92,7 @@ def open(cls, connection: Connection):
if schema not in attached:
cursor.execute(f"attach '{path}' as '{schema}'")
else:
raise FailedToConnectException(
raise FailedToConnectError(
f"found {path} while scanning schema_directory, but cannot attach it as '{schema}' " +
f"because that schema name is already defined in schemas_and_paths. " +
f"fix your ~/.dbt/profiles.yml file")
Expand All @@ -112,7 +112,7 @@ def open(cls, connection: Connection):
connection.handle = None
connection.state = "fail"

raise FailedToConnectException(str(e))
raise FailedToConnectError(str(e))
except Exception as e:
print(f"Unknown error opening SQLite connection: {e}")
raise e
Expand Down Expand Up @@ -151,12 +151,12 @@ def exception_handler(self, sql: str):
except sqlite3.DatabaseError as e:
self.release()
logger.debug("sqlite3 error: {}".format(str(e)))
raise DatabaseException(str(e))
raise DbtDatabaseError(str(e))
except Exception as e:
logger.debug("Error running SQL: {}".format(sql))
logger.debug("Rolling back transaction.")
self.release()
raise RuntimeException(str(e))
raise DbtRuntimeError(str(e))

def add_query(
self,
Expand Down
4 changes: 2 additions & 2 deletions dbt/adapters/sqlite/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from dbt.adapters.sqlite import SQLiteConnectionManager
from dbt.adapters.sqlite.relation import SQLiteRelation
from dbt.contracts.graph.manifest import Manifest
from dbt.exceptions import NotImplementedException
from dbt.exceptions import NotImplementedError


class SQLiteAdapter(SQLAdapter):
Expand Down Expand Up @@ -93,7 +93,7 @@ def rename_relation(self, from_relation, to_relation):
self.connections.execute(new_definition)

else:
raise NotImplementedException(
raise NotImplementedError(
f"I don't know how to rename this type of relation: {from_relation.type}," +
f" from: {from_relation}, to: {to_relation}")

Expand Down
6 changes: 3 additions & 3 deletions dbt/adapters/sqlite/relation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dataclasses import dataclass
from dataclasses import dataclass, field

from dbt.adapters.base.relation import BaseRelation, Policy

Expand All @@ -19,5 +19,5 @@ class SQLiteIncludePolicy(Policy):

@dataclass(frozen=True, eq=False, repr=False)
class SQLiteRelation(BaseRelation):
quote_policy: SQLiteQuotePolicy = SQLiteQuotePolicy()
include_policy: SQLiteIncludePolicy = SQLiteIncludePolicy()
quote_policy: SQLiteQuotePolicy = field(default_factory=SQLiteQuotePolicy)
include_policy: SQLiteIncludePolicy = field(default_factory=SQLiteIncludePolicy)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _get_plugin_version():
]
},
install_requires=[
"dbt-core>=1.3.0"
"dbt-core>=1.4.0"
],
classifiers=[
'Development Status :: 4 - Beta',
Expand Down

0 comments on commit ba845bb

Please sign in to comment.