Enable Google AI Model, Gemini in BigQuery

Use the power of AI to generate SQL queries using natural language

In partnership with

Gemini is a Google AI model that you can now use in BigQuery to assist you in writing SQL queries for any data including GA4.

It is a great tool for both beginners and experienced analysts. Beginners can learn SQL with help of Gemini while experienced folks can use it to expedite the SQL writing.

Gemini is not enabled by default in your BigQuery console. Follow the steps below to enable it.

Note: If you haven’t yet started with BigQuery then don’t be left behind. Here is a course to get you started, https://academy.optizent.com/courses/bigquery-sql-fundamentals-ga4?coupon=BQFUNDAMENTALSYT

How to Enable Gemini in BigQuery

  1. Enable necessary APIs.

  2. Grant required Identity and Access Management (IAM) roles.

  3. Turn on Gemini in BigQuery features in the Google Cloud console.

Enable Gemini APIs

Note: You will need to be either an administrator or project owner with the serviceusage.services.enable permission to perform the following steps.

  1. Go to Gemini for Google Cloud page.

  2. Click Enable.

  3. You will see the status as Enabled and now Gemini is available in BigQuery in the selected Google Cloud project.

IAM Permissions

  1. Go to the IAM & Admin page.

  2. Click on View by principals.

  3. In the Principal column, find the user (principal) for which you want to enable access to Gemini in BigQuery

  4. Click edit Edit principal in that row.

  5. In the Edit access pane, click add Add another role.

  6. In the Select a role list, select Gemini for Google Cloud User.

  7. This will grant the Cloud AI Companion User IAM role (roles/cloudaicompanion.user) to the user.

Turn on BigQuery Features in Your Project

  1. In the Google Cloud console, on the project selector page, select the Google Cloud project.

  2. In the Google Cloud console, go to the BigQuery page.

  3. In the toolbar, click the pen with sparks (Gemini) drop-down icon.

  4. In the dropdown list of features, select the features that you want to enable in your project. I have enabled all the features (see the screenshot above):

    • Gemini in SQL query:

      • Auto-generation: Allows you to use Gemini in BigQuery to generate a SQL query using natural language prompts.

      • SQL generation tool: Same as above to generate a SQL query, with options to refine query results, choose table sources, and compare results.

      • Explanation: This help you use Gemini to explain the SQL query in natural language so that you can easily understand it.

    • Gemini in Python notebook:

      • Code completion (Preview): Use Gemini to contextually appropriate recommendations based on what you already have in the notebook.

      • Code generation: Use Gemini to generate Python code using natural language.

Now Gemini is enabled and ready to be used. In the next post, I will show how to use Gemini to generate SQL.

Need BigQuery and GA4 help?

Contact us at [email protected] or fill the contact us form.

Use AI as Your Personal Assistant

Ready to embrace a new era of task delegation?

HubSpot’s highly anticipated AI Task Delegation Playbook is your key to supercharging your productivity and saving precious time.

Learn how to integrate AI technology into your processes, allowing you to optimize resource allocation and maximize output with precision and ease.

Reply

or to participate.