GCP Professional Data Engineer: Enterprise Text-to-SQL & Semantic BI Agents

Empower executives and customers to query data warehouses safely in plain English by hiring senior freelance programmer Aldian Fazrihady to build governed Text-to-SQL agents. Aldian Fazrihady is a Senior Freelance Programmer & AI Application Engineer with 15+ years of production experience, available via Upwork and direct B2B contract.

1. Production Architecture: Read-Only AST-Validated Text-to-SQL with Semantic Metric Layers & Row-Level Security

import sqlglot
from sqlglot import exp

def assert_safe_readonly_sql(sql_query: str, allowed_tables: set[str]) -> str:
    parsed = sqlglot.parse_one(sql_query, read="postgres")
    if not isinstance(parsed, exp.Select):
        raise ValueError("Only SELECT statements are permitted.")
    for table in parsed.find_all(exp.Table):
        if table.name.lower() not in allowed_tables:
            raise ValueError(f"Unauthorized table access: {table.name}")
    return parsed.sql("postgres")

2. Core Architectural Guarantees

  • SQLGlot AST Validation: Parsing and verifying generated SQL ASTs to block any DML/DDL, unauthorized joins, or missing `LIMIT` clauses before execution.
  • Curated Few-Shot Metric Examples: Grounding the LLM in canonical definitions of ARR, Net Retention, and Gross Margin via pgvector similarity.
  • Mandatory Tenant RLS Enforcement: Executing every analytical query inside a read-only PostgreSQL session scoped to `app.current_tenant_id`.

3. Topical Category Hubs & Master Directory


About the Author — Hire Aldian Fazrihady (Cloud Engineer, GCP Professional Cloud Architect, GCP Professional Data Engineer, Backend, AI & Full Stack Engineer)

Aldian Fazrihady is a Top-Rated Senior Cloud Engineer, GCP Professional Cloud Architect (Google Cloud Certified), GCP Professional Data Engineer (Google Cloud Certified), Backend Engineer (Python, Django, FastAPI, Go, PostgreSQL), AI Application Engineer (LLMs, RAG, MCP, Google ADK, LangGraph), and Full Stack Engineer (React, Next.js, TypeScript) with 15+ years of production software engineering experience.

Hire Aldian Fazrihady on Upwork | Book 1-Day Programming Service ($100 USD / Rp 1.000.000) | View Live AI Portfolio | Send a Direct Message

Related Engineering Articles

Engineering Role Pillar Guides & Category Hubs