Docs
Connectors

Google BigQuery connector

Google Cloud analytics warehouse for SQL queries, datasets, and tables.

View Markdown

Use this as an implementation starting point: adapt the worked example to the requested dataset and the source documentation. See Custom API for the shared SDK pattern and document-upload workflow.

What this connector is for

Google Cloud analytics warehouse for SQL queries, datasets, and tables.

A connector owns access to the source. Separate syncs shape selected resources into tables for analysis and downstream transformations using the Python SDK.

Data and tables you can pull

These are representative dataset families to consider, not a claim that the worked example implements every resource. Access, fields, and availability depend on the source account, product edition, and permissions. Use the vendor reference to select concrete resources.

Suggested tableOne row represents
datasetsa dataset
tablesa table
table_rowsa table row
query_rowsa query result row

Relationships and extraction considerations

Datasets and tables describe storage; table/query rows contain the business data. Query execution can incur charges and needs job permissions in addition to table read access.

Connecting to Google BigQuery

Uses a service account or application default credentials with BigQuery metadata and table data read permissions. Discovery lists real dataset tables and column schemas. list_rows reads table rows without running a SQL query; views require query jobs and are outside this example.

Additional resources may require additional scopes. Connection settings belong to the connector; dataset filters and resource selection belong to each sync. See the CLI workflow for registration and configuration.

Connection settings used by the example

SettingRequirementPurpose
projectRequiredProject
service_accountOptional; secretOptional service-account JSON object; otherwise use application default credentials.
datasetRequiredDataset

requirements.in

Save these dependencies in requirements.in alongside connector.py; the example includes packages used by its sync. Install the published vortexify package for local development. Keep sync-specific dependencies in the sync's own requirements.in when splitting the implementation into separate resources.

vortexify==0.1.1
google-cloud-bigquery>=3.25,<4
pandas>=2,<3

Google client libraries use the configured credentials and scopes. Installing the library does not grant project/account access; select a supported Python runtime and compatible library version.

Worked example: sync table_rows

table_rows — Reads the configured table via the BigQuery tabledata API; schema comes from the actual table.

The complete files below implement only this example resource. They illustrate the current SDK signatures, a separate preview, bounded DataFrame output, and source-specific extraction. They do not establish complete source coverage. Live credentials and platform ingestion have not been used to validate this guide.

With default paths, place the connector files in connectors/bigquery/ and sync files in connectors/bigquery/syncs/table_rows/. Use your project configuration if it specifies different paths.

Connection schema: config.json

This file contains a JSON Schema, not actual credential values. Provide those through platform configuration.

{
  "type": "object",
  "properties": {
    "project": {
      "type": "string",
      "minLength": 1,
      "title": "Project",
      "order": 0
    },
    "service_account": {
      "type": "object",
      "title": "Service Account",
      "description": "Optional service-account JSON object; otherwise use application default credentials.",
      "x-vortexify-secret": true,
      "order": 1
    },
    "dataset": {
      "type": "string",
      "minLength": 1,
      "title": "Dataset",
      "order": 2
    }
  },
  "required": [
    "project",
    "dataset"
  ]
}

Connector: connector.py

from google.cloud.bigquery import Client
from vortexify import Column, Connector, DiscoveredTable


class BigqueryConnector(Connector):
    vendor_domain = "google.com"

    def client(self):
        if self._client is None:
            if self.config.get("service_account"):
                self._client = Client.from_service_account_info(
                    self.config["service_account"], project=self.config["project"]
                )
            else:
                self._client = Client(project=self.config["project"])
        return self._client

    def check(self) -> bool:
        self.client().get_dataset(self.config["project"] + "." + self.config["dataset"])
        return True

    def discover(self) -> list[DiscoveredTable]:
        client = self.client()
        dataset = self.config["project"] + "." + self.config["dataset"]
        resources = []
        for entry in client.list_tables(dataset):
            if entry.table_type != "TABLE":
                continue
            table = client.get_table(entry.reference)
            resources.append(
                DiscoveredTable(
                    name=table.full_table_id.replace(":", "."),
                    schema=[
                        Column(
                            name=column.name,
                            type=column.field_type,
                            nullable=column.mode != "REQUIRED",
                        )
                        for column in table.schema
                    ],
                )
            )
        return resources

    def close(self) -> None:
        if self._client is not None:
            try:
                self._client.close()
            finally:
                self._client = None

Sync schema: syncs/table_rows/config.json

{
  "type": "object",
  "properties": {
    "table": {
      "type": "string",
      "title": "Table",
      "description": "Table ID within the configured dataset.",
      "minLength": 1,
      "order": 0
    }
  },
  "required": [
    "table"
  ]
}

Sync: syncs/table_rows/sync.py

from collections.abc import Iterator
from math import isfinite
import json
import pandas as pd
from vortexify import Sync


class BigqueryTableRowsSync(Sync):

    def preview(self) -> pd.DataFrame:
        cfg = self.connector.config
        table = self.client.get_table(
            cfg["project"] + "." + cfg["dataset"] + "." + self.config["table"]
        )
        columns = [column.name for column in table.schema]
        records = self.client.list_rows(table, page_size=100, max_results=100)
        rows = [
            {
                key: (
                    json.dumps(value, default=str)
                    if isinstance(value, (dict, list))
                    else value
                )
                for key, value in dict(record).items()
            }
            for record in records
        ]
        return pd.DataFrame(rows, columns=columns, dtype=object)

    def extract(
        self, *, avg_row_size_bytes: float | None = None
    ) -> Iterator[pd.DataFrame]:
        memory_mib = self.compute.memory if self.compute else None
        memory_mib = memory_mib if memory_mib is not None and memory_mib > 0 else 1024
        target_bytes = min(16 * 1024 * 1024, max(1, memory_mib * 1024 * 1024 // 20))
        batch_size = 100
        if avg_row_size_bytes is not None:
            if not isfinite(avg_row_size_bytes) or avg_row_size_bytes <= 0:
                raise ValueError("avg_row_size_bytes must be finite and positive")
            batch_size = max(1, int(target_bytes / max(1.0, avg_row_size_bytes) / 4))
        batch_size = min(batch_size, 10000)
        cfg = self.connector.config
        table = self.client.get_table(
            cfg["project"] + "." + cfg["dataset"] + "." + self.config["table"]
        )
        columns = [column.name for column in table.schema]
        records = self.client.list_rows(table, page_size=batch_size)
        rows = []
        for record in records:
            rows.append(
                {
                    key: (
                        json.dumps(value, default=str)
                        if isinstance(value, (dict, list))
                        else value
                    )
                    for key, value in dict(record).items()
                }
            )
            if len(rows) == batch_size:
                yield pd.DataFrame(rows, columns=columns, dtype=object)
                rows = []
        if rows:
            yield pd.DataFrame(rows, columns=columns, dtype=object)

Running and extending the example

Register the connector before the sync and commit each resource separately:

vortexify create connector bigquery
vortexify create sync bigquery/table_rows

Edit the files, inspect vortexify status, and use the CLI guide to commit and configure them. Registration alone does not run extraction or deploy the connector.

Preview must run with a fresh connector and disposable state. The extraction implementation determines full/incremental behavior; merely setting a mode does not implement change capture. API/driver failures propagate unless explicitly handled in the code. Check source limits and single-record/response sizes as well as output batch size.

Sources and further reading