Skip to content

Chore!!: Migrate sqlglot to v30#5736

Open
VaggelisD wants to merge 4 commits intomainfrom
vaggelisd/migrate_sqlglot
Open

Chore!!: Migrate sqlglot to v30#5736
VaggelisD wants to merge 4 commits intomainfrom
vaggelisd/migrate_sqlglot

Conversation

@VaggelisD
Copy link
Collaborator

Summary of Changes

File Change Why
pyproject.toml sqlglot[rs]~=28.10.1sqlglot~=30.0.1 Version bump; [rs] extra removed (replaced by sqlglotc)
60+ files across sqlmesh/, tests/, web/ exp.Expressionexp.Expr in all type hints, isinstance checks, and type casts. Class definitions remain as exp.Expression subclasses sqlglot v30 introduced exp.Expr as the new base class; Expression is now a subclass. Functions like exp.alias_(), exp.func(), parse_one() return Expr, causing mypy errors when assigned to Expression-typed variables. Custom expression classes must still inherit Expression since Expr doesn't support constructor arguments
sqlmesh/core/schema_diff.py, tests/core/integration/utils.py exp.DataType.Typeexp.DType in type annotations DataType.Type enum is no longer recognized as a valid type by mypy; exp.DType is the v30 alias
sqlmesh/core/dialect.py New import path for AthenaTrinoParser, updated self.expression() calls sqlglot API: Athena parser renamed, expression() now takes pre-constructed objects
sqlmesh/utils/jinja.py Import Expression from sqlglot.expressions instead of sqlglot sqlglot.expressions is now a package; top-level re-export changed
sqlmesh/core/model/kind.py Clear meta["sql"] in _time_data_type_validator DataType.build now preserves the parsed expression directly. Our _parse_types extension sets meta["sql"], which the pydantic encoder prioritizes over dialect-aware rendering
sqlmesh/core/model/meta.py Normalize column types through dialect roundtrip during deserialization BigQuery INT no longer auto-maps to BIGINT during DataType.build; roundtripping through dialect SQL restores canonical form for stable data hashes
sqlmesh/utils/metaprogramming.py Added _resolve_import_module() to walk module hierarchy for re-exports to_table.__module__ is now sqlglot.expressions.builders but it's re-exported from sqlglot.expressions; generated import statements must use the public module
sqlmesh/core/context_diff.py Added sqlglotc to IGNORED_PACKAGES New sqlglot conditionally imports sqlglotc (C extension); dependency detection was picking it up as a user requirement
tests/core/test_macros.py Simplified expected Snowflake ARRAY_GENERATE_RANGE arithmetic sqlglot now simplifies (DATEDIFF(...) + 1 - 1) + 1 to DATEDIFF(...) + 1
tests/core/test_config.py Relaxed regex for error message module path Column class now reports __module__ as sqlglot.expressions.core instead of sqlglot.expressions

@VaggelisD VaggelisD force-pushed the vaggelisd/migrate_sqlglot branch from 3fd7c5d to a90a4bd Compare March 17, 2026 11:52
Signed-off-by: vaggelisd <daniasevangelos@gmail.com>
@VaggelisD VaggelisD force-pushed the vaggelisd/migrate_sqlglot branch from a90a4bd to 8df9c29 Compare March 17, 2026 11:53
@VaggelisD
Copy link
Collaborator Author

The DuckDB test failure is preexisting

Signed-off-by: vaggelisd <daniasevangelos@gmail.com>
@VaggelisD VaggelisD force-pushed the vaggelisd/migrate_sqlglot branch from 45dbbbc to 264240e Compare March 17, 2026 13:45
Signed-off-by: vaggelisd <daniasevangelos@gmail.com>
@VaggelisD VaggelisD force-pushed the vaggelisd/migrate_sqlglot branch from 7e212c0 to 9b9261d Compare March 18, 2026 08:49
Signed-off-by: vaggelisd <daniasevangelos@gmail.com>
@VaggelisD VaggelisD force-pushed the vaggelisd/migrate_sqlglot branch from 5bca319 to c65b310 Compare March 18, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants