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

fix(hooks/exasol): handle non resultSet query result types #25227

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions airflow/providers/exasol/hooks/exasol.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ def run(
with closing(conn.execute(query, parameters)) as cur:
results = []

if cur.result_type != "resultSet":
# can't be iterated over
break

if handler is not None:
cur = handler(cur)

Expand Down
9 changes: 9 additions & 0 deletions tests/providers/exasol/hooks/test_exasol.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ def test_run_no_queries(self):
self.db_hook.run(sql=[])
assert err.value.args[0] == "List of SQL statements is empty"

def test_no_result_set(self):
"""Queries like DROP and SELECT are of type rowCount (not resultSet),
which raises an error in pyexasol if trying to iterate over them"""
self.cur.result_type = mock.Mock()
self.cur.result_type.return_value = 'rowCount'

sql = 'SQL'
self.db_hook.run(sql)

def test_bulk_load(self):
with pytest.raises(NotImplementedError):
self.db_hook.bulk_load('table', '/tmp/file')
Expand Down