MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / from_id

Method from_id

src/sql/src/catalog.rs:1722–1751  ·  view source on GitHub ↗

Generate a new [`ErrorMessageObjectDescription`] from an [`ObjectId`].

(
        object_id: &ObjectId,
        catalog: &dyn SessionCatalog,
    )

Source from the content-addressed store, hash-verified

1720impl ErrorMessageObjectDescription {
1721 /// Generate a new [`ErrorMessageObjectDescription`] from an [`ObjectId`].
1722 pub fn from_id(
1723 object_id: &ObjectId,
1724 catalog: &dyn SessionCatalog,
1725 ) -> ErrorMessageObjectDescription {
1726 let object_name = match object_id {
1727 ObjectId::Cluster(cluster_id) => catalog.get_cluster(*cluster_id).name().to_string(),
1728 ObjectId::ClusterReplica((cluster_id, replica_id)) => catalog
1729 .get_cluster_replica(*cluster_id, *replica_id)
1730 .name()
1731 .to_string(),
1732 ObjectId::Database(database_id) => catalog.get_database(database_id).name().to_string(),
1733 ObjectId::Schema((database_spec, schema_spec)) => {
1734 let name = catalog.get_schema(database_spec, schema_spec).name();
1735 catalog.resolve_full_schema_name(name).to_string()
1736 }
1737 ObjectId::Role(role_id) => catalog.get_role(role_id).name().to_string(),
1738 ObjectId::Item(id) => {
1739 let name = catalog.get_item(id).name();
1740 catalog.resolve_full_name(name).to_string()
1741 }
1742 ObjectId::NetworkPolicy(network_policy_id) => catalog
1743 .get_network_policy(network_policy_id)
1744 .name()
1745 .to_string(),
1746 };
1747 ErrorMessageObjectDescription::Object {
1748 object_type: catalog.get_object_type(object_id),
1749 object_name: Some(object_name),
1750 }
1751 }
1752
1753 /// Generate a new [`ErrorMessageObjectDescription`] from a [`SystemObjectId`].
1754 pub fn from_sys_id(

Callers

nothing calls this directly

Calls 12

to_stringMethod · 0.45
nameMethod · 0.45
get_clusterMethod · 0.45
get_cluster_replicaMethod · 0.45
get_databaseMethod · 0.45
get_schemaMethod · 0.45
get_roleMethod · 0.45
get_itemMethod · 0.45
resolve_full_nameMethod · 0.45
get_network_policyMethod · 0.45
get_object_typeMethod · 0.45

Tested by

no test coverage detected