Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Real-time Gen AI with BigQuery Continuous Queries: a low-code approach

issaghaba
Staff

To stay competitive, businesses must deliver actionable insights in real time. From enhancing customer experiences in retail to dynamic pricing in hospitality, real-time inference has become indispensable. Yet, the lack of resources like data scientists often hampers AI adoption.

In this blog, I'll demonstrate how organizations can overcome this hurdle by using BigQuery's latest feature, Continuous Queries, combined with Google's GenAI models and Pub/Sub to implement real-time AI with minimal coding.

We will leverage the following services:

  • BigQuery Continuous Queries: This new BigQuery feature allows real-time data stream processing and supports reverse ETL without requiring traditional ETL pipelines.
  • BigQuery ML: BQML enables data practitioners to build AI/ML solutions using SQL directly within BigQuery, without the need to manage infrastructure or move data to external environments, making AI accessible to a broader audience.
  • Pub/Sub: Google Cloud's messaging service, designed to handle real-time data streams at scale from sources like IoT devices, social media feeds, or application logs.

Use cases

  • Personalized User Experience in retail: Deliver personalized recommendations to customers in real time, boosting engagement and driving satisfaction. Retailers can enhance interactions by instantly tailoring experiences to meet individual preferences
  • Increased Efficiency and Productivity: Eliminate the need for complex ETL pipelines by using a low-code/no-code approach to execute real-time analytics, seamlessly integrating insights into operational systems.
  • Gain Real-Time Insights from Customer Feedback: Track social media, customer reviews, and support tickets to gauge shifting customer sentiment in real time. This enables businesses to promptly address negative feedback, improving customer satisfaction and loyalty.

Technical benefits

  • Low Code / No Code: The proposed solution leverages continuous queries, a feature currently in preview, enabling real-time analysis of incoming data streams using SQL—a familiar language for data practitioners. Continuous queries can output results to BigQuery, a Pub/Sub topic for downstream applications, or BigTable (Reverse ETL), augmenting operational databases with powerful analytics by combining data from various sources within your organization.
  • When configuring Pub/Sub for data ingestion, set the subscription's delivery type to "Write to BigQuery." This ensures that incoming messages are directly pushed to an existing BigQuery table, removing the need for traditional ETL pipelines.
  • Streaming AI & ML: With continuous queries in BigQuery, you can tap into Vertex AI’s large language models (LLMs) by creating remote models using BQML, all without managing complex computing infrastructure. Data practitioners can use SQL, their preferred language, to build and train AI models. This solution also allows you to create embeddings on streaming data enabling use cases such as Semantic search, classification, clustering and Outlier Detection.

Continuous Queries with AI low code architectureContinuous Queries with AI low code architecture

 

Design considerations

As mentioned above, the continuous queries feature is currently in preview. We recommend not implementing for production workloads and critical use cases until it becomes generally available. We'll announce the official launch date soon. Stay tuned!

 

Step Description
Extract - Real time input and output The architecture assumes Cloud Pub/Sub for receiving data from transactions in real time. Setting up the real time export from those systems into Pub/Sub is out of the scope of this design.
Load PubSub publishes the messages directly in an existing BigQuery table.
Inference The solution assumes you have created a remote Vertex AI model in BigQuery using BQML. You can then use that model to implement your use case. An example is available here.
Reverse ETL Leverage the Export function to output the data in PubSub or Bigtable

In this blog, we've explored how to use the newly released Continuous Queries feature in BigQuery to perform real-time AI inference on streaming data. By utilizing a low-code/no-code approach, we’ve shown how to apply AI-driven insights without the need for extensive technical expertise, making it accessible to businesses across industries.

To see this architecture in action, check out the actual implementation available in my GitHub repository.

Additional Resources

3 0 1,245
Authors