This runs a Dataflow pipeline that reads a table already sitting in BigQuery, processes it with a Python script using Apache Beam, and writes the result into a Cloud Storage bucket. It is a useful third variation alongside the other two Dataflow guides in this series, ETL Processing With Dataflow and BigQuery reads from a file and writes into BigQuery, and Pub/Sub Stream Processing With Dataflow reads a continuous stream of messages, while this one starts from data that is already a BigQuery table.
This walks through querying the source table directly in BigQuery first, then running the same underlying data through a Dataflow pipeline that finds Java projects with a high ratio of comments suggesting they need help, such as TODO or FIXME notes.
Open the console, then the menu, then BigQuery.

SELECT
content
FROM
fh-bigquery.github_extracts.contents_java_2016
LIMIT
10
Click Run.

It will display the results.

SELECT
COUNT(*)
FROM
fh-bigquery.github_extracts.contents_java_2016
Click Run.

This gives you the total number of rows in the table.

Activate Cloud Shell, then run:
git clone https://github.com/GoogleCloudPlatform/training-data-analyst

ls

Create a bucket in the console first, using the same name as your project ID, then set it as a variable in Cloud Shell:
BUCKET=”your-bucket-name”
echo $BUCKET

cd training-data-analyst/courses/data_analysis/lab2/python
ls
The lab files will be displayed.

nano JavaProjectsThatNeedHelp.py

This is a good point to actually read through the script before running it, so you know what it is doing to the data rather than just running it blind.
Exit with control x.

python3 JavaProjectsThatNeedHelp.py –bucket $BUCKET –project $DEVSHELL_PROJECT_ID –DataFlowRunner
This specific lab script expects that exact set of arguments, bucket and project as regular flags, with DataFlowRunner as a separate flag that switches it from running locally to running on Dataflow. If your copy of the script has been updated since this was written, check its own argument parser for the current flag names before assuming the command is wrong.

Go to DataFlow > Jobs The jobs will be running

Open the running job

Watch its progress.

Once finished, the job shows a Succeeded status.

Open the menu, then Cloud Storage, then your bucket.

Open the javahelp folder.

The pipeline’s output is stored there.

Across this series, the three Dataflow examples cover the three common shapes a pipeline’s source and destination can take. ETL Processing With Dataflow and BigQuery reads a file and writes into BigQuery. Pub/Sub Stream Processing With Dataflow reads a continuous stream and writes to Cloud Storage. This one reads a table already inside BigQuery and writes back out to Cloud Storage, showing that Dataflow treats BigQuery as just another data source, not only a destination.
That covers running a Dataflow pipeline against a BigQuery source table and writing its output to Cloud Storage. To go further, explore Prwatech’s Google Cloud training program, which includes placement assistance.