From a5ecca2bf0cae375e0b6650e0d0ffe0febdb5b9b Mon Sep 17 00:00:00 2001 From: Ravjot Brar <83892020+ravjotbrar@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:01:04 -0800 Subject: [PATCH] Fix test failures (#217) ### Summary Tests were failing due to changes to dremio and updating fetch in our adapter. ### Description Modified a utility method provided by dbt-core to fetch test results as they're required in some cases. Also changed the error message returned by invalid grants. ### Test Results All tests ran ### Changelog N/A --- dbt/adapters/dremio/impl.py | 23 +++++++++++++++++++ .../functional/adapter/basic/test_base_mat.py | 1 - .../dremio_specific/test_schema_parsing.py | 2 +- .../adapter/grants/test_invalid_grants.py | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/dbt/adapters/dremio/impl.py b/dbt/adapters/dremio/impl.py index 9baffc5..7d45ede 100644 --- a/dbt/adapters/dremio/impl.py +++ b/dbt/adapters/dremio/impl.py @@ -138,6 +138,29 @@ def standardize_grants_dict(self, grants_table: agate.Table) -> dict: grants_dict.update({privilege: [grantee]}) return grants_dict + # This is for use in the test suite + # Need to override to add fetch to the execute method + def run_sql_for_tests(self, sql, fetch, conn): + cursor = conn.handle.cursor() + try: + cursor.execute(sql, None, True) + if hasattr(conn.handle, "commit"): + conn.handle.commit() + if fetch == "one": + return cursor.fetchone() + elif fetch == "all": + return cursor.fetchall() + else: + return + except BaseException as e: + if conn.handle and not getattr(conn.handle, "closed", True): + conn.handle.rollback() + print(sql) + print(e) + raise + finally: + conn.transaction_open = False + COLUMNS_EQUAL_SQL = """ with diff_count as ( diff --git a/tests/functional/adapter/basic/test_base_mat.py b/tests/functional/adapter/basic/test_base_mat.py index 3654392..c521bda 100644 --- a/tests/functional/adapter/basic/test_base_mat.py +++ b/tests/functional/adapter/basic/test_base_mat.py @@ -96,7 +96,6 @@ def dbt_profile_data( return profile def test_base(self, project): - # seed command results = run_dbt(["seed"]) # seed result length diff --git a/tests/functional/adapter/dremio_specific/test_schema_parsing.py b/tests/functional/adapter/dremio_specific/test_schema_parsing.py index 40b43ea..5e5aff0 100644 --- a/tests/functional/adapter/dremio_specific/test_schema_parsing.py +++ b/tests/functional/adapter/dremio_specific/test_schema_parsing.py @@ -32,7 +32,7 @@ def update_config_file(self, updates, *paths): def test_schema_with_dots(self, project): self.update_config_file( - {"object_storage_path": 'dbtdremios3."test.dot"'}, + {"object_storage_path": 'dbtdremios3."test.schema"'}, project.profiles_dir, "profiles.yml", ) diff --git a/tests/functional/adapter/grants/test_invalid_grants.py b/tests/functional/adapter/grants/test_invalid_grants.py index 030bd64..5668919 100644 --- a/tests/functional/adapter/grants/test_invalid_grants.py +++ b/tests/functional/adapter/grants/test_invalid_grants.py @@ -21,7 +21,7 @@ class TestInvalidGrantsDremio(BaseGrantsDremio, BaseInvalidGrants): def grantee_does_not_exist_error(self): - return "StatusRuntimeException: INTERNAL" + return "Grant on catalog entity failed. User invalid_user does not exist." def privilege_does_not_exist_error(self): return 'Encountered "fake_privilege"'