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
Original file line number Diff line number Diff line change
Expand Up @@ -1990,18 +1990,19 @@ def _format_schema_for_description(schema: dict) -> list:
internal_size, precision, scale, null_ok.
"""
description = []
for field in schema["fields"]:
mode = field.get("mode", "NULLABLE")
field_description = (
field["name"],
field["type"],
None,
None,
None,
None,
mode == "NULLABLE",
)
description.append(field_description)
if "fields" in schema:
for field in schema["fields"]:
mode = field.get("mode", "NULLABLE")
field_description = (
field["name"],
field["type"],
None,
None,
None,
None,
mode == "NULLABLE",
)
description.append(field_description)
return description


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,11 @@ def test_format_schema_for_description(self):
("field_3", "STRING", None, None, None, None, False),
]

def test_format_schema_for_description_no_fields_key(self):
test_query_result = {"schema": {}}
description = _format_schema_for_description(test_query_result["schema"])
assert description == []

@mock.patch("airflow.providers.google.cloud.hooks.bigquery.build")
@mock.patch("airflow.providers.google.cloud.hooks.bigquery.BigQueryHook.insert_job")
def test_description(self, mock_insert, mock_build):
Expand Down
Loading