예제 #1
0
    def test_execute(self, mock_hook):
        dataset_resource = {"friendlyName": 'Test DS'}
        operator = BigQueryPatchDatasetOperator(
            dataset_resource=dataset_resource,
            task_id=TASK_ID,
            dataset_id=TEST_DATASET,
            project_id=TEST_GCP_PROJECT_ID)

        operator.execute(None)
        mock_hook.return_value \
            .get_conn.return_value \
            .cursor.return_value \
            .patch_dataset \
            .assert_called_once_with(
                dataset_resource=dataset_resource,
                dataset_id=TEST_DATASET,
                project_id=TEST_GCP_PROJECT_ID
            )
예제 #2
0
        task_id="delete-table",
        deletion_dataset_table="{}.test_table".format(DATASET_NAME))

    get_dataset = BigQueryGetDatasetOperator(task_id="get-dataset",
                                             dataset_id=DATASET_NAME)

    get_dataset_result = BashOperator(
        task_id="get-dataset-result",
        bash_command=
        "echo \"{{ task_instance.xcom_pull('get-dataset')['id'] }}\"",
    )

    patch_dataset = BigQueryPatchDatasetOperator(
        task_id="patch-dataset",
        dataset_id=DATASET_NAME,
        dataset_resource={
            "friendlyName": "Patched Dataset",
            "description": "Patched dataset"
        },
    )

    update_dataset = BigQueryUpdateDatasetOperator(
        task_id="update-dataset",
        dataset_id=DATASET_NAME,
        dataset_resource={"description": "Updated dataset"})

    delete_dataset = BigQueryDeleteDatasetOperator(task_id="delete-dataset",
                                                   dataset_id=DATASET_NAME,
                                                   delete_contents=True)

    delete_dataset_with_location = BigQueryDeleteDatasetOperator(
        task_id="delete_dataset_with_location",