Skip to content
Merged
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
2 changes: 2 additions & 0 deletions airflow/providers/databricks/hooks/databricks_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ def _make_common_data_structure(self, result: Sequence[Row] | Row) -> list[tuple
# instantiated namedtuple, and will never do: https://github.com/python/mypy/issues/848
if isinstance(result, list):
rows: list[Row] = result
if not rows:
return []
rows_fields = rows[0].__fields__
rows_object = namedtuple("Row", rows_fields) # type: ignore[misc]
return cast(List[tuple], [rows_object(*row) for row in rows])
Expand Down
16 changes: 14 additions & 2 deletions tests/providers/databricks/hooks/test_databricks_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,23 @@ def get_cursor_descriptions(fields: list[str]) -> list[tuple[str]]:
["select * from test.test"],
True,
[["id", "value"]],
(Row(id=1, value=2),),
([Row(id=1, value=2)],),
[[("id",), ("value",)]],
SerializableRow(1, 2),
[SerializableRow(1, 2)],
id="The return_last set and no split statements set on single query in string",
),
pytest.param(
True,
False,
"select * from test.test",
["select * from test.test"],
True,
[["id", "value"]],
([],),
[[("id",), ("value",)]],
[],
id="Empty list",
),
],
)
def test_query(
Expand Down