This template is deprecated and will be removed in Q3 2023. Please migrate to Firestore Bulk Delete template.
The Datastore Bulk Delete template is a pipeline which reads in Entities from Datastore with a given GQL query and then deletes all matching Entities in the selected target project. The pipeline can optionally pass the JSON encoded Datastore Entities to your Javascript UDF, which you can use to filter out Entities by returning null values.
| Parameter | Description |
|---|---|
datastoreReadGqlQuery |
GQL query which specifies which entities to match for deletion. Using a keys-only query may improve performance. For example: "SELECT __key__ FROM MyKind". |
datastoreReadProjectId |
Project ID of the Datastore instance from which you want to read entities (using your GQL query) that are used for matching. |
datastoreDeleteProjectId |
Project ID of the Datastore instance from which to delete matching entities. This can be the same as datastoreReadProjectId if you want to read and delete within the same Datastore instance. |
datastoreReadNamespace |
(Optional) Namespace of requested Entities. Set as "" for default namespace. |
datastoreHintNumWorkers |
(Optional) Hint for the expected number of workers in the Datastore ramp-up throttling step. Default is 500. |
javascriptTextTransformGcsPath |
(Optional)
The Cloud Storage URI of the .js file that defines the JavaScript user-defined
function (UDF) you want to use. For example, gs://my-bucket/my-udfs/my_file.js.
|
javascriptTextTransformFunctionName |
(Optional)
The name of the JavaScript user-defined function (UDF) that you want to use.
For example, if your JavaScript function code is
myTransform(inJson) { /*...do stuff...*/ }, then the function name is
myTransform. For sample JavaScript UDFs, see
UDF Examples.
If this function returns a value of undefined or null for
a given Datastore entity, then that entity is not deleted. |
us-central1.
For a list of regions where you can run a Dataflow job, see Dataflow locations.
In your shell or terminal, run the template:
gcloud dataflow jobs run JOB_NAME \ --gcs-location gs://dataflow-templates-REGION_NAME/VERSION/ \ --region REGION_NAME \ --parameters \ datastoreReadGqlQuery="GQL_QUERY",\ datastoreReadProjectId=DATASTORE_READ_AND_DELETE_PROJECT_ID,\ datastoreDeleteProjectId=DATASTORE_READ_AND_DELETE_PROJECT_ID
Replace the following:
JOB_NAME:
a unique job name of your choice
REGION_NAME:
the region where you want to
deploy your Dataflow job—for example, us-central1
VERSION:
the version of the template that you want to use
You can use the following values:
latest to use the latest version of the template, which is available in the
non-dated parent folder in the bucket—
gs://dataflow-templates-REGION_NAME/latest/2023-09-12-00_RC00, to use a specific version of the
template, which can be found nested in the respective dated parent folder in the bucket—
gs://dataflow-templates-REGION_NAME/GQL_QUERY: the query you'll use to match entities for deletionDATASTORE_READ_AND_DELETE_PROJECT_ID: your Datastore instance project ID. This example both reads and deletes from the same Datastore instance.To run the template using the REST API, send an HTTP POST request. For more information on the
API and its authorization scopes, see
projects.templates.launch.
POST https://dataflow.googleapis.com/v1b3/projects/PROJECT_ID/locations/LOCATION/templates:launch?gcsPath=gs://dataflow-templates-LOCATION/VERSION/ { "jobName": "JOB_NAME", "parameters": { "datastoreReadGqlQuery": "GQL_QUERY", "datastoreReadProjectId": "DATASTORE_READ_AND_DELETE_PROJECT_ID", "datastoreDeleteProjectId": "DATASTORE_READ_AND_DELETE_PROJECT_ID" }, "environment": { "zone": "us-central1-f" } } }
Replace the following:
PROJECT_ID:
the Google Cloud project ID where you want to run the Dataflow job
JOB_NAME:
a unique job name of your choice
LOCATION:
the region where you want to
deploy your Dataflow job—for example, us-central1
VERSION:
the version of the template that you want to use
You can use the following values:
latest to use the latest version of the template, which is available in the
non-dated parent folder in the bucket—
gs://dataflow-templates-REGION_NAME/latest/2023-09-12-00_RC00, to use a specific version of the
template, which can be found nested in the respective dated parent folder in the bucket—
gs://dataflow-templates-REGION_NAME/GQL_QUERY: the query you'll use to match entities for deletionDATASTORE_READ_AND_DELETE_PROJECT_ID: your Datastore instance project ID. This example both reads and deletes from the same Datastore instance.Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-06-09 UTC.