From 7a578a7ef2abd7ff6f08e7f5f20ccb9ccc0fdb89 Mon Sep 17 00:00:00 2001 From: Marvin Froemming Date: Sat, 2 Sep 2023 22:46:52 +0200 Subject: [PATCH 1/2] add encryption, fix grants, docs still open --- README.md | 5 ++++- dbt/adapters/exasol/connections.py | 2 +- tests/functional/adapter/grants/test_grants.py | 5 ++++- tests/functional/adapter/test_basic.py | 10 ++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 45f9fb3..57828d6 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ OpenID login through access_token or refresh_token instead of user+password
  • socket_timeout: defaults to pyexasol default
  • query_timeout: defaults to pyexasol default
  • compression: default: False
  • -
  • encryption: default: False
  • +
  • encryption: default: True
  • protocol_version: default: v3
  • row_separator: default: CRLF for windows - LF otherwise
  • timestamp_format: default: YYYY-MM-DDTHH:MI:SS.FF6
  • @@ -37,6 +37,9 @@ OpenID login through access_token or refresh_token instead of user+password # Known isues +## Using encryption in Exasol 7 vs. 8 +Starting from Exasol 8, encryption is enforced by default. If you are still using Exasol 7 and have trouble connecting, you can disable encryption in profiles.yaml (see optional parameters). + ## Model contracts The following database constraints are implemented for Exasol: diff --git a/dbt/adapters/exasol/connections.py b/dbt/adapters/exasol/connections.py index 7fd3709..9768a6a 100644 --- a/dbt/adapters/exasol/connections.py +++ b/dbt/adapters/exasol/connections.py @@ -83,7 +83,7 @@ class ExasolCredentials(Credentials): socket_timeout: int = pyexasol.constant.DEFAULT_SOCKET_TIMEOUT query_timeout: int = pyexasol.constant.DEFAULT_QUERY_TIMEOUT compression: bool = False - encryption: bool = False + encryption: bool = True ## Because of potential interference with dbt, # the following statements are not (yet) implemented # fetch_dict: bool diff --git a/tests/functional/adapter/grants/test_grants.py b/tests/functional/adapter/grants/test_grants.py index 3494c2f..19653fa 100644 --- a/tests/functional/adapter/grants/test_grants.py +++ b/tests/functional/adapter/grants/test_grants.py @@ -12,7 +12,10 @@ class TestIncrementalGrantsExasol(BaseIncrementalGrants): class TestInvalidGrantsExasol(BaseInvalidGrants): def grantee_does_not_exist_error(self): - return "user or role 'INVALID_USER' does not exist" + # Exasol versions have different error messages: + # Exasol 7: "user or role 'INVALID_USER does not exist" + # Exasol 8: "user or role INVALID_USER does not exist" + return "does not exist" def privilege_does_not_exist_error(self): return "syntax error, unexpected ON_, expecting ',' or TO_ [line 3, column 34]" diff --git a/tests/functional/adapter/test_basic.py b/tests/functional/adapter/test_basic.py index 9985093..5fafb9b 100644 --- a/tests/functional/adapter/test_basic.py +++ b/tests/functional/adapter/test_basic.py @@ -77,6 +77,16 @@ def dbt_profile_target(self): } class TestDocsGenReferencesExasol(BaseDocsGenReferences): + + # TODO: + # Exasol 8 throws this error, don't know yet where difference comes from: + # AssertionError("Key 'columns' in 'model.test.model' did not match\n + # assert {'EMAIL': {'c...) UTF8'}, ...} == {'EMAIL': {'c...) UTF8'}, ...}\n Omitting 4 identical items, use -vv to show\n Differing items:\n + # {'UPDATED_AT': {'comment': None, 'index': 5, + # 'name': 'UPDATED_AT', + # 'type': 'TIMESTAMP(3)'}} != + # {'UPDATED_AT': {'comment': None, 'index': , + # 'name': 'UPDATED_AT', 'type': 'TIMESTAMP'}}\n Use -v to get more diff") @pytest.fixture(scope="class") def dbt_profile_target(self): From 4ea336be28751f1eea4a72de670d24c149ee7536 Mon Sep 17 00:00:00 2001 From: Marvin Froemming Date: Fri, 3 Nov 2023 11:42:48 +0100 Subject: [PATCH 2/2] add EXASOL_RELEASE env var and condition in test, 100% test passing rate --- test.env | 2 ++ tests/functional/adapter/test_basic.py | 50 +++++++++++++++++++------- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/test.env b/test.env index 51ce80b..efdf883 100644 --- a/test.env +++ b/test.env @@ -5,3 +5,5 @@ DBT_PASS=. DBT_TEST_USER_1=dbt_test_role_1 DBT_TEST_USER_2=dbt_test_role_2 DBT_TEST_USER_3=dbt_test_role_3 + +EXASOL_RELEASE=8 diff --git a/tests/functional/adapter/test_basic.py b/tests/functional/adapter/test_basic.py index 5fafb9b..1462532 100644 --- a/tests/functional/adapter/test_basic.py +++ b/tests/functional/adapter/test_basic.py @@ -14,7 +14,11 @@ from dbt.tests.adapter.basic.test_snapshot_timestamp import BaseSnapshotTimestamp from dbt.tests.adapter.basic.test_validate_connection import BaseValidateConnection from test_docs_generate import (BaseDocsGenerate, BaseDocsGenReferences) - +from expected_catalog import ( + base_expected_catalog, + no_stats, + expected_references_catalog, +) class TestSimpleMaterializationsExasol(BaseSimpleMaterializations): pass @@ -75,19 +79,25 @@ def dbt_profile_target(self): "dbname": "DB", "timestamp_format": "YYYY-MM-DD HH:MI:SS.FF6" } + + @pytest.fixture(scope="class") + def expected_catalog(self, project, unique_schema): + return base_expected_catalog( + project, + role=unique_schema.upper(), + id_type="DECIMAL(18,0)", + text_type="VARCHAR(2000000) UTF8", + time_type="TIMESTAMP(3)" if os.getenv('EXASOL_RELEASE', "8") == "8" else "TIMESTAMP", + view_type="VIEW", + table_type="TABLE", + model_stats=no_stats(), + case=lambda x: x.upper(), + case_columns=True + ) -class TestDocsGenReferencesExasol(BaseDocsGenReferences): - # TODO: - # Exasol 8 throws this error, don't know yet where difference comes from: - # AssertionError("Key 'columns' in 'model.test.model' did not match\n - # assert {'EMAIL': {'c...) UTF8'}, ...} == {'EMAIL': {'c...) UTF8'}, ...}\n Omitting 4 identical items, use -vv to show\n Differing items:\n - # {'UPDATED_AT': {'comment': None, 'index': 5, - # 'name': 'UPDATED_AT', - # 'type': 'TIMESTAMP(3)'}} != - # {'UPDATED_AT': {'comment': None, 'index': , - # 'name': 'UPDATED_AT', 'type': 'TIMESTAMP'}}\n Use -v to get more diff") - + +class TestDocsGenReferencesExasol(BaseDocsGenReferences): @pytest.fixture(scope="class") def dbt_profile_target(self): return { @@ -99,6 +109,22 @@ def dbt_profile_target(self): "dbname": "DB", "timestamp_format": "YYYY-MM-DD HH:MI:SS.FF6" } + + @pytest.fixture(scope="class") + def expected_catalog(self, project, unique_schema): + return expected_references_catalog( + project, + role=unique_schema.upper(), + id_type="DECIMAL(18,0)", + text_type="VARCHAR(2000000) UTF8", + time_type="TIMESTAMP(3)" if os.getenv('EXASOL_RELEASE', "8") == "8" else "TIMESTAMP", + bigint_type="DECIMAL(18,0)", + view_type="VIEW", + table_type="TABLE", + model_stats=no_stats(), + case=lambda x: x.upper(), + case_columns=True + ) class TestBaseIncrementalNotSchemaChangeExasol(BaseIncrementalNotSchemaChange): pass \ No newline at end of file