Edit on GitHub

Lazy re-exports from optimizer submodules.

Eager re-exports here trip a circular import under sqlglot[c]: importing sqlglot loads compiled expressions.builders, which eagerly wires up its links to compiled optimizer modules, which causes Python to run this file. The eager from sqlglot.optimizer.optimizer import ... then asks for sqlglot.Schema, but sqlglot/__init__.py hasn't bound it yet.

PEP 562 __getattr__ defers the import to first attribute access, by which point sqlglot is fully loaded. Tracked upstream in python/mypy#21299.