Ejemplo n.º 1
0
    def test_execute(self, mock_hook):
        operator = BigQueryGetDatasetTablesOperator(
            task_id=TASK_ID, dataset_id=TEST_DATASET, project_id=TEST_GCP_PROJECT_ID, max_results=2
        )

        operator.execute(None)
        mock_hook.return_value.get_dataset_tables.assert_called_once_with(
            dataset_id=TEST_DATASET,
            project_id=TEST_GCP_PROJECT_ID,
            max_results=2,
        )
Ejemplo n.º 2
0
                "type": "INTEGER",
                "mode": "NULLABLE"
            },
        ],
    )

    create_view = BigQueryCreateEmptyTableOperator(
        task_id="create_view",
        dataset_id=LOCATION_DATASET_NAME,
        table_id="test_view",
        view={
            "query": "SELECT * FROM `{}.test_table`".format(DATASET_NAME),
            "useLegacySql": False
        })

    get_empty_dataset_tables = BigQueryGetDatasetTablesOperator(
        task_id="get_empty_dataset_tables", dataset_id=DATASET_NAME)

    get_dataset_tables = BigQueryGetDatasetTablesOperator(
        task_id="get_dataset_tables", dataset_id=DATASET_NAME)

    delete_view = BigQueryDeleteTableOperator(
        task_id="delete_view",
        deletion_dataset_table="{}.test_view".format(DATASET_NAME))

    delete_table = BigQueryDeleteTableOperator(
        task_id="delete_table",
        deletion_dataset_table="{}.test_table".format(DATASET_NAME))

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