BigQuery sharing integration

Google Cloud Cortex Framework lets you register subscribed linked datasets from BigQuery sharing as external analytics_hub catalog modules. By connecting zero-copy shared datasets, you can blend external commercial, environmental, partner, or cross-organization data directly with prebuilt SAP ERP, SAP Business Data Cloud (SAP BDC), and Salesforce data products in BigQuery without building or maintaining extraction pipelines.

Supported sharing scenarios

You can register any linked BigQuery dataset subscribed through BigQuery sharing under data.modules.catalogs (type: analytics_hub), including:

  • Environmental and geospatial forecasts: Blend weather ensemble forecasts (such as Google WeatherNext) with plant, warehouse, and inbound delivery schedules to model supply chain disruption risk.
  • Commercial and logistics intelligence: Join third-party risk, credit, and maritime telemetry feeds (such as Dun & Bradstreet Global Shipping Insights) with vendor and purchase order models.
  • Public and partner data exchanges: Enrich enterprise metrics with macroeconomic indicators, demographic reference tables, or industry benchmarks published on Google Cloud Marketplace and public data exchanges.
  • Cross-organization and customer 360 shares: Connect internal data mesh listings shared across Google Cloud organizations or zero-copy Salesforce Data 360 shares.

Compare external catalog types

Cortex Framework supports two external zero-copy catalog module types. Compare their infrastructure requirements in the following table:

Dimension BigQuery sharing (analytics_hub) BigLake Delta Sharing (lakehouse_delta_share)
Primary sources Subscribed BigQuery linked datasets (commercial listings, WeatherNext, Dun & Bradstreet, public datasets, cross-org shares, Salesforce Data 360) Delta Sharing shares imported into BigLake (such as SAP Business Data Cloud)
Required Google Cloud APIs bigquery.googleapis.com and analyticshub.googleapis.com bigquery.googleapis.com, biglake.googleapis.com, bigqueryreservation.googleapis.com, and cloudresourcemanager.googleapis.com
BigQuery edition requirement Standard on-demand or edition capacity (no Enterprise Plus reservation required) Requires an active BigQuery Enterprise Plus reservation assignment
Source table discovery Deterministic table and view allowlist declared in inlineTableSettings.tables (or inlineTableSettings.variants) Discovered from imported connectionSettings.shares in the BigLake catalog (optionally filtered with tableSettings or inlineTableSettings)

Before you begin

Before you register an analytics_hub catalog module in Cortex Framework, complete the following prerequisites.

Enable Google Cloud APIs

Enable the required Google Cloud APIs on the project that hosts your subscribed linked dataset and on your deployment projects:

gcloud services enable bigquery.googleapis.com \
    analyticshub.googleapis.com \
    dataform.googleapis.com \
    --project=PROJECT_ID

Replace the following:

  • PROJECT_ID: the Google Cloud project ID where you host the linked dataset or run Dataform pipelines, for example: my-cortex-project.

Subscribe to a listing

In Google Cloud, subscribe to a listing in BigQuery sharing to create a read-only linked dataset in your consumer project. Verify that the linked dataset (or a configured cross-region dataset replica) resides in the same location as data.bigQueryLocation in config/config.yaml, and record the shared table or view names to include in inlineTableSettings.tables (or inlineTableSettings.variants).

Get the required roles

To get the permissions that you need to subscribe to listings and build data products on BigQuery sharing catalogs, ask your administrator to grant you the following IAM roles:

For more information about granting roles, see Manage access to projects, folders, and organizations.

You might also be able to get the required permissions through custom roles or other predefined roles.

Register an analytics_hub catalog

In config/config.yaml, register each subscribed linked dataset under data.modules.catalogs with type: analytics_hub. Specify only the short BigQuery dataset identifier (letters, digits, and underscores) in connectionSettings.datasetId, and declare a non-empty list of shared table or view names in inlineTableSettings.tables (or optional variant-specific lists under inlineTableSettings.variants, paired with variants on the catalog entry). During uv run cortex-build, AnalyticsHubCatalogBuilder generates Dataform source declarations (definitions/sources/<project>_<dataset>_sources.js) exclusively for the listed tables without scanning unrelated objects or copying data.

buildEnvironment:
  buildProjectId: BUILD_PROJECT_ID

data:
  bigQueryLocation: US
  namespaces:
    - name: cortex
    - name: cortex_samples
    - name: custom
      path: ../src/data_modules/custom
  datasets:
    - id: custom_products
      projectId: TARGET_PROJECT_ID
      datasetId: custom_supply_chain_insights

  modules:
    catalogs:
      # Example 1: Google WeatherNext linked dataset subscribed from BigQuery sharing.
      - id: ah_weathernext_catalog
        type: analytics_hub
        enabled: true
        bindsNamespaces:
          - cortex.external.weathernext
        connectionSettings:
          projectId: LINKED_DATASET_PROJECT_ID
          datasetId: WEATHERNEXT_DATASET_ID
          location: US
          # Optional source listing ID (auto-discovered when omitted):
          listingId: projects/PROVIDER_PROJECT_ID/locations/US/dataExchanges/EXCHANGE_ID/listings/LISTING_ID
        inlineTableSettings:
          tables:
            - weathernext_3_0_0
            - weathernext_daily_forecast

      # Example 2: Dun & Bradstreet shipping insights linked dataset.
      - id: ah_dnb_catalog
        type: analytics_hub
        enabled: true
        bindsNamespaces:
          - cortex.external.dnb
        connectionSettings:
          projectId: LINKED_DATASET_PROJECT_ID
          datasetId: DNB_DATASET_ID
          location: US
        inlineTableSettings:
          tables:
            - shipping_insights
            - company_profile

    products:
      # Composite data product blending SAP or Salesforce models with shared catalog tables.
      - moduleId: custom_delivery_weather_risk
        modulePath: custom.sap.products.delivery_weather_risk
        dataTargetId: custom_products
        dependencyBindings:
          sapDeliveries: sap_delivery_documents
          sapCustomers: sap_customers
          weatherNext: ah_weathernext_catalog.weathernext_daily_forecast
          dnbCatalog: ah_dnb_catalog

Replace the following:

  • BUILD_PROJECT_ID: the Google Cloud project ID used for build validation, for example: my-build-project.
  • TARGET_PROJECT_ID: the Google Cloud project ID where writable downstream data products are materialized, for example: my-target-project.
  • LINKED_DATASET_PROJECT_ID: the Google Cloud project ID that hosts your subscribed linked datasets, for example: my-subscriber-project.
  • WEATHERNEXT_DATASET_ID: the BigQuery dataset ID of the subscribed WeatherNext linked dataset, for example: weathernext_linked.
  • DNB_DATASET_ID: the BigQuery dataset ID of the subscribed Dun & Bradstreet linked dataset, for example: dnb_shipping_insights_linked.
  • PROVIDER_PROJECT_ID: optional publisher Google Cloud project ID for connectionSettings.listingId, for example: weathernext-provider.
  • EXCHANGE_ID: optional BigQuery sharing data exchange ID for connectionSettings.listingId, for example: weather_data_exchange.
  • LISTING_ID: optional BigQuery sharing listing ID for connectionSettings.listingId, for example: weathernext_daily. You can specify listingId as a canonical resource path, a full listing URL, or a four-part dot-separated ID copied from the Google Cloud console (where LOCATION is the exchange location such as US):

    projects/PROVIDER_PROJECT_ID/locations/LOCATION/dataExchanges/EXCHANGE_ID/listings/LISTING_ID
    PROVIDER_PROJECT_ID.LOCATION.EXCHANGE_ID.LISTING_ID
    

    When you omit listingId, Cortex Framework automatically discovers the source listing from the linked dataset's subscription metadata or dataset description.

For full field specifications, see Data: Modules: Catalogs.

Bind shared tables in composite data products

Downstream data products under data.modules.products can bind to an analytics_hub catalog in dependencyBindings by using either of two formats:

  • Two-part binding (<catalog_id>.<table_name> or <catalog_id>.<dataset_id>): Binds a logical dependency key to a specific table or view listed in inlineTableSettings.tables (for example, weatherNext: ah_weathernext_catalog.weathernext_daily_forecast) or to the catalog's configured datasetId. Inside includes/config.js, moduleConfig.sources.<dependencyKey> resolves { projectId, datasetId, tables: [...] } (without a tableName property), so pass projectId, datasetId, and the declared table name string to ctx.ref(...).
  • One-part catalog binding (<catalog_id>): Binds a logical dependency key to the entire catalog instance (for example, dnbCatalog: ah_dnb_catalog) when your module's manifest.yaml declares the required table names under a namespace matching bindsNamespaces.

The following Dataform .js example uses publish_config.getPublishConfig(...) and publisher.publish(...) from includes/ (so table settings and upstream blocking: true assertions attach automatically) to join the prebuilt sap_delivery_documents (cortex.sap.products.delivery_documents) and sap_customers (cortex.sap.products.customers) data products with a shared table bound using the two-part format:

// ___MODULE_CONTEXT___
// ___TABLE_CONFIG___

const publish_config = require("includes/publish_config.js");
const publisher = require("includes/publisher.js");

const moduleConfig = config.product[moduleContext.moduleId];
const sapDeliveriesDataset = moduleConfig.sources.sapDeliveries.datasetId;
const sapCustomersDataset = moduleConfig.sources.sapCustomers.datasetId;
const weatherSource = moduleConfig.sources.weatherNext;

const materializationType = tableConfig.materializationType || "table";
const publishConfig = publish_config.getPublishConfig(
  materializationType,
  tableConfig,
  moduleConfig
);

publisher.publish(moduleContext.moduleId + "_" + tableConfig.tableName, publishConfig).query(
  (ctx) => `
    SELECT
      d.document_number_vbeln,
      d.ship_to_party_kunnr,
      c.postal_code_pstlz,
      w.init_time,
      w.precipitation_total_mm
    FROM ${ctx.ref(sapDeliveriesDataset, "delivery_document_headers")} AS d
    LEFT JOIN ${ctx.ref(sapCustomersDataset, "customers")} AS c
      ON d.client_mandt = c.client_mandt
      AND d.ship_to_party_kunnr = c.customer_number_kunnr
    LEFT JOIN ${ctx.ref(
      weatherSource.projectId,
      weatherSource.datasetId,
      "weathernext_daily_forecast"
    )} AS w
      ON c.postal_code_pstlz = w.postal_code
  `
);

For deployable multi-source reference implementations that combine SAP BDC with Google WeatherNext 3 and Dun & Bradstreet Global Shipping Insights, see Supplier and Plant Weather Risk Insights and Supplier Inbound Delivery Weather Risk Insights.

Fetch and cache metadata for agentic workflows

When you build custom composite data products with agentic skills, Cortex Framework can automatically inspect and cache both BigQuery physical table schemas and BigQuery sharing listing metadata locally so your AI coding assistant generates accurate SQL joins without guessing column names.

Run cortex-metadata fetch against your configured catalog ID:

export CORTEX_CONFIG_FILE=config/config.yaml
uv run cortex-metadata fetch \
    --config $CORTEX_CONFIG_FILE \
    --module-id CATALOG_ID

Replace the following:

  • CATALOG_ID: the id of your analytics_hub catalog entry in config/config.yaml, for example: ah_weathernext_catalog.

The extractor retrieves and caches:

  • Physical BigQuery metadata: Column names, data types, descriptions, partitioning and clustering definitions, estimated row counts, and byte sizes for each table in inlineTableSettings.tables.
  • Listing governance metadata: Publisher, data provider, display name, categories, documentation URL, source listing URI, and dataset link status when listingId or subscription permissions are available.

Pre-flight validation and troubleshooting

During uv run cortex-build and uv run cortex-build-and-deploy, GcpEnvironmentChecker validates every enabled analytics_hub catalog against BigQuery and BigQuery sharing before staging Dataform code (standalone uv run cortex-deploy runs deployment-target checks only). The following table summarizes pre-flight validation behaviors and resolutions:

Check Condition Outcome Resolution
Dataset existence connectionSettings.datasetId is not found in connectionSettings.projectId Error (CortexGcpError) Verify the project and dataset IDs, confirm your subscription succeeded in BigQuery sharing, and grant roles/bigquery.dataViewer to the build principal.
Dataset link state linkedDatasetMetadata.linkState is UNLINKED Error (CortexGcpError) The publisher revoked or deleted the underlying listing link. Re-subscribe to an active listing in BigQuery sharing and update datasetId if a new dataset was created.
Copied or standard dataset Dataset exists in BigQuery without linked-dataset metadata Warning (build continues) Link and subscription checks are skipped. Note that copied snapshot datasets don't automatically receive updates from the original provider.
Subscription health Subscription state is STATE_STALE or STATE_INACTIVE Warning (build continues) Inspect the subscription in the Google Cloud console under BigQuery > Sharing to restore or renew the subscription. If the caller lacks analyticshub.subscriptions.list, Cortex Framework logs a warning and continues.
Configured location mismatch connectionSettings.location differs from the actual BigQuery dataset location Warning (uses actual dataset location) Update connectionSettings.location in config/config.yaml to match the physical dataset region.
Cross-region compatibility (replica supported) Linked dataset location differs from data.bigQueryLocation, and the listing supports data.bigQueryLocation (or listing regions cannot be read) Warning (replica guidance) Add a cross-region dataset replica in data.bigQueryLocation (requires bigquery.datasets.update) so BigQuery can execute co-located joins.
Cross-region compatibility (unsupported region) Linked dataset location differs from data.bigQueryLocation, and the discovered or configured listingId confirms the listing isn't offered in data.bigQueryLocation Error (CortexGcpError) Align data.bigQueryLocation with a region supported by the listing, or copy the shared tables into a standard dataset in data.bigQueryLocation if your provider license permits.

What's next