How to Configure LlamaIndex Bigquery Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up llamaindex bigquery read only access by giving your app a restricted database role. You also pass an explicit table list to the query engine so it only reads approved tables. Many teams start by linking their AI app with a broad cloud account key. That approach works fast in tests, but it creates huge risks in production. If an agent uses an admin role, one bad prompt can delete tables or leak sensitive rows. How llamaindex bigquery read only access works in practice LlamaIndex con

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up llamaindex bigquery read only access by giving your app a restricted database role. You also pass an explicit table list to the query engine so it only reads approved tables. Many teams start by linking their AI app with a broad cloud account key. That approach works fast in tests, but it creates huge risks in production. If an agent uses an admin role, one bad prompt can delete tables or leak sensitive rows.

How llamaindex bigquery read only access works in practice

LlamaIndex connects to data warehouses through a light wrapper around SQLAlchemy. When a user asks a question, the table query engine turns that question into a SQL query. It then runs that generated SQL straight against your BigQuery project. If you do not specify which tables to use, the query engine pulls all schema context. Pulling every table wastes context tokens and exposes internal tables to the language model.

To lock this down, you first build a dedicated service identity in your cloud project. You grant this identity permission to run query jobs and read only the specific datasets needed. You leave out permissions that allow creating, updating, or dropping tables. Next, you pass your limited table list when you set up the SQL wrapper in your app. The official LlamaIndex docs warn that running arbitrary SQL queries is a security risk. They advise teams to use restricted roles, read-only databases, and sandboxing to reduce harm.

Why cloud roles alone leave a gap

A read-only role stops an agent from dropping tables or altering rows. That is a vital first step for any team running text-to-SQL apps. Still, cloud roles only check who logs in and which datasets they can touch. They do not inspect what individual SQL statements do in flight.

Even with read-only rules, a language model can still write a massive join across huge tables. That single bad query can drive up cloud compute bills in seconds. Also, a read-only role allows the agent to read every column in an allowed table by default. If that table holds customer emails, phone numbers, or card numbers, the model pulls them right into memory. The raw values then flow out to external model providers and appear in chat answers.

Auditor Read-Only Access + Customer Support Access to Production: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Adding query checks and data masking

To run AI agents safely, teams need controls that work at the query level. You must inspect the generated SQL before it ever reaches the data warehouse. Statement rules let you block risky patterns, such as unconstrained scans or missing row limits. This keeps a confused agent from scanning terabytes of historical data by mistake.

You also need a way to handle sensitive columns during read queries. Data masking rewrites matched fields like emails, phone numbers, and national IDs in the query results. The agent still gets the row structure it needs to answer questions and count records. Meanwhile, the sensitive strings get replaced before they reach the language model. Combining restricted cloud roles with query-level checks gives your team safe, predictable data access.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Why does LlamaIndex pull my entire BigQuery schema by default?

If you do not name specific tables, the query engine fetches all available schema context. Naming your target tables stops this behavior and keeps your prompts smaller and safer.

Can a read-only BigQuery role stop sensitive data leaks?

No, a read-only role only stops write actions like deleting or changing data. The agent can still select and read sensitive fields like card numbers or emails from allowed tables.

What does LlamaIndex recommend for securing text-to-SQL apps?

The official docs states that running arbitrary generated SQL is a security risk. It recommends using restricted database roles, read-only databases, and sandboxing for every text-to-SQL app.

The query runs. The emails stay hidden.