Skip to content

Commit

Permalink
Fix execute signature based on core (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
nssalian authored May 9, 2023
1 parent 2c52b30 commit 52a666e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230509-143721.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Update signature for execute method
time: 2023-05-09T14:37:21.163869-07:00
custom:
Author: nssalian
Issue: ''' '''
8 changes: 6 additions & 2 deletions dbt/adapters/redshift/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,16 @@ def exponential_backoff(attempt: int):
)

def execute(
self, sql: str, auto_begin: bool = False, fetch: bool = False
self,
sql: str,
auto_begin: bool = False,
fetch: bool = False,
limit: Optional[int] = None,
) -> Tuple[AdapterResponse, agate.Table]:
_, cursor = self.add_query(sql, auto_begin)
response = self.get_response(cursor)
if fetch:
table = self.get_result_from_cursor(cursor)
table = self.get_result_from_cursor(cursor, limit)
else:
table = dbt.clients.agate_helper.empty_table()
return response, table
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_redshift_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def test_execute_with_fetch(self):
mock_get_result_from_cursor.return_value = table
self.adapter.connections.execute(sql="select * from test", fetch=True)
mock_add_query.assert_called_once_with("select * from test", False)
mock_get_result_from_cursor.assert_called_once_with(cursor)
mock_get_result_from_cursor.assert_called_once_with(cursor, None)
mock_get_response.assert_called_once_with(cursor)

def test_execute_without_fetch(self):
Expand Down

0 comments on commit 52a666e

Please sign in to comment.