1717import typing as t
1818import zlib
1919
20- import pandas as pd
2120from dataclasses import dataclass
2221from enum import Enum
2322from jinja2 import Environment , nodes
2726import sqlmesh .core .dialect as d
2827from sqlmesh .core .console import get_console
2928from sqlmesh .utils import unique
30- from sqlmesh .utils .migration import index_text_type
31- from sqlmesh .utils .migration import blob_text_type
3229from sqlmesh .utils .pydantic import PydanticModel
3330
3431GATEWAY = "gateway"
@@ -41,12 +38,9 @@ def migrate(state_sync, **kwargs): # type: ignore
4138 engine_adapter = state_sync .engine_adapter
4239 schema = state_sync .schema
4340 snapshots_table = "_snapshots"
44- index_type = index_text_type (engine_adapter .dialect )
4541 if schema :
4642 snapshots_table = f"{ schema } .{ snapshots_table } "
4743
48- new_snapshots = []
49-
5044 for (
5145 name ,
5246 identifier ,
@@ -146,40 +140,6 @@ def migrate(state_sync, **kwargs): # type: ignore
146140 except Exception :
147141 pass
148142
149- new_snapshots .append (
150- {
151- "name" : name ,
152- "identifier" : identifier ,
153- "version" : version ,
154- "snapshot" : json .dumps (parsed_snapshot ),
155- "kind_name" : kind_name ,
156- "updated_ts" : updated_ts ,
157- "unpaused_ts" : unpaused_ts ,
158- "ttl_ms" : ttl_ms ,
159- "unrestorable" : unrestorable ,
160- }
161- )
162-
163- if new_snapshots :
164- engine_adapter .delete_from (snapshots_table , "TRUE" )
165- blob_type = blob_text_type (engine_adapter .dialect )
166-
167- engine_adapter .insert_append (
168- snapshots_table ,
169- pd .DataFrame (new_snapshots ),
170- columns_to_types = {
171- "name" : exp .DataType .build (index_type ),
172- "identifier" : exp .DataType .build (index_type ),
173- "version" : exp .DataType .build (index_type ),
174- "snapshot" : exp .DataType .build (blob_type ),
175- "kind_name" : exp .DataType .build (index_type ),
176- "updated_ts" : exp .DataType .build ("bigint" ),
177- "unpaused_ts" : exp .DataType .build ("bigint" ),
178- "ttl_ms" : exp .DataType .build ("bigint" ),
179- "unrestorable" : exp .DataType .build ("boolean" ),
180- },
181- )
182-
183143
184144def environment (** kwargs ):
185145 extensions = kwargs .pop ("extensions" , [])
0 commit comments