Query remote data

After setting up cross-cloud data access, you can query remote data from multiple sources. This capability of borderless Lakehouse lets you access data using standard SQL in BigQuery, the open-source version of Apache Spark, or Managed Service for Apache Spark. In addition to analytical queries, you can use your federated data for AI-driven insights and governance:

  • Conversational Analytics: Build specialized agents grounded in your exact data sources, including federated tables, to analyze data across clouds from a single conversation.
  • Dataplex Catalog: Use Knowledge Catalog features for data profiling and insights with federated data sources.

For deeper insights, you can author specialized agents grounded in your data sources, from projects, datasets, and tables to views, graphs, and user-defined functions. Because your data rarely lives in one place, conversational analytics reaches beyond BigQuery Standard tables to Apache Iceberg tables managed by Lakehouse and Lakehouse sources like Databricks Unity, AWS Glue, SAP, and Salesforce. This lets you break down data silos and analyze data across clouds from a single conversation.

This page shows you how to query remote data after you set up cross-cloud data access.

Before you begin

Before you can query your data, you must complete the following:

  1. Ensure that you have data within your remote catalog.
  2. Set up a cross-cloud connection for AWS Glue, Databricks Unity Catalog, Snowflake Horizon Catalog, or SAP Business Data Cloud.

Required roles

To get the permissions that you need to query federated data, ask your administrator to grant you the following IAM roles on your project:

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.

Query data

After you set up federation, you can query your remote data using standard SQL in BigQuery or Apache Spark in Managed Service for Apache Spark.

Lakehouse handles the metadata translation and secure data access, which lets you treat remote Apache Iceberg tables as if they were local to your Google Cloud environment.

Query from BigQuery

To query federated Apache Iceberg tables, use standard BigQuery SQL. The table path follows a 4-part structure: project.federated_catalog.namespace.table. Caching, credential vending, and CCI transit routing are automatically handled.

SELECT
  user_id,
  action,
  COUNT(*) as total_actions
FROM `PROJECT_ID.FEDERATED_CATALOG_NAME.NAMESPACE_NAME.TABLE_NAME`
WHERE event_date >= '2026-04-01'
GROUP BY 1, 2;

Replace the following:

  • PROJECT_ID: your Google Cloud project ID.
  • FEDERATED_CATALOG_NAME: the name of the federated catalog.
  • NAMESPACE_NAME: the namespace within the catalog.
  • TABLE_NAME: the name of the table.
  • REGION: the Google Cloud region. For example, us-east4.

You can also run the query using the bq command-line tool:

bq --location="REGION" --project_id="PROJECT_ID" query --use_legacy_sql=false \
  "SELECT * FROM \`PROJECT_ID.FEDERATED_CATALOG_NAME.NAMESPACE_NAME.TABLE_NAME\` LIMIT 10"

Query from Managed Service for Apache Spark

Submit a PySpark batch workload to Managed Service for Apache Spark with credential vending enabled using X-Iceberg-Access-Delegation=vended-credentials. Spark will use the short-lived scoped vended credentials to connect to S3 securely, all without needing to manage separate AWS credentials or S3 connectors.

  1. Enable outbound connectivity for Managed Service for Apache Spark.

    Managed Service for Apache Spark cannot connect to AWS S3 with its default network configuration. You must provision a Cloud Router and Cloud NAT.

    gcloud compute routers create lakehouse-router \
      --network=NETWORK_NAME \
      --region=REGION
    
    gcloud compute routers nats create lakehouse-nat \
      --router=lakehouse-router \
      --auto-allocate-nat-external-ips \
      --nat-all-subnet-ip-ranges \
      --region=REGION

    Replace the following:

    • NETWORK_NAME: the network for the Managed Service for Apache Spark batch workload (for example, default).
    • REGION: the region for the Managed Service for Apache Spark batch workload.
  2. Create a PySpark application file and run the PySpark job.

    from pyspark.sql import SparkSession
    spark = SparkSession.builder.appName("CATALOG_NAME").getOrCreate()
    
    df = spark.table("CATALOG_NAME.NAMESPACE_NAME.TABLE_NAME")
    df.show(10, truncate=False)

    Upload this to Cloud Storage at PYSPARK_FILE.

    gcloud