Connect to SAP Datasphere

Preview

This product or feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of theService Specific Terms. Pre-GA products and features are available "as is" and might have limited support. For more information, see thelaunch stage descriptions.

Note: To get support or provide feedback for this preview feature, contactbq-sap-federation-support@google.com.

As a BigQuery administrator, you can create aconnection to accessSAP Datasphere data. This connection enables data analysts toquerydata in SAP Datasphere.

Before you begin

  1. Enable the BigQuery Connection API.

    Enable the API

  2. Create a SAP Datasphere database user.Note the username, password, hostname, and port for BigQueryto connect to.

  3. Configure your SAP Datasphere tenant to accept traffic fromyour selected IP addresses by doing one of the following:

    For more information about configuring your SAP Dataspheretenant, seeAdd IP address to IP Allowlist.

Required roles

To get the permissions that you need to connect to SAP Datasphere, ask your administrator to grant you theBigQuery Connection Admin (roles/bigquery.connectionAdmin) IAM role on the project. For more information about granting roles, seeManage access to projects, folders, and organizations.

You might also be able to get the required permissions throughcustom roles or otherpredefined roles.

Connect BigQuery to SAP Datasphere

You can connect BigQuery to SAP Datasphere in the Google Cloud console or thebq command-line tool.

Console

  1. In the Google Cloud console, go to theBigQuery page.

    Go to BigQuery

  2. In theExplorer pane, clickAdd data.

    TheAdd data dialog opens.

  3. In theFilter By pane, in theData Source Type section, selectDatabases.

    Alternatively, in theSearch for data sources field, you can enterSAP HANA.

  4. In theFeatured data sources section, clickSAP HANA.

  5. Click theSAP HANA: BigQuery Federation solution card.

  6. In theExternal data source dialog, do the following:

    • ForConnection type, selectSAP HANA.
    • ForConnection ID, enter a connection ID to identify this connection.
    • ForLocation type, specify a region of the BigQuerydataset to be combined with the data from SAP Datasphere. Queries that usethis connection must be run from this region.
    • Optional: ForFriendly name, enter a user-friendly name forthe connection, such asMy connection resource. The friendly namecan be any value that helps you identify the connectionresource if you need to modify it later.
    • Optional: ForDescription, enter a description for thisconnection resource.
    • ForEncryption, select eitherGoogle-managed encryption key orCustomer-managed encryption key (CMEK). The use of a CMEK is optional.
    • ForHost:port: enter the host and port of the SAP database instance, as shown in theDatabase User Details in the SAP Datasphere web console, in the formatHOST:PORT.
    • Optional: ForNetwork attachment, enter a path to thenetwork attachmentthat defines the network configuration that is used for establishing aconnection to SAP Datasphere.
    • ForUsername: enter the database username fromDatabase User Details in the SAP Datasphere web console. For example,MY_SPACE#BIGQUERY.
    • ForPassword: enter the database user's password.
  7. ClickCreate connection.

bq

Enter thebq mk commandwith the following flags:

bqmk\--connection\--location=LOCATION\--project_id=PROJECT_ID\--connector_configuration'{    "connector_id": "saphana",    "endpoint": {      "host_port": "HOST_PORT"    },    "authentication": {      "username_password": {        "username": "USERNAME",        "password": {          "plaintext": "PASSWORD"        }      }    },    "network": {      "private_service_connect": {        "network_attachment": "NETWORK_ATTACHMENT"      }    }  }'\CONNECTION_ID

Replace the following:

  • LOCATION: specify a region of the BigQuerydataset to be combined with the data from SAP Datasphere. Queries that usethis connection must be run from this region.
  • PROJECT_ID: enter your Google Cloud project ID.
  • HOST_PORT: enter the host and port of the SAPdatabase instance, as shown in theDatabase User Details in the SAPDatasphere web console, in the formatHOST:PORT.
  • NETWORK_ATTACHMENT (optional): enter thenetwork attachmentin the formatprojects/{project}/regions/{region}/networkAttachments/{networkattachment}.With this field, you can configure the SAP Datasphere connectionso that BigQuery opens the connection from a static IPaddress.
  • USERNAME: enter the database username fromDatabaseUser Details in the SAP Datasphere web console. For example,MY_SPACE#BIGQUERY.
  • PASSWORD: enter the database user's password.
  • CONNECTION_ID: enter a connection ID to identify thisconnection.

Optional flag:

  • --kms_key_name: A customer-managed encryption key. If omitted, credentials are protected by the default Google-owned and Google-managed encryption key.

Share connections with users

You can grant the following roles to let users query data and manage connections:

  • roles/bigquery.connectionUser: enables users to use connections to connectwith external data sources and run queries on them.

  • roles/bigquery.connectionAdmin: enables users to manage connections.

For more information about IAM roles and permissions inBigQuery, seePredefined roles and permissions.

Select one of the following options:

Console

  1. Go to theBigQuery page.

    Go to BigQuery

    Connections are listed in your project, in a group calledConnections.

  2. In the left pane, clickExplorer:

    Highlighted button for the Explorer pane.

    If you don't see the left pane, clickExpand left pane to open the pane.

  3. Click your project, clickConnections, and then select a connection.

  4. In theDetails pane, clickShare to share a connection.Then do the following:

    1. In theConnection permissions dialog, share theconnection with other principals by adding or editingprincipals.

    2. ClickSave.

bq

You cannot share a connection with the bq command-line tool.To share a connection, use the Google Cloud console orthe BigQuery Connections API method to share a connection.

API

Use theprojects.locations.connections.setIAM methodin the BigQuery Connections REST API reference section, andsupply an instance of thepolicy resource.

Java

Before trying this sample, follow theJava setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryJava API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

importcom.google.api.resourcenames.ResourceName;importcom.google.cloud.bigquery.connection.v1.ConnectionName;importcom.google.cloud.bigqueryconnection.v1.ConnectionServiceClient;importcom.google.iam.v1.Binding;importcom.google.iam.v1.Policy;importcom.google.iam.v1.SetIamPolicyRequest;importjava.io.IOException;// Sample to share connectionspublicclassShareConnection{publicstaticvoidmain(String[]args)throwsIOException{// TODO(developer): Replace these variables before running the sample.StringprojectId="MY_PROJECT_ID";Stringlocation="MY_LOCATION";StringconnectionId="MY_CONNECTION_ID";shareConnection(projectId,location,connectionId);}staticvoidshareConnection(StringprojectId,Stringlocation,StringconnectionId)throwsIOException{try(ConnectionServiceClientclient=ConnectionServiceClient.create()){ResourceNameresource=ConnectionName.of(projectId,location,connectionId);Bindingbinding=Binding.newBuilder().addMembers("group:example-analyst-group@google.com").setRole("roles/bigquery.connectionUser").build();Policypolicy=Policy.newBuilder().addBindings(binding).build();SetIamPolicyRequestrequest=SetIamPolicyRequest.newBuilder().setResource(resource.toString()).setPolicy(policy).build();client.setIamPolicy(request);System.out.println("Connection shared successfully");}}}

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.