Google BigQuery Connector
Documentation
Version: 12
Documentation

How to read Google BigQuery data in MS SQL/SSRS/Java using ZappySys Data Gateway?


In this section we will learn how to configure and use Google BigQuery Connector in the API Driver to extract data from the Google BigQuery.

Create Data Source in ZappySys Data Gateway based on API Driver

  1. Download and install ZappySys ODBC PowerPack.

  2. Search for gateway in start menu and Open ZappySys Data Gateway:
    Open ZappySys Data Gateway

  3. Go to Users Tab to add our first Gateway user. Click Add; we will give it a name tdsuser and enter password you like to give. Check Admin option and click OK to save. We will use these details later when we create linked server:
    ZappySys Data Gateway - Add User

  4. Now we are ready to add a data source. Click Add, give data source a name (Copy this name somewhere, we will need it later) and then select Native - ZappySys API Driver. Finally, click OK. And it will create the Data Set for it and open the ZS driver UI.

    GoogleBigqueryDSN

    ZappySys Data Gateway - Add Data Source

  5. When the Configuration window appears give your data source a name if you haven't done that already, then select "Google BigQuery" from the list of Popular Connectors. If "Google BigQuery" is not present in the list, then click "Search Online" and download it. Then set the path to the location where you downloaded it. Finally, click Continue >> to proceed with configuring the DSN:

    GoogleBigqueryDSN
    Google BigQuery
    ODBC DSN Template Selection

  6. Now it's time to configure the Connection Manager. Select Authentication Type, e.g. Token Authentication. Then select API Base URL (in most cases, the default one is the right one). More info is available in the Authentication section.

    User accounts represent a developer, administrator, or any other person who interacts with Google APIs and services. User accounts are managed as Google Accounts, either with Google Workspace or Cloud Identity. They can also be user accounts that are managed by a third-party identity provider and federated with Workforce Identity Federation. [API reference]

    Steps how to get and use Google BigQuery credentials

    Follow these steps on how to create Client Credentials (User Account principle) to authenticate and access BigQuery API in SSIS package or ODBC data source:

    WARNING: If you are planning to automate processes, we recommend that you use a Service Account authentication method. In case, you still need to use User Account, then make sure you use a system/generic account (e.g. automation@my-company.com). When you use a personal account which is tied to a specific employee profile and that employee leaves the company, the token may become invalid and any automated processes using that token will start to fail.

    Step-1: Create project

    This step is optional, if you already have a project in Google Cloud and can use it. However, if you don't, proceed with these simple steps to create one:

    1. First of all, go to Google API Console.

    2. Then click Select a project button and then click NEW PROJECT button:

      Start creating a new project in Google Cloud
    3. Name your project and click CREATE button:

      Create a new project in Google Cloud
    4. Wait until the project is created:

      Wait until project is created in Google Cloud
    5. Done! Let's proceed to the next step.

    Step-2: Enable Google Cloud APIs

    In this step we will enable BigQuery API and Cloud Resource Manager API:

    1. Select your project on the top bar:

      Select project in Google Cloud
    2. Then click the "hamburger" icon on the top left and access APIs & Services:

      Access APIs and services in Google Cloud
    3. Now let's enable several APIs by clicking ENABLE APIS AND SERVICES button:

      Enable API for project in Google Cloud
    4. In the search bar search for bigquery api and then locate and select BigQuery API:

      Search for API in Google Cloud
    5. If BigQuery API is not enabled, enable it:

      Enable Google BigQuery API
    6. Then repeat the step and enable Cloud Resource Manager API as well:

      Enable Cloud Resource Manager API
    7. Done! Let's proceed to the next step.

    Step-3: Create OAuth application

    1. First of all, click the "hamburger" icon on the top left and then hit VIEW ALL PRODUCTS:

      View all products in Google Cloud
    2. Then access Google Auth Platform to start creating an OAuth application:

      Open Google Auth Platform in Google Cloud
    3. Start by pressing GET STARTED button:

      Start creating an app in Google Cloud
    4. Next, continue by filling in App name and User support email fields:

      Fill app info in Google Cloud
    5. Choose Internal option, if it's enabled, otherwise select External:

      Choose app audience in Google Cloud
    6. Optional step if you used Internal option in the previous step. Nevertheless, if you had to use External option, then click ADD USERS to add a user:

      Add test user in Google Cloud app
    7. Then add your contact Email address:

      Enter app contact info in Google Cloud
    8. Finally, check the checkbox and click CREATE button:

      Create app in Google Cloud
    9. Done! Let's create Client Credentials in the next step.

    Step-4: Create Client Credentials

    1. In Google Auth Platform, select Clients menu item and click CREATE CLIENT button:

      Start creating app client in Google Cloud
    2. Choose Desktop app as Application type and name your credentials:

      Create OAuth app client in Google Cloud
    3. Continue by opening the created credentials:

      View app client credentials in Google Cloud
    4. Finally, copy Client ID and Client secret for the later step:

      Use client ID and secret to read Google REST API data
    5. Done! We have all the data needed for authentication, let's proceed to the last step!

    Step-5: Configure connection

    1. Now go to SSIS package or ODBC data source and use previously copied values in User Account authentication configuration:

      • In the ClientId field paste the Client ID value.
      • In the ClientSecret field paste the Client secret value.
    2. Press Generate Token button to generate Access and Refresh Tokens.

    3. Then choose ProjectId from the drop down menu.

    4. Continue by choosing DatasetId from the drop down menu.

    5. Finally, click Test Connection to confirm the connection is working.

    6. Done! Now you are ready to use Google BigQuery Connector!

    Fill in all required parameters and set optional parameters if needed:

    GoogleBigqueryDSN
    Google BigQuery
    User Account [OAuth]
    https://www.googleapis.com/bigquery/v2
    Required Parameters
    UseCustomApp Fill-in the parameter...
    ProjectId (Choose after [Generate Token] clicked) Fill-in the parameter...
    DatasetId (Choose after [Generate Token] clicked and ProjectId selected) Fill-in the parameter...
    Optional Parameters
    ClientId
    ClientSecret
    Scope https://www.googleapis.com/auth/bigquery https://www.googleapis.com/auth/bigquery.insertdata https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/cloud-platform.read-only https://www.googleapis.com/auth/devstorage.full_control https://www.googleapis.com/auth/devstorage.read_only https://www.googleapis.com/auth/devstorage.read_write
    RetryMode RetryWhenStatusCodeMatch
    RetryStatusCodeList 429|503
    RetryCountMax 5
    RetryMultiplyWaitTime True
    Job Location
    Redirect URL (Only for Web App)
    ODBC DSN Oauth Connection Configuration

    Service accounts are accounts that do not represent a human user. They provide a way to manage authentication and authorization when a human is not directly involved, such as when an application needs to access Google Cloud resources. Service accounts are managed by IAM. [API reference]

    Steps how to get and use Google BigQuery credentials

    Follow these steps on how to create Service Account to authenticate and access BigQuery API in SSIS package or ODBC data source:

    Step-1: Create project

    This step is optional, if you already have a project in Google Cloud and can use it. However, if you don't, proceed with these simple steps to create one:

    1. First of all, go to Google API Console.

    2. Then click Select a project button and then click NEW PROJECT button:

      Start creating a new project in Google Cloud
    3. Name your project and click CREATE button:

      Create a new project in Google Cloud
    4. Wait until the project is created:

      Wait until project is created in Google Cloud
    5. Done! Let's proceed to the next step.

    Step-2: Enable Google Cloud APIs

    In this step we will enable BigQuery API and Cloud Resource Manager API:

    1. Select your project on the top bar:

      Select project in Google Cloud
    2. Then click the "hamburger" icon on the top left and access APIs & Services:

      Access APIs and services in Google Cloud
    3. Now let's enable several APIs by clicking ENABLE APIS AND SERVICES button:

      Enable API for project in Google Cloud
    4. In the search bar search for bigquery api and then locate and select BigQuery API:

      Search for API in Google Cloud
    5. If BigQuery API is not enabled, enable it:

      Enable Google BigQuery API
    6. Then repeat the step and enable Cloud Resource Manager API as well:

      Enable Cloud Resource Manager API
    7. Done! Let's proceed to the next step and create a service account.

    Step-3: Create Service Account

    Use the steps below to create a Service Account in Google Cloud:

    1. First of all, go to IAM & Admin in Google Cloud console:

      Access IAM & Admin in Google Cloud
    2. Once you do that, click Service Accounts on the left side and click CREATE SERVICE ACCOUNT button:

      Start creating service account in Google Cloud
    3. Then name your service account and click CREATE AND CONTINUE button:

      Create service account in Google Cloud
    4. Continue by clicking Select a role dropdown and start granting service account BigQuery Admin and Project Viewer roles:

      Start granting service account project roles in Google Cloud
    5. Find BigQuery group on the left and then click on BigQuery Admin role on the right:

      Grant service account BigQuery Admin role
    6. Then click ADD ANOTHER ROLE button, find Project group and select Viewer role:

      Grant service account project viewer role
    7. Finish adding roles by clicking CONTINUE button:

      Finish granting service account project roles in Google Cloud
      You can always add or modify permissions later in IAM & Admin.
    8. Finally, in the last step, just click button DONE:

      Finish configuring service account in Google Cloud
    9. Done! We are ready to add a Key to this service account in the next step.

    Step-4: Add Key to Service Account

    We are ready to add a Key (P12 certificate) to the created Service Account:

    1. In Service Accounts open newly created service account:

      Open service account in Google Cloud
    2. Next, copy email address of your service account for the later step:

      Copy service account email address in Google Cloud
    3. Continue by selecting KEYS tab, then press ADD KEY dropdown, and click Create new key menu item:

      Start creating key for service account in Google Cloud
    4. Finally, select P12 option and hit CREATE button:

      Create P12 key for service account in Google Cloud
    5. P12 certificate downloads into your machine. We have all the data needed for authentication, let's proceed to the last step!

    Step-5: Configure connection

    1. Now go to SSIS package or ODBC data source and configure these fields in Service Account authentication configuration:

      • In the Service Account Email field paste the service account Email address value you copied in the previous step.
      • In the Service Account Private Key Path (i.e. *.p12) field use downloaded certificate's file path.
    2. Done! Now you are ready to use Google BigQuery Connector!

    Fill in all required parameters and set optional parameters if needed:

    GoogleBigqueryDSN
    Google BigQuery
    Service Account [OAuth]
    https://www.googleapis.com/bigquery/v2
    Required Parameters
    Service Account Email Fill-in the parameter...
    Service Account Private Key Path (i.e. *.p12) Fill-in the parameter...
    ProjectId Fill-in the parameter...
    DatasetId (Choose after ProjectId) Fill-in the parameter...
    Optional Parameters
    Scope https://www.googleapis.com/auth/bigquery https://www.googleapis.com/auth/bigquery.insertdata https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/cloud-platform.read-only https://www.googleapis.com/auth/devstorage.full_control https://www.googleapis.com/auth/devstorage.read_only https://www.googleapis.com/auth/devstorage.read_write
    RetryMode RetryWhenStatusCodeMatch
    RetryStatusCodeList 429
    RetryCountMax 5
    RetryMultiplyWaitTime True
    Job Location
    Impersonate As (Enter Email Id)
    ODBC DSN Oauth Connection Configuration

  7. Once the data source has been configured, you can preview data. Select the Preview tab and use settings similar to the following to preview data:
    ODBC ZappySys Data Source Preview

  8. Click OK to finish creating the data source.

Reading data from client application

  1. Firstly, to get data from ODBC data source based on ZappySys ODBC driver, in your client application, you would need to connect to ODBC source and then from the list select the data source.
  2. Finally, to read the data just read tables/views in your app or enter a SQL statement to extract data, e.g.:

    SELECT * FROM [$parent.tableReference.tableId$]

Google BigQuery Connector Examples

The ZappySys API Driver is a user-friendly interface designed to facilitate the seamless integration of various applications with the Google BigQuery API. With its intuitive design and robust functionality, the ZappySys API Driver simplifies the process of configuring specific API endpoints to efficiently read or write data from Google BigQuery.

Click here to find more Google BigQuery Connector examples designed for seamless integration with the ZappySys API ODBC Driver under ODBC Data Source (36/64) or ZappySys Data Gateway, enhancing your ability to connect and interact with Prebuilt Connectors effectively.

Consume Data inside your App / Programming Language

Once you know how to load data from Google BigQuery Connector, you can click on one of the below links to learn the steps how to consume data inside your App / Programming Language from Google BigQuery Connector.

ODBC inside ETL / Reporting / BI Tools

ODBC inside Programming Languages

Key features of the ZappySys API Driver include:

The API ODBC driver facilitates the reading and writing of data from numerous popular online services (refer to the complete list here) using familiar SQL language without learning complexity of REST API calls. The driver allows querying nested structure and output as a flat table. You can also create your own ODBC / Data Gateway API connector file and use it with this driver.

  1. Intuitive Configuration: The interface is designed to be user-friendly, enabling users to easily set up the specific API endpoints within Google BigQuery without requiring extensive technical expertise or programming knowledge.

  2. Customizable Endpoint Setup: Users can conveniently configure the API endpoint settings, including the HTTP request method, endpoint URL, and any necessary parameters, to precisely target the desired data within Google BigQuery.

  3. Data Manipulation Capabilities: The ZappySys API Driver allows for seamless data retrieval and writing, enabling users to fetch data from Google BigQuery and perform various data manipulation operations as needed, all through an intuitive and straightforward interface.

  4. Secure Authentication Integration: The driver provides secure authentication integration, allowing users to securely connect to the Google BigQuery API by inputting the necessary authentication credentials, such as API tokens or other authentication keys.

  5. Error Handling Support: The interface is equipped with comprehensive error handling support, ensuring that any errors or exceptions encountered during the data retrieval or writing process are efficiently managed and appropriately communicated to users for prompt resolution.

  6. Data Visualization and Reporting: The ZappySys API Driver facilitates the seamless processing and presentation of the retrieved data from Google BigQuery, enabling users to generate comprehensive reports and visualizations for further analysis and decision-making purposes.

Overall, the ZappySys API Driver serves as a powerful tool for streamlining the integration of applications with Google BigQuery, providing users with a convenient and efficient way to access and manage data, all through a user-friendly and intuitive interface.