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

Dbt teradata team 1.6 #104

Merged
merged 14 commits into from
Sep 28, 2023
2 changes: 1 addition & 1 deletion .github/workflows/ci-integration-tests-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
test:
strategy:
matrix:
python: ['3.7']
python: ['3.8']
runs-on: ubuntu-latest
name: Functional test
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
test:
strategy:
matrix:
python: ['3.7.16', '3.8', '3.9','3.10', '3.11']
python: ['3.8', '3.9','3.10', '3.11']
runs-on: macos-12
name: Functional test
steps:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ At a minimum, you need to specify `host`, `user`, `password`, `schema` (database
|1.3.x.x | ❌ | ✅ | ✅ | ✅ | ✅ | ❌
|1.4.x.x | ❌ | ✅ | ✅ | ✅ | ✅ | ✅
|1.5.x | ❌ | ✅ | ✅ | ✅ | ✅ | ✅
|1.6.x | ❌ | ❌ | ✅ | ✅ | ✅ | ✅


## dbt dependent packages version compatibility
Expand Down
29 changes: 17 additions & 12 deletions dbt/adapters/teradata/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
from dbt.events import AdapterLogger
logger = AdapterLogger("teradata")
from dataclasses import dataclass
from typing import Optional, Tuple, Any
from typing import Optional, Tuple, Any, Dict


@dataclass(init=False)
class TeradataCredentials(Credentials):
@dataclass
class TeradataCredentials(Credentials):
# Mandatory required arguments.
server: str
database: Optional[str] = None
# Specifying database is optional
database: Optional[str]

username: Optional[str] = None
password: Optional[str] = None
port: Optional[str] = None
Expand Down Expand Up @@ -64,11 +67,6 @@ class TeradataCredentials(Credentials):
"host": "server"
}

def __init__(self, **kwargs):
for k, v in kwargs.items():
setattr(self, k, v)
self.database = None

def __post_init__(self):
# teradata classifies database and schema as the same thing
if (
Expand Down Expand Up @@ -140,8 +138,15 @@ def _connection_keys(self):
"connect_timeout",
"request_timeout"
)



@classmethod
def __pre_deserialize__(cls, data: Dict[Any, Any]) -> Dict[Any, Any]:
# If database is not defined as adapter credentials
data = super().__pre_deserialize__(data)
if "database" not in data:
data["database"] = None
return data

class TeradataConnectionManager(SQLConnectionManager):
TYPE = "teradata"
TMODE = "ANSI"
Expand Down Expand Up @@ -345,4 +350,4 @@ def add_query(
ignored = True
return None, None
if not ignored:
raise # rethrow
raise # rethrow
3 changes: 2 additions & 1 deletion dbt/adapters/teradata/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,5 @@ def valid_incremental_strategies(self):
"""The set of standard builtin strategies which this adapter supports out-of-the-box.
Not used to validate custom strategies defined by end users.
"""
return ["delete+insert","append","merge"]
return ["delete+insert","append","merge"]

4 changes: 2 additions & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ bump2version
wheel
pytest~=7.0
tox~=3.2
dbt-tests-adapter~=1.5.4
dbt-tests-adapter~=1.6.2
pylava~=0.3.0
teradatasql>=16.20.0.0
dbt-core==1.5.4
dbt-core==1.6.2
MarkupSafe==2.0.1
pytest-dotenv
pytest-cov
Expand Down
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from setuptools import setup


if sys.version_info < (3, 7) or sys.version_info >= (3, 12):
if sys.version_info < (3, 8) or sys.version_info >= (3, 12):
print('Error: dbt-teradata does not support this version of Python.')
print('Please install Python 3.7 or higher but less than 3.12.')
print('Please install Python 3.8 or higher but less than 3.12.')
sys.exit(1)


Expand Down Expand Up @@ -45,7 +45,7 @@
],
},
install_requires=[
"dbt-core==1.5.4",
"dbt-core==1.6.2",
"teradatasql>=16.20.0.0",
],
classifiers=[
Expand All @@ -57,11 +57,10 @@
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX :: Linux',

'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
],
python_requires=">=3.7,<3.12",
python_requires=">=3.8,<3.12",
)
38 changes: 38 additions & 0 deletions tests/functional/adapter/test_dbt_debug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# from dbt.tests.util import run_dbt, run_dbt_and_capture
# from dbt.tests.adapter.dbt_debug.test_dbt_debug import BaseDebug
# import re

# class TestDebugTeradata(BaseDebug):
# def test_ok(self, project):
# run_dbt(["debug"])
# assert "ERROR" not in self.capsys.readouterr().out

# def test_connection_flag(self, project):
# """Testing that the --connection flag works as expected, including that output is not lost"""
# _, out = run_dbt_and_capture(["debug", "--connection"])
# assert "Skipping steps before connection verification" in out

# _, out = run_dbt_and_capture(
# ["debug", "--connection", "--target", "NONE"], expect_pass=False
# )
# assert "1 check failed" in out
# assert "The profile 'test' does not have a target named 'NONE'." in out

# _, out = run_dbt_and_capture(
# ["debug", "--connection", "--profiles-dir", "NONE"], expect_pass=False
# )
# assert "Using profiles dir at NONE"
# assert "1 check failed" in out
# assert "dbt looked for a profiles.yml file in NONE" in out

# def test_nopass(self, project):
# run_dbt(["debug", "--target", "nopass"], expect_pass=False)
# self.assertGotValue(re.compile(r"\s+profiles\.yml file"), "ERROR invalid")

# def test_wronguser(self, project):
# run_dbt(["debug", "--target", "wronguser"], expect_pass=False)
# self.assertGotValue(re.compile(r"\s+Connection test"), "ERROR")

# def test_empty_target(self, project):
# run_dbt(["debug", "--target", "none_target"], expect_pass=False)
# self.assertGotValue(re.compile(r"\s+output 'none_target'"), "misconfigured")
Loading
Loading