tobymao/sqlglot

Python SQL Parser and Transpiler

View on GitHub ↗Jump to charts ↓Open shareable report

Summary Information

Updated 60 minutes ago
Added to GitGenius on May 5th, 2026
Created on March 13th, 2021
Open Issues & Pull Requests: 6 (+0)
Number of forks: 1,236
Total Stargazers: 9,512 (+0)
Total Subscribers: 50 (+0)

Issue Activity (beta)

Open issues: 2
New in 7 days: 34
Closed in 7 days: 34
Avg open age: 0 days
Stale 30+ days: 0
Stale 90+ days: 0

Recent activity

Opened in 7 days: 31
Closed in 7 days: 30
Comments in 7 days: 13
Events in 7 days: 73

Top labels

  • enhancement (4)
  • bug (2)
  • good first issue (2)
  • postgres (2)

Repository Insights (GitGenius)

Median issue/PR response: 1.0 hours
Mean response time: 6.7 hours
90th percentile: 19.2 hours
Tracked items: 1,495

Most active contributors

Sign in to see contributor activity.

Detailed Description

SQLGlot is a Python-based SQL parser, transpiler, optimizer, and execution engine that operates with no external dependencies. The project supports translation between 31 different SQL dialects including DuckDB, Presto, Trino, Spark, Databricks, Snowflake, BigQuery, PostgreSQL, MySQL, Redshift, Hive, ClickHouse, and SQLite. Its primary purpose is to read diverse SQL inputs and output syntactically and semantically correct SQL in target dialects, making it valuable for cross-database query migration and standardization.

The repository implements a comprehensive generic SQL parser backed by a robust test suite and demonstrates strong performance despite being written entirely in Python. Core capabilities include SQL formatting, dialect translation, syntax error detection, query optimization, abstract syntax tree manipulation, and programmatic SQL construction. The parser can identify various syntax errors such as unbalanced parentheses and incorrect keyword usage, with dialect incompatibilities configurable to warn or raise exceptions based on user settings.

SQLGlot's architecture centers on expression tree traversal and manipulation. Users can parse SQL into an abstract syntax tree, analyze queries to extract metadata like columns and tables, modify parsed trees programmatically, and transform expressions recursively. The optimizer performs multiple rewriting techniques to create canonical AST representations, useful for standardizing queries or building query engines. The project also supports custom dialect creation through subclassing the Dialect class, enabling users to extend support for proprietary or specialized SQL variants.

The repository demonstrates active maintenance and community engagement. Enhancement requests and PostgreSQL-related issues represent the most active issue categories.

SQLGlot is widely adopted across the data and analytics industry. Known users include SQLMesh, Apache Superset, Dagster, Fugue, Ibis, dlt, mysql-mimic, Querybook, Quokka, Splink, and SQLFrame. The project uses semantic versioning where patch versions indicate backwards-compatible changes, minor versions indicate backwards-incompatible additions, and major versions indicate significant breaking changes.

The project provides comprehensive documentation through pdoc-generated API references hosted on sqlglot.com, along with educational resources including an AST primer, onboarding documentation, and posts on topics like building Python SQL engines and semantic SQL diffing. Installation is available via PyPI with optional development dependencies. The codebase includes benchmarking utilities comparing SQLGlot's parsing performance against other Python-based parsers and Rust bindings. A community Slack channel facilitates user engagement and support.

sqlglot
by
tobymaotobymao/sqlglot

Repository Details

Fetching additional details & charts...