Skip to content

Commit

Permalink
perf(BigQuery): pass table_id as str type (#23141)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan824 committed Jul 4, 2022
1 parent 37ea530 commit fe13eae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/hooks/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ def delete_table(
:param project_id: the project used to perform the request
"""
self.get_client(project_id=project_id).delete_table(
table=Table.from_string(table_id),
table=table_id,
not_found_ok=not_found_ok,
)
self.log.info('Deleted table %s', table_id)
Expand Down
10 changes: 4 additions & 6 deletions tests/providers/google/cloud/hooks/test_bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 +474,12 @@ def test_list_rows_with_empty_selected_fields(self, mock_client, mock_table):
start_index=5,
)

@mock.patch("airflow.providers.google.cloud.hooks.bigquery.Table")
@mock.patch("airflow.providers.google.cloud.hooks.bigquery.Client")
def test_run_table_delete(self, mock_client, mock_table):
source_project_dataset_table = f"{PROJECT_ID}.{DATASET_ID}.{TABLE_ID}"
self.hook.run_table_delete(source_project_dataset_table, ignore_if_missing=False)
mock_table.from_string.assert_called_once_with(source_project_dataset_table)
def test_run_table_delete(self, mock_client):
source_dataset_table = f"{DATASET_ID}.{TABLE_ID}"
self.hook.run_table_delete(source_dataset_table, ignore_if_missing=False)
mock_client.return_value.delete_table.assert_called_once_with(
table=mock_table.from_string.return_value, not_found_ok=False
table=source_dataset_table, not_found_ok=False
)

@mock.patch("airflow.providers.google.cloud.hooks.bigquery.BigQueryHook.create_empty_table")
Expand Down

0 comments on commit fe13eae

Please sign in to comment.