[ ABORT TO HUD ]
SEQ. 1
SEQ. 2

Calling Gemini from BigQuery

📊 BigQuery ML & Data AI 15m 300 BASE XP⌨ HANDS-ON LAB

Generative AI over Structured Data

BigQuery ML now integrates directly with Vertex AI foundation models. You can run Gemini over millions of rows of text data directly within a SQL query.

SELECT * FROM ML.GENERATE_TEXT(
  MODEL `my_dataset.gemini_pro_model`,
  (SELECT text_column as prompt FROM `my_dataset.reviews`),
  STRUCT(0.2 AS temperature, 100 AS max_output_tokens)
);

This allows you to perform sentiment analysis, summarization, and entity extraction on massive datasets in seconds.

⌨ HANDS-ON LABRun Gemini over SQL Rows
⭐ +150 XP

Your reviews table has a million rows. Run Gemini across them without leaving BigQuery, using the bq CLI and ML.GENERATE_TEXT.

1Execute a query with the bq CLI that calls ML.GENERATE_TEXT over your remote Gemini model.
lab-sandbox — simulated environment
INFINITY LAB SANDBOX v2.6 — simulated shell
Type the command for the current objective. Helpers: "hint", "solution", "clear".
$
OBJECTIVE 1 / 1 — type "hint" if stuck
SYNAPSE VERIFICATION
QUERY 1 // 1
How can you run the Gemini model over millions of rows in BigQuery?
Export the data to Python and loop over it
Use the ML.GENERATE_TEXT function directly in a SQL query
It is not possible
Use a Cloud Function to trigger the API