Skip to content

Commit

Permalink
Fix test failures (#217)
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
ravjotbrar authored Jan 31, 2024
1 parent dee0a2d commit a5ecca2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
23 changes: 23 additions & 0 deletions dbt/adapters/dremio/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
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 @@ -96,7 +96,6 @@ def dbt_profile_data(
return profile

def test_base(self, project):

# seed command
results = run_dbt(["seed"])
# seed result length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/adapter/grants/test_invalid_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"'

0 comments on commit a5ecca2

Please sign in to comment.