Gemini Now Runs Inside Your BigQuery SQL. Three WooCommerce Recipes.

April 27, 2026
by Cherry Rose

On January 27, 2026, Google Cloud announced that AI.GENERATE and AI.GENERATE_TABLE are generally available in BigQuery, joining AI.IF, AI.SCORE, AI.EMBED, and AI.SIMILARITY as native SQL functions. The Gemini call happens inside the query. No Vertex AI engineering. No data egress. No separate per-token budget negotiation with finance. For a WooCommerce store with two years of orders, products, and reviews already in BigQuery, the cost of asking “which product categories are driving the most negative reviews this quarter” just dropped from a multi-day engineering project to a single SELECT statement.

What Actually Changed on January 27

The function family is small and composable. Each one slots into standard SQL where you would otherwise put a UDF or a window function — meaning the Gemini call is a piece of normal query syntax, not a separate pipeline.

  • AI.GENERATE: calls Gemini with a text prompt; returns generated text. Default endpoint is Gemini 2.5 Flash; Gemini 3.0 is available in preview via explicit endpoint argument.
  • AI.GENERATE_TABLE: same call, but the output is a structured table rather than a single string — useful when you want one row per output element (themes, tags, categories).
  • AI.IF: returns a boolean. Place it in a WHERE clause to filter rows by a natural-language condition.
  • AI.SCORE: returns a numeric score against a prompt-defined criterion. Place it in ORDER BY to rank rows.
  • AI.EMBED: returns a vector embedding for input text or media.
  • AI.SIMILARITY: takes two embeddings and returns a similarity score. Pair with AI.EMBED for semantic search and grouping.

Two operational details that changed the practical setup story. First, BigQuery AI functions can analyze five input modalities from one query: text, image, audio, video, and PDF (BigQuery Generative AI overview). Second, End User Credentials (EUC) eliminates the need for a separate Vertex AI connection_id for interactive queries — meaning a WooCommerce operator can call AI.GENERATE with their own IAM identity, no service-account plumbing required.

The AI is no longer a separate system you integrate. It is a function in your query.

This complements but does not replace the external-tool pattern Seresa already covered in The Intelligence Layer: BigQuery + Claude as a WooCommerce Co-Pilot for Business Decisions. Claude Desktop is the conversational, exploratory tool. AI.GENERATE is the per-row, scheduled, batch-processing tool. Both belong in a serious WooCommerce stack — they answer different questions.

Recipe 1: Summarize Last Month’s Product Reviews Into Top 5 Themes

The classic problem: 500 product reviews came in last month, you want to know what customers actually said, and you do not have time to read them. Pre-2026, this required exporting reviews to a spreadsheet, sending them through an external API, and writing a summarization script. Post-2026, it is a single query.

Assuming WooCommerce review data has landed in BigQuery via Transmute Engine™’s outPIPE — comment text in wp_comments, joined to product ID via comment_post_ID — the query looks like this:

SELECT
  product_id,
  AI.GENERATE(
    CONCAT(
      'Summarize the top 5 themes in these product reviews. ',
      'Return as numbered list. Reviews:n',
      STRING_AGG(comment_content, 'n---n')
    )
  ) AS top_themes
FROM `project.dataset.wp_comments`
WHERE comment_approved = '1'
  AND comment_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
GROUP BY product_id
HAVING COUNT(*) >= 10;

One query, one row per product, one summarized theme list per row. The HAVING COUNT(*) >= 10 filter keeps Gemini away from products with too few reviews to summarize meaningfully.

The 16,000-token prompt ceiling (roughly 12,000 words) means you can stuff a small-novel-sized batch of reviews into a single function call (ML.GENERATE_TEXT documentation). For most WooCommerce stores, that is enough headroom to summarize a quarter of reviews per product in one pass.

Recipe 2: AI.IF in a WHERE Clause for Support Ticket Triage

Second classic problem: support inbox has 200 unread tickets. Most are routine. A handful require escalation. SQL alone cannot tell which is which because the filter criterion — “this customer is frustrated and needs a senior agent” — is not expressible in standard predicates.

AI.IF makes it expressible:

SELECT
  ticket_id,
  customer_email,
  ticket_subject,
  ticket_body,
  created_at
FROM `project.dataset.support_tickets`
WHERE status = 'open'
  AND AI.IF(
    CONCAT(
      'Does this support ticket indicate the customer is frustrated, ',
      'considering a refund, or threatening a chargeback? Reply true or false. ',
      'Ticket: ', ticket_subject, ' — ', ticket_body
    )
  )
ORDER BY created_at ASC;

The output: a list of escalation-worthy tickets, ordered by age, ready for the senior support queue. The criterion lives in the prompt, not in a regex or a keyword list — meaning the filter understands a customer who wrote “I think I’m done with you guys” without needing to enumerate every angry phrase a human might use.

The interesting line is “AI.IF in a WHERE clause.” The Gemini call is now a SQL predicate.

Cost-wise, this scales linearly with the number of rows that survive the upstream filters, so the WHERE status = 'open' clause runs first and the AI call only fires on the open tickets. Standard SQL optimizer rules apply.

Third problem: a customer bought a product two months ago. You want to email them about semantically similar products — not the same SKU, not the same exact category, but products whose descriptions read like the kind of thing the same customer would buy. Standard “customers who bought X also bought Y” segmentation only finds co-purchase correlations. Semantic similarity finds products the model thinks are conceptually related, even if no co-purchase has occurred yet.

The pattern is two queries. First, embed the catalog:

CREATE OR REPLACE TABLE `project.dataset.product_embeddings` AS
SELECT
  product_id,
  product_name,
  AI.EMBED(
    CONCAT(product_name, '. ', short_description, '. ', long_description)
  ) AS embedding
FROM `project.dataset.wp_posts`
WHERE post_type = 'product' AND post_status = 'publish';

Then, find products similar to a target customer’s last purchase:

WITH last_purchase AS (
  SELECT product_id, embedding
  FROM `project.dataset.product_embeddings`
  WHERE product_id = (
    SELECT product_id
    FROM `project.dataset.wp_wc_orders` o
    JOIN `project.dataset.wp_wc_order_items` i USING (order_id)
    WHERE o.customer_email = '[email protected]'
    ORDER BY o.order_date DESC LIMIT 1
  )
)
SELECT
  p.product_id,
  p.product_name,
  AI.SIMILARITY(p.embedding, lp.embedding) AS similarity_score
FROM `project.dataset.product_embeddings` p
CROSS JOIN last_purchase lp
WHERE p.product_id != lp.product_id
ORDER BY similarity_score DESC
LIMIT 10;

Run this against your full customer table and you have a recommendation engine — built in SQL, scoring against your own catalog, no third-party recommendation service in the loop. Why Your Two-Year-Old BigQuery Data Is More Valuable Than Last Week’s Dashboard covers the compounding-data thesis that makes this kind of analysis genuinely valuable: more catalog history means richer embeddings means better recommendations.

Cost and Sovereignty vs External LLMs

For a WooCommerce store already running BigQuery, AI.GENERATE wins on three measurable dimensions when compared to sending the same data to an external LLM API.

Cost. Gemini 2.5 Flash through AI.GENERATE bills against your existing Google Cloud project at per-token rates with no data-egress charge. Calling OpenAI or Claude from outside Google Cloud adds the third-party per-token cost plus the operational cost of moving rows out of BigQuery — typically through a Cloud Run job or Cloud Function. For high-volume per-row analysis (review summarization across thousands of products, ticket triage across hundreds of tickets a day), the cost gap widens fast.

Latency. The Gemini call is in-region with your data. There is no network hop out to a third-party API, no auth token rotation, no rate-limit handshake. For batch jobs, this is a wash. For interactive queries — the analyst running ad-hoc questions — it matters.

Data sovereignty. The data does not leave the Google Cloud project. For stores with EU customers, GCC customers, or any regulatory framework that takes a hard line on cross-border processing, in-place inference is the difference between a clean compliance posture and an extended legal review.

The trade is loss of conversational iteration. Claude Desktop with BigQuery MCP is still the better tool for “let me explore this dataset for an hour and figure out what to ask.” AI.GENERATE is the better tool for “I have figured out the question, now run it across every row, every night.”

Where Transmute Engine Fits

None of the three recipes work without the data being in BigQuery in the first place. Transmute Engine is a first-party Node.js server that runs on your subdomain (e.g., data.yourstore.com); the inPIPE WordPress plugin captures WooCommerce events at the order, customer, product, and review hook layer, and outPIPE streams them into your BigQuery project alongside your GA4 export, your Meta CAPI logs, and your Google Ads conversions. By the time AI.GENERATE went GA in January 2026, Seresa merchants already had two years of structured first-party data sitting in the same project where the new Gemini SQL functions run. The capability landed on top of infrastructure that was ready for it.

Key Takeaways

  • AI.GENERATE went GA on January 27, 2026, alongside AI.GENERATE_TABLE, AI.EMBED, AI.SIMILARITY, AI.IF, and AI.SCORE — all callable from standard SQL.
  • The Gemini call is in-place. EUC removes the Vertex AI connection_id requirement for interactive queries; data does not leave the Google Cloud project.
  • Three immediate WooCommerce recipes: AI.GENERATE on a GROUP BY for review theme extraction, AI.IF in a WHERE clause for support ticket triage, AI.EMBED + AI.SIMILARITY for semantic product recommendations.
  • The 16,000-token prompt ceiling (≈12,000 words) is enough headroom to summarize a quarter of reviews per product in one call.
  • Use AI.GENERATE for scheduled per-row work; use Claude Desktop for conversational exploration. Both belong in a serious WooCommerce stack.

Frequently Asked Questions

Do I need Vertex AI set up separately, or can I just call AI.GENERATE from a BigQuery query?

For interactive queries, no separate Vertex AI setup is required. End User Credentials (EUC) lets BigQuery call Gemini directly using your IAM identity. A separate connection_id is only required for scheduled queries, BigQuery Studio notebooks running unattended, or service-account-driven jobs. The minimum setup for an interactive AI.GENERATE call is a BigQuery user role with the appropriate AI permissions enabled in the project.

Is BigQuery’s AI.GENERATE cheaper than calling the OpenAI API for the same volume of ecommerce analysis?

It depends on volume and data location. AI.GENERATE bills against your Google Cloud project at Gemini 2.5 Flash per-token pricing, with no data egress charge because the data never leaves the project. Calling OpenAI from outside Google Cloud adds OpenAI’s per-token cost plus the operational cost of moving rows out of BigQuery. For analytical workloads where data already lives in BigQuery, AI.GENERATE almost always wins on total cost. For exploratory work where the prompt is the bottleneck, an interactive Claude Desktop session may be faster to iterate.

Can I use AI.GENERATE on product images stored in Cloud Storage to generate category tags for my WooCommerce catalog?

Yes. BigQuery AI functions support five input modalities from a single query: text, image, audio, video, and PDF. Reference Cloud Storage images via an ObjectRef column and pass it to AI.GENERATE alongside a text prompt. The function returns generated text, which can be written back to a category or tag column in your WooCommerce product table.

What is AI.IF in BigQuery and how do I use it in a WHERE clause?

AI.IF is a BigQuery function that returns TRUE or FALSE based on a natural-language condition evaluated by Gemini. Used in a WHERE clause, it filters rows by criteria that would be impractical to express as standard SQL — for example, “rows where the support ticket text contains a refund request” or “rows where the review expresses frustration with shipping speed.” The condition is passed as a string prompt; the function returns a boolean.

Open your BigQuery console. Paste the three starter queries above. See what your WooCommerce data actually says. See how Seresa lands WooCommerce data in BigQuery, ready for AI.GENERATE.

Share this post
Related posts