Create and run a workflow in Dataform
This quickstart walks you through the following process in Dataform to create a workflow and run it in BigQuery:
Before you begin
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Verify that billing is enabled for your Google Cloud project .
-
Enable the BigQuery and Dataform APIs.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Verify that billing is enabled for your Google Cloud project .
-
Enable the BigQuery and Dataform APIs.
Required roles
To get the permissions that you need to create and run a workflow in Dataform, ask your administrator to grant you the following IAM roles on the project that will host your Dataform repository:
- Create and manage repositories, workspaces, and workflow invocations: Dataform Admin
(
roles/dataform.admin
) - Run workflows in BigQuery:
- BigQuery Data Editor
(
roles/bigquery.dataEditor
) - BigQuery Job User
(
roles/bigquery.jobUser
)
- BigQuery Data Editor
(
For more information about granting roles, see Manage access to projects, folders, and organizations .
You might also be able to get the required permissions through custom roles or other predefined roles .
Create a Dataform repository
-
In the Google Cloud console, go to the Dataformpage.
-
Click Create repository.
-
On the Create repositorypage, do the following:
-
In the Repository IDfield, enter
quickstart-repository
. -
In the Regionlist, select
europe-west4
. -
Click Create.
-
Create and initialize a Dataform development workspace
-
In the Google Cloud console, go to the Dataformpage.
-
Click
quickstart-repository
. -
Click Create development workspace.
-
In the Create development workspacewindow, do the following:
-
In the Workspace IDfield, enter
quickstart-workspace
. -
Click Create.
The development workspace page appears.
-
-
Click Initialize workspace.
Create a view
In the following sections, you define a view that you will later use as a data source for a table.
Create a SQLX file for defining a view
-
In the Filespane, next to
definitions/
, click the Moremenu. -
Click Create file.
-
In the Create new filepane, do the following:
-
In the Add a file pathfield, enter
definitions/quickstart-source.sqlx
. -
Click Create file.
-
Define a view
-
In the Filespane, expand the definitions folder.
-
Click
definitions/quickstart-source.sqlx
. -
In the file, enter the following code snippet:
config { type : "view" } SELECT "apples" AS fruit , 2 AS count UNION ALL SELECT "oranges" AS fruit , 5 AS count UNION ALL SELECT "pears" AS fruit , 1 AS count UNION ALL SELECT "bananas" AS fruit , 0 AS count
-
Click Format.
Create a table
In the following sections, you define the table type in a SQLX file, and then
write a SELECT
statement to define the table structure within the same file.
Create a SQLX file for table definition
-
In the Filespane, next to
definitions/
, click the Moremenu, and then select Create file. -
In the Add a file pathfield, enter
definitions/quickstart-table.sqlx
. -
Click Create file.
Define the table type, structure and dependencies
-
In the Filespane, expand the
definitions/
directory. -
Select
quickstart-table.sqlx
, and then enter the following table type andSELECT
statement:config { type : "table" } SELECT fruit , SUM ( count ) as count FROM ${ ref ( "quickstart-source" ) } GROUP BY 1
-
Click Format.
After defining the table type, Dataform throws a query validation error
because quickstart-source
does not exist in BigQuery yet. This
error is resolved when you run the workflow later in this tutorial.
Run the workflow in BigQuery
-
In the Google Cloud console, go to the Dataformpage.
-
On the
quickstart-workspace
page, click Start execution. -
Click All actions.
-
Click Start execution.
-
In the dialog that opens, click Allowto give permission to BigQuery Pipelinesto access your Google Account.
Dataform uses the default repository settings to create the contents of your workflow in a BigQuery dataset called
dataform
.
View execution logs in Dataform
-
On the
quickstart-repository
page, click Workflow Execution Logs. -
To view details of your execution, click the latest execution.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.
Delete the dataset created in BigQuery
To avoid incurring charges for BigQuery assets, delete the
dataset called dataform
.
-
In the Google Cloud console, go to the BigQuerypage.
-
In the Explorerpanel, expand your project and select
dataform
. -
Click the Actionsmenu, and then select Delete.
-
In the Delete datasetdialog, enter
delete
into the field, and then click Delete.
Delete the Dataform development workspace
Dataform development workspace creation incurs no costs, but to delete the development workspace you can follow these steps:
-
In the Google Cloud console, go to the Dataformpage.
-
Click
quickstart-repository
. -
In the Development workspacestab, click the Moremenu by
quickstart-workspace
, and then select Delete. -
To confirm, click Delete.
Delete the Dataform repository
Dataform repository creation incurs no costs, but to delete the repository you can follow these steps:
-
In the Google Cloud console, go to the Dataformpage.
-
By
quickstart-repository
, click the Moremenu, and then select Delete. -
In the Delete repositorywindow, enter the name of the repository to confirm deletion.
-
To confirm, click Delete.
What's next
-
To learn more about Dataform, see Dataform overview .
-
To learn more about Dataform features, see Dataform features .
-
To learn more about Dataform core, see Overview of Dataform core .
-
To learn how to override default Dataform settings of your repository, see Configure Dataform workflow settings .
-
To learn more about managing datasets in BigQuery, see Managing datasets .
-
To learn more about managing tables in BigQuery, see Manage tables .