How to Configure LlamaIndex Bigquery Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up a llamaindex bigquery prevent delete rule, assign a read-only database role. You must also limit which tables the query engine can read. Many teams connect their AI apps to data warehouses using broad service keys. Those broad keys often allow write and delete actions by mistake. When a model writes bad SQL, broad permissions let it drop production data. How llamaindex bigquery prevent delete works in native setups LlamaIndex connects to relational databases and warehouses through a

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.

To set up a llamaindex bigquery prevent delete rule, assign a read-only database role. You must also limit which tables the query engine can read. Many teams connect their AI apps to data warehouses using broad service keys. Those broad keys often allow write and delete actions by mistake. When a model writes bad SQL, broad permissions let it drop production data.

How llamaindex bigquery prevent delete works in native setups

LlamaIndex connects to relational databases and warehouses through a light wrapper around SQLAlchemy. Its natural language query engine turns user questions into SQL statements. The engine runs those generated statements directly against the tables you name. If you do not name specific tables, the engine pulls all schema context. Pulling every table wastes tokens and exposes sensitive tables to the model.

The official LlamaIndex docs warns that running arbitrary SQL queries brings security risks. It advises teams to take clear precautions when building text-to-SQL apps. Those precautions include using restricted roles, read-only databases, and sandboxing. None of these protections turn on by default inside the framework itself. The framework simply passes the generated SQL string to the database driver.

To block deletes natively, you must change permissions inside your cloud database project. Start by creating a dedicated service identity just for your LlamaIndex app. Never reuse an admin key or a general backend key for an agent. Grant this new identity permissions to run jobs and read table data only. Leave out any permission that allows table mutation, row deletion, or schema drops.

Next, restrict the schema context inside your LlamaIndex query engine setup. Pass an explicit list of safe table names when you build the engine. This step stops the agent from reading metadata about internal or restricted tables. When the model does not know a table exists, it rarely queries it. Still, hiding table names in prompts is not a real security boundary.

Why database roles alone leave an operational gap

Cloud database roles do a good job of blocking unauthorized write commands. If the service identity lacks delete rights, the warehouse rejects a delete statement. This native setup decides who logs in and which broad actions can run. Still, static roles cannot inspect what individual statements do while in flight. A read-only role still lets a model run massive queries across huge tables.

Even without delete rights, an agent can cause big problems with read queries. A poorly written join can scan terabytes of data and drive up costs. Worse, a valid select query can pull raw customer emails and phone numbers. It can also read credit card numbers or national IDs from allowed tables. The database role sees a legal read request and returns all the rows.

BigQuery IAM + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Wait times and audit trails also suffer when every agent shares one key. In the warehouse logs, every query looks like it came from one service account. Your team cannot tell which user prompt triggered a slow or risky query. You also cannot pause a single risky query for human review before execution. Managing dozens of custom roles across many datasets quickly becomes hard to track.

Adding statement checks and data masking for AI queries

Safe text-to-SQL setups pair least-privilege database roles with controls at the query level. First, your team should check the structure of every generated SQL string. If a statement includes a delete, drop, or update keyword, block it early. Stopping bad queries before they reach the warehouse saves compute and reduces noise. You can also require human approval when an agent asks for sensitive tables.

Second, you should protect sensitive fields in the query results before models read them. Data masking rewrites matched fields like emails, phone numbers, and card numbers in results. The agent gets the structure it needs to answer the user question safely. Meanwhile, raw national IDs and contact details stay out of third-party model prompts. Combining read-only roles with query checks gives your team control over agent traffic.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Does LlamaIndex block delete queries on its own?

No, LlamaIndex executes the SQL queries that the language model generates. Its docs tells developers to use read-only databases, restricted roles, and sandboxing for safety.

What happens if I do not list tables in the query engine?

If you do not name specific tables, the query engine pulls all schema context. This exposes every table in that database connection to the language model.

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

No, a read-only role only stops the agent from changing or deleting data. The agent can still select and read emails, phone numbers, or card numbers unless you mask results.

The query runs. The emails stay hidden.