From 2b6da0e5b5bbbf20486422990d6ab6ec4992a140 Mon Sep 17 00:00:00 2001 From: George Sittas Date: Wed, 7 Feb 2024 16:46:07 +0200 Subject: [PATCH] Chore!: bump sqlglot to v21.0.0 --- setup.py | 2 +- sqlmesh/core/dialect.py | 6 ++++-- sqlmesh/core/schema_diff.py | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 7dbf8da82a..d0304b22da 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ "requests", "rich[jupyter]", "ruamel.yaml", - "sqlglot[rs]~=20.11.0", + "sqlglot[rs]~=21.0.0", ], extras_require={ "bigquery": [ diff --git a/sqlmesh/core/dialect.py b/sqlmesh/core/dialect.py index 8d15a40962..177a2a4197 100644 --- a/sqlmesh/core/dialect.py +++ b/sqlmesh/core/dialect.py @@ -356,8 +356,10 @@ def _parse_types( # MacroVar, it'll render into @, so it won't break staged file path references. # # See: https://docs.snowflake.com/en/user-guide/querying-stage -def _parse_table_parts(self: Parser, schema: bool = False) -> exp.Table: - table = self.__parse_table_parts(schema=schema) # type: ignore +def _parse_table_parts( + self: Parser, schema: bool = False, is_db_reference: bool = False +) -> exp.Table: + table = self.__parse_table_parts(schema=schema, is_db_reference=is_db_reference) # type: ignore table_arg = table.this if isinstance(table_arg, exp.Var) and table_arg.name.startswith(SQLMESH_MACRO_PREFIX): diff --git a/sqlmesh/core/schema_diff.py b/sqlmesh/core/schema_diff.py index a356528719..23161c41ae 100644 --- a/sqlmesh/core/schema_diff.py +++ b/sqlmesh/core/schema_diff.py @@ -453,7 +453,9 @@ def _alter_operation( root_struct: exp.DataType, new_kwarg: exp.ColumnDef, ) -> t.List[TableAlterOperation]: - current_type = exp.DataType.build(current_type) + # We don't copy on purpose here because current_type may need to be mutated inside + # _get_operations (struct.expressions.pop and struct.expressions.insert) + current_type = exp.DataType.build(current_type, copy=False) if self.support_nested_operations: if new_type.this == current_type.this == exp.DataType.Type.STRUCT: return self._get_operations(