@@ -40,9 +40,9 @@ use mz_sql::ast::{
4040} ;
4141use mz_sql:: catalog:: {
4242 CatalogClusterReplica , CatalogError as SqlCatalogError , CatalogItem as SqlCatalogItem ,
43- CatalogItemType as SqlCatalogItemType , CatalogItemType , CatalogSchema , CatalogTypeDetails ,
44- DefaultPrivilegeAclItem , DefaultPrivilegeObject , IdReference , RoleAttributes , RoleMembership ,
45- RoleVars , SystemObjectType ,
43+ CatalogItemType as SqlCatalogItemType , CatalogItemType , CatalogSchema , CatalogType ,
44+ CatalogTypeDetails , DefaultPrivilegeAclItem , DefaultPrivilegeObject , IdReference ,
45+ RoleAttributes , RoleMembership , RoleVars , SystemObjectType ,
4646} ;
4747use mz_sql:: names:: {
4848 Aug , CommentObjectId , DatabaseId , DependencyIds , FullItemName , QualifiedItemName ,
@@ -1486,7 +1486,6 @@ pub struct Type {
14861486 pub global_id : GlobalId ,
14871487 #[ serde( skip) ]
14881488 pub details : CatalogTypeDetails < IdReference > ,
1489- pub desc : Option < RelationDesc > ,
14901489 /// Other catalog objects referenced by this type.
14911490 pub resolved_ids : ResolvedIds ,
14921491}
@@ -1706,6 +1705,14 @@ impl CatalogItem {
17061705 }
17071706 }
17081707
1708+ /// Returns the [`RelationDesc`] for items that yield rows, at the requested
1709+ /// version.
1710+ ///
1711+ /// Some item types honor `version` so callers can ask for the schema that
1712+ /// matches a specific [`GlobalId`] or historical definition. Other relation
1713+ /// types ignore `version` because they have a single shape. Non-relational
1714+ /// items ( for example functions, indexes, sinks, secrets, and connections)
1715+ /// return [`SqlCatalogError::InvalidDependency`].
17091716 pub fn desc (
17101717 & self ,
17111718 name : & FullItemName ,
@@ -1727,13 +1734,13 @@ impl CatalogItem {
17271734 CatalogItem :: MaterializedView ( mview) => {
17281735 Some ( Cow :: Owned ( mview. desc . at_version ( version) ) )
17291736 }
1730- CatalogItem :: Type ( typ) => typ. desc . as_ref ( ) . map ( Cow :: Borrowed ) ,
17311737 CatalogItem :: ContinualTask ( ct) => Some ( Cow :: Borrowed ( & ct. desc ) ) ,
17321738 CatalogItem :: Func ( _)
17331739 | CatalogItem :: Index ( _)
17341740 | CatalogItem :: Sink ( _)
17351741 | CatalogItem :: Secret ( _)
1736- | CatalogItem :: Connection ( _) => None ,
1742+ | CatalogItem :: Connection ( _)
1743+ | CatalogItem :: Type ( _) => None ,
17371744 }
17381745 }
17391746
@@ -2434,7 +2441,12 @@ impl CatalogEntry {
24342441
24352442 /// Reports if the item has columns.
24362443 pub fn has_columns ( & self ) -> bool {
2437- self . desc_opt_latest ( ) . is_some ( )
2444+ match self . item ( ) {
2445+ CatalogItem :: Type ( Type { details, .. } ) => {
2446+ matches ! ( details. typ, CatalogType :: Record { .. } )
2447+ }
2448+ _ => self . desc_opt_latest ( ) . is_some ( ) ,
2449+ }
24382450 }
24392451
24402452 /// Returns the [`mz_sql::func::Func`] associated with this `CatalogEntry`.
0 commit comments