@@ -901,13 +901,7 @@ def get_snapshot(
901901 """
902902 if isinstance (node_or_snapshot , Snapshot ):
903903 return node_or_snapshot
904- if isinstance (node_or_snapshot , str ) and not self .standalone_audits .get (node_or_snapshot ):
905- node_or_snapshot = normalize_model_name (
906- node_or_snapshot ,
907- dialect = self .default_dialect ,
908- default_catalog = self .default_catalog ,
909- )
910- fqn = node_or_snapshot if isinstance (node_or_snapshot , str ) else node_or_snapshot .fqn
904+ fqn = self ._node_or_snapshot_to_fqn (node_or_snapshot )
911905 snapshot = self .snapshots .get (fqn )
912906
913907 if raise_if_missing and not snapshot :
@@ -1052,14 +1046,30 @@ def evaluate(
10521046 execution_time: The date/time time reference to use for execution time.
10531047 limit: A limit applied to the model.
10541048 """
1055- snapshot = self .get_snapshot (model_or_snapshot , raise_if_missing = True )
1049+ snapshots = self .snapshots
1050+ fqn = self ._node_or_snapshot_to_fqn (model_or_snapshot )
1051+ if fqn not in snapshots :
1052+ raise SQLMeshError (f"Cannot find snapshot for '{ fqn } '" )
1053+ snapshot = snapshots [fqn ]
1054+
1055+ # Expand all uncategorized parents since physical tables don't exist for them yet
1056+ expand = [
1057+ parent
1058+ for parent in self .dag .upstream (snapshot .model .fqn )
1059+ if (parent_snapshot := snapshots .get (parent ))
1060+ and parent_snapshot .is_model
1061+ and parent_snapshot .model .is_sql
1062+ and not parent_snapshot .categorized
1063+ ]
1064+
10561065 df = self .snapshot_evaluator .evaluate_and_fetch (
10571066 snapshot ,
10581067 start = start ,
10591068 end = end ,
10601069 execution_time = execution_time ,
10611070 snapshots = self .snapshots ,
10621071 limit = limit or c .DEFAULT_MAX_LIMIT ,
1072+ expand = expand ,
10631073 )
10641074
10651075 if df is None :
@@ -2448,6 +2458,19 @@ def _nodes_to_snapshots(self, nodes: t.Dict[str, Node]) -> t.Dict[str, Snapshot]
24482458 snapshots [snapshot .name ] = snapshot
24492459 return snapshots
24502460
2461+ def _node_or_snapshot_to_fqn (self , node_or_snapshot : NodeOrSnapshot ) -> str :
2462+ if isinstance (node_or_snapshot , Snapshot ):
2463+ return node_or_snapshot .name
2464+ if isinstance (node_or_snapshot , str ) and not self .standalone_audits .get (node_or_snapshot ):
2465+ return normalize_model_name (
2466+ node_or_snapshot ,
2467+ dialect = self .default_dialect ,
2468+ default_catalog = self .default_catalog ,
2469+ )
2470+ if not isinstance (node_or_snapshot , str ):
2471+ return node_or_snapshot .fqn
2472+ return node_or_snapshot
2473+
24512474 @property
24522475 def _plan_preview_enabled (self ) -> bool :
24532476 if self .config .plan .enable_preview is not None :
0 commit comments