@@ -34,10 +34,10 @@ def migrate(state_sync, **kwargs): # type: ignore
3434 warning = (
3535 "SQLMesh detected that it may not be able to fully migrate the state database. This should not impact "
3636 "the migration process, but may result in unexpected changes being reported by the next `sqlmesh plan` "
37- "command. Please run the `sqlmesh diff` (https://sqlmesh.readthedocs.io/en/stable/reference/cli/?h=cli#diff) "
38- "command after the migration has completed, before making any new changes. If any unexpected changes are reported, "
39- "consider running a forward-only plan (https:// sqlmesh.readthedocs.io/en/stable/concepts/plans/# forward-only-plans) "
40- "to avoid unnecessary backfills .\n "
37+ "command. Please run `sqlmesh diff prod` after the migration has completed, before making any new "
38+ "changes. If any unexpected changes are reported, consider running a forward-only plan to apply these "
39+ "changes and avoid unnecessary backfills: sqlmesh plan prod -- forward-only. "
40+ "See https://sqlmesh.readthedocs.io/en/stable/concepts/plans/#forward-only-plans for more details .\n "
4141 )
4242
4343 for (snapshot ,) in engine_adapter .fetchall (
@@ -50,7 +50,6 @@ def migrate(state_sync, **kwargs): # type: ignore
5050 if node .get ("source_type" ) == "audit" :
5151 continue
5252
53- name = node ["name" ]
5453 python_env = node .get ("python_env" ) or {}
5554
5655 has_metadata = False
@@ -69,29 +68,33 @@ def migrate(state_sync, **kwargs): # type: ignore
6968 dialect = node .get ("dialect" )
7069 metadata_hash_statements = []
7170
72- if on_virtual_update := node .get ("on_virtual_update" ):
73- metadata_hash_statements .extend (parse_expression (on_virtual_update , dialect ))
74-
75- for _ , audit_args in func_call_validator (node .get ("audits" ) or []):
76- metadata_hash_statements .extend (audit_args .values ())
77-
78- for signal_name , signal_args in func_call_validator (
79- node .get ("signals" ) or [], is_signal = True
80- ):
81- metadata_hash_statements .extend (signal_args .values ())
82-
83- if audit_definitions := node .get ("audit_definitions" ):
84- audit_queries = [
85- parse_expression (audit ["query" ], audit ["dialect" ])
86- for audit in audit_definitions .values ()
87- ]
88- metadata_hash_statements .extend (audit_queries )
89-
90- for macro_name in extract_used_macros (metadata_hash_statements ):
91- serialized_macro = python_env .get (macro_name )
92- if isinstance (serialized_macro , dict ) and not serialized_macro .get ("is_metadata" ):
93- get_console ().log_warning (warning )
94- return
71+ # We use try-except here as a conservative measure to avoid any unexpected exceptions
72+ try :
73+ if on_virtual_update := node .get ("on_virtual_update" ):
74+ metadata_hash_statements .extend (parse_expression (on_virtual_update , dialect ))
75+
76+ for _ , audit_args in func_call_validator (node .get ("audits" ) or []):
77+ metadata_hash_statements .extend (audit_args .values ())
78+
79+ for signal_name , signal_args in func_call_validator (
80+ node .get ("signals" ) or [], is_signal = True
81+ ):
82+ metadata_hash_statements .extend (signal_args .values ())
83+
84+ if audit_definitions := node .get ("audit_definitions" ):
85+ audit_queries = [
86+ parse_expression (audit ["query" ], audit ["dialect" ])
87+ for audit in audit_definitions .values ()
88+ ]
89+ metadata_hash_statements .extend (audit_queries )
90+
91+ for macro_name in extract_used_macros (metadata_hash_statements ):
92+ serialized_macro = python_env .get (macro_name )
93+ if isinstance (serialized_macro , dict ) and not serialized_macro .get ("is_metadata" ):
94+ get_console ().log_warning (warning )
95+ return
96+ except Exception :
97+ pass
9598
9699
97100def extract_used_macros (expressions ):
0 commit comments