This quickstart shows you how to run a query against some data in BigQuery, then format and email the results.
Objectives
- Find the top 50 presidential candidates who received the most individual donations in the year 2016.
- Format and email the results.
Copying the sample Workflow
- Open the sample Workflow: quickstart_001
- Click on the Copy button at the bottom of the page.
- Click OK when prompted "Do you want to make a copy this workflow?".
- Specify the Workflow ID.
Workflow ID is global and must be unique. The Workflow ID, which must start with a letter, can contain only letters, numbers, and underscores. One way to make your Workflow ID unique is to incorporate your user name into the ID. For example, if your email address is bigquery.user@gmail.com:
- Specify the email address of the report recipient.
- Click Save to save the Workflow.
Running the Workflow
- Click on the Run button to run the Workflow.
- On completion, the report will be sent to the specified recipient email address.
What's next
- Check out quickstart 2 to learn how to parameterize this Workflow to get data for a specified month. You will also learn how to export the BigQuery table to Cloud Storage.
Workflow explained
This Workflow contains 2 core Task Types, namely, the BigQuery Task and Email Task.
- The first BigQuery Task, named get_top_candidates, runs a query against the candidates and contributions tables in BigQuery and get the top 50 presidential candidates who received the most donations.
We specify Table as the Destination Type and left the Destination Table name empty. Thus, the query results will be stored in a BigQuery temporary table. We can then refer to this temporary table very easily in the next Task by the magic parameter in the format of <var_taskId_output>. In this case, since the Task ID is get_top_candidates, we can refer to its output as <var_get_top_candidates_output>. For more on magic parameters, see section Magic Parameters from Parameters documentation.
- The next BigQuery Task simply queries the previously created BigQuery table via the magic parameter reference <var_get_top_candidates_output>, and format the table rows into an HTML code.
The Destination Type this time is a custom parameter named var_report because we want to store the content of report in the parameter and then use it in the email body in the next Task.
Custom parameter is created and managed by user in the Parameters panel.
- Finally, the report content <var_report> is sent by an Email Task in the email body.
View Completed Workflow
A completed version of the workflow in this quickstart can be found at https://magnus.potens.io/?l=cXVpY2tzdGFydF8wMDE=