Set up Gemini in BigQuery

Before you can use Gemini in BigQuery, which offers AI-powered assistance for your data analytics, your team must do the following:

  1. Purchase Gemini in BigQuery
  2. Enable necessary APIs.
  3. Grant required Identity and Access Management (IAM) roles.
  4. Turn on Gemini in BigQuery features in the Google Cloud console.

Purchase Gemini in BigQuery

To use Gemini in BigQuery, you must do one of the following:

For a list of included capabilities, see Gemini in BigQuery Pricing Overview.

Purchase Enterprise Plus edition

To give users access to Gemini in BigQuery capabilities, create a BigQuery Enterprise Plus edition reservation and an assignment with job_type of QUERY for the organization or project. Query jobs that run in projects assigned to that reservation can use Gemini in BigQuery capabilities.

Required permissions

To create and assign a reservation that allows Gemini in BigQuery capabilities, you must have the BigQuery Resource Admin or another role with the bigquery.reservations.create and bigquery.reservationAssignments.create IAM permissions. For more information about IAM roles in BigQuery, see Predefined roles and permissions.

Create Enterprise Plus assignments with Gemini in BigQuery

  1. In the Google Cloud console, go to the BigQuery Capacity Management page.

    Go to BigQuery Capacity Management

  2. On the Capacity Management page in the Slot Reservation section, identify the Enterprise Plus edition reservation you want to use to assign Gemini in BigQuery capabilities. To create a new reservation, follow the instructions in Create reservations and select Enterprise Plus for Edition.

  3. In the Actions column for your Enterprise Plus edition reservation, click Reservation Actions, and then click Create assignment.

  4. On the Create an assignment pane, for Select an organization, folder, or project, click Browse to search for the project or organization to assign the selected reservation. Folders are not supported for Gemini in BigQuery assignments.

  5. For Job Type, only QUERY job types are supported for Gemini in BigQuery assignments.

  6. To enable Gemini in BigQuery, toggle Enable Gemini in BigQuery for this assignment. By allowing Gemini in BigQuery to be used for the QUERY type assignment, you agree to its terms and conditions.

  7. Click Create to create the assignment.

Purchase Gemini Code Assist Enterprise

Gemini Code Assist Enterprise includes Gemini in BigQuery capabilities that accelerate end-to-end data & analytics lifecycle with AI assistance. To learn how to purchase, see Purchase a Gemini Code Assist Enterprise subscription and follow the instructions to purchase Enterprise edition.

Enable necessary APIs

To use Gemini in BigQuery, you must enable the Gemini for Google Cloud API. A service administrator or project owner with the serviceusage.services.enable IAM permission typically performs this step.

  1. To enable the Gemini for Google Cloud API, go to the Gemini for Google Cloud page in the Google Cloud Marketplace.

    Go to Gemini for Google Cloud

  2. In the project selector, select a project.

  3. Click Enable.

    The page updates and shows a status of Enabled. Gemini in BigQuery is now available in the selected Google Cloud project to all users who have the required IAM permissions.

  4. To use recommendations for the partitioning and clustering recommender and materialized view recommender, enable the Recommender API if it's not already enabled.

Enable Apache Spark in BigQuery

To use autotuning and assisted troubleshooting for Apache Spark, you must enable the Dataproc API for a project.

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Dataproc API.

    Enable the API

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Make sure that billing is enabled for your Google Cloud project.

  7. Enable the Dataproc API.

    Enable the API

Automatic enablement of asset management APIs

The following asset management APIs are automatically enabled for all Google Cloud projects that use BigQuery:

If you have automation scripts from before March 2024 that depended on the status of these APIs, you might need to update them.

These APIs don't incur any additional costs. Users that have IAM permissions to use enabled services on corresponding resources can incur charges, as described in BigQuery pricing, Dataform pricing, and Dataplex pricing.

You can prevent enablement of additional APIs by setting the Restrict Resource Service Usage organization policy constraint. You can disable selected APIs at any time.

Enable Gemini in BigQuery preview features

Certain Gemini in BigQuery features in Preview are part of the trusted tester program. To request access to these features, an administrator must complete the Gemini in BigQuery Pre-GA Sign-up form. Gemini in BigQuery pre-GA feature access is enabled periodically in batches.

Preview features that require Gemini in BigQuery sign-up include the following:

  • SQL query completion
  • Materialized view recommendations
  • Apache Spark autotuning and assisted troubleshooting

Grant IAM roles on a Google Cloud project

This section describes the steps required to grant the Gemini for Google Cloud User role (roles/cloudaicompanion.user) to users. Additional roles are required for other Gemini in BigQuery features. An administrator typically performs this step.

  1. To grant the IAM roles that are required to use Gemini in BigQuery, go to the IAM & Admin page.

    Go to IAM & Admin

  2. To grant access, click View by principals.

  3. In the Principal column, find a principal for which you want to enable access to Gemini in BigQuery, and then click Edit principal in that row.

  4. In the Edit access pane, click Add another role.

  5. In the Select a role list, select Gemini for Google Cloud User. Users with the Gemini for Google Cloud User role can use Gemini for Google Cloud, but they might need additional permission to use specific Gemini in BigQuery features.

  6. Optional: Grant roles that give permissions to access other Gemini in BigQuery features, if necessary:

  7. Click Save.

Grant IAM roles for Gemini in BigQuery Apache Spark features

To grant the necessary IAM roles to use Gemini in BigQuery Apache Spark features to optimize with autotuning and to use advanced troubleshooting, see Dataproc Serverless roles.

Turn on Gemini in BigQuery features

If you're a data analyst, data scientist, or developer who wants to use specific Gemini in BigQuery features to write SQL queries and Python code, then you need to turn on the feature in the Google Cloud console. To learn how to turn on features, see Before you begin in "Write queries with Gemini assistance." Users who have the necessary IAM roles or permissions can access the Gemini in BigQuery features that are enabled for their Google Cloud project. For more information, see Gemini for Google Cloud overview.

What's next