@@ -462,13 +462,14 @@ def update_schema(self, schema: MappingSchema) -> None:
462462 else :
463463 # Reset the entire mapping if at least one upstream dependency is missing from the mapping
464464 # to prevent partial mappings from being used.
465- logger .warning (
466- "Missing schema for model '%s' referenced in model '%s'. Run `sqlmesh create_external_models` "
467- "and / or make sure that the model '%s' can be rendered at parse time" ,
468- dep ,
469- self .name ,
470- dep ,
471- )
465+ if self .contains_star_projection :
466+ logger .warning (
467+ "Missing schema for model '%s' referenced in model '%s'. Run `sqlmesh create_external_models` "
468+ "and / or make sure that the model '%s' can be rendered at parse time" ,
469+ dep ,
470+ self .name ,
471+ dep ,
472+ )
472473 self .mapping_schema .clear ()
473474 return
474475
@@ -481,6 +482,12 @@ def depends_on(self) -> t.Set[str]:
481482 """
482483 return self .depends_on_ or set ()
483484
485+ @property
486+ def contains_star_projection (self ) -> t .Optional [bool ]:
487+ """Returns True if the model contains a star projection, False if it does not, and None if this
488+ cannot be determined at parse time."""
489+ return False
490+
484491 @property
485492 def columns_to_types (self ) -> t .Optional [t .Dict [str , exp .DataType ]]:
486493 """Returns the mapping of column names to types of this model."""
@@ -756,21 +763,22 @@ def depends_on(self) -> t.Set[str]:
756763 self ._depends_on -= {self .name }
757764 return self ._depends_on
758765
766+ @property
767+ def contains_star_projection (self ) -> t .Optional [bool ]:
768+ columns_to_types = self ._extract_columns_to_types ()
769+ if columns_to_types is None :
770+ return None
771+ return "*" in columns_to_types
772+
759773 @property
760774 def columns_to_types (self ) -> t .Optional [t .Dict [str , exp .DataType ]]:
761775 if self .columns_to_types_ is not None :
762776 return self .columns_to_types_
763777
764- if self ._columns_to_types is None :
765- query = self ._query_renderer .render ()
766- if query is None :
767- return None
768- self ._columns_to_types = d .extract_columns_to_types (query )
769-
770- if "*" in self ._columns_to_types :
778+ columns_to_types = self ._extract_columns_to_types ()
779+ if columns_to_types and "*" in columns_to_types :
771780 return None
772-
773- return self ._columns_to_types
781+ return columns_to_types
774782
775783 @property
776784 def column_descriptions (self ) -> t .Dict [str , str ]:
@@ -873,6 +881,13 @@ def _query_renderer(self) -> QueryRenderer:
873881 )
874882 return self .__query_renderer
875883
884+ def _extract_columns_to_types (self ) -> t .Optional [t .Dict [str , exp .DataType ]]:
885+ if self ._columns_to_types is None :
886+ query = self ._query_renderer .render ()
887+ if query is not None :
888+ self ._columns_to_types = d .extract_columns_to_types (query )
889+ return self ._columns_to_types
890+
876891 def __repr__ (self ) -> str :
877892 return f"Model<name: { self .name } , query: { str (self .query )[0 :30 ]} >"
878893
0 commit comments