How do I chain multiple Google Cloud DataPrep flows?

773 views Asked by At

I've created two Flows in Cloud DataPrep - the first outputs to a BigQuery table and also creates a reference dataset. The second flow takes the reference dataset and processes it further before outputting to a second BigQuery table.

Is it possible to schedule these two Flows to run sequentially? At the moment I have to estimate the time taken for the first flow, and schedule the second one to run XX minutes after the first.

Either a recipe in the first flow to trigger the second, or a way to schedule them in sequence would be ideal.

This question shows how to create a reference dataset, but doesn't explain if it's possible to run them automatically/sequentially.

1

There are 1 answers

0
JSDBroughton On BEST ANSWER

The documentation for reference datasets sort of alludes to the behaviour, but could be clearer.

  • The second flow that uses the first flow as reference dataset WILL RUN the first flow job and therefore use updated data for flow 2.
  • BUT the export to BigQuery would not perform the export from flow 1.

The easiest solution, but not necessarily what you want is that can choose to perform the BigQuery export from Flow 1 in Flow 2, i.e. have a simple recipe that does nothing but host the export job.

The solution I use, where recipes/jobs are stable, is to run the resultant Dataflow jobs rather than use the Dataprep tool itself for execution: Run Job on Cloud Dataflow

You have a few options for scheduling the two Dataflow jobs. (Cloud Scheduler could be a good one - its a new project and I'm looking at replacing custom solution I have right now hosted as Cloud Functions)

In terms of running them in sequence, however, BigQuery doesn't have update event that could trigger Job2 so you can either schedule them long enough apart and hope Job 1 finishes soon enough, OR you can poll the BigQuery table metadata to see if the modified date changes.