Bigtable to JSON template

The Bigtable to JSON template is a pipeline that reads data from a Bigtable table and writes it to a Cloud Storage bucket in the JSON format.

Pipeline requirements

  • The Bigtable table must exist.
  • The output Cloud Storage bucket must exist before you run the pipeline.

Template parameters

Required parameters

  • bigtableProjectId : The ID for the Google Cloud project that contains the Bigtable instance that you want to read data from.
  • bigtableInstanceId : The ID of the Bigtable instance that contains the table.
  • bigtableTableId : The ID of the Bigtable table to read from.
  • outputDirectory : The Cloud Storage path where the output JSON files are stored. (Example: gs://your-bucket/your-path/).

Optional parameters

  • filenamePrefix : The prefix of the JSON file name. For example, "table1-". If no value is provided, defaults to part.
  • userOption : Possible values are FLATTEN or NONE. FLATTEN flattens the row to the single level. NONE stores the whole row as a JSON string. Defaults to NONE.
  • columnsAliases : A comma-separated list of columns that are required for the Vertex AI Vector Search index. The columns id and embedding are required for Vertex AI Vector Search. You can use the notation fromfamily:fromcolumn;to. For example, if the columns are rowkey and cf:my_embedding, where rowkey has a different name than the embedding column, specify cf:my_embedding;embedding and, rowkey;id. Only use this option when the value for userOption is FLATTEN.
  • bigtableAppProfileId : The ID of the Bigtable application profile to use for the export. If you don't specify an app profile, Bigtable uses the instance's default app profile: https://cloud.google.com/bigtable/docs/app-profiles#default-app-profile.

Run the template

Console

  1. Go to the Dataflow Create job from template page.
  2. Go to Create job from template
  3. In the Job name field, enter a unique job name.
  4. Optional: For Regional endpoint, select a value from the drop-down menu. The default region is us-central1.

    For a list of regions where you can run a Dataflow job, see Dataflow locations.

  5. From the Dataflow template drop-down menu, select the Bigtable to JSON template.
  6. In the provided parameter fields, enter your parameter values.
  7. Click Run job.

gcloud CLI

In your shell or terminal, run the template:

gcloud dataflow jobs run JOB_NAME \
    --gcs-location=gs://dataflow-templates-REGION_NAME/VERSION/Cloud_Bigtable_to_GCS_Json \
    --project=PROJECT_ID \
    --region=REGION_NAME \
    --parameters \
       bigtableProjectId=BIGTABLE_PROJECT_ID,\
       bigtableInstanceId=BIGTABLE_INSTANCE_ID,\
       bigtableTableId=BIGTABLE_TABLE_ID,\
       filenamePrefix=FILENAME_PREFIX,\

Replace the following:

  • JOB_NAME: a unique job name of your choice
  • VERSION: the version of the template that you want to use

    You can use the following values:

  • REGION_NAME: the region where you want to deploy your Dataflow job—for example, us-central1
  • BIGTABLE_PROJECT_ID: the Project ID
  • BIGTABLE_INSTANCE_ID: the Instance ID
  • BIGTABLE_TABLE_ID: the Table ID
  • FILENAME_PREFIX: the JSON file prefix

API

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/Cloud_Bigtable_to_GCS_Json
{
   "jobName": "JOB_NAME",
   "parameters": {
     "bigtableProjectId": "BIGTABLE_PROJECT_ID",
     "bigtableInstanceId": "BIGTABLE_INSTANCE_ID",
     "bigtableTableId": "BIGTABLE_TABLE_ID",
     "filenamePrefix": "FILENAME_PREFIX",
   },
   "environment": { "maxWorkers": "10" }
}

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
  • VERSION: the version of the template that you want to use

    You can use the following values:

  • LOCATION: the region where you want to deploy your Dataflow job—for example, us-central1
  • BIGTABLE_PROJECT_ID: the Project ID
  • BIGTABLE_INSTANCE_ID: the Instance ID
  • BIGTABLE_TABLE_ID: the Table ID
  • FILENAME_PREFIX: the JSON file prefix

What's next