Model Online / On-Site
Duration
Modules 6 modules

Course Objective & Scope

Executing LLM-generated SQL directly against an enterprise database introduces severe risks: cross-tenant data leakage, unauthorized access to sensitive columns, runaway Cartesian joins that stall the warehouse, and syntactically valid queries that silently compute the wrong answer. This course covers the deterministic validation, access-control and resource-protection layers required before taking Text-to-SQL to production.

Participants use SQLGlot for Abstract Syntax Tree (AST) inspection and predicate rewriting, combine application checks with database Row-Level Security (RLS) and `EXPLAIN` cost gates, and build a hardened SQL execution pipeline.

Who Should Attend?

  • AI and backend engineers taking Text-to-SQL and database-connected agents into production
  • Data/platform architects and DBAs responsible for data security, access control and warehouse stability
  • Technical teams building conversational analytics in regulated or multi-tenant environments
  • Prerequisite: strong SQL skills, database security fundamentals and Python proficiency

Key Takeaways

  • Parse LLM-generated SQL into an AST with SQLGlot to enforce table, column and statement allowlists
  • Block DML/DDL, multi-statement payloads, system catalog probing and dangerous database functions
  • Enforce tenant and role isolation through defense-in-depth: AST predicate injection plus database RLS
  • Protect the warehouse using `EXPLAIN` dry-run cost checks, mandatory `LIMIT` clauses, timeouts and scan quotas
  • Detect semantic SQL pitfalls (unbounded JOINs, NULL traps, silent truncation) before returning answers to users

Curriculum

The Text-to-SQL Threat Model and Defense-in-Depth
  • Why prompt-level safety rules are easily bypassed and why enforcement belongs in code and the database
  • Four concentric rings: schema scoping -> AST validation -> session-scoped RLS -> execution/result guards
Deterministic Query Validation with SQLGlot and AST Inspection
  • Parsing generated SQL into an AST to enforce single-statement read-only `SELECT`/`WITH` rules
  • Table and column allowlisting, blocking catalog access (`information_schema`, `pg_catalog`) and dialect transpilation
Multi-Tenant Access Control: RLS, Column Security and Masking
  • Read-only database roles, session-context Row-Level Security (RLS) policies and authorized views
  • Combining AST tenant-predicate injection with column-level PII masking and aggregation-only rules
Warehouse Protection: EXPLAIN Dry-Runs, Cost Guards and Timeouts
  • Pre-execution `EXPLAIN` and dry-run byte estimation to block full-table scans and Cartesian joins
  • Enforcing `LIMIT` caps, `statement_timeout`, connection pools and read-replica routing
Semantic SQL Verification and Bounded Self-Correction Loops
  • Catching syntactically valid bugs: fan-out joins, all-NULL/zero results, missing filters and date mismatches
  • Feeding structured validation diagnostics back to the model for bounded repair
Lab: Building a Hardened Text-to-SQL Execution Gateway
  • Implementing a SQLGlot + RLS + EXPLAIN validation pipeline in Python
  • Red-teaming the gateway against prompt injection, cross-tenant leaks and resource exhaustion

Other Courses in This Category

  • Text-to-SQL Accuracy Evaluation and Enterprise Benchmarking

    Evaluating Text-to-SQL systems rigorously using Execution Accuracy, result-set matching, AST structural comparison, query efficiency scoring and enterprise benchmark construction.

    RAG & Enterprise Knowledge Systems Corporate
    Live Course
    6 modules
  • RAG with LangChain RAG with LangChain

    Hands-on workshop on building an end-to-end Retrieval-Augmented Generation (RAG) chatbot using LangChain, covering document chunking, embeddings, vector databases, and a Gradio interface.

    RAG & Enterprise Knowledge Systems Corporate, Individual Workshop
    Live Course
    6 modules
  • Multimodal RAG Multimodal RAG

    Hands-on workshop on building a Multimodal RAG system with LangChain to extract, embed, and query text, tables, and images from complex PDF documents.

    RAG & Enterprise Knowledge Systems Corporate, Individual Workshop
    Live Course
    6 modules
  • Retrieval-Augmented Generation (RAG) Fundamentals

    Hands-on fundamentals for building an end-to-end RAG system over enterprise documents: ingestion, chunking, embeddings, vector retrieval, grounded prompting with citations and baseline evaluation.

    RAG & Enterprise Knowledge Systems Corporate
    Live Course
    6 modules
  • Embeddings and Semantic Search Engineering

    Deep dive into dense, sparse (SPLADE/BM25), Matryoshka and late-interaction (ColBERT) embeddings, Turkish/multilingual retrieval quality, domain adaptation and semantic search engineering.

    RAG & Enterprise Knowledge Systems Corporate
    Live Course
    6 modules
  • Vector Database Architectures: pgvector, Milvus, FAISS, Weaviate and Pinecone

    Engineering deep dive into ANN indexing (HNSW, IVF, DiskANN, PQ) and vector databases (pgvector, Milvus, Weaviate, FAISS, Pinecone), covering filtered search, multi-tenancy and capacity planning.

    RAG & Enterprise Knowledge Systems Corporate
    Live Course
    6 modules

Get in touch