def test_execute(self, mock_hook): table_resource = {"friendlyName": 'Test TB'} operator = BigQueryUpdateTableOperator( table_resource=table_resource, task_id=TASK_ID, dataset_id=TEST_DATASET, table_id=TEST_TABLE_ID, project_id=TEST_GCP_PROJECT_ID, ) operator.execute(None) mock_hook.return_value.update_table.assert_called_once_with( table_resource=table_resource, fields=None, dataset_id=TEST_DATASET, table_id=TEST_TABLE_ID, project_id=TEST_GCP_PROJECT_ID, )
bash_command= "echo \"{{ task_instance.xcom_pull('get-dataset')['id'] }}\"", ) # [START howto_operator_bigquery_update_table] update_table = BigQueryUpdateTableOperator( task_id="update_table", dataset_id=DATASET_NAME, table_id="test_table", fields=[ { "name": "emp_name", "type": "STRING", "mode": "REQUIRED" }, { "name": "salary", "type": "INTEGER", "mode": "NULLABLE" }, ], table_resource={ "friendlyName": "Updated Table", "description": "Updated Table", }, ) # [END howto_operator_bigquery_update_table] # [START howto_operator_bigquery_update_dataset] update_dataset = BigQueryUpdateDatasetOperator( task_id="update_dataset",
# [START howto_operator_bigquery_get_dataset] get_dataset = BigQueryGetDatasetOperator(task_id="get-dataset", dataset_id=DATASET_NAME) # [END howto_operator_bigquery_get_dataset] get_dataset_result = BashOperator( task_id="get_dataset_result", bash_command="echo \"{{ task_instance.xcom_pull('get-dataset')['id'] }}\"", ) # [START howto_operator_bigquery_update_table] update_table = BigQueryUpdateTableOperator( task_id="update_table", dataset_id=DATASET_NAME, table_id="test_table", fields=["emp_name", "salary"], table_resource={ "friendlyName": "Updated Table", "description": "Updated Table", }, ) # [END howto_operator_bigquery_update_table] # [START howto_operator_bigquery_update_dataset] update_dataset = BigQueryUpdateDatasetOperator( task_id="update_dataset", dataset_id=DATASET_NAME, dataset_resource={"description": "Updated dataset"}, ) # [END howto_operator_bigquery_update_dataset] # [START howto_operator_bigquery_delete_dataset]