How to Configure LlamaIndex ClickHouse Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a llamaindex clickhouse approval workflow by pairing restricted database roles with human review. First, you limit what the query engine can read, and then you check queries before execution. Many teams start by giving an AI app a broad database user. That setup lets the language model pull every table schema at once. If a prompt tricks the model, it can run heavy scans or read sensitive columns. How a native llamaindex clickhouse approval workflow operates LlamaIndex connects to r

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 a llamaindex clickhouse approval workflow by pairing restricted database roles with human review. First, you limit what the query engine can read, and then you check queries before execution. Many teams start by giving an AI app a broad database user. That setup lets the language model pull every table schema at once. If a prompt tricks the model, it can run heavy scans or read sensitive columns.

How a native llamaindex clickhouse approval workflow operates

LlamaIndex connects to relational data through a light wrapper around SQLAlchemy. Its natural language query engine turns user questions into SQL statements over named tables. If you do not name specific tables, the engine pulls all schema context into the prompt. The official LlamaIndex docs note that running arbitrary SQL queries is a security risk. They advise teams to use restricted roles, read-only databases, and sandboxing.

On the database side, ClickHouse manages users, roles, row policies, settings profiles, and quotas as SQL entities. An admin turns on SQL-driven control by setting a server storage path and enabling user management privileges. When you create a database user for your AI app, you set its login method and allowed hosts. You also assign default roles and per-user settings. A user can only grant privileges that they hold themselves.

To tighten this native setup, you grant read rights on specific columns instead of full tables. When a user only has column grants, queries must name those exact columns. A wildcard select fails and returns no data unless the table only has those granted columns. Since version 24.10, admins can also use a trailing asterisk to grant rights by table name prefix. For human sign-off, developers must build custom app code that pauses the agent and asks a reviewer.

What native roles solve and what they leave open

Native ClickHouse roles and column grants stop an agent from reading restricted tables. They also block logins from unknown hosts and enforce basic account limits. Scoping the table list in LlamaIndex also keeps extra schema details out of model prompts. These controls decide who can log in and which objects remain visible.

Approval Chains & Escalation + ClickHouse Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, static database roles cannot check what individual statements do in flight. ClickHouse does not have a built-in pause button that waits for a human to approve a query. Once the agent logs in, the database runs every permitted query right away. If a permitted column holds emails, phone numbers, or card numbers, the query returns them in plain text. Building custom pause logic inside every Python app takes extra work and is hard to audit across teams.

Adding runtime query review and column controls

A safer approach separates query review from both the agent code and the database server. When the AI app sends a SQL statement, a runtime check can hold it for human sign-off. A reviewer sees the exact statement and approves or rejects it before the database runs it. At the same time, data masking rewrites matched fields like national IDs or emails in the query results. This setup keeps raw credentials out of the app while giving security teams a clear log of every query.

Check ClickHouse queries and result columns on the wire

ClickHouse users and row policies decide who connects. They do not check each statement on the wire or redact sensitive string columns in query results. With hoop.dev, you run an open-source proxy, a sidecar for your ClickHouse. It reads ClickHouse's native TCP protocol before queries run while ClickHouse stays in charge of login and grants.

Multi-statement queries and table mutations are split and checked by hoop.dev guardrails. Banned actions are refused with a native ClickHouse error. On returned rows, hoop.dev data masking rewrites String and FixedString columns that match your rules. The audit trail logs each query, table, and verdict. See the MIT-licensed source on GitHub.

Frequently asked questions

Why does LlamaIndex warn about arbitrary SQL execution?

Natural language query engines turn plain text questions into live SQL statements. Without strict limits, a bad prompt can make the engine run slow queries or read private records. Using restricted roles and read-only users reduces this risk.

What happens if a ClickHouse user with column grants runs a wildcard query?

ClickHouse refuses a wildcard select when a user only has access to specific columns on a wider table. The query returns no data at all. The agent must list the exact allowed column names in its select statement.

Can ClickHouse pause a query for human approval by itself?

No, ClickHouse evaluates grants right away and either runs or blocks the statement. To require human sign-off before a query runs, you must pause execution outside the database engine.

The query runs. The emails stay hidden.