Skip to main content

Create Materialized Views

πŸ“„ <ENV> - [BigQuery] Create BigQuery Materialized View​

This GitHub Actions workflow is designed to manually trigger the creation of a BigQuery Materialized View using a TypeScript helper script. It authenticates with GCP using a service account and runs the logic defined in the specified TypeScript file.


πŸ“Œ Workflow Trigger​

This workflow is triggered manually via the GitHub actions in functions repo

Required Input:​

  • table_name (string): The BigQuery latest table name for which the materialized view should be created.

πŸ’  Environment Variables​

VariableDescription
GCP_PROJECT_IDGCP Project ID (e.g., biddirect-2)
TABLE_NAMEName of the latest BigQuery table (input)


πŸš€ Job: deploy-bigquery-materialized-view​

StepDescription
Checkout repositoryClones the repo.
Set project env variableStores the GCP project ID in the GitHub Actions environment.
Set table name variableStores the input table_name in the GitHub Actions environment.
Authenticate with GCPAuthenticates using a service account (ENV_BIGQUERY_ADMIN_SERVICE_ACCOUNT) stored in GitHub Secrets.
Set up Cloud SDKInstalls and sets up the Google Cloud SDK CLI.
Install dependenciesRuns npm install inside the functions directory.
Create materialized viewExecutes the helper script createMaterializedView.ts using npx ts-node.

🧹 Script Location​

The script responsible for creating the BigQuery Materialized View is located at:

functions/src/bqDataLake/definitions/views/helpers/createMaterializedView.ts

Make sure this script handles:

  • Connecting to BigQuery using the provided credentials.
  • Creating the desired materialized view using the given TABLE_NAME.

πŸ” Required Secrets​

Secret NameDescription
<ENV>_BIGQUERY_ADMIN_SERVICE_ACCOUNTService account key JSON for GCP auth.

βœ… Example Usage​

To run this workflow:

  1. Go to the Actions tab in your GitHub repository.
  2. Select the workflow <ENV> - [BigQuery] Create BigQuery Materialized View.
  3. Enter the table_name (e.g., accounts_latest).
  4. Click "Run workflow".