Lee-W commented on code in PR #42668:
URL: https://github.com/apache/airflow/pull/42668#discussion_r1805988063
##########
providers/src/airflow/providers/databricks/hooks/databricks_sql.py:
##########
@@ -180,6 +196,7 @@ def run(
self,
sql: str | Iterable[str],
autocommit: bool = ...,
+ execution_timeout: timedelta | None = ...,
Review Comment:
It would be better for us to add it as the last argument or keyword only
argument to avoid breaking change
##########
providers/tests/databricks/hooks/test_databricks_sql.py:
##########
@@ -236,67 +298,51 @@ def test_query(
return_last,
split_statements,
sql,
+ execution_timeout,
cursor_calls,
return_tuple,
cursor_descriptions,
cursor_results,
hook_descriptions,
hook_results,
+ mock_get_conn,
+ mock_get_requests,
):
- with (
-
patch("airflow.providers.databricks.hooks.databricks_sql.DatabricksSqlHook.get_conn")
as mock_conn,
- patch("airflow.providers.databricks.hooks.databricks_base.requests")
as mock_requests,
- ):
- mock_requests.codes.ok = 200
- mock_requests.get.return_value.json.return_value = {
- "endpoints": [
- {
- "id": "1264e5078741679a",
- "name": "Test",
- "odbc_params": {
- "hostname": "xx.cloud.databricks.com",
- "path": "/sql/1.0/endpoints/1264e5078741679a",
- },
- }
- ]
- }
- status_code_mock = mock.PropertyMock(return_value=200)
- type(mock_requests.get.return_value).status_code = status_code_mock
- connections = []
- cursors = []
- for index in range(len(cursor_descriptions)):
- conn = mock.MagicMock()
- cur = mock.MagicMock(
- rowcount=len(cursor_results[index]),
-
description=get_cursor_descriptions(cursor_descriptions[index]),
- )
- cur.fetchall.return_value = cursor_results[index]
- conn.cursor.return_value = cur
- cursors.append(cur)
- connections.append(conn)
- mock_conn.side_effect = connections
-
- if not return_tuple:
- with pytest.warns(
- AirflowProviderDeprecationWarning,
- match="""Returning a raw `databricks.sql.Row` object is
deprecated. A namedtuple will be
+ connections = []
+ cursors = []
+ for index in range(len(cursor_descriptions)):
Review Comment:
```suggestion
for index, cursor_description in enumerate(cursor_descriptions):
```
##########
providers/tests/databricks/hooks/test_databricks_sql.py:
##########
@@ -236,67 +298,51 @@ def test_query(
return_last,
split_statements,
sql,
+ execution_timeout,
cursor_calls,
return_tuple,
cursor_descriptions,
cursor_results,
hook_descriptions,
hook_results,
+ mock_get_conn,
+ mock_get_requests,
):
- with (
-
patch("airflow.providers.databricks.hooks.databricks_sql.DatabricksSqlHook.get_conn")
as mock_conn,
- patch("airflow.providers.databricks.hooks.databricks_base.requests")
as mock_requests,
- ):
- mock_requests.codes.ok = 200
- mock_requests.get.return_value.json.return_value = {
- "endpoints": [
- {
- "id": "1264e5078741679a",
- "name": "Test",
- "odbc_params": {
- "hostname": "xx.cloud.databricks.com",
- "path": "/sql/1.0/endpoints/1264e5078741679a",
- },
- }
- ]
- }
- status_code_mock = mock.PropertyMock(return_value=200)
- type(mock_requests.get.return_value).status_code = status_code_mock
- connections = []
- cursors = []
- for index in range(len(cursor_descriptions)):
- conn = mock.MagicMock()
- cur = mock.MagicMock(
- rowcount=len(cursor_results[index]),
-
description=get_cursor_descriptions(cursor_descriptions[index]),
- )
- cur.fetchall.return_value = cursor_results[index]
- conn.cursor.return_value = cur
- cursors.append(cur)
- connections.append(conn)
- mock_conn.side_effect = connections
-
- if not return_tuple:
- with pytest.warns(
- AirflowProviderDeprecationWarning,
- match="""Returning a raw `databricks.sql.Row` object is
deprecated. A namedtuple will be
+ connections = []
+ cursors = []
+ for index in range(len(cursor_descriptions)):
+ conn = mock.MagicMock()
+ cur = mock.MagicMock(
+ rowcount=len(cursor_results[index]),
+ description=get_cursor_descriptions(cursor_descriptions[index]),
Review Comment:
```suggestion
description=get_cursor_descriptions(cursor_description),
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]