SQLGlot

No-dependency SQL parser, transpiler, optimizer, and execution engine

Library
PyPI
v30.17.0
9,541stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
81/100Excellent
Development Activity100
Maintenance52
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture88
Code Quality85
Innovation82
Learning Curve72

SQLGlot is a pure-Python SQL parser, transpiler, optimizer, and lightweight execution engine with zero runtime dependencies. It reads SQL written for one dialect and can output syntactically and semantically correct SQL for another, supporting 31 dialects including DuckDB, Presto/Trino, Spark/Databricks, Snowflake, and BigQuery.

Beyond format conversion, SQLGlot exposes a full expression-tree API for programmatically building, analyzing, and rewriting SQL, plus a query optimizer and an in-process executor capable of running queries directly against Python objects. Its comprehensive test suite and dialect coverage have made it a common building block inside data-engineering tools that need to parse or translate SQL rather than hand-roll a parser.

What You Get

  • A SQL parser and generator covering 31 dialects with cross-dialect transpilation
  • A programmatic expression-tree API for building and rewriting SQL queries in code
  • A query optimizer that normalizes, qualifies, and rewrites expression trees for better plans
  • A pure-Python execution engine that can run SQL directly against in-memory data
  • Column-level lineage and metadata analysis over parsed queries

Common Use Cases

  • Translating SQL written for one warehouse (e.g. Snowflake) into another dialect (e.g. DuckDB or BigQuery)
  • Statically analyzing or linting SQL queries inside a data pipeline before execution
  • Programmatically generating SQL queries from application code via the expression-tree builder API
  • Computing column-level lineage across a chain of SQL transformations for data governance

Under The Hood

Architecture - SQLGlot’s pipeline runs tokens.py/tokenizer_core.py to tokenize raw SQL, parser.py (a ~10k-line hand-written recursive-descent parser) to build a typed expression tree defined in sqlglot/expressions, then generator.py to re-render that tree back into dialect-specific SQL text; the sqlglot/optimizer package applies a pipeline of rule-based rewrites (qualification, simplification, pushdown) on the same tree, and sqlglot/executor walks it to evaluate queries directly against Python data structures without a real database.

Tech Stack - Pure Python (3.9+) with zero required runtime dependencies, packaged via setuptools with setuptools_scm for version derivation; dialect definitions live under sqlglot/dialects as per-database subclasses that override tokenizer/parser/generator behavior, keeping dialect-specific quirks isolated from the shared core.

Code Quality - The tests/ directory contains 61 test files exercising individual dialects, the optimizer, the executor, and diffing/lineage features; the project ships py.typed for downstream type-checking support and maintains a CHANGELOG documenting behavior changes across its frequent release cadence (100+ commits/month at the time of writing).

API Design - The top-level API is deliberately small — sqlglot.parse_one(), sqlglot.transpile(), and sqlglot.exp for tree construction cover the majority of use cases in one import, while power users can drop down to the expression tree, optimizer, or executor modules directly; this layering lets simple format-conversion tasks stay one-liners while still exposing the full internals for advanced query rewriting.

Used by 9 apps in this directory

Python
66%
Apache 2.0

Agent Control

AI Agents

295

An open-source runtime control plane for AI agents — define safety guardrails once, apply them across agents built on LangChain, CrewAI, Google ADK, or AWS Strands, and update controls without redeploying code.

View details
79
Repo Health
71
Technical
70
Dependency
Built with
Python66%
TypeScript33%
Updated yesterday
Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,530

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
66
Dependency
Built with
Python90%
Updated today
C++
69%
Apache 2.0

ClickHouse

Databases · Analytics · Data Engineering

49,325

Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.

View details
95
Repo Health
90
Technical
68
Dependency
Built with
C++69%
Python13%
Updated today
Python
57%
MIT

Docglow

Data Engineering

137

A next-generation documentation site generator for dbt Core projects — lineage explorer, health scoring, and full-text search for teams without access to dbt Cloud's built-in docs features.

View details
67
Repo Health
65
Technical
82
Dependency
Built with
Python57%
TypeScript42%
Updated 1 weeks ago
TypeScript
84%
Apache 2.0

ktx

Data Engineering · Analytics · AI Development

1,547

ktx builds a self-improving context layer over your data warehouse so AI agents like Claude Code and Codex query it with approved metric definitions instead of reinventing SQL logic from scratch.

View details
73
Repo Health
85
Technical
73
Dependency
Built with
TypeScript84%
Updated 1 months ago
Python
61%
Apache 2.0

marimo

Developer Tools · Data Engineering

22,393

A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.

View details
90
Repo Health
91
Technical
66
Dependency
Built with
Python61%
TypeScript37%
Updated today
Clojure
54%
Other

Metabase

Analytics

48,828

The open-source BI platform that lets anyone ask questions and build dashboards without writing SQL — with an embedded analytics SDK and AI-powered query assistant included.

View details
95
Repo Health
84
Technical
65
Dependency
Built with
Clojure54%
TypeScript40%
Updated today
TypeScript
80%
Apache 2.0

nao

AI Development · Analytics

1,570

Build and deploy an open-source analytics agent that understands your data warehouse and answers business questions in plain English.

View details
83
Repo Health
76
Technical
68
Dependency
Built with
TypeScript80%
Python19%
Updated yesterday
Python
61%
Apache 2.0

WrenAI

Analytics · AI Agents · Data Engineering

17,313

Open-source GenBI engine that lets AI agents turn natural-language questions into governed SQL, charts, and shareable dashboards across 20+ data sources — no vendor lock-in, no black-box prompts.

View details
91
Repo Health
91
Technical
69
Dependency
Built with
Python61%
Rust36%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search