Google BigQuery
Loads data from a BigQuery table using timestamp-based tracking and scheduled ingestion.
Sync Type: Incremental
Overview
The BigQuery Input allows you to read data from BigQuery tables or custom queries incrementally.
Requirements
Setting up a Service Account
- Create a new service account:
Code
- Grant the required permissions:
Code
- Create and save the service account key (credentials):
Code
This creates a bigquery-reader-credentials.json file in your current directory. Use the contents of this file as the value for the credentials_json secret in your input configuration.
Note: Keep this credentials file secure and never commit it to version control.
Configuration
The BigQuery Input is configured using the following settings:
Settings
| Setting | Type | Required | Default | Description |
|---|---|---|---|---|
project | string | Yes | - | The GCP project ID containing the BigQuery dataset |
dataset | string | Yes | - | The BigQuery dataset ID containing the table |
table | string | Yes | - | The BigQuery table ID to query data from |
timestamp_column | string | Yes | - | The column containing timestamp values for incremental loading |
query | text | No | - | Optional custom query |
Secrets
| Secret | Type | Required | Description |
|---|---|---|---|
credentials_json | secret | No | JSON credentials to authenticate with Google Cloud (required for service account auth). |
Features
Sync Mode
- Incremental Sync: Uses the timestamp_column provided to read new or updated records
- Automatically manages state between runs for incremental syncs
- On the first run the cursor is empty, so the whole table (or query result) is read; there is no backfill start setting
Query Support
- Simple table queries with automatic schema detection
- Custom SQL queries for complex data transformations
- Wraps custom queries in CTEs for incremental loading
Efficient Data Reading
- Uses BigQuery Query API for reliable data access
- Automatic connection and retry handling
- Supports both simple and complex queries
Best Practices
- Query Optimization
- Keep queries simple for better performance
- Test custom queries with small data sets first
Example Configurations
Incremental Sync with Table
Code
Troubleshooting
Common issues and solutions:
-
Permission Denied
- Verify service account has both bigquery.dataViewer and bigquery.jobUser roles
- Check project ID matches credentials
- Ensure dataset and table exist
-
Invalid Query
- Test custom queries in BigQuery console first
- Verify column names and types
- Check for proper SQL syntax
-
Timestamp Column Issues
- Verify column exists in table/query results
- Ensure column is TIMESTAMP type
- Check column name matches exactly
-
Performance Issues
- Review query efficiency
- Check BigQuery usage quotas
Sync frequency
By default this input polls approximately every 10 seconds, with each sync beginning after the previous one completes. A cron schedule configured on the pipeline overrides this cadence. See Input Sync Frequency for details.
Each poll runs a query job against BigQuery, so put timestamp_column on a partitioned or clustered column, or set a cron schedule, to control query cost.