Architecture of tobymao/sqlglot
tobymao/sqlglot is 275 source files holding 6,434 symbols across 7 modules, written mainly in Python, Makefile, Shell. The largest module is sqlglot, with 183 files, and 3 files are entry points into the dependency graph.
How sqlglot fits together
SQL text enters through the functions exposed at the package root in sqlglot/__init__.py, and sqlglot/__main__.py is the module entry point. The parser in sqlglot/parser.py builds the dialect-neutral expression tree from the input. An optional optimizer can rewrite that tree into a canonical form. sqlglot/generator.py then produces SQL text from the tree, and dialect modules such as sqlglot/dialects/duckdb.py supply the rules for each target dialect. The same tree is also used by the in-memory executor and the AST diff. pdoc/cli.py builds the HTML API reference.
Largest modules
- sqlglot: 183 files and 66,589 lines of code
- tests: 64 files and 57,517 lines of code
- benchmarks: 4 files and 541 lines of code
- .github: 2 files and 262 lines of code
- root: 2 files and 145 lines of code
- pdoc: 1 file and 25 lines of code
- sqlglotc: 1 file and 152 lines of code
Languages
By file count: Python 255 files, Makefile 1 file, Shell 1 file.
Documentation
Repowise documents sqlglot in 690 pages generated from the source, 18 of them written explanations of the repository and its modules. Module guides include:
- pdoc: API Documentation Generation
- sqlglotc: Compiled Extension Build
- sqlglot/dialects: Dialect Implementations
More on sqlglot: summary and FAQ, codebase overview, code health.
Related guide: Best dependency graph tools for monorepos