From 2f6c81fe7afc4067557b74788e7f2c87e4fe0344 Mon Sep 17 00:00:00 2001 From: mtabebe Date: Fri, 17 Apr 2026 16:09:47 -0400 Subject: [PATCH 01/14] [ontology] add built-in ontology view infrastructure Add the structural foundation for built-in ontology views that describe the Materialize system catalog. This includes: - `Ontology` and `OntologyLink` structs on builtin definitions - `semantic_types` field on `RelationDesc` with `with_semantic_type()` builder - View generation code in `ontology.rs` that produces 4 views: `mz_ontology_entity_types`, `mz_ontology_semantic_types`, `mz_ontology_properties`, `mz_ontology_link_types` - OID constants for the new views - `ontology: None` on all existing builtins (no annotations yet) The views are generated at startup by enumerating builtins that have `ontology: Some(...)` annotations. This commit only adds the infrastructure; annotations are added in the next commit. --- .../reference/system-catalog/mz_internal.md | 4 + .../open/builtin_schema_migration_tests.rs | 2 + src/catalog/src/builtin.rs | 306 ++++++++++++++++- src/catalog/src/builtin/builtin.rs | 1 + src/catalog/src/builtin/notice.rs | 3 + src/catalog/src/builtin/ontology.rs | 323 ++++++++++++++++++ src/pgrepr-consts/src/oid.rs | 4 + src/repr/src/relation.rs | 50 ++- .../autogenerated/mz_internal.slt | 4 + 9 files changed, 694 insertions(+), 3 deletions(-) create mode 100644 src/catalog/src/builtin/ontology.rs diff --git a/doc/user/content/reference/system-catalog/mz_internal.md b/doc/user/content/reference/system-catalog/mz_internal.md index 1e3c5f8679f34..c9124e86abbab 100644 --- a/doc/user/content/reference/system-catalog/mz_internal.md +++ b/doc/user/content/reference/system-catalog/mz_internal.md @@ -658,6 +658,10 @@ system. The view can be accessed by Materialize _superusers_. | `object_id` | [`text`] | The ID of the materialized view or index. Corresponds to [`mz_objects.id`](../mz_catalog/#mz_objects). For global notices, this column is `NULL`. | | `created_at` | [`timestamp with time zone`] | The time at which the notice was created. Note that some notices are re-created on `environmentd` restart. | + + + + ## `mz_notices_redacted` diff --git a/src/adapter/src/catalog/open/builtin_schema_migration_tests.rs b/src/adapter/src/catalog/open/builtin_schema_migration_tests.rs index b7d8e56f7de29..eeacfea1c459f 100644 --- a/src/adapter/src/catalog/open/builtin_schema_migration_tests.rs +++ b/src/adapter/src/catalog/open/builtin_schema_migration_tests.rs @@ -285,6 +285,7 @@ fn make_builtin_table(name: String) -> (SystemObjectDescription, &'static Builti column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: Vec::new(), + ontology: None, }; let builtin = leak(Builtin::Table(leak(builtin))); @@ -309,6 +310,7 @@ fn make_builtin_source(name: String) -> (SystemObjectDescription, &'static Built column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: Vec::new(), + ontology: None, }; let builtin = leak(Builtin::Source(leak(builtin))); diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index e02b14e3e1d9d..469dbe1a28db7 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -24,6 +24,7 @@ mod builtin; pub mod notice; +mod ontology; use std::collections::BTreeMap; use std::hash::Hash; @@ -161,6 +162,32 @@ pub struct BuiltinLog { pub access: Vec, } +/// Ontology metadata for a builtin catalog object. +/// +/// When present on a builtin, it marks it as an ontology entity with an explicit +/// `entity_name` and `description`. Column-level semantic types are annotated +/// separately via `RelationDescBuilder::with_semantic_type()`. +#[derive(Clone, Hash, Debug, PartialEq, Eq)] +pub struct Ontology { + /// The ontology entity name (e.g., "database", "table", "mv"). + pub entity_name: &'static str, + /// One-line description of this entity. + pub description: &'static str, + /// FK relationships originating from this entity. + pub links: &'static [OntologyLink], +} + +/// A foreign key / relationship link in the ontology. +#[derive(Clone, Hash, Debug, PartialEq, Eq)] +pub struct OntologyLink { + /// Relationship name (e.g., "owned_by", "in_schema"). + pub name: &'static str, + /// Target entity name (e.g., "role", "schema"). + pub target: &'static str, + /// JSON for the `properties` JSONB column (kind, source_column, target_column, etc.). + pub properties_json: &'static str, +} + #[derive(Clone, Hash, Debug, PartialEq, Eq)] pub struct BuiltinTable { pub name: &'static str, @@ -173,6 +200,8 @@ pub struct BuiltinTable { pub is_retained_metrics_object: bool, /// ACL items to apply to the object pub access: Vec, + /// Ontology metadata. None means this builtin is not an ontology entity. + pub ontology: Option, } #[derive(Clone, Debug, PartialEq, Eq)] @@ -188,6 +217,8 @@ pub struct BuiltinSource { pub is_retained_metrics_object: bool, /// ACL items to apply to the object pub access: Vec, + /// Ontology metadata. None means this builtin is not an ontology entity. + pub ontology: Option, } #[derive(Hash, Debug)] @@ -200,6 +231,8 @@ pub struct BuiltinView { pub sql: &'static str, /// ACL items to apply to the object pub access: Vec, + /// Ontology metadata. None means this builtin is not an ontology entity. + pub ontology: Option, } impl BuiltinView { @@ -224,6 +257,8 @@ pub struct BuiltinMaterializedView { pub is_retained_metrics_object: bool, /// ACL items to apply to the object pub access: Vec, + /// Ontology metadata. None means this builtin is not an ontology entity. + pub ontology: Option, } impl BuiltinMaterializedView { @@ -1773,6 +1808,7 @@ pub static MZ_CATALOG_RAW: LazyLock = LazyLock::new(|| BuiltinSou is_retained_metrics_object: false, // The raw catalog contains unredacted SQL statements, so we limit access to the system user. access: vec![], + ontology: None, }); pub static MZ_CATALOG_RAW_DESCRIPTION: LazyLock = @@ -2068,6 +2104,7 @@ pub static MZ_ICEBERG_SINKS: LazyLock = LazyLock::new(|| BuiltinTa ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_KAFKA_SINKS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2088,6 +2125,7 @@ pub static MZ_KAFKA_SINKS: LazyLock = LazyLock::new(|| BuiltinTabl ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_KAFKA_CONNECTIONS: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_kafka_connections", @@ -2114,6 +2152,7 @@ pub static MZ_KAFKA_CONNECTIONS: LazyLock = LazyLock::new(|| Built ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_KAFKA_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_kafka_sources", @@ -2140,6 +2179,7 @@ pub static MZ_KAFKA_SOURCES: LazyLock = LazyLock::new(|| BuiltinTa ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_postgres_sources", @@ -2166,6 +2206,7 @@ pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| Builti ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_postgres_source_tables", @@ -2192,6 +2233,7 @@ pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_mysql_source_tables", @@ -2218,6 +2260,7 @@ pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_sql_server_source_tables", @@ -2244,6 +2287,7 @@ pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(| ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_kafka_source_tables", @@ -2277,6 +2321,7 @@ pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_object_dependencies", @@ -2301,6 +2346,7 @@ pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| Bui ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| BuiltinSource { name: "mz_compute_dependencies", @@ -2323,6 +2369,7 @@ pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| B ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATABASES: LazyLock = @@ -2371,6 +2418,7 @@ FROM mz_internal.mz_catalog_raw WHERE data->>'kind' = 'Database'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SCHEMAS: LazyLock = @@ -2427,6 +2475,7 @@ FROM mz_internal.mz_catalog_raw WHERE data->>'kind' = 'Schema'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2464,6 +2513,7 @@ pub static MZ_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_INDEXES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_indexes", @@ -2505,6 +2555,7 @@ pub static MZ_INDEXES: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_INDEX_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_index_columns", @@ -2541,6 +2592,7 @@ pub static MZ_INDEX_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTa ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_tables", @@ -2587,6 +2639,7 @@ pub static MZ_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_CONNECTIONS: LazyLock = LazyLock::new(|| { @@ -2665,6 +2718,7 @@ WHERE mz_internal.parse_catalog_create_sql(data->'value'->'definition'->'V1'->>'create_sql')->>'type' = 'connection'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -2690,6 +2744,7 @@ pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock = LazyLock::new(|| ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_sources", @@ -2763,6 +2818,7 @@ pub static MZ_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SINKS: LazyLock = LazyLock::new(|| { BuiltinTable { @@ -2836,6 +2892,7 @@ pub static MZ_SINKS: LazyLock = LazyLock::new(|| { ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], + ontology: None, } }); pub static MZ_VIEWS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2880,6 +2937,7 @@ pub static MZ_VIEWS: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_MATERIALIZED_VIEWS: LazyLock = LazyLock::new(|| { @@ -3005,6 +3063,7 @@ UNION ALL SELECT * FROM builtin_mvs").into_boxed_str()), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -3053,6 +3112,7 @@ pub static MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES: LazyLock = Laz ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, } }); pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3097,6 +3157,7 @@ pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_NETWORK_POLICIES: LazyLock = LazyLock::new(|| { @@ -3148,6 +3209,7 @@ FROM mz_internal.mz_catalog_raw WHERE data->>'kind' = 'NetworkPolicy'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -3203,6 +3265,7 @@ FROM WHERE data->>'kind' = 'NetworkPolicy'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -3220,6 +3283,7 @@ pub static MZ_TYPE_PG_METADATA: LazyLock = LazyLock::new(|| Builti column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_array_types", @@ -3235,6 +3299,7 @@ pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| BuiltinTabl ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_base_types", @@ -3246,6 +3311,7 @@ pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinTable column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_list_types", @@ -3273,6 +3339,7 @@ pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_map_types", @@ -3314,6 +3381,7 @@ pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_ROLES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_roles", @@ -3342,6 +3410,7 @@ pub static MZ_ROLES: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_ROLE_MEMBERS: LazyLock = LazyLock::new(|| { @@ -3385,6 +3454,7 @@ FROM WHERE data->>'kind' = 'Role'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -3413,6 +3483,7 @@ pub static MZ_ROLE_PARAMETERS: LazyLock = LazyLock::new(|| Builtin ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_ROLE_AUTH: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_role_auth", @@ -3444,6 +3515,7 @@ pub static MZ_ROLE_AUTH: LazyLock = LazyLock::new(|| BuiltinTable ]), is_retained_metrics_object: false, access: vec![rbac::owner_privilege(ObjectType::Table, MZ_SYSTEM_ROLE_ID)], + ontology: None, }); pub static MZ_PSEUDO_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_pseudo_types", @@ -3455,6 +3527,7 @@ pub static MZ_PSEUDO_TYPES: LazyLock = LazyLock::new(|| BuiltinTab column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { BuiltinTable { @@ -3509,6 +3582,7 @@ pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, } }); pub static MZ_OPERATORS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3527,6 +3601,7 @@ pub static MZ_OPERATORS: LazyLock = LazyLock::new(|| BuiltinTable column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_aggregates", @@ -3540,6 +3615,7 @@ pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinTable column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_CLUSTERS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3615,6 +3691,7 @@ pub static MZ_CLUSTERS: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_CLUSTER_WORKLOAD_CLASSES: LazyLock = @@ -3642,6 +3719,7 @@ FROM mz_internal.mz_catalog_raw WHERE data->>'kind' = 'Cluster'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub const MZ_CLUSTER_WORKLOAD_CLASSES_IND: BuiltinIndex = BuiltinIndex { @@ -3678,6 +3756,7 @@ pub static MZ_CLUSTER_SCHEDULES: LazyLock = LazyLock::new(|| Built ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SECRETS: LazyLock = LazyLock::new(|| { @@ -3733,6 +3812,7 @@ WHERE mz_internal.parse_catalog_create_sql(data->'value'->'definition'->'V1'->>'create_sql')->>'type' = 'secret'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -3774,6 +3854,7 @@ pub static MZ_CLUSTER_REPLICAS: LazyLock = LazyLock::new(|| Builti ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_INTERNAL_CLUSTER_REPLICAS: LazyLock = @@ -3801,6 +3882,7 @@ WHERE (data->'value'->'config'->'location'->'Managed'->>'internal')::bool = true", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_PENDING_CLUSTER_REPLICAS: LazyLock = @@ -3828,6 +3910,7 @@ WHERE (data->'value'->'config'->'location'->'Managed'->>'pending')::bool = true", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY: LazyLock = LazyLock::new(|| { @@ -3855,6 +3938,7 @@ pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY: LazyLock = LazyLock ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -3907,6 +3991,7 @@ FROM mz_internal.mz_cluster_replica_status_history JOIN mz_cluster_replicas r ON r.id = replica_id ORDER BY replica_id, process_id, occurred_at DESC", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3948,6 +4033,7 @@ pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock = LazyLock::new(|| B ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_AUDIT_EVENTS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3994,6 +4080,7 @@ pub static MZ_AUDIT_EVENTS: LazyLock = LazyLock::new(|| BuiltinTab ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SOURCE_STATUS_HISTORY: LazyLock = LazyLock::new(|| BuiltinSource { @@ -4030,6 +4117,7 @@ pub static MZ_SOURCE_STATUS_HISTORY: LazyLock = LazyLock::new(|| ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY: LazyLock = LazyLock::new( @@ -4054,6 +4142,7 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY: LazyLock ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }, ); @@ -4113,6 +4202,7 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUSES: LazyLock = LazyL JOIN mz_catalog.mz_connections AS conns ON conns.id = latest_events.connection_id", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -4126,6 +4216,7 @@ pub static MZ_STATEMENT_EXECUTION_HISTORY: LazyLock = column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![MONITOR_SELECT], + ontology: None, }); pub static MZ_STATEMENT_EXECUTION_HISTORY_REDACTED: LazyLock = LazyLock::new(|| { @@ -4163,6 +4254,7 @@ transient_index_id, mz_version, began_at, finished_at, finished_status, result_size, rows_returned, execution_strategy FROM mz_internal.mz_statement_execution_history", access: vec![SUPPORT_SELECT, ANALYTICS_SELECT, MONITOR_REDACTED_SELECT, MONITOR_SELECT], + ontology: None, } }); @@ -4181,6 +4273,7 @@ pub static MZ_PREPARED_STATEMENT_HISTORY: LazyLock = MONITOR_REDACTED_SELECT, MONITOR_SELECT, ], + ontology: None, }); pub static MZ_SQL_TEXT: LazyLock = LazyLock::new(|| BuiltinSource { @@ -4192,6 +4285,7 @@ pub static MZ_SQL_TEXT: LazyLock = LazyLock::new(|| BuiltinSource column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![MONITOR_SELECT], + ontology: None, }); pub static MZ_SQL_TEXT_REDACTED: LazyLock = LazyLock::new(|| BuiltinView { @@ -4210,6 +4304,7 @@ pub static MZ_SQL_TEXT_REDACTED: LazyLock = LazyLock::new(|| Builti SUPPORT_SELECT, ANALYTICS_SELECT, ], + ontology: None, }); pub static MZ_RECENT_SQL_TEXT: LazyLock = LazyLock::new(|| { @@ -4230,6 +4325,7 @@ pub static MZ_RECENT_SQL_TEXT: LazyLock = LazyLock::new(|| { column_comments: BTreeMap::new(), sql: "SELECT DISTINCT sql_hash, sql, redacted_sql FROM mz_internal.mz_sql_text WHERE prepared_day + INTERVAL '4 days' >= mz_now()", access: vec![MONITOR_SELECT], + ontology: None, } }); @@ -4249,6 +4345,7 @@ pub static MZ_RECENT_SQL_TEXT_REDACTED: LazyLock = LazyLock::new(|| SUPPORT_SELECT, ANALYTICS_SELECT, ], + ontology: None, }); pub static MZ_RECENT_SQL_TEXT_IND: LazyLock = LazyLock::new(|| BuiltinIndex { @@ -4285,6 +4382,7 @@ pub static MZ_SESSION_HISTORY: LazyLock = LazyLock::new(|| Builti ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_ACTIVITY_LOG_THINNED: LazyLock = LazyLock::new(|| { @@ -4338,6 +4436,7 @@ FROM mz_internal.mz_statement_execution_history mseh, WHERE mseh.prepared_statement_id = mpsh.id AND mpsh.session_id = msh.session_id", access: vec![MONITOR_SELECT], + ontology: None, } }); @@ -4385,6 +4484,7 @@ pub static MZ_RECENT_ACTIVITY_LOG_THINNED: LazyLock = LazyLock::new "SELECT * FROM mz_internal.mz_activity_log_thinned WHERE prepared_at + INTERVAL '1 day' > mz_now() AND began_at + INTERVAL '1 day' > mz_now() AND connected_at + INTERVAL '2 days' > mz_now()", access: vec![MONITOR_SELECT], + ontology: None, } }); @@ -4584,6 +4684,7 @@ FROM mz_internal.mz_recent_activity_log_thinned mralt, mz_internal.mz_recent_sql_text mrst WHERE mralt.sql_hash = mrst.sql_hash", access: vec![MONITOR_SELECT], + ontology: None, }); pub static MZ_RECENT_ACTIVITY_LOG_REDACTED: LazyLock = LazyLock::new(|| { @@ -4635,6 +4736,7 @@ FROM mz_internal.mz_recent_activity_log_thinned mralt, mz_internal.mz_recent_sql_text mrst WHERE mralt.sql_hash = mrst.sql_hash", access: vec![MONITOR_SELECT, MONITOR_REDACTED_SELECT, SUPPORT_SELECT, ANALYTICS_SELECT], + ontology: None, } }); @@ -4673,6 +4775,7 @@ pub static MZ_STATEMENT_LIFECYCLE_HISTORY: LazyLock = LazyLock::n MONITOR_REDACTED_SELECT, MONITOR_SELECT, ], + ontology: None, } }); @@ -4855,6 +4958,7 @@ SELECT FROM combined WHERE id NOT LIKE 's%';", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SINK_STATUS_HISTORY: LazyLock = LazyLock::new(|| BuiltinSource { @@ -4891,6 +4995,7 @@ pub static MZ_SINK_STATUS_HISTORY: LazyLock = LazyLock::new(|| Bu ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SINK_STATUSES: LazyLock = LazyLock::new(|| BuiltinView { @@ -4996,6 +5101,7 @@ WHERE -- This is a convenient way to filter out system sinks, like the status_history table itself. mz_sinks.id NOT LIKE 's%'", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_STORAGE_USAGE_BY_SHARD_DESCRIPTION: LazyLock = @@ -5021,6 +5127,7 @@ pub static MZ_STORAGE_USAGE_BY_SHARD: LazyLock = LazyLock::new(|| column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_EGRESS_IPS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5042,6 +5149,7 @@ pub static MZ_EGRESS_IPS: LazyLock = LazyLock::new(|| BuiltinTable ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock = @@ -5062,6 +5170,7 @@ pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock = ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_AWS_CONNECTIONS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5142,6 +5251,7 @@ pub static MZ_AWS_CONNECTIONS: LazyLock = LazyLock::new(|| Builtin ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_CLUSTER_REPLICA_METRICS_HISTORY: LazyLock = @@ -5172,6 +5282,7 @@ pub static MZ_CLUSTER_REPLICA_METRICS_HISTORY: LazyLock = ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_CLUSTER_REPLICA_METRICS: LazyLock = LazyLock::new(|| BuiltinView { @@ -5217,6 +5328,7 @@ FROM mz_internal.mz_cluster_replica_metrics_history JOIN mz_cluster_replicas r ON r.id = replica_id ORDER BY replica_id, process_id, occurred_at DESC", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_CLUSTER_REPLICA_FRONTIERS: LazyLock = @@ -5243,6 +5355,7 @@ pub static MZ_CLUSTER_REPLICA_FRONTIERS: LazyLock = ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_CLUSTER_REPLICA_FRONTIERS_IND: LazyLock = @@ -5280,6 +5393,7 @@ pub static MZ_FRONTIERS: LazyLock = LazyLock::new(|| BuiltinSourc ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); /// DEPRECATED and scheduled for removal! Use `mz_frontiers` instead. @@ -5297,6 +5411,7 @@ SELECT object_id, write_frontier AS time FROM mz_internal.mz_frontiers WHERE write_frontier IS NOT NULL", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_WALLCLOCK_LAG_HISTORY: LazyLock = LazyLock::new(|| BuiltinSource { @@ -5325,6 +5440,7 @@ pub static MZ_WALLCLOCK_LAG_HISTORY: LazyLock = LazyLock::new(|| ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTORY: LazyLock = LazyLock::new(|| BuiltinView { @@ -5370,6 +5486,7 @@ FROM times_binned GROUP BY object_id, occurred_at OPTIONS (AGGREGATE INPUT GROUP SIZE = 1)", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY: LazyLock = LazyLock::new(|| { @@ -5405,6 +5522,7 @@ SELECT object_id, lag, occurred_at FROM mz_internal.mz_wallclock_global_lag_history WHERE occurred_at + '1 day' > mz_now()", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -5433,6 +5551,7 @@ FROM mz_internal.mz_wallclock_global_lag_recent_history WHERE occurred_at + '5 minutes' > mz_now() ORDER BY object_id, occurred_at DESC", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW: LazyLock = @@ -5445,6 +5564,7 @@ pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW: LazyLock = data_source: IntrospectionType::WallclockLagHistogram.into(), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM: LazyLock = @@ -5473,6 +5593,7 @@ SELECT *, count(*) AS count FROM mz_internal.mz_wallclock_global_lag_histogram_raw GROUP BY period_start, period_end, object_id, lag_seconds, labels", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_MATERIALIZED_VIEW_REFRESHES: LazyLock = LazyLock::new(|| { @@ -5510,6 +5631,7 @@ pub static MZ_MATERIALIZED_VIEW_REFRESHES: LazyLock = LazyLock::n ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -5555,6 +5677,7 @@ pub static MZ_SUBSCRIPTIONS: LazyLock = LazyLock::new(|| BuiltinTa ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SESSIONS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5592,6 +5715,7 @@ pub static MZ_SESSIONS: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DEFAULT_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5631,6 +5755,7 @@ pub static MZ_DEFAULT_PRIVILEGES: LazyLock = LazyLock::new(|| Buil ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SYSTEM_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5646,6 +5771,7 @@ pub static MZ_SYSTEM_PRIVILEGES: LazyLock = LazyLock::new(|| Built )]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_COMMENTS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5675,6 +5801,7 @@ pub static MZ_COMMENTS: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SOURCE_REFERENCES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5697,6 +5824,7 @@ pub static MZ_SOURCE_REFERENCES: LazyLock = LazyLock::new(|| Built column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_WEBHOOKS_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5721,6 +5849,7 @@ pub static MZ_WEBHOOKS_SOURCES: LazyLock = LazyLock::new(|| Builti ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_HISTORY_RETENTION_STRATEGIES: LazyLock = LazyLock::new(|| { @@ -5746,6 +5875,7 @@ pub static MZ_HISTORY_RETENTION_STRATEGIES: LazyLock = LazyLock::n ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -5787,6 +5917,7 @@ pub static MZ_LICENSE_KEYS: LazyLock = LazyLock::new(|| BuiltinTab ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_REPLACEMENTS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5809,6 +5940,7 @@ pub static MZ_REPLACEMENTS: LazyLock = LazyLock::new(|| BuiltinTab ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); // These will be replaced with per-replica tables once source/sink multiplexing on @@ -5822,6 +5954,7 @@ pub static MZ_SOURCE_STATISTICS_RAW: LazyLock = LazyLock::new(|| column_comments: BTreeMap::new(), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SINK_STATISTICS_RAW: LazyLock = LazyLock::new(|| BuiltinSource { name: "mz_sink_statistics_raw", @@ -5832,6 +5965,7 @@ pub static MZ_SINK_STATISTICS_RAW: LazyLock = LazyLock::new(|| Bu column_comments: BTreeMap::new(), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_STORAGE_SHARDS: LazyLock = LazyLock::new(|| BuiltinSource { @@ -5846,6 +5980,7 @@ pub static MZ_STORAGE_SHARDS: LazyLock = LazyLock::new(|| Builtin column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_STORAGE_USAGE: LazyLock = LazyLock::new(|| BuiltinView { @@ -5885,6 +6020,7 @@ FROM JOIN mz_internal.mz_storage_usage_by_shard USING (shard_id) GROUP BY object_id, collection_timestamp", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_RECENT_STORAGE_USAGE: LazyLock = LazyLock::new(|| { @@ -5929,6 +6065,7 @@ FROM AND most_recent_collection_timestamp_by_shard.collection_timestamp = recent_storage_usage_by_shard.collection_timestamp GROUP BY object_id", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -5971,6 +6108,7 @@ UNION ALL SELECT id, oid, schema_id, name, 'source', owner_id, cluster_id, privi UNION ALL SELECT id, oid, schema_id, name, 'view', owner_id, NULL::text, privileges FROM mz_catalog.mz_views UNION ALL SELECT id, oid, schema_id, name, 'materialized-view', owner_id, cluster_id, privileges FROM mz_catalog.mz_materialized_views", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -5999,6 +6137,7 @@ pub static MZ_OBJECTS_ID_NAMESPACE_TYPES: LazyLock = LazyLock::new( ) AS _ (object_type)"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_OBJECT_OID_ALIAS: LazyLock = LazyLock::new(|| BuiltinView { @@ -6027,6 +6166,7 @@ pub static MZ_OBJECT_OID_ALIAS: LazyLock = LazyLock::new(|| Builtin ) AS _ (object_type, oid_alias);", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_OBJECTS: LazyLock = LazyLock::new(|| { @@ -6071,6 +6211,7 @@ UNION ALL UNION ALL SELECT id, oid, schema_id, name, 'secret', owner_id, NULL::text, privileges FROM mz_catalog.mz_secrets", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -6130,6 +6271,7 @@ pub static MZ_OBJECT_FULLY_QUALIFIED_NAMES: LazyLock = LazyLock::ne -- LEFT JOIN accounts for objects in the ambient database. LEFT JOIN mz_catalog.mz_databases db ON db.id = sc.database_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_OBJECT_GLOBAL_IDS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -6149,6 +6291,7 @@ pub static MZ_OBJECT_GLOBAL_IDS: LazyLock = LazyLock::new(|| Built ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); // TODO (SangJunBak): Remove once mz_object_history is released and used in the Console https://github.com/MaterializeInc/console/issues/3342 @@ -6195,6 +6338,7 @@ pub static MZ_OBJECT_LIFETIMES: LazyLock = LazyLock::new(|| Builtin FROM mz_catalog.mz_audit_events a WHERE a.event_type = 'create' OR a.event_type = 'drop'", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_OBJECT_HISTORY: LazyLock = LazyLock::new(|| BuiltinView { @@ -6280,6 +6424,7 @@ pub static MZ_OBJECT_HISTORY: LazyLock = LazyLock::new(|| BuiltinVi ) SELECT * FROM user_object_history UNION ALL (SELECT * FROM built_in_objects)"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOWS_PER_WORKER: LazyLock = LazyLock::new(|| BuiltinView { @@ -6304,6 +6449,7 @@ WHERE addrs.worker_id = ops.worker_id AND mz_catalog.list_length(addrs.address) = 1", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOWS: LazyLock = LazyLock::new(|| BuiltinView { @@ -6323,6 +6469,7 @@ SELECT id, name FROM mz_introspection.mz_dataflows_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOW_ADDRESSES: LazyLock = LazyLock::new(|| BuiltinView { @@ -6356,6 +6503,7 @@ SELECT id, address FROM mz_introspection.mz_dataflow_addresses_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOW_CHANNELS: LazyLock = LazyLock::new(|| BuiltinView { @@ -6390,6 +6538,7 @@ SELECT id, from_index, from_port, to_index, to_port, type FROM mz_introspection.mz_dataflow_channels_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOW_OPERATORS: LazyLock = LazyLock::new(|| BuiltinView { @@ -6410,6 +6559,7 @@ SELECT id, name FROM mz_introspection.mz_dataflow_operators_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOW_GLOBAL_IDS: LazyLock = LazyLock::new(|| BuiltinView { @@ -6430,6 +6580,7 @@ SELECT id, global_id FROM mz_introspection.mz_compute_dataflow_global_ids_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_MAPPABLE_OBJECTS: LazyLock = LazyLock::new(|| BuiltinView { @@ -6455,6 +6606,7 @@ FROM mz_catalog.mz_objects mo JOIN mz_introspection.mz_dataflow_global_ids mgi ON (mce.dataflow_id = mgi.id) LEFT JOIN mz_catalog.mz_databases md ON (ms.database_id = md.id);", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_LIR_MAPPING: LazyLock = LazyLock::new(|| BuiltinView { @@ -6497,6 +6649,7 @@ SELECT global_id, lir_id, operator, parent_lir_id, nesting, operator_id_start, o FROM mz_introspection.mz_compute_lir_mapping_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOW_OPERATOR_DATAFLOWS_PER_WORKER: LazyLock = @@ -6528,6 +6681,7 @@ WHERE dfs.id = addrs.address[1] AND dfs.worker_id = addrs.worker_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOW_OPERATOR_DATAFLOWS: LazyLock = LazyLock::new(|| BuiltinView { @@ -6560,6 +6714,7 @@ SELECT id, name, dataflow_id, dataflow_name FROM mz_introspection.mz_dataflow_operator_dataflows_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_OBJECT_TRANSITIVE_DEPENDENCIES: LazyLock = LazyLock::new(|| { @@ -6594,6 +6749,7 @@ WITH MUTUALLY RECURSIVE ) SELECT object_id, referenced_object_id FROM reach;", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -6621,6 +6777,7 @@ SELECT export_id, dataflow_id FROM mz_introspection.mz_compute_exports_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_COMPUTE_FRONTIERS: LazyLock = LazyLock::new(|| BuiltinView { @@ -6647,6 +6804,7 @@ pub static MZ_COMPUTE_FRONTIERS: LazyLock = LazyLock::new(|| Builti FROM mz_introspection.mz_compute_frontiers_per_worker GROUP BY export_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOW_CHANNEL_OPERATORS_PER_WORKER: LazyLock = @@ -6715,6 +6873,7 @@ FROM channel_operator_addresses coa coa.worker_id = to_ops.worker_id ", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOW_CHANNEL_OPERATORS: LazyLock = LazyLock::new(|| BuiltinView { @@ -6771,6 +6930,7 @@ SELECT id, from_operator_id, from_operator_address, to_operator_id, to_operator_ FROM mz_introspection.mz_dataflow_channel_operators_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_COMPUTE_IMPORT_FRONTIERS: LazyLock = LazyLock::new(|| BuiltinView { @@ -6802,6 +6962,7 @@ pub static MZ_COMPUTE_IMPORT_FRONTIERS: LazyLock = LazyLock::new(|| FROM mz_introspection.mz_compute_import_frontiers_per_worker GROUP BY export_id, import_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_RECORDS_PER_DATAFLOW_OPERATOR_PER_WORKER: LazyLock = @@ -6838,6 +6999,7 @@ FROM dod.id = ar_size.operator_id AND dod.worker_id = ar_size.worker_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_RECORDS_PER_DATAFLOW_OPERATOR: LazyLock = @@ -6891,6 +7053,7 @@ SELECT FROM mz_introspection.mz_records_per_dataflow_operator_per_worker GROUP BY id, name, dataflow_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_RECORDS_PER_DATAFLOW_PER_WORKER: LazyLock = @@ -6931,6 +7094,7 @@ GROUP BY dfs.name, rdo.worker_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_RECORDS_PER_DATAFLOW: LazyLock = LazyLock::new(|| BuiltinView { @@ -6980,6 +7144,7 @@ GROUP BY id, name", access: vec![PUBLIC_SELECT], + ontology: None, }); /// Peeled version of `PG_NAMESPACE`: @@ -7013,6 +7178,7 @@ FROM mz_catalog.mz_schemas s LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id JOIN mz_catalog.mz_roles role_owner ON role_owner.id = s.owner_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub const PG_NAMESPACE_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex { @@ -7044,6 +7210,7 @@ SELECT FROM mz_internal.pg_namespace_all_databases WHERE database_name IS NULL OR database_name = pg_catalog.current_database();", access: vec![PUBLIC_SELECT], + ontology: None, }); /// Peeled version of `PG_CLASS`: @@ -7151,6 +7318,7 @@ JOIN mz_catalog.mz_schemas ON mz_schemas.id = class_objects.schema_id LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id JOIN mz_catalog.mz_roles role_owner ON role_owner.id = class_objects.owner_id", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -7206,6 +7374,7 @@ FROM mz_internal.pg_class_all_databases WHERE database_name IS NULL OR database_name = pg_catalog.current_database(); ", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -7271,6 +7440,7 @@ FROM mz_internal.mz_object_dependencies JOIN current_objects objects ON object_id = objects.id JOIN current_objects dependents ON referenced_object_id = dependents.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_DATABASE: LazyLock = LazyLock::new(|| BuiltinView { @@ -7307,6 +7477,7 @@ pub static PG_DATABASE: LazyLock = LazyLock::new(|| BuiltinView { FROM mz_catalog.mz_databases d JOIN mz_catalog.mz_roles role_owner ON role_owner.id = d.owner_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_INDEX: LazyLock = LazyLock::new(|| { @@ -7373,6 +7544,7 @@ LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database() GROUP BY mz_indexes.oid, mz_relations.oid", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -7403,6 +7575,7 @@ JOIN mz_catalog.mz_schemas s ON s.id = r.schema_id LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id WHERE s.database_id IS NULL OR d.name = current_database()", access: vec![PUBLIC_SELECT], + ontology: None, }); /// Peeled version of `PG_DESCRIPTION`: @@ -7466,6 +7639,7 @@ pub static PG_DESCRIPTION_ALL_DATABASES: LazyLock = LazyLock::new(| mz_internal.mz_comments AS cmt ON mz_objects.id = cmt.id AND lower(mz_objects.type) = lower(cmt.object_type) )", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -7504,6 +7678,7 @@ WHERE (oid_database_name IS NULL OR oid_database_name = pg_catalog.current_database()) AND (class_database_name IS NULL OR class_database_name = pg_catalog.current_database());", access: vec![PUBLIC_SELECT], + ontology: None, }); /// Peeled version of `PG_TYPE`: @@ -7622,6 +7797,7 @@ FROM LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id JOIN mz_catalog.mz_roles role_owner ON role_owner.id = mz_types.owner_id", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -7665,6 +7841,7 @@ pub static PG_TYPE: LazyLock = LazyLock::new(|| BuiltinView { FROM mz_internal.pg_type_all_databases WHERE database_name IS NULL OR database_name = pg_catalog.current_database();", access: vec![PUBLIC_SELECT], + ontology: None, }); /// Peeled version of `PG_ATTRIBUTE`: @@ -7732,6 +7909,7 @@ LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id", // Since this depends on pg_type, its id must be higher due to initialization // ordering. access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -7780,6 +7958,7 @@ WHERE // Since this depends on pg_type, its id must be higher due to initialization // ordering. access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -7810,6 +7989,7 @@ JOIN mz_catalog.mz_types AS ret_type ON mz_functions.return_type_id = ret_type.i JOIN mz_catalog.mz_roles role_owner ON role_owner.id = mz_functions.owner_id WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_OPERATOR: LazyLock = LazyLock::new(|| BuiltinView { @@ -7847,6 +8027,7 @@ JOIN mz_catalog.mz_types AS ret_type ON mz_operators.return_type_id = ret_type.i JOIN mz_catalog.mz_types AS right_type ON mz_operators.argument_type_ids[1] = right_type.id WHERE array_length(mz_operators.argument_type_ids, 1) = 1", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_RANGE: LazyLock = LazyLock::new(|| BuiltinView { @@ -7864,6 +8045,7 @@ pub static PG_RANGE: LazyLock = LazyLock::new(|| BuiltinView { NULL::pg_catalog.oid AS rngsubtype WHERE false", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_ENUM: LazyLock = LazyLock::new(|| BuiltinView { @@ -7885,6 +8067,7 @@ pub static PG_ENUM: LazyLock = LazyLock::new(|| BuiltinView { NULL::pg_catalog.text AS enumlabel WHERE false", access: vec![PUBLIC_SELECT], + ontology: None, }); /// Peeled version of `PG_ATTRDEF`: @@ -7913,6 +8096,7 @@ FROM mz_catalog.mz_columns JOIN mz_catalog.mz_objects ON mz_columns.id = mz_objects.id WHERE default IS NOT NULL", access: vec![PUBLIC_SELECT], + ontology: None, }); pub const PG_ATTRDEF_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex { @@ -7946,6 +8130,7 @@ SELECT FROM mz_internal.pg_attrdef_all_databases JOIN mz_catalog.mz_databases d ON (d.id IS NULL OR d.name = pg_catalog.current_database());", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_SETTINGS: LazyLock = LazyLock::new(|| BuiltinView { @@ -7964,6 +8149,7 @@ FROM (VALUES ('max_index_keys'::pg_catalog.text, '1000'::pg_catalog.text) ) AS _ (name, setting)", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_AUTH_MEMBERS: LazyLock = LazyLock::new(|| BuiltinView { @@ -7988,6 +8174,7 @@ JOIN mz_catalog.mz_roles role ON membership.role_id = role.id JOIN mz_catalog.mz_roles member ON membership.member = member.id JOIN mz_catalog.mz_roles grantor ON membership.grantor = grantor.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_EVENT_TRIGGER: LazyLock = LazyLock::new(|| BuiltinView { @@ -8018,6 +8205,7 @@ pub static PG_EVENT_TRIGGER: LazyLock = LazyLock::new(|| BuiltinVie NULL::pg_catalog.text[] AS evttags WHERE false", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_LANGUAGE: LazyLock = LazyLock::new(|| BuiltinView { @@ -8052,6 +8240,7 @@ pub static PG_LANGUAGE: LazyLock = LazyLock::new(|| BuiltinView { NULL::pg_catalog.text[] AS lanacl WHERE false", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_SHDESCRIPTION: LazyLock = LazyLock::new(|| BuiltinView { @@ -8071,6 +8260,7 @@ pub static PG_SHDESCRIPTION: LazyLock = LazyLock::new(|| BuiltinVie NULL::pg_catalog.text AS description WHERE false", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_TIMEZONE_ABBREVS: LazyLock = LazyLock::new(|| { @@ -8093,6 +8283,7 @@ pub static PG_TIMEZONE_ABBREVS: LazyLock = LazyLock::new(|| { AS is_dst FROM mz_catalog.mz_timezone_abbreviations", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -8117,6 +8308,7 @@ pub static PG_TIMEZONE_NAMES: LazyLock = LazyLock::new(|| BuiltinVi AS is_dst FROM mz_catalog.mz_timezone_names", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_TIMEZONE_ABBREVIATIONS: LazyLock = LazyLock::new(|| BuiltinView { @@ -8151,6 +8343,7 @@ pub static MZ_TIMEZONE_ABBREVIATIONS: LazyLock = LazyLock::new(|| B ) .leak(), access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_TIMEZONE_NAMES: LazyLock = LazyLock::new(|| BuiltinView { @@ -8168,6 +8361,7 @@ pub static MZ_TIMEZONE_NAMES: LazyLock = LazyLock::new(|| BuiltinVi ) .leak(), access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_PEEK_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock = @@ -8190,6 +8384,7 @@ FROM GROUP BY worker_id, type, duration_ns", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_PEEK_DURATIONS_HISTOGRAM: LazyLock = LazyLock::new(|| BuiltinView { @@ -8226,6 +8421,7 @@ SELECT FROM mz_introspection.mz_peek_durations_histogram_per_worker GROUP BY type, duration_ns", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SCHEDULING_ELAPSED_PER_WORKER: LazyLock = @@ -8247,6 +8443,7 @@ FROM GROUP BY id, worker_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SCHEDULING_ELAPSED: LazyLock = LazyLock::new(|| BuiltinView { @@ -8281,6 +8478,7 @@ SELECT FROM mz_introspection.mz_scheduling_elapsed_per_worker GROUP BY id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock = @@ -8303,6 +8501,7 @@ FROM GROUP BY id, worker_id, duration_ns", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM: LazyLock = @@ -8344,6 +8543,7 @@ SELECT FROM mz_introspection.mz_compute_operator_durations_histogram_per_worker GROUP BY id, duration_ns", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SCHEDULING_PARKS_HISTOGRAM_PER_WORKER: LazyLock = @@ -8366,6 +8566,7 @@ FROM GROUP BY worker_id, slept_for_ns, requested_ns", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SCHEDULING_PARKS_HISTOGRAM: LazyLock = LazyLock::new(|| BuiltinView { @@ -8406,6 +8607,7 @@ SELECT FROM mz_introspection.mz_scheduling_parks_histogram_per_worker GROUP BY slept_for_ns, requested_ns", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_COMPUTE_ERROR_COUNTS_PER_WORKER: LazyLock = @@ -8449,6 +8651,7 @@ WITH MUTUALLY RECURSIVE ) SELECT * FROM all_errors", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_COMPUTE_ERROR_COUNTS: LazyLock = LazyLock::new(|| BuiltinView { @@ -8484,6 +8687,7 @@ FROM mz_introspection.mz_compute_error_counts_per_worker GROUP BY export_id HAVING pg_catalog.sum(count) != 0", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED: LazyLock = @@ -8506,6 +8710,7 @@ pub static MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED: LazyLock = column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_COMPUTE_HYDRATION_TIMES: LazyLock = LazyLock::new(|| BuiltinSource { @@ -8521,6 +8726,7 @@ pub static MZ_COMPUTE_HYDRATION_TIMES: LazyLock = LazyLock::new(| column_comments: BTreeMap::new(), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_COMPUTE_HYDRATION_TIMES_IND: LazyLock = @@ -8586,6 +8792,7 @@ SELECT * FROM dataflows UNION ALL SELECT * FROM complete_mvs", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES: LazyLock = LazyLock::new(|| { @@ -8618,6 +8825,7 @@ pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES: LazyLock = Laz ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -8694,6 +8902,7 @@ JOIN received_cte USING (channel_id, from_worker_id, to_worker_id) JOIN batch_sent_cte USING (channel_id, from_worker_id, to_worker_id) JOIN batch_received_cte USING (channel_id, from_worker_id, to_worker_id)", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_MESSAGE_COUNTS: LazyLock = LazyLock::new(|| BuiltinView { @@ -8752,6 +8961,7 @@ SELECT FROM mz_introspection.mz_message_counts_per_worker GROUP BY channel_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_ACTIVE_PEEKS: LazyLock = LazyLock::new(|| BuiltinView { @@ -8782,6 +8992,7 @@ SELECT id, object_id, type, time FROM mz_introspection.mz_active_peeks_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOW_OPERATOR_REACHABILITY_PER_WORKER: LazyLock = @@ -8821,6 +9032,7 @@ WHERE AND addr2.worker_id = reachability.worker_id GROUP BY addr2.id, reachability.worker_id, port, update_type, time", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOW_OPERATOR_REACHABILITY: LazyLock = @@ -8853,6 +9065,7 @@ SELECT FROM mz_introspection.mz_dataflow_operator_reachability_per_worker GROUP BY id, port, update_type, time", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_ARRANGEMENT_SIZES_PER_WORKER: LazyLock = LazyLock::new(|| { @@ -9012,6 +9225,7 @@ WHERE OR allocations IS NOT NULL ", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -9056,6 +9270,7 @@ SELECT FROM mz_introspection.mz_arrangement_sizes_per_worker GROUP BY operator_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_ARRANGEMENT_SHARING_PER_WORKER: LazyLock = @@ -9078,6 +9293,7 @@ SELECT FROM mz_introspection.mz_arrangement_sharing_raw GROUP BY operator_id, worker_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_ARRANGEMENT_SHARING: LazyLock = LazyLock::new(|| BuiltinView { @@ -9104,6 +9320,7 @@ SELECT operator_id, count FROM mz_introspection.mz_arrangement_sharing_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_CLUSTER_REPLICA_UTILIZATION: LazyLock = LazyLock::new(|| BuiltinView { @@ -9151,6 +9368,7 @@ FROM JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size JOIN mz_internal.mz_cluster_replica_metrics AS m ON m.replica_id = r.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_CLUSTER_REPLICA_UTILIZATION_HISTORY: LazyLock = @@ -9208,6 +9426,7 @@ FROM JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size JOIN mz_internal.mz_cluster_replica_metrics_history AS m ON m.replica_id = r.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOW_OPERATOR_PARENTS_PER_WORKER: LazyLock = @@ -9242,6 +9461,7 @@ FROM parent_addrs AS pa ON pa.parent_address = oa.address AND pa.worker_id = oa.worker_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOW_OPERATOR_PARENTS: LazyLock = LazyLock::new(|| BuiltinView { @@ -9267,6 +9487,7 @@ SELECT id, parent_id FROM mz_introspection.mz_dataflow_operator_parents_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_DATAFLOW_ARRANGEMENT_SIZES: LazyLock = LazyLock::new(|| BuiltinView { @@ -9321,6 +9542,7 @@ LEFT JOIN mz_introspection.mz_arrangement_sizes AS mas ON mdod.id = mas.operator_id GROUP BY mdod.dataflow_id, mdod.dataflow_name", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_EXPECTED_GROUP_SIZE_ADVICE: LazyLock = LazyLock::new(|| BuiltinView { @@ -9506,6 +9728,7 @@ pub static MZ_EXPECTED_GROUP_SIZE_ADVICE: LazyLock = LazyLock::new( JOIN mz_introspection.mz_dataflow_operator_dataflows dod ON dod.dataflow_id = c.dataflow_id AND dod.id = c.region_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_INDEX_ADVICE: LazyLock = LazyLock::new(|| { @@ -9839,6 +10062,7 @@ SELECT h.justification AS referenced_object_ids FROM hints_resolved_ids AS h", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -9923,6 +10147,7 @@ pub static PG_CONSTRAINT: LazyLock = LazyLock::new(|| BuiltinView { NULL::pg_catalog.text as conbin WHERE false", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_TABLES: LazyLock = LazyLock::new(|| BuiltinView { @@ -9943,6 +10168,7 @@ FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN ('r', 'p')", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_TABLESPACE: LazyLock = LazyLock::new(|| BuiltinView { @@ -9978,6 +10204,7 @@ pub static PG_TABLESPACE: LazyLock = LazyLock::new(|| BuiltinView { ) AS _ (oid, spcname, spcowner, spcacl, spcoptions) ", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_ACCESS_METHODS: LazyLock = LazyLock::new(|| BuiltinView { @@ -9999,6 +10226,7 @@ SELECT NULL::pg_catalog.oid AS oid, NULL::pg_catalog.\"char\" AS amtype WHERE false", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_ROLES: LazyLock = LazyLock::new(|| BuiltinView { @@ -10048,6 +10276,7 @@ pub static PG_ROLES: LazyLock = LazyLock::new(|| BuiltinView { oid FROM pg_catalog.pg_authid ai", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_USER: LazyLock = LazyLock::new(|| BuiltinView { @@ -10091,6 +10320,7 @@ SELECT FROM pg_catalog.pg_authid ai WHERE rolcanlogin", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_VIEWS: LazyLock = LazyLock::new(|| BuiltinView { @@ -10115,6 +10345,7 @@ LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id JOIN mz_catalog.mz_roles role_owner ON role_owner.id = v.owner_id WHERE s.database_id IS NULL OR d.name = current_database()", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_MATVIEWS: LazyLock = LazyLock::new(|| BuiltinView { @@ -10139,6 +10370,7 @@ LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id JOIN mz_catalog.mz_roles role_owner ON role_owner.id = m.owner_id WHERE s.database_id IS NULL OR d.name = current_database()", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static INFORMATION_SCHEMA_APPLICABLE_ROLES: LazyLock = @@ -10163,6 +10395,7 @@ JOIN mz_catalog.mz_roles role ON membership.role_id = role.id JOIN mz_catalog.mz_roles member ON membership.member = member.id WHERE mz_catalog.mz_is_superuser() OR pg_has_role(current_role, member.oid, 'USAGE')", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static INFORMATION_SCHEMA_COLUMNS: LazyLock = LazyLock::new(|| BuiltinView { @@ -10205,6 +10438,7 @@ JOIN mz_catalog.mz_schemas s ON s.id = o.schema_id LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id WHERE s.database_id IS NULL OR d.name = current_database()", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static INFORMATION_SCHEMA_ENABLED_ROLES: LazyLock = @@ -10221,6 +10455,7 @@ SELECT name AS role_name FROM mz_catalog.mz_roles WHERE mz_catalog.mz_is_superuser() OR pg_has_role(current_role, oid, 'USAGE')", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static INFORMATION_SCHEMA_ROLE_TABLE_GRANTS: LazyLock = LazyLock::new(|| { @@ -10246,6 +10481,7 @@ WHERE grantor IN (SELECT role_name FROM information_schema.enabled_roles) OR grantee IN (SELECT role_name FROM information_schema.enabled_roles)", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -10282,6 +10518,7 @@ pub static INFORMATION_SCHEMA_KEY_COLUMN_USAGE: LazyLock = NULL::integer AS position_in_unique_constraint WHERE false", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static INFORMATION_SCHEMA_REFERENTIAL_CONSTRAINTS: LazyLock = @@ -10323,6 +10560,7 @@ pub static INFORMATION_SCHEMA_REFERENTIAL_CONSTRAINTS: LazyLock = NULL::text AS delete_rule WHERE false", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static INFORMATION_SCHEMA_ROUTINES: LazyLock = LazyLock::new(|| BuiltinView { @@ -10348,6 +10586,7 @@ JOIN mz_catalog.mz_schemas s ON s.id = f.schema_id LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id WHERE s.database_id IS NULL OR d.name = current_database()", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static INFORMATION_SCHEMA_SCHEMATA: LazyLock = LazyLock::new(|| BuiltinView { @@ -10367,6 +10606,7 @@ FROM mz_catalog.mz_schemas s LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id WHERE s.database_id IS NULL OR d.name = current_database()", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static INFORMATION_SCHEMA_TABLES: LazyLock = LazyLock::new(|| BuiltinView { @@ -10394,6 +10634,7 @@ JOIN mz_catalog.mz_schemas s ON s.id = r.schema_id LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id WHERE s.database_id IS NULL OR d.name = current_database()", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static INFORMATION_SCHEMA_TABLE_CONSTRAINTS: LazyLock = @@ -10430,6 +10671,7 @@ pub static INFORMATION_SCHEMA_TABLE_CONSTRAINTS: LazyLock = NULL::text AS nulls_distinct WHERE false", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static INFORMATION_SCHEMA_TABLE_PRIVILEGES: LazyLock = LazyLock::new(|| { @@ -10499,6 +10741,7 @@ WHERE OR pg_has_role(current_role, grantor, 'USAGE') END", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -10550,6 +10793,7 @@ pub static INFORMATION_SCHEMA_TRIGGERS: LazyLock = LazyLock::new(|| NULL::text AS action_reference_new_table WHERE FALSE", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static INFORMATION_SCHEMA_VIEWS: LazyLock = LazyLock::new(|| BuiltinView { @@ -10573,6 +10817,7 @@ JOIN mz_catalog.mz_schemas s ON s.id = v.schema_id LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id WHERE s.database_id IS NULL OR d.name = current_database()", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static INFORMATION_SCHEMA_CHARACTER_SETS: LazyLock = @@ -10617,6 +10862,7 @@ pub static INFORMATION_SCHEMA_CHARACTER_SETS: LazyLock = 'pg_catalog' as default_collate_schema, 'en_US.utf8' as default_collate_name", access: vec![PUBLIC_SELECT], + ontology: None, }); // MZ doesn't support COLLATE so the table is filled with NULLs and made empty. pg_database hard @@ -10653,6 +10899,7 @@ SELECT NULL::pg_catalog.text AS collversion WHERE false", access: vec![PUBLIC_SELECT], + ontology: None, }); // MZ doesn't support row level security policies so the table is filled in with NULLs and made empty. @@ -10687,6 +10934,7 @@ SELECT NULL::pg_catalog.text AS polwithcheck WHERE false", access: vec![PUBLIC_SELECT], + ontology: None, }); // MZ doesn't support table inheritance so the table is filled in with NULLs and made empty. @@ -10710,6 +10958,7 @@ SELECT NULL::pg_catalog.bool AS inhdetachpending WHERE false", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_LOCKS: LazyLock = LazyLock::new(|| BuiltinView { @@ -10760,6 +11009,7 @@ SELECT NULL::pg_catalog.timestamptz AS waitstart WHERE false", access: vec![PUBLIC_SELECT], + ontology: None, }); /// Peeled version of `PG_AUTHID`: Excludes the columns rolcreaterole and rolcreatedb, to make this @@ -10802,6 +11052,7 @@ SELECT FROM mz_catalog.mz_roles r LEFT JOIN mz_catalog.mz_role_auth a ON r.oid = a.role_oid"#, access: vec![rbac::owner_privilege(ObjectType::Table, MZ_SYSTEM_ROLE_ID)], + ontology: None, }); pub const PG_AUTHID_CORE_IND: BuiltinIndex = BuiltinIndex { @@ -10875,6 +11126,7 @@ SELECT FROM mz_internal.pg_authid_core LEFT JOIN extra USING (oid)"#, access: vec![rbac::owner_privilege(ObjectType::Table, MZ_SYSTEM_ROLE_ID)], + ontology: None, }); pub static PG_AGGREGATE: LazyLock = LazyLock::new(|| BuiltinView { @@ -10936,6 +11188,7 @@ pub static PG_AGGREGATE: LazyLock = LazyLock::new(|| BuiltinView { NULL::pg_catalog.text as aggminitval FROM mz_internal.mz_aggregates a", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_TRIGGER: LazyLock = LazyLock::new(|| BuiltinView { @@ -10991,6 +11244,7 @@ pub static PG_TRIGGER: LazyLock = LazyLock::new(|| BuiltinView { WHERE false ", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_REWRITE: LazyLock = LazyLock::new(|| BuiltinView { @@ -11024,6 +11278,7 @@ pub static PG_REWRITE: LazyLock = LazyLock::new(|| BuiltinView { WHERE false ", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static PG_EXTENSION: LazyLock = LazyLock::new(|| BuiltinView { @@ -11061,6 +11316,7 @@ pub static PG_EXTENSION: LazyLock = LazyLock::new(|| BuiltinView { WHERE false ", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_ALL_OBJECTS: LazyLock = LazyLock::new(|| BuiltinView { @@ -11084,6 +11340,7 @@ pub static MZ_SHOW_ALL_OBJECTS: LazyLock = LazyLock::new(|| Builtin LEFT JOIN comments ON objs.id = comments.id WHERE (comments.object_type = objs.type OR comments.object_type IS NULL)", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_CLUSTERS: LazyLock = LazyLock::new(|| { @@ -11117,6 +11374,7 @@ pub static MZ_SHOW_CLUSTERS: LazyLock = LazyLock::new(|| { FROM clusters LEFT JOIN comments ON clusters.id = comments.id", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -11139,6 +11397,7 @@ pub static MZ_SHOW_SECRETS: LazyLock = LazyLock::new(|| BuiltinView FROM mz_catalog.mz_secrets secrets LEFT JOIN comments ON secrets.id = comments.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_COLUMNS: LazyLock = LazyLock::new(|| BuiltinView { @@ -11160,6 +11419,7 @@ pub static MZ_SHOW_COLUMNS: LazyLock = LazyLock::new(|| BuiltinView LEFT JOIN mz_internal.mz_comments comments ON columns.id = comments.id AND columns.position = comments.object_sub_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_DATABASES: LazyLock = LazyLock::new(|| BuiltinView { @@ -11180,6 +11440,7 @@ pub static MZ_SHOW_DATABASES: LazyLock = LazyLock::new(|| BuiltinVi FROM mz_catalog.mz_databases databases LEFT JOIN comments ON databases.id = comments.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_SCHEMAS: LazyLock = LazyLock::new(|| BuiltinView { @@ -11201,6 +11462,7 @@ pub static MZ_SHOW_SCHEMAS: LazyLock = LazyLock::new(|| BuiltinView FROM mz_catalog.mz_schemas schemas LEFT JOIN comments ON schemas.id = comments.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_ROLES: LazyLock = LazyLock::new(|| BuiltinView { @@ -11223,6 +11485,7 @@ pub static MZ_SHOW_ROLES: LazyLock = LazyLock::new(|| BuiltinView { WHERE roles.id NOT LIKE 's%' AND roles.id NOT LIKE 'g%'", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_TABLES: LazyLock = LazyLock::new(|| BuiltinView { @@ -11245,6 +11508,7 @@ pub static MZ_SHOW_TABLES: LazyLock = LazyLock::new(|| BuiltinView FROM mz_catalog.mz_tables tables LEFT JOIN comments ON tables.id = comments.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_VIEWS: LazyLock = LazyLock::new(|| BuiltinView { @@ -11266,6 +11530,7 @@ pub static MZ_SHOW_VIEWS: LazyLock = LazyLock::new(|| BuiltinView { FROM mz_catalog.mz_views views LEFT JOIN comments ON views.id = comments.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_TYPES: LazyLock = LazyLock::new(|| BuiltinView { @@ -11287,6 +11552,7 @@ pub static MZ_SHOW_TYPES: LazyLock = LazyLock::new(|| BuiltinView { FROM mz_catalog.mz_types types LEFT JOIN comments ON types.id = comments.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_CONNECTIONS: LazyLock = LazyLock::new(|| BuiltinView { @@ -11309,6 +11575,7 @@ pub static MZ_SHOW_CONNECTIONS: LazyLock = LazyLock::new(|| Builtin FROM mz_catalog.mz_connections connections LEFT JOIN comments ON connections.id = comments.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_SOURCES: LazyLock = LazyLock::new(|| BuiltinView { @@ -11346,6 +11613,7 @@ FROM ON clusters.id = sources.cluster_id LEFT JOIN comments ON sources.id = comments.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_SINKS: LazyLock = LazyLock::new(|| BuiltinView { @@ -11383,6 +11651,7 @@ FROM ON clusters.id = sinks.cluster_id LEFT JOIN comments ON sinks.id = comments.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_MATERIALIZED_VIEWS: LazyLock = LazyLock::new(|| BuiltinView { @@ -11417,6 +11686,7 @@ FROM JOIN mz_catalog.mz_clusters AS clusters ON clusters.id = mviews.cluster_id LEFT JOIN comments ON mviews.id = comments.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_INDEXES: LazyLock = LazyLock::new(|| BuiltinView { @@ -11477,6 +11747,7 @@ FROM ON idxs.id = keys.id LEFT JOIN comments ON idxs.id = comments.id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_CLUSTER_REPLICAS: LazyLock = LazyLock::new(|| BuiltinView { @@ -11518,6 +11789,7 @@ FROM WHERE (comments.object_type = 'cluster-replica' OR comments.object_type IS NULL) ORDER BY 1, 2"#, access: vec![PUBLIC_SELECT], + ontology: None, }); /// Lightweight data product discovery for MCP (Model Context Protocol). @@ -11571,6 +11843,7 @@ WHERE op.privilege_type = 'SELECT' AND s.name NOT IN ('mz_catalog', 'mz_internal', 'pg_catalog', 'information_schema', 'mz_introspection') "#, access: vec![PUBLIC_SELECT], + ontology: None, }); /// Full data product details with JSON Schema for MCP agents. @@ -11690,6 +11963,7 @@ GROUP BY 1, 2, 3 ) "#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_ROLE_MEMBERS: LazyLock = LazyLock::new(|| BuiltinView { @@ -11719,6 +11993,7 @@ JOIN mz_catalog.mz_roles r2 ON r2.id = rm.member JOIN mz_catalog.mz_roles r3 ON r3.id = rm.grantor ORDER BY role"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_MY_ROLE_MEMBERS: LazyLock = LazyLock::new(|| BuiltinView { @@ -11742,6 +12017,7 @@ pub static MZ_SHOW_MY_ROLE_MEMBERS: LazyLock = LazyLock::new(|| Bui FROM mz_internal.mz_show_role_members WHERE pg_has_role(member, 'USAGE')"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_SYSTEM_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinView { @@ -11772,6 +12048,7 @@ LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id WHERE privileges.grantee NOT LIKE 's%'"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_MY_SYSTEM_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinView { @@ -11796,6 +12073,7 @@ WHERE ELSE pg_has_role(grantee, 'USAGE') END"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_CLUSTER_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinView { @@ -11830,6 +12108,7 @@ LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id WHERE privileges.grantee NOT LIKE 's%'"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_MY_CLUSTER_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinView { @@ -11856,6 +12135,7 @@ WHERE ELSE pg_has_role(grantee, 'USAGE') END"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_DATABASE_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinView { @@ -11890,6 +12170,7 @@ LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id WHERE privileges.grantee NOT LIKE 's%'"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_MY_DATABASE_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinView { @@ -11916,6 +12197,7 @@ WHERE ELSE pg_has_role(grantee, 'USAGE') END"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_SCHEMA_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinView { @@ -11957,6 +12239,7 @@ LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id LEFT JOIN mz_catalog.mz_databases databases ON privileges.database_id = databases.id WHERE privileges.grantee NOT LIKE 's%'"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_MY_SCHEMA_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinView { @@ -11988,6 +12271,7 @@ WHERE ELSE pg_has_role(grantee, 'USAGE') END"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_OBJECT_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinView { @@ -12039,6 +12323,7 @@ LEFT JOIN mz_catalog.mz_schemas schemas ON privileges.schema_id = schemas.id LEFT JOIN mz_catalog.mz_databases databases ON schemas.database_id = databases.id WHERE privileges.grantee NOT LIKE 's%'"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_MY_OBJECT_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinView { @@ -12077,6 +12362,7 @@ WHERE ELSE pg_has_role(grantee, 'USAGE') END"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_ALL_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinView { @@ -12122,6 +12408,7 @@ UNION ALL SELECT grantor, grantee, database, schema, name, object_type, privilege_type FROM mz_internal.mz_show_object_privileges"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_ALL_MY_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinView { @@ -12160,6 +12447,7 @@ WHERE ELSE pg_has_role(grantee, 'USAGE') END"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_DEFAULT_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinView { @@ -12219,6 +12507,7 @@ WHERE defaults.grantee NOT LIKE 's%' AND defaults.database_id IS NULL OR defaults.database_id NOT LIKE 's%' AND defaults.schema_id IS NULL OR defaults.schema_id NOT LIKE 's%'"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_MY_DEFAULT_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinView { @@ -12264,6 +12553,7 @@ WHERE ELSE pg_has_role(grantee, 'USAGE') END"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_SHOW_NETWORK_POLICIES: LazyLock = LazyLock::new(|| BuiltinView { @@ -12298,6 +12588,7 @@ AND policy.id NOT LIKE 'g%' GROUP BY policy.name, comments.comment;", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_CLUSTER_REPLICA_HISTORY: LazyLock = LazyLock::new(|| BuiltinView { @@ -12389,6 +12680,7 @@ pub static MZ_CLUSTER_REPLICA_HISTORY: LazyLock = LazyLock::new(|| mz_catalog.mz_cluster_replica_sizes ON mz_cluster_replica_sizes.size = creates.size"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_CLUSTER_REPLICA_NAME_HISTORY: LazyLock = LazyLock::new(|| BuiltinView { @@ -12455,6 +12747,7 @@ UNION ALL SELECT * FROM system_replicas"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_HYDRATION_STATUSES: LazyLock = LazyLock::new(|| BuiltinView { @@ -12469,7 +12762,7 @@ pub static MZ_HYDRATION_STATUSES: LazyLock = LazyLock::new(|| Built column_comments: BTreeMap::from_iter([ ( "object_id", - "The ID of a dataflow-powered object. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, `mz_internal.mz_subscriptions`, `mz_catalog.mz_sources.id`, or `mz_catalog.mz_sinks.id`.", + "The ID of a dataflow-powered object (CatalogItemId). Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, `mz_internal.mz_subscriptions`, `mz_catalog.mz_sources.id`, or `mz_catalog.mz_sinks.id`.", ), ("replica_id", "The ID of a cluster replica."), ("hydrated", "Whether the object is hydrated on the replica."), @@ -12540,6 +12833,7 @@ SELECT * FROM sources UNION ALL SELECT * FROM sinks"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub const MZ_HYDRATION_STATUSES_IND: BuiltinIndex = BuiltinIndex { @@ -12578,6 +12872,7 @@ FROM mz_internal.mz_object_dependencies d JOIN mz_catalog.mz_sinks s ON (s.id = d.object_id) JOIN mz_catalog.mz_relations r ON (r.id = d.referenced_object_id)", access: vec![PUBLIC_SELECT], + ontology: None, }); pub static MZ_MATERIALIZATION_LAG: LazyLock = LazyLock::new(|| BuiltinView { @@ -12701,6 +12996,7 @@ FROM materialization_times m JOIN input_times i USING (id) JOIN root_times r USING (id)", access: vec![PUBLIC_SELECT], + ontology: None, }); /** @@ -12971,6 +13267,7 @@ CROSS JOIN LATERAL ( ) AS replica_name_history LEFT JOIN replica_offline_event_history USING (bucket_start, replica_id)"#, access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -13101,6 +13398,7 @@ dropped_clusters ( SELECT * FROM mz_cluster_deployment_lineage"#, access: vec![PUBLIC_SELECT], + ontology: None, }); pub const MZ_SHOW_DATABASES_IND: BuiltinIndex = BuiltinIndex { @@ -13545,6 +13843,7 @@ FROM mz_internal.mz_source_statistics_raw JOIN report_paths USING (id) GROUP BY report_paths.report_id, replica_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub const MZ_SOURCE_STATISTICS_WITH_HISTORY_IND: BuiltinIndex = BuiltinIndex { @@ -13650,6 +13949,7 @@ pub static MZ_SOURCE_STATISTICS: LazyLock = LazyLock::new(|| { ]), sql: "SELECT * FROM mz_internal.mz_source_statistics_with_history WHERE length(id) > 0", access: vec![PUBLIC_SELECT], + ontology: None, } }); @@ -13712,6 +14012,7 @@ SELECT FROM mz_internal.mz_sink_statistics_raw GROUP BY id, replica_id", access: vec![PUBLIC_SELECT], + ontology: None, }); pub const MZ_SINK_STATISTICS_IND: BuiltinIndex = BuiltinIndex { @@ -14537,6 +14838,9 @@ pub static BUILTINS_STATIC: LazyLock>> = LazyLock::ne builtin_items.extend(notice::builtins()); + // Generate ontology views by enumerating existing builtins. + builtin_items.extend(ontology::generate_views(&builtin_items)); + // Generate builtin relations reporting builtin objects last, since they need a complete view // of all other builtins. let mut builtin_builtins = builtin::builtins(&builtin_items).collect(); diff --git a/src/catalog/src/builtin/builtin.rs b/src/catalog/src/builtin/builtin.rs index 6930532672a3f..3a808a91890d5 100644 --- a/src/catalog/src/builtin/builtin.rs +++ b/src/catalog/src/builtin/builtin.rs @@ -102,6 +102,7 @@ FROM (VALUES {values}) AS v(oid, schema_name, name, cluster_name, definition, pr column_comments: Default::default(), sql: Box::leak(sql.into_boxed_str()), access: vec![PUBLIC_SELECT], + ontology: None, } } diff --git a/src/catalog/src/builtin/notice.rs b/src/catalog/src/builtin/notice.rs index c285524a73334..9c8d05d9c8981 100644 --- a/src/catalog/src/builtin/notice.rs +++ b/src/catalog/src/builtin/notice.rs @@ -54,6 +54,7 @@ pub static MZ_OPTIMIZER_NOTICES: LazyLock = LazyLock::new(|| { column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![MONITOR_SELECT], + ontology: None, } }); @@ -139,6 +140,7 @@ FROM mz_internal.mz_optimizer_notices n ", access: vec![MONITOR_SELECT], + ontology: None, }); /// A redacted version of [`MZ_NOTICES`] that is made safe to be viewed by @@ -203,6 +205,7 @@ FROM mz_internal.mz_notices ", access: vec![SUPPORT_SELECT, MONITOR_REDACTED_SELECT, MONITOR_SELECT], + ontology: None, }); pub const MZ_NOTICES_IND: BuiltinIndex = BuiltinIndex { diff --git a/src/catalog/src/builtin/ontology.rs b/src/catalog/src/builtin/ontology.rs new file mode 100644 index 0000000000000..8e5225abd1e5a --- /dev/null +++ b/src/catalog/src/builtin/ontology.rs @@ -0,0 +1,323 @@ +// Copyright Materialize, Inc. and contributors. All rights reserved. +// +// Use of this software is governed by the Business Source License +// included in the LICENSE file. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0. + +//! Catalog ontology views derived from existing builtin definitions. +//! +//! Enumerates builtins that have `ontology: Some(...)` and generates 4 views: +//! - entity_types: from ontology.description + RelationDesc::keys() +//! - properties: from mz_columns + mz_comments + semantic type inference +//! - semantic_types: small const reference data +//! - link_types: from ontology.links on each builtin + +use std::collections::BTreeMap; + +use mz_pgrepr::oid; +use mz_repr::namespaces::MZ_INTERNAL_SCHEMA; +use mz_repr::{RelationDesc, SqlScalarType}; +use mz_sql::catalog::NameReference; + +use super::{Builtin, BuiltinView, Ontology, PUBLIC_SELECT}; + +pub(super) fn generate_views(builtins: &[Builtin]) -> Vec> { + let infos: Vec<_> = builtins + .iter() + .filter_map(|b| { + let (name, schema, desc, ontology) = match b { + Builtin::Table(t) => (t.name, t.schema, &t.desc, t.ontology.as_ref()?), + Builtin::View(v) => (v.name, v.schema, &v.desc, v.ontology.as_ref()?), + Builtin::MaterializedView(mv) => { + (mv.name, mv.schema, &mv.desc, mv.ontology.as_ref()?) + } + Builtin::Source(s) => (s.name, s.schema, &s.desc, s.ontology.as_ref()?), + _ => return None, + }; + let entity_name = ontology.entity_name.to_string(); + Some(Info { + table_name: name, + schema_name: schema, + entity_name, + desc, + ontology, + }) + }) + .collect(); + + vec![ + Builtin::View(leak(entity_types_view(&infos))), + Builtin::View(leak(semantic_types_view())), + Builtin::View(leak(properties_view(&infos))), + Builtin::View(leak(link_types_view(&infos))), + ] +} + +/// Leak a `BuiltinView` to get a `&'static` reference. Called exactly 4 times +/// at startup (one per ontology view). These views live for the entire process +/// lifetime (same as `LazyLock<&'static BuiltinView>` used by other builtins), +/// so the leak is intentional and bounded. +fn leak(v: BuiltinView) -> &'static BuiltinView { + Box::leak(Box::new(v)) +} + +struct Info<'a> { + table_name: &'static str, + schema_name: &'static str, + entity_name: String, + desc: &'a RelationDesc, + ontology: &'a Ontology, +} + +/// Escape single quotes for SQL string literals. Only safe for trusted +/// compile-time constants (entity names, descriptions, link JSON from +/// `Ontology` annotations) — never use with user-supplied input. +fn esc(s: &str) -> String { + s.replace('\'', "''") +} + +/// Build a simple ontology view from a name, OID, column defs, and SQL. +fn view( + name: &'static str, + o: u32, + cols: &[(&'static str, SqlScalarType, bool)], + keys: &[Vec], + sql: String, +) -> BuiltinView { + let mut b = RelationDesc::builder(); + for (n, ty, nullable) in cols { + b = b.with_column(*n, ty.clone().nullable(*nullable)); + } + let mut desc = b.finish(); + for key in keys { + desc = desc.with_key(key.clone()); + } + BuiltinView { + name, + schema: MZ_INTERNAL_SCHEMA, + oid: o, + desc, + column_comments: BTreeMap::new(), + sql: Box::leak(sql.into_boxed_str()), + access: vec![PUBLIC_SELECT], + ontology: None, + } +} + +/// Extract the first primary key from a `RelationDesc` and format it as a +/// JSON object, e.g. `{"primary_key": ["id", "schema_id"]}`. Returns `None` +/// if the relation has no keys defined. +fn pk_json(desc: &RelationDesc) -> Option { + let keys = desc.typ().keys.first()?; + let cols: Vec<_> = keys + .iter() + .map(|&i| format!("\"{}\"", desc.get_name(i))) + .collect(); + Some(format!("{{\"primary_key\": [{}]}}", cols.join(", "))) +} + +// ── View builders ──────────────────────────────────────────── + +fn entity_types_view(infos: &[Info]) -> BuiltinView { + let vals: Vec<_> = infos + .iter() + .map(|i| { + let pk = pk_json(i.desc) + .map_or_else(|| "NULL::jsonb".into(), |j| format!("'{}'::jsonb", esc(&j))); + format!( + "('{}','{}.{}',{},'{}')", + esc(&i.entity_name), + esc(i.schema_name), + esc(i.table_name), + pk, + esc(i.ontology.description) + ) + }) + .collect(); + view( + "mz_ontology_entity_types", + oid::VIEW_MZ_ONTOLOGY_ENTITY_TYPES_OID, + &[ + ("name", SqlScalarType::String, false), + ("relation", SqlScalarType::String, false), + ("properties", SqlScalarType::Jsonb, true), + ("description", SqlScalarType::String, false), + ], + &[vec![0], vec![1], vec![3]], + format!( + "SELECT name::text,relation::text,properties::jsonb,description::text FROM (VALUES {}) AS t(name,relation,properties,description)", + vals.join(",") + ), + ) +} + +fn semantic_types_view() -> BuiltinView { + let vals: Vec<_> = SEMANTIC_TYPE_DEFS + .iter() + .map(|(n, t, d)| format!("('{}','{}','{}')", esc(n), esc(t), esc(d))) + .collect(); + view( + "mz_ontology_semantic_types", + oid::VIEW_MZ_ONTOLOGY_SEMANTIC_TYPES_OID, + &[ + ("name", SqlScalarType::String, false), + ("sql_type", SqlScalarType::String, false), + ("description", SqlScalarType::String, false), + ], + &[vec![0], vec![2]], + format!( + "SELECT name::text,sql_type::text,description::text FROM (VALUES {}) AS t(name,sql_type,description)", + vals.join(",") + ), + ) +} + +/// Build the `mz_ontology_properties` view: one row per column of every +/// annotated builtin relation. +/// +/// The generated SQL works in two halves: +/// +/// 1. **Column discovery** — An inline VALUES list (`ent`) maps each entity to +/// its (schema, table) pair. This is joined through `mz_schemas` → +/// `mz_objects` → `mz_columns` so the view always reflects the live catalog +/// (column additions/removals are picked up automatically). +/// +/// 2. **Annotation enrichment** — A second VALUES list (`ann`) carries the +/// semantic-type annotations from `RelationDesc` (e.g. "CatalogItemId"). +/// Column descriptions come from `mz_comments`. Both are LEFT JOINed so +/// columns without annotations or comments still appear (with NULLs). +fn properties_view(infos: &[Info]) -> BuiltinView { + let mut ent = Vec::new(); + let mut ann = Vec::new(); + for i in infos { + ent.push(format!( + "('{}','{}','{}')", + esc(i.schema_name), + esc(i.table_name), + esc(&i.entity_name) + )); + for (idx, col) in i.desc.iter_names().enumerate() { + if let Some(sem) = i.desc.get_semantic_type(idx) { + ann.push(format!( + "('{}','{}','{}')", + esc(&i.entity_name), + esc(col.as_str()), + sem + )); + } + } + } + view( + "mz_ontology_properties", + oid::VIEW_MZ_ONTOLOGY_PROPERTIES_OID, + &[ + ("entity_type", SqlScalarType::String, false), + ("column_name", SqlScalarType::String, false), + ("semantic_type", SqlScalarType::String, true), + ("description", SqlScalarType::String, true), + ], + &[], + format!( + "SELECT ent.entity_name AS entity_type,col.name AS column_name,\ + ann.semantic_type::text AS semantic_type,cmt.comment AS description \ + FROM (VALUES {ent}) AS ent(schema_name,table_name,entity_name) \ + JOIN mz_catalog.mz_schemas s ON s.name=ent.schema_name \ + JOIN mz_catalog.mz_objects o ON o.schema_id=s.id AND o.name=ent.table_name \ + JOIN mz_catalog.mz_columns col ON col.id=o.id \ + LEFT JOIN mz_internal.mz_comments cmt ON cmt.id=o.id AND cmt.object_sub_id=col.position \ + LEFT JOIN (VALUES {ann}) AS ann(entity_name,column_name,semantic_type) \ + ON ann.entity_name=ent.entity_name AND ann.column_name=col.name", + ent = ent.join(","), + ann = ann.join(","), + ), + ) +} + +fn link_types_view(infos: &[Info]) -> BuiltinView { + let vals: Vec<_> = infos + .iter() + .flat_map(|i| { + i.ontology.links.iter().map(move |l| { + format!( + "('{}','{}','{}','{}'::jsonb,NULL::text)", + esc(l.name), + esc(&i.entity_name), + esc(l.target), + esc(l.properties_json), + ) + }) + }) + .collect(); + view( + "mz_ontology_link_types", + oid::VIEW_MZ_ONTOLOGY_LINK_TYPES_OID, + &[ + ("name", SqlScalarType::String, false), + ("source_entity", SqlScalarType::String, false), + ("target_entity", SqlScalarType::String, false), + ("properties", SqlScalarType::Jsonb, false), + ("description", SqlScalarType::String, true), + ], + &[], + format!( + "SELECT name::text,source_entity::text,target_entity::text,properties::jsonb,description::text FROM (VALUES {}) AS t(name,source_entity,target_entity,properties,description)", + vals.join(",") + ), + ) +} + +// ── Semantic type reference data ───────────────────────────── + +const SEMANTIC_TYPE_DEFS: &[(&str, &str, &str)] = &[ + ( + "CatalogItemId", + "text", + "SQL-layer object ID. Format: s{n}/u{n}.", + ), + ( + "GlobalId", + "text", + "Runtime ID used by compute/storage. Format: s{n}/u{n}/si{n}.", + ), + ("ClusterId", "text", "Cluster ID. Format: s{n}/u{n}."), + ( + "ReplicaId", + "text", + "Cluster replica ID. Format: s{n}/u{n}.", + ), + ("SchemaId", "text", "Schema ID. Format: s{n}/u{n}."), + ("DatabaseId", "text", "Database ID. Format: s{n}/u{n}."), + ("RoleId", "text", "Role ID. Format: s{n}/g{n}/u{n}/p."), + ( + "NetworkPolicyId", + "text", + "Network policy ID. Format: s{n}/u{n}.", + ), + ("ShardId", "text", "Persist shard ID. Format: s{uuid}."), + ("OID", "oid", "PostgreSQL-compatible object identifier."), + ("ObjectType", "text", "Catalog object type discriminator."), + ("ConnectionType", "text", "Connection type discriminator."), + ("SourceType", "text", "Source type discriminator."), + ( + "MzTimestamp", + "mz_timestamp", + "Internal logical timestamp (uint64).", + ), + ( + "WallclockTimestamp", + "timestamp with time zone", + "Wall clock timestamp.", + ), + ("ByteCount", "uint8", "A count of bytes."), + ("RecordCount", "uint8", "A count of records/rows."), + ("CreditRate", "numeric", "Credits consumed per hour."), + ("SqlDefinition", "text", "A SQL CREATE statement."), + ( + "RedactedSqlDefinition", + "text", + "A redacted SQL CREATE statement.", + ), +]; diff --git a/src/pgrepr-consts/src/oid.rs b/src/pgrepr-consts/src/oid.rs index ded0875d9db04..c4905027cc46f 100644 --- a/src/pgrepr-consts/src/oid.rs +++ b/src/pgrepr-consts/src/oid.rs @@ -787,3 +787,7 @@ pub const FUNC_PARSE_CATALOG_CREATE_SQL_OID: u32 = 17073; pub const FUNC_REDACT_SQL_OID: u32 = 17074; pub const FUNC_REPEAT_ROW_NON_NEGATIVE_OID: u32 = 17075; pub const ROLE_MZ_JWT_SYNC_OID: u32 = 17076; +pub const VIEW_MZ_ONTOLOGY_ENTITY_TYPES_OID: u32 = 17077; +pub const VIEW_MZ_ONTOLOGY_SEMANTIC_TYPES_OID: u32 = 17078; +pub const VIEW_MZ_ONTOLOGY_PROPERTIES_OID: u32 = 17079; +pub const VIEW_MZ_ONTOLOGY_LINK_TYPES_OID: u32 = 17080; diff --git a/src/repr/src/relation.rs b/src/repr/src/relation.rs index 7e4a3ff71839c..72658183e1b51 100644 --- a/src/repr/src/relation.rs +++ b/src/repr/src/relation.rs @@ -902,10 +902,30 @@ struct ColumnMetadata { /// the index in [`SqlRelationType`] that corresponds to a given column, and the /// version at which this column was added or dropped. /// -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash, MzReflect)] +#[derive(Clone, Debug, Serialize, Deserialize, MzReflect)] pub struct RelationDesc { typ: SqlRelationType, metadata: BTreeMap, + /// Optional semantic type annotations for columns (e.g., "CatalogItemId", "RoleId"). + /// Keyed by column index. Only populated for builtin catalog objects. + /// Excluded from Eq/Hash/serialization — it's ontology metadata, not schema. + #[serde(skip)] + semantic_types: BTreeMap, +} + +impl PartialEq for RelationDesc { + fn eq(&self, other: &Self) -> bool { + self.typ == other.typ && self.metadata == other.metadata + } +} + +impl Eq for RelationDesc {} + +impl std::hash::Hash for RelationDesc { + fn hash(&self, state: &mut H) { + self.typ.hash(state); + self.metadata.hash(state); + } } impl RustType for RelationDesc { @@ -978,6 +998,7 @@ impl RustType for RelationDesc { Ok(RelationDesc { typ: proto.typ.into_rust_if_some("ProtoRelationDesc::typ")?, metadata, + semantic_types: BTreeMap::default(), }) } } @@ -994,6 +1015,7 @@ impl RelationDesc { RelationDesc { typ: SqlRelationType::empty(), metadata: BTreeMap::default(), + semantic_types: BTreeMap::default(), } } @@ -1037,7 +1059,11 @@ impl RelationDesc { // TODO(parkmycar): Add better validation here. assert_eq!(typ.column_types.len(), metadata.len()); - RelationDesc { typ, metadata } + RelationDesc { + typ, + metadata, + semantic_types: BTreeMap::default(), + } } pub fn from_names_and_types(iter: I) -> Self @@ -1200,6 +1226,11 @@ impl RelationDesc { self.get_name_idx(&ColumnIndex(i)) } + /// Gets the semantic type annotation for column `i`, if any. + pub fn get_semantic_type(&self, i: usize) -> Option<&'static str> { + self.semantic_types.get(&i).copied() + } + /// Gets the name of the column at `idx`. /// /// # Panics @@ -1520,6 +1551,8 @@ pub struct RelationDescBuilder { columns: Vec<(ColumnName, SqlColumnType)>, /// Sets of indices that are "keys" for the collection. keys: Vec>, + /// Semantic type annotations for columns. + semantic_types: BTreeMap, } impl RelationDescBuilder { @@ -1555,6 +1588,17 @@ impl RelationDescBuilder { self } + /// Annotates the most recently added column with a semantic type. + pub fn with_semantic_type(mut self, semantic_type: &'static str) -> RelationDescBuilder { + let idx = self + .columns + .len() + .checked_sub(1) + .expect("no column to annotate"); + self.semantic_types.insert(idx, semantic_type); + self + } + /// Removes all previously inserted keys. pub fn without_keys(mut self) -> RelationDescBuilder { self.keys.clear(); @@ -1579,6 +1623,7 @@ impl RelationDescBuilder { pub fn finish(self) -> RelationDesc { let mut desc = RelationDesc::from_names_and_types(self.columns); desc.typ = desc.typ.with_keys(self.keys); + desc.semantic_types = self.semantic_types; desc } } @@ -1765,6 +1810,7 @@ impl VersionedRelationDesc { RelationDesc { typ: relation_type, metadata: column_metas, + semantic_types: BTreeMap::default(), } } diff --git a/test/sqllogictest/autogenerated/mz_internal.slt b/test/sqllogictest/autogenerated/mz_internal.slt index ea87e6201290c..e3cee6579873c 100644 --- a/test/sqllogictest/autogenerated/mz_internal.slt +++ b/test/sqllogictest/autogenerated/mz_internal.slt @@ -787,6 +787,10 @@ mz_object_lifetimes mz_object_oid_alias mz_object_transitive_dependencies mz_objects_id_namespace_types +mz_ontology_entity_types +mz_ontology_link_types +mz_ontology_properties +mz_ontology_semantic_types mz_optimizer_notices mz_pending_cluster_replicas mz_postgres_source_tables From 43b808db92fbd91c1d2227e321e7bc63eb0f1cff Mon Sep 17 00:00:00 2001 From: mtabebe Date: Fri, 17 Apr 2026 16:14:41 -0400 Subject: [PATCH 02/14] [ontology] annotate builtins with ontology metadata and semantic types Add ontology annotations to builtin catalog objects and semantic type annotations. This populates the ontology views introduced in the previous commit with: - Entity types: databases, schemas, roles, clusters, replicas, tables, sources, views, MVs, indexes, sinks, connections, secrets, types, functions, and ~100 internal/introspection objects - Semantic types: CatalogItemId, GlobalId, ClusterId, ReplicaId, etc. - Link types: relationships (owned_by, in_schema, runs_on_cluster, depends_on, details_of, etc.) - Column-level semantic type annotations via with_semantic_type() --- src/catalog/src/builtin.rs | 1445 ++++++++++++++++++++++--- src/storage-client/src/healthcheck.rs | 11 + 2 files changed, 1330 insertions(+), 126 deletions(-) diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index 469dbe1a28db7..7d5d1fb94b647 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -2091,6 +2091,7 @@ pub static MZ_ICEBERG_SINKS: LazyLock = LazyLock::new(|| BuiltinTa oid: oid::TABLE_MZ_ICEBERG_SINKS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("namespace", SqlScalarType::String.nullable(false)) .with_column("table", SqlScalarType::String.nullable(false)) .finish(), @@ -2104,7 +2105,15 @@ pub static MZ_ICEBERG_SINKS: LazyLock = LazyLock::new(|| BuiltinTa ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "iceberg_sink", + description: "Iceberg-specific sink configuration (namespace, table)", + links: &[OntologyLink { + name: "details_of", + target: "sink", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], + }), }); pub static MZ_KAFKA_SINKS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2113,6 +2122,7 @@ pub static MZ_KAFKA_SINKS: LazyLock = LazyLock::new(|| BuiltinTabl oid: oid::TABLE_MZ_KAFKA_SINKS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("topic", SqlScalarType::String.nullable(false)) .with_key(vec![0]) .finish(), @@ -2125,7 +2135,15 @@ pub static MZ_KAFKA_SINKS: LazyLock = LazyLock::new(|| BuiltinTabl ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "kafka_sink", + description: "Kafka-specific sink configuration (topic)", + links: &[OntologyLink { + name: "details_of", + target: "sink", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], + }), }); pub static MZ_KAFKA_CONNECTIONS: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_kafka_connections", @@ -2133,6 +2151,7 @@ pub static MZ_KAFKA_CONNECTIONS: LazyLock = LazyLock::new(|| Built oid: oid::TABLE_MZ_KAFKA_CONNECTIONS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column( "brokers", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), @@ -2152,7 +2171,15 @@ pub static MZ_KAFKA_CONNECTIONS: LazyLock = LazyLock::new(|| Built ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "kafka_connection", + description: "Kafka-specific connection configuration (brokers, progress topic)", + links: &[OntologyLink { + name: "details_of", + target: "connection", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], + }), }); pub static MZ_KAFKA_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_kafka_sources", @@ -2160,6 +2187,7 @@ pub static MZ_KAFKA_SOURCES: LazyLock = LazyLock::new(|| BuiltinTa oid: oid::TABLE_MZ_KAFKA_SOURCES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("group_id_prefix", SqlScalarType::String.nullable(false)) .with_column("topic", SqlScalarType::String.nullable(false)) .finish(), @@ -2179,7 +2207,15 @@ pub static MZ_KAFKA_SOURCES: LazyLock = LazyLock::new(|| BuiltinTa ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "kafka_source", + description: "Kafka-specific source configuration (topic, group ID)", + links: &[OntologyLink { + name: "details_of", + target: "source", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], + }), }); pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_postgres_sources", @@ -2187,6 +2223,7 @@ pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| Builti oid: oid::TABLE_MZ_POSTGRES_SOURCES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("replication_slot", SqlScalarType::String.nullable(false)) .with_column("timeline_id", SqlScalarType::UInt64.nullable(true)) .finish(), @@ -2206,7 +2243,11 @@ pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| Builti ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "postgres_source", + description: "Postgres source-level details", + links: &[], + }), }); pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_postgres_source_tables", @@ -2214,6 +2255,7 @@ pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| oid: oid::TABLE_MZ_POSTGRES_SOURCE_TABLES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("schema_name", SqlScalarType::String.nullable(false)) .with_column("table_name", SqlScalarType::String.nullable(false)) .finish(), @@ -2233,7 +2275,11 @@ pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "postgres_source_table", + description: "Postgres source table-level details", + links: &[], + }), }); pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_mysql_source_tables", @@ -2241,6 +2287,7 @@ pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui oid: oid::TABLE_MZ_MYSQL_SOURCE_TABLES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("schema_name", SqlScalarType::String.nullable(false)) .with_column("table_name", SqlScalarType::String.nullable(false)) .finish(), @@ -2260,7 +2307,11 @@ pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "mysql_source_table", + description: "MySQL source table-level details", + links: &[], + }), }); pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_sql_server_source_tables", @@ -2268,6 +2319,7 @@ pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(| oid: oid::TABLE_MZ_SQL_SERVER_SOURCE_TABLES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("schema_name", SqlScalarType::String.nullable(false)) .with_column("table_name", SqlScalarType::String.nullable(false)) .finish(), @@ -2287,7 +2339,11 @@ pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(| ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "sql_server_source_table", + description: "SQL Server source table-level details", + links: &[], + }), }); pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_kafka_source_tables", @@ -2295,6 +2351,7 @@ pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui oid: oid::TABLE_MZ_KAFKA_SOURCE_TABLES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("topic", SqlScalarType::String.nullable(false)) .with_column("envelope_type", SqlScalarType::String.nullable(true)) .with_column("key_format", SqlScalarType::String.nullable(true)) @@ -2321,7 +2378,11 @@ pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "kafka_source_table", + description: "Kafka source table-level details", + links: &[], + }), }); pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_object_dependencies", @@ -2329,10 +2390,12 @@ pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| Bui oid: oid::TABLE_MZ_OBJECT_DEPENDENCIES_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column( "referenced_object_id", SqlScalarType::String.nullable(false), ) + .with_semantic_type("CatalogItemId") .finish(), column_comments: BTreeMap::from_iter([ ( @@ -2346,7 +2409,22 @@ pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| Bui ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "object_dependency", + description: "A dependency edge: one object depends on another", + links: &[ + OntologyLink { + name: "depends_on", + target: "object", + properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "depended_on_by", + target: "object", + properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "referenced_object_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], + }), }); pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| BuiltinSource { name: "mz_compute_dependencies", @@ -2355,7 +2433,9 @@ pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| B data_source: IntrospectionType::ComputeDependencies.into(), desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("dependency_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .finish(), column_comments: BTreeMap::from_iter([ ( @@ -2369,19 +2449,37 @@ pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| B ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "compute_dependency", + description: "Dependency edges within compute dataflows", + links: &[ + OntologyLink { + name: "compute_depends_on", + target: "object", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "compute_depended_by", + target: "object", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "dependency_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], + }), }); -pub static MZ_DATABASES: LazyLock = - LazyLock::new(|| BuiltinMaterializedView { +pub static MZ_DATABASES: LazyLock = LazyLock::new(|| { + BuiltinMaterializedView { name: "mz_databases", schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_DATABASES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("DatabaseId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -2418,20 +2516,33 @@ FROM mz_internal.mz_catalog_raw WHERE data->>'kind' = 'Database'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, - }); + ontology: Some(Ontology { + entity_name: "database", + description: "A top-level namespace that contains schemas", + links: &[OntologyLink { + name: "owned_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), + } +}); -pub static MZ_SCHEMAS: LazyLock = - LazyLock::new(|| BuiltinMaterializedView { +pub static MZ_SCHEMAS: LazyLock = LazyLock::new(|| { + BuiltinMaterializedView { name: "mz_schemas", schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_SCHEMAS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("SchemaId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("database_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("DatabaseId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -2475,8 +2586,24 @@ FROM mz_internal.mz_catalog_raw WHERE data->>'kind' = 'Schema'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, - }); + ontology: Some(Ontology { + entity_name: "schema", + description: "A namespace within a database that contains objects", + links: &[ + OntologyLink { + name: "in_database", + target: "database", + properties_json: r#"{"kind": "foreign_key", "source_column": "database_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + }, + OntologyLink { + name: "owned_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], + }), + } +}); pub static MZ_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_columns", @@ -2484,12 +2611,14 @@ pub static MZ_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_COLUMNS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) // not a key + .with_semantic_type("CatalogItemId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("position", SqlScalarType::UInt64.nullable(false)) .with_column("nullable", SqlScalarType::Bool.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) .with_column("default", SqlScalarType::String.nullable(true)) .with_column("type_oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("type_mod", SqlScalarType::Int32.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -2513,7 +2642,15 @@ pub static MZ_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "column", + description: "A column of a relation, with its name, position, type, and nullability", + links: &[OntologyLink { + name: "belongs_to_relation", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "many_to_one", "note": "id in mz_columns is the relation ID, not a unique column ID"}"#, + }], + }), }); pub static MZ_INDEXES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_indexes", @@ -2521,13 +2658,20 @@ pub static MZ_INDEXES: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_INDEXES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("on_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("cluster_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ClusterId") .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column("create_sql", SqlScalarType::String.nullable(false)) + .with_semantic_type("SqlDefinition") .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) + .with_semantic_type("RedactedSqlDefinition") .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -2555,7 +2699,27 @@ pub static MZ_INDEXES: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "index", + description: "An in-memory index on a relation for fast lookups", + links: &[ + OntologyLink { + name: "owned_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "runs_on_cluster", + target: "cluster", + properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "indexes_relation", + target: "relation", + properties_json: r#"{"kind": "foreign_key", "source_column": "on_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], + }), }); pub static MZ_INDEX_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_index_columns", @@ -2563,6 +2727,7 @@ pub static MZ_INDEX_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTa oid: oid::TABLE_MZ_INDEX_COLUMNS_OID, desc: RelationDesc::builder() .with_column("index_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("index_position", SqlScalarType::UInt64.nullable(false)) .with_column("on_position", SqlScalarType::UInt64.nullable(true)) .with_column("on_expression", SqlScalarType::String.nullable(true)) @@ -2592,7 +2757,15 @@ pub static MZ_INDEX_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTa ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "index_column", + description: "A column or expression in an index, with its position", + links: &[OntologyLink { + name: "belongs_to_index", + target: "index", + properties_json: r#"{"kind": "foreign_key", "source_column": "index_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), }); pub static MZ_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_tables", @@ -2600,17 +2773,24 @@ pub static MZ_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_TABLES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("schema_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("SchemaId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) .with_column("create_sql", SqlScalarType::String.nullable(true)) + .with_semantic_type("SqlDefinition") .with_column("redacted_create_sql", SqlScalarType::String.nullable(true)) + .with_semantic_type("RedactedSqlDefinition") .with_column("source_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("CatalogItemId") .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -2639,7 +2819,27 @@ pub static MZ_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "table", + description: "A user-writable table that can be inserted into and updated", + links: &[ + OntologyLink { + name: "in_schema", + target: "schema", + properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "owned_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "created_by_source", + target: "source", + properties_json: r#"{"kind": "foreign_key", "source_column": "source_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + }, + ], + }), }); pub static MZ_CONNECTIONS: LazyLock = LazyLock::new(|| { @@ -2649,17 +2849,24 @@ pub static MZ_CONNECTIONS: LazyLock = LazyLock::new(|| oid: oid::MV_MZ_CONNECTIONS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("schema_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("SchemaId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) + .with_semantic_type("ConnectionType") .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) .with_column("create_sql", SqlScalarType::String.nullable(false)) + .with_semantic_type("SqlDefinition") .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) + .with_semantic_type("RedactedSqlDefinition") .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -2718,7 +2925,22 @@ WHERE mz_internal.parse_catalog_create_sql(data->'value'->'definition'->'V1'->>'create_sql')->>'type' = 'connection'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "connection", + description: "A reusable connection configuration to an external system", + links: &[ + OntologyLink { + name: "in_schema", + target: "schema", + properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "owned_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], + }), } }); @@ -2728,6 +2950,7 @@ pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock = LazyLock::new(|| oid: oid::TABLE_MZ_SSH_TUNNEL_CONNECTIONS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("public_key_1", SqlScalarType::String.nullable(false)) .with_column("public_key_2", SqlScalarType::String.nullable(false)) .finish(), @@ -2744,7 +2967,15 @@ pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock = LazyLock::new(|| ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "ssh_tunnel", + description: "SSH tunnel connection with public keys", + links: &[OntologyLink { + name: "details_of", + target: "connection", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], + }), }); pub static MZ_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_sources", @@ -2752,23 +2983,32 @@ pub static MZ_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_SOURCES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("schema_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("SchemaId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) + .with_semantic_type("SourceType") .with_column("connection_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("CatalogItemId") .with_column("size", SqlScalarType::String.nullable(true)) .with_column("envelope_type", SqlScalarType::String.nullable(true)) .with_column("key_format", SqlScalarType::String.nullable(true)) .with_column("value_format", SqlScalarType::String.nullable(true)) .with_column("cluster_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("ClusterId") .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) .with_column("create_sql", SqlScalarType::String.nullable(true)) + .with_semantic_type("SqlDefinition") .with_column("redacted_create_sql", SqlScalarType::String.nullable(true)) + .with_semantic_type("RedactedSqlDefinition") .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -2818,7 +3058,32 @@ pub static MZ_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "source", + description: "An external data source ingested into Materialize (e.g., Kafka, Postgres)", + links: &[ + OntologyLink { + name: "in_schema", + target: "schema", + properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "owned_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "runs_on_cluster", + target: "cluster", + properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + }, + OntologyLink { + name: "uses_connection", + target: "connection", + properties_json: r#"{"kind": "foreign_key", "source_column": "connection_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + }, + ], + }), }); pub static MZ_SINKS: LazyLock = LazyLock::new(|| { BuiltinTable { @@ -2827,11 +3092,15 @@ pub static MZ_SINKS: LazyLock = LazyLock::new(|| { oid: oid::TABLE_MZ_SINKS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("schema_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("SchemaId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) .with_column("connection_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("CatalogItemId") .with_column("size", SqlScalarType::String.nullable(true)) .with_column("envelope_type", SqlScalarType::String.nullable(true)) // This `format` column is deprecated and replaced by the `key_format` and `value_format` columns @@ -2840,9 +3109,13 @@ pub static MZ_SINKS: LazyLock = LazyLock::new(|| { .with_column("key_format", SqlScalarType::String.nullable(true)) .with_column("value_format", SqlScalarType::String.nullable(true)) .with_column("cluster_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ClusterId") .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column("create_sql", SqlScalarType::String.nullable(false)) + .with_semantic_type("SqlDefinition") .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) + .with_semantic_type("RedactedSqlDefinition") .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -2892,7 +3165,27 @@ pub static MZ_SINKS: LazyLock = LazyLock::new(|| { ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "sink", + description: "An export of data from Materialize to an external system", + links: &[ + OntologyLink { + name: "in_schema", + target: "schema", + properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "owned_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "runs_on_cluster", + target: "cluster", + properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], + }), } }); pub static MZ_VIEWS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2901,17 +3194,24 @@ pub static MZ_VIEWS: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_VIEWS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("schema_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("SchemaId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("definition", SqlScalarType::String.nullable(false)) + .with_semantic_type("SqlDefinition") .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) .with_column("create_sql", SqlScalarType::String.nullable(false)) + .with_semantic_type("SqlDefinition") .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) + .with_semantic_type("RedactedSqlDefinition") .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -2937,7 +3237,22 @@ pub static MZ_VIEWS: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "view", + description: "A non-materialized view defined by a SQL query", + links: &[ + OntologyLink { + name: "in_schema", + target: "schema", + properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "owned_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], + }), }); pub static MZ_MATERIALIZED_VIEWS: LazyLock = LazyLock::new(|| { @@ -2947,18 +3262,26 @@ pub static MZ_MATERIALIZED_VIEWS: LazyLock = LazyLock:: oid: oid::MV_MZ_MATERIALIZED_VIEWS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("schema_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("SchemaId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("cluster_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ClusterId") .with_column("definition", SqlScalarType::String.nullable(false)) + .with_semantic_type("SqlDefinition") .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) .with_column("create_sql", SqlScalarType::String.nullable(false)) + .with_semantic_type("SqlDefinition") .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) + .with_semantic_type("RedactedSqlDefinition") .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3063,7 +3386,15 @@ UNION ALL SELECT * FROM builtin_mvs").into_boxed_str()), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "mv", + description: "A materialized view maintained incrementally on a cluster", + links: &[ + OntologyLink { name: "in_schema", target: "schema", properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"# }, + OntologyLink { name: "owned_by", target: "role", properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"# }, + OntologyLink { name: "runs_on_cluster", target: "cluster", properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"# }, + ], + }), } }); @@ -3121,17 +3452,23 @@ pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("schema_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("SchemaId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("category", SqlScalarType::String.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) .with_column("create_sql", SqlScalarType::String.nullable(true)) + .with_semantic_type("SqlDefinition") .with_column("redacted_create_sql", SqlScalarType::String.nullable(true)) + .with_semantic_type("RedactedSqlDefinition") .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3157,7 +3494,22 @@ pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "type", + description: "A named data type (base, array, list, map, or pseudo)", + links: &[ + OntologyLink { + name: "in_schema", + target: "schema", + properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "owned_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], + }), }); pub static MZ_NETWORK_POLICIES: LazyLock = LazyLock::new(|| { @@ -3167,13 +3519,16 @@ pub static MZ_NETWORK_POLICIES: LazyLock = LazyLock::ne oid: oid::MV_MZ_NETWORK_POLICIES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("NetworkPolicyId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_key(vec![0]) .with_key(vec![4]) .finish(), @@ -3209,7 +3564,11 @@ FROM mz_internal.mz_catalog_raw WHERE data->>'kind' = 'NetworkPolicy'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "network_policy", + description: "Network access policies", + links: &[], + }), } }); @@ -3265,7 +3624,11 @@ FROM WHERE data->>'kind' = 'NetworkPolicy'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "network_policy_rule", + description: "Individual rules within a network policy", + links: &[], + }), } }); @@ -3277,8 +3640,11 @@ pub static MZ_TYPE_PG_METADATA: LazyLock = LazyLock::new(|| Builti oid: oid::TABLE_MZ_TYPE_PG_METADATA_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("typinput", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("typreceive", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, @@ -3291,7 +3657,9 @@ pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| BuiltinTabl oid: oid::TABLE_MZ_ARRAY_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("element_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .finish(), column_comments: BTreeMap::from_iter([ ("id", "The ID of the array type."), @@ -3299,7 +3667,22 @@ pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| BuiltinTabl ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "array_type", + description: "An array type with its element type", + links: &[ + OntologyLink { + name: "is_subtype_of", + target: "type", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }, + OntologyLink { + name: "has_element_type", + target: "type", + properties_json: r#"{"kind": "foreign_key", "source_column": "element_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], + }), }); pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_base_types", @@ -3307,11 +3690,16 @@ pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinTable oid: oid::TABLE_MZ_BASE_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .finish(), column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "base_type", + description: "A primitive/base data type", + links: &[], + }), }); pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_list_types", @@ -3319,7 +3707,9 @@ pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable oid: oid::TABLE_MZ_LIST_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("element_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column( "element_modifiers", SqlScalarType::List { @@ -3339,7 +3729,22 @@ pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "list_type", + description: "A list type with its element type", + links: &[ + OntologyLink { + name: "is_subtype_of", + target: "type", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }, + OntologyLink { + name: "has_element_type", + target: "type", + properties_json: r#"{"kind": "foreign_key", "source_column": "element_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], + }), }); pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_map_types", @@ -3347,8 +3752,11 @@ pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable oid: oid::TABLE_MZ_MAP_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("key_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("value_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column( "key_modifiers", SqlScalarType::List { @@ -3381,7 +3789,27 @@ pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "map_type", + description: "A map type with its key and value types", + links: &[ + OntologyLink { + name: "is_subtype_of", + target: "type", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }, + OntologyLink { + name: "has_key_type", + target: "type", + properties_json: r#"{"kind": "foreign_key", "source_column": "key_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "has_value_type", + target: "type", + properties_json: r#"{"kind": "foreign_key", "source_column": "value_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], + }), }); pub static MZ_ROLES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_roles", @@ -3389,7 +3817,9 @@ pub static MZ_ROLES: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_ROLES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("inherit", SqlScalarType::Bool.nullable(false)) .with_column("rolcanlogin", SqlScalarType::Bool.nullable(true)) @@ -3410,7 +3840,11 @@ pub static MZ_ROLES: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "role", + description: "A user or role for authentication and access control", + links: &[], + }), }); pub static MZ_ROLE_MEMBERS: LazyLock = LazyLock::new(|| { @@ -3420,8 +3854,11 @@ pub static MZ_ROLE_MEMBERS: LazyLock = LazyLock::new(|| oid: oid::MV_MZ_ROLE_MEMBERS_OID, desc: RelationDesc::builder() .with_column("role_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column("member", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column("grantor", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .finish(), column_comments: BTreeMap::from_iter([ ( @@ -3454,7 +3891,27 @@ FROM WHERE data->>'kind' = 'Role'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "role_member", + description: "A membership grant: one role is a member of another role", + links: &[ + OntologyLink { + name: "member_of_role", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "role_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "has_member", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "member", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "granted_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "grantor", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], + }), } }); @@ -3464,6 +3921,7 @@ pub static MZ_ROLE_PARAMETERS: LazyLock = LazyLock::new(|| Builtin oid: oid::TABLE_MZ_ROLE_PARAMETERS_OID, desc: RelationDesc::builder() .with_column("role_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column("parameter_name", SqlScalarType::String.nullable(false)) .with_column("parameter_value", SqlScalarType::String.nullable(false)) .finish(), @@ -3483,7 +3941,15 @@ pub static MZ_ROLE_PARAMETERS: LazyLock = LazyLock::new(|| Builtin ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "role_parameter", + description: "A session parameter default set for a role", + links: &[OntologyLink { + name: "parameter_of", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "role_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), }); pub static MZ_ROLE_AUTH: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_role_auth", @@ -3491,7 +3957,9 @@ pub static MZ_ROLE_AUTH: LazyLock = LazyLock::new(|| BuiltinTable oid: oid::TABLE_MZ_ROLE_AUTH_OID, desc: RelationDesc::builder() .with_column("role_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column("role_oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("password_hash", SqlScalarType::String.nullable(true)) .with_column( "updated_at", @@ -3523,11 +3991,16 @@ pub static MZ_PSEUDO_TYPES: LazyLock = LazyLock::new(|| BuiltinTab oid: oid::TABLE_MZ_PSEUDO_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .finish(), column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "pseudo_type", + description: "A pseudo-type used in function signatures", + links: &[], + }), }); pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { BuiltinTable { @@ -3536,8 +4009,11 @@ pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { oid: oid::TABLE_MZ_FUNCTIONS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) // not a key! + .with_semantic_type("CatalogItemId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("schema_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("SchemaId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column( "argument_type_ids", @@ -3547,9 +4023,12 @@ pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { "variadic_argument_type_id", SqlScalarType::String.nullable(true), ) + .with_semantic_type("CatalogItemId") .with_column("return_type_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("CatalogItemId") .with_column("returns_set", SqlScalarType::Bool.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .finish(), column_comments: BTreeMap::from_iter([ ("id", "Materialize's unique ID for the function."), @@ -3582,7 +4061,27 @@ pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "function", + description: "A built-in or user-defined function", + links: &[ + OntologyLink { + name: "in_schema", + target: "schema", + properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "owned_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "returns_type", + target: "type", + properties_json: r#"{"kind": "foreign_key", "source_column": "return_type_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + }, + ], + }), } }); pub static MZ_OPERATORS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3591,17 +4090,23 @@ pub static MZ_OPERATORS: LazyLock = LazyLock::new(|| BuiltinTable oid: oid::TABLE_MZ_OPERATORS_OID, desc: RelationDesc::builder() .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("name", SqlScalarType::String.nullable(false)) .with_column( "argument_type_ids", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), ) .with_column("return_type_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("CatalogItemId") .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "operator", + description: "A built-in SQL operator", + links: &[], + }), }); pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_aggregates", @@ -3609,13 +4114,18 @@ pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinTable oid: oid::TABLE_MZ_AGGREGATES_OID, desc: RelationDesc::builder() .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("agg_kind", SqlScalarType::String.nullable(false)) .with_column("agg_num_direct_args", SqlScalarType::Int16.nullable(false)) .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "aggregate", + description: "Aggregate function metadata", + links: &[], + }), }); pub static MZ_CLUSTERS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3624,8 +4134,10 @@ pub static MZ_CLUSTERS: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_CLUSTERS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ClusterId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -3691,7 +4203,22 @@ pub static MZ_CLUSTERS: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "cluster", + description: "A compute cluster that runs dataflows for sources, sinks, MVs, and indexes", + links: &[ + OntologyLink { + name: "owned_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "has_size", + target: "replica_size", + properties_json: r#"{"kind": "foreign_key", "source_column": "size", "target_column": "size", "cardinality": "many_to_one", "nullable": true}"#, + }, + ], + }), }); pub static MZ_CLUSTER_WORKLOAD_CLASSES: LazyLock = @@ -3701,6 +4228,7 @@ pub static MZ_CLUSTER_WORKLOAD_CLASSES: LazyLock = oid: oid::MV_MZ_CLUSTER_WORKLOAD_CLASSES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ClusterId") .with_column("workload_class", SqlScalarType::String.nullable(true)) .with_key(vec![0]) .finish(), @@ -3737,6 +4265,7 @@ pub static MZ_CLUSTER_SCHEDULES: LazyLock = LazyLock::new(|| Built oid: oid::TABLE_MZ_CLUSTER_SCHEDULES_OID, desc: RelationDesc::builder() .with_column("cluster_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ClusterId") .with_column("type", SqlScalarType::String.nullable(false)) .with_column( "refresh_hydration_time_estimate", @@ -3756,7 +4285,11 @@ pub static MZ_CLUSTER_SCHEDULES: LazyLock = LazyLock::new(|| Built ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "cluster_schedule", + description: "Cluster scheduling configuration", + links: &[], + }), }); pub static MZ_SECRETS: LazyLock = LazyLock::new(|| { @@ -3766,10 +4299,14 @@ pub static MZ_SECRETS: LazyLock = LazyLock::new(|| { oid: oid::MV_MZ_SECRETS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("schema_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("SchemaId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -3812,7 +4349,22 @@ WHERE mz_internal.parse_catalog_create_sql(data->'value'->'definition'->'V1'->>'create_sql')->>'type' = 'secret'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "secret", + description: "An encrypted secret value used by connections", + links: &[ + OntologyLink { + name: "in_schema", + target: "schema", + properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "owned_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], + }), } }); @@ -3822,13 +4374,16 @@ pub static MZ_CLUSTER_REPLICAS: LazyLock = LazyLock::new(|| Builti oid: oid::TABLE_MZ_CLUSTER_REPLICAS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ReplicaId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("cluster_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ClusterId") .with_column("size", SqlScalarType::String.nullable(true)) // `NULL` for un-orchestrated clusters and for replicas where the user // hasn't specified them. .with_column("availability_zone", SqlScalarType::String.nullable(true)) .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column("disk", SqlScalarType::Bool.nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ @@ -3854,7 +4409,27 @@ pub static MZ_CLUSTER_REPLICAS: LazyLock = LazyLock::new(|| Builti ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "replica", + description: "A physical replica of a cluster providing fault tolerance", + links: &[ + OntologyLink { + name: "owned_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "belongs_to_cluster", + target: "cluster", + properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "has_size", + target: "replica_size", + properties_json: r#"{"kind": "foreign_key", "source_column": "size", "target_column": "size", "cardinality": "many_to_one", "nullable": true}"#, + }, + ], + }), }); pub static MZ_INTERNAL_CLUSTER_REPLICAS: LazyLock = @@ -3892,6 +4467,7 @@ pub static MZ_PENDING_CLUSTER_REPLICAS: LazyLock = oid: oid::MV_MZ_PENDING_CLUSTER_REPLICAS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ReplicaId") .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([( @@ -3938,7 +4514,15 @@ pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY: LazyLock = LazyLock ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "replica_status_history", + description: "Historical replica status events (ready, not-ready, etc.)", + links: &[OntologyLink { + name: "status_history_of_replica", + target: "replica", + properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), } }); @@ -3948,6 +4532,7 @@ pub static MZ_CLUSTER_REPLICA_STATUSES: LazyLock = LazyLock::new(|| oid: oid::VIEW_MZ_CLUSTER_REPLICA_STATUSES_OID, desc: RelationDesc::builder() .with_column("replica_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ReplicaId") .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("reason", SqlScalarType::String.nullable(true)) @@ -3955,6 +4540,7 @@ pub static MZ_CLUSTER_REPLICA_STATUSES: LazyLock = LazyLock::new(|| "updated_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) + .with_semantic_type("WallclockTimestamp") .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -3991,7 +4577,15 @@ FROM mz_internal.mz_cluster_replica_status_history JOIN mz_cluster_replicas r ON r.id = replica_id ORDER BY replica_id, process_id, occurred_at DESC", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "replica_status", + description: "Current status of each replica", + links: &[OntologyLink { + name: "status_of_replica", + target: "replica", + properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], + }), }); pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4004,11 +4598,14 @@ pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock = LazyLock::new(|| B .with_column("workers", SqlScalarType::UInt64.nullable(false)) .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(false)) .with_column("memory_bytes", SqlScalarType::UInt64.nullable(false)) + .with_semantic_type("ByteCount") .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true)) + .with_semantic_type("ByteCount") .with_column( "credits_per_hour", SqlScalarType::Numeric { max_scale: None }.nullable(false), ) + .with_semantic_type("CreditRate") .finish(), column_comments: BTreeMap::from_iter([ ("size", "The human-readable replica size."), @@ -4033,7 +4630,11 @@ pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock = LazyLock::new(|| B ]), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "replica_size", + description: "Available cluster replica sizes with CPU, memory, and credit cost", + links: &[], + }), }); pub static MZ_AUDIT_EVENTS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4044,12 +4645,14 @@ pub static MZ_AUDIT_EVENTS: LazyLock = LazyLock::new(|| BuiltinTab .with_column("id", SqlScalarType::UInt64.nullable(false)) .with_column("event_type", SqlScalarType::String.nullable(false)) .with_column("object_type", SqlScalarType::String.nullable(false)) + .with_semantic_type("ObjectType") .with_column("details", SqlScalarType::Jsonb.nullable(false)) .with_column("user", SqlScalarType::String.nullable(true)) .with_column( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) + .with_semantic_type("WallclockTimestamp") .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -4080,7 +4683,11 @@ pub static MZ_AUDIT_EVENTS: LazyLock = LazyLock::new(|| BuiltinTab ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "audit_event", + description: "An audit log entry recording a DDL operation", + links: &[], + }), }); pub static MZ_SOURCE_STATUS_HISTORY: LazyLock = LazyLock::new(|| BuiltinSource { @@ -4117,7 +4724,15 @@ pub static MZ_SOURCE_STATUS_HISTORY: LazyLock = LazyLock::new(|| ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "source_status_history", + description: "Historical source status events", + links: &[OntologyLink { + name: "status_history_of_source", + target: "source", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "source_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), }); pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY: LazyLock = LazyLock::new( @@ -4153,6 +4768,7 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUSES: LazyLock = LazyL oid: oid::VIEW_MZ_AWS_PRIVATELINK_CONNECTION_STATUSES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column( "last_status_change_at", @@ -4202,7 +4818,11 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUSES: LazyLock = LazyL JOIN mz_catalog.mz_connections AS conns ON conns.id = latest_events.connection_id", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "privatelink_status", + description: "PrivateLink connection health status", + links: &[], + }), } }); @@ -4285,7 +4905,11 @@ pub static MZ_SQL_TEXT: LazyLock = LazyLock::new(|| BuiltinSource column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![MONITOR_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "sql_text", + description: "Raw SQL text of executed statements", + links: &[], + }), }); pub static MZ_SQL_TEXT_REDACTED: LazyLock = LazyLock::new(|| BuiltinView { @@ -4319,13 +4943,18 @@ pub static MZ_RECENT_SQL_TEXT: LazyLock = LazyLock::new(|| { desc: RelationDesc::builder() .with_column("sql_hash", SqlScalarType::Bytes.nullable(false)) .with_column("sql", SqlScalarType::String.nullable(false)) + .with_semantic_type("SqlDefinition") .with_column("redacted_sql", SqlScalarType::String.nullable(false)) .with_key(vec![0, 1, 2]) .finish(), column_comments: BTreeMap::new(), sql: "SELECT DISTINCT sql_hash, sql, redacted_sql FROM mz_internal.mz_sql_text WHERE prepared_day + INTERVAL '4 days' >= mz_now()", access: vec![MONITOR_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "recent_sql_text", + description: "Recent SQL text (indexed, last 3 days)", + links: &[], + }), } }); @@ -4382,7 +5011,11 @@ pub static MZ_SESSION_HISTORY: LazyLock = LazyLock::new(|| Builti ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "session_history", + description: "Historical session connection events", + links: &[], + }), }); pub static MZ_ACTIVITY_LOG_THINNED: LazyLock = LazyLock::new(|| { @@ -4496,6 +5129,7 @@ pub static MZ_RECENT_ACTIVITY_LOG: LazyLock = LazyLock::new(|| Buil .with_column("execution_id", SqlScalarType::Uuid.nullable(false)) .with_column("sample_rate", SqlScalarType::Float64.nullable(false)) .with_column("cluster_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("ClusterId") .with_column("application_name", SqlScalarType::String.nullable(false)) .with_column("cluster_name", SqlScalarType::String.nullable(true)) .with_column("database_name", SqlScalarType::String.nullable(false)) @@ -4512,7 +5146,9 @@ pub static MZ_RECENT_ACTIVITY_LOG: LazyLock = LazyLock::new(|| Buil SqlScalarType::String.nullable(false), ) .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true)) + .with_semantic_type("MzTimestamp") .with_column("transient_index_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("GlobalId") .with_column( "params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), @@ -4522,10 +5158,12 @@ pub static MZ_RECENT_ACTIVITY_LOG: LazyLock = LazyLock::new(|| Buil "began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) + .with_semantic_type("WallclockTimestamp") .with_column( "finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true), ) + .with_semantic_type("WallclockTimestamp") .with_column("finished_status", SqlScalarType::String.nullable(true)) .with_column("error_message", SqlScalarType::String.nullable(true)) .with_column("result_size", SqlScalarType::Int64.nullable(true)) @@ -4543,18 +5181,21 @@ pub static MZ_RECENT_ACTIVITY_LOG: LazyLock = LazyLock::new(|| Buil "prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) + .with_semantic_type("WallclockTimestamp") .with_column("statement_type", SqlScalarType::String.nullable(true)) .with_column("throttled_count", SqlScalarType::UInt64.nullable(false)) .with_column( "connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) + .with_semantic_type("WallclockTimestamp") .with_column( "initial_application_name", SqlScalarType::String.nullable(false), ) .with_column("authenticated_user", SqlScalarType::String.nullable(false)) .with_column("sql", SqlScalarType::String.nullable(false)) + .with_semantic_type("SqlDefinition") .finish(), column_comments: BTreeMap::from_iter([ ( @@ -4684,7 +5325,15 @@ FROM mz_internal.mz_recent_activity_log_thinned mralt, mz_internal.mz_recent_sql_text mrst WHERE mralt.sql_hash = mrst.sql_hash", access: vec![MONITOR_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "activity_log", + description: "Recent query activity with execution stats", + links: &[OntologyLink { + name: "session_on_cluster", + target: "cluster", + properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), }); pub static MZ_RECENT_ACTIVITY_LOG_REDACTED: LazyLock = LazyLock::new(|| { @@ -4775,7 +5424,11 @@ pub static MZ_STATEMENT_LIFECYCLE_HISTORY: LazyLock = LazyLock::n MONITOR_REDACTED_SELECT, MONITOR_SELECT, ], - ontology: None, + ontology: Some(Ontology { + entity_name: "statement_lifecycle", + description: "Statement lifecycle events (parse, bind, execute)", + links: &[], + }), } }); @@ -4785,12 +5438,15 @@ pub static MZ_SOURCE_STATUSES: LazyLock = LazyLock::new(|| BuiltinV oid: oid::VIEW_MZ_SOURCE_STATUSES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) + .with_semantic_type("SourceType") .with_column( "last_status_change_at", SqlScalarType::TimestampTz { precision: None }.nullable(true), ) + .with_semantic_type("WallclockTimestamp") .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) .with_column("details", SqlScalarType::Jsonb.nullable(true)) @@ -4958,7 +5614,15 @@ SELECT FROM combined WHERE id NOT LIKE 's%';", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "source_status", + description: "Current source status (running, stalled, etc.)", + links: &[OntologyLink { + name: "status_of_source", + target: "source", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], + }), }); pub static MZ_SINK_STATUS_HISTORY: LazyLock = LazyLock::new(|| BuiltinSource { @@ -4995,7 +5659,15 @@ pub static MZ_SINK_STATUS_HISTORY: LazyLock = LazyLock::new(|| Bu ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "sink_status_history", + description: "Historical sink status events", + links: &[OntologyLink { + name: "status_history_of_sink", + target: "sink", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "sink_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), }); pub static MZ_SINK_STATUSES: LazyLock = LazyLock::new(|| BuiltinView { @@ -5004,12 +5676,14 @@ pub static MZ_SINK_STATUSES: LazyLock = LazyLock::new(|| BuiltinVie oid: oid::VIEW_MZ_SINK_STATUSES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) .with_column( "last_status_change_at", SqlScalarType::TimestampTz { precision: None }.nullable(true), ) + .with_semantic_type("WallclockTimestamp") .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) .with_column("details", SqlScalarType::Jsonb.nullable(true)) @@ -5101,7 +5775,15 @@ WHERE -- This is a convenient way to filter out system sinks, like the status_history table itself. mz_sinks.id NOT LIKE 's%'", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "sink_status", + description: "Current sink status", + links: &[OntologyLink { + name: "status_of_sink", + target: "sink", + properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], + }), }); pub static MZ_STORAGE_USAGE_BY_SHARD_DESCRIPTION: LazyLock = @@ -5118,16 +5800,23 @@ pub static MZ_STORAGE_USAGE_BY_SHARD: LazyLock = LazyLock::new(|| desc: RelationDesc::builder() .with_column("id", SqlScalarType::UInt64.nullable(false)) .with_column("shard_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("ShardId") .with_column("size_bytes", SqlScalarType::UInt64.nullable(false)) + .with_semantic_type("ByteCount") .with_column( "collection_timestamp", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) + .with_semantic_type("WallclockTimestamp") .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "storage_usage_by_shard", + description: "Storage usage broken down by shard", + links: &[], + }), }); pub static MZ_EGRESS_IPS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5149,16 +5838,21 @@ pub static MZ_EGRESS_IPS: LazyLock = LazyLock::new(|| BuiltinTable ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "egress_ip", + description: "IP addresses used for outbound connections from Materialize", + links: &[], + }), }); -pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock = - LazyLock::new(|| BuiltinTable { +pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock = LazyLock::new(|| { + BuiltinTable { name: "mz_aws_privatelink_connections", schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_AWS_PRIVATELINK_CONNECTIONS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("principal", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -5170,8 +5864,17 @@ pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock = ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, - }); + ontology: Some(Ontology { + entity_name: "aws_privatelink", + description: "AWS PrivateLink connection configuration", + links: &[OntologyLink { + name: "details_of", + target: "connection", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], + }), + } +}); pub static MZ_AWS_CONNECTIONS: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_aws_connections", @@ -5251,7 +5954,11 @@ pub static MZ_AWS_CONNECTIONS: LazyLock = LazyLock::new(|| Builtin ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "aws_connection", + description: "AWS connection configuration details", + links: &[], + }), }); pub static MZ_CLUSTER_REPLICA_METRICS_HISTORY: LazyLock = @@ -5291,12 +5998,17 @@ pub static MZ_CLUSTER_REPLICA_METRICS: LazyLock = LazyLock::new(|| oid: oid::VIEW_MZ_CLUSTER_REPLICA_METRICS_OID, desc: RelationDesc::builder() .with_column("replica_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ReplicaId") .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(true)) .with_column("memory_bytes", SqlScalarType::UInt64.nullable(true)) + .with_semantic_type("ByteCount") .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true)) + .with_semantic_type("ByteCount") .with_column("heap_bytes", SqlScalarType::UInt64.nullable(true)) + .with_semantic_type("ByteCount") .with_column("heap_limit", SqlScalarType::UInt64.nullable(true)) + .with_semantic_type("ByteCount") .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -5328,7 +6040,15 @@ FROM mz_internal.mz_cluster_replica_metrics_history JOIN mz_cluster_replicas r ON r.id = replica_id ORDER BY replica_id, process_id, occurred_at DESC", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "replica_metrics", + description: "CPU and memory metrics per replica", + links: &[OntologyLink { + name: "metrics_of_replica", + target: "replica", + properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], + }), }); pub static MZ_CLUSTER_REPLICA_FRONTIERS: LazyLock = @@ -5339,8 +6059,11 @@ pub static MZ_CLUSTER_REPLICA_FRONTIERS: LazyLock = data_source: IntrospectionType::ReplicaFrontiers.into(), desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("replica_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ReplicaId") .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true)) + .with_semantic_type("MzTimestamp") .finish(), column_comments: BTreeMap::from_iter([ ( @@ -5374,8 +6097,11 @@ pub static MZ_FRONTIERS: LazyLock = LazyLock::new(|| BuiltinSourc data_source: IntrospectionType::Frontiers.into(), desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("read_frontier", SqlScalarType::MzTimestamp.nullable(true)) + .with_semantic_type("MzTimestamp") .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true)) + .with_semantic_type("MzTimestamp") .finish(), column_comments: BTreeMap::from_iter([ ( @@ -5393,7 +6119,15 @@ pub static MZ_FRONTIERS: LazyLock = LazyLock::new(|| BuiltinSourc ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "frontier", + description: "Current read/write frontiers per object (source)", + links: &[OntologyLink { + name: "frontier_of", + target: "object", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), }); /// DEPRECATED and scheduled for removal! Use `mz_frontiers` instead. @@ -5403,7 +6137,9 @@ pub static MZ_GLOBAL_FRONTIERS: LazyLock = LazyLock::new(|| Builtin oid: oid::VIEW_MZ_GLOBAL_FRONTIERS_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) + .with_semantic_type("MzTimestamp") .finish(), column_comments: BTreeMap::new(), sql: " @@ -5440,7 +6176,15 @@ pub static MZ_WALLCLOCK_LAG_HISTORY: LazyLock = LazyLock::new(|| ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "wallclock_lag_history", + description: "Historical wallclock lag per object", + links: &[OntologyLink { + name: "measures_lag_of", + target: "object", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "measures", "source_column": "object_id", "target_column": "id", "metric": "wallclock_lag"}"#, + }], + }), }); pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTORY: LazyLock = LazyLock::new(|| BuiltinView { @@ -5449,11 +6193,13 @@ pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTORY: LazyLock = LazyLock::ne oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_HISTORY_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("lag", SqlScalarType::Interval.nullable(true)) .with_column( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) + .with_semantic_type("WallclockTimestamp") .with_key(vec![0, 2]) .finish(), column_comments: BTreeMap::from_iter([ @@ -5486,7 +6232,11 @@ FROM times_binned GROUP BY object_id, occurred_at OPTIONS (AGGREGATE INPUT GROUP SIZE = 1)", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "wallclock_global_lag_history", + description: "Historical global wallclock lag", + links: &[], + }), }); pub static MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY: LazyLock = LazyLock::new(|| { @@ -5496,6 +6246,7 @@ pub static MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY: LazyLock = LazyL oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("lag", SqlScalarType::Interval.nullable(true)) .with_column( "occurred_at", @@ -5532,6 +6283,7 @@ pub static MZ_WALLCLOCK_GLOBAL_LAG: LazyLock = LazyLock::new(|| Bui oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("lag", SqlScalarType::Interval.nullable(true)) .with_key(vec![0]) .finish(), @@ -5551,7 +6303,15 @@ FROM mz_internal.mz_wallclock_global_lag_recent_history WHERE occurred_at + '5 minutes' > mz_now() ORDER BY object_id, occurred_at DESC", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "wallclock_global_lag", + description: "Current wallclock lag aggregated across replicas", + links: &[OntologyLink { + name: "measures_global_lag_of", + target: "object", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "measures", "source_column": "object_id", "target_column": "id", "metric": "wallclock_lag_global"}"#, + }], + }), }); pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW: LazyLock = @@ -5641,8 +6401,10 @@ pub static MZ_SUBSCRIPTIONS: LazyLock = LazyLock::new(|| BuiltinTa oid: oid::TABLE_MZ_SUBSCRIPTIONS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("session_id", SqlScalarType::Uuid.nullable(false)) .with_column("cluster_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ClusterId") .with_column( "created_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), @@ -5677,7 +6439,11 @@ pub static MZ_SUBSCRIPTIONS: LazyLock = LazyLock::new(|| BuiltinTa ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "subscription", + description: "Active SUBSCRIBE operations", + links: &[], + }), }); pub static MZ_SESSIONS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5688,6 +6454,7 @@ pub static MZ_SESSIONS: LazyLock = LazyLock::new(|| BuiltinTable { .with_column("id", SqlScalarType::Uuid.nullable(false)) .with_column("connection_id", SqlScalarType::UInt32.nullable(false)) .with_column("role_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column("client_ip", SqlScalarType::String.nullable(true)) .with_column( "connected_at", @@ -5715,7 +6482,11 @@ pub static MZ_SESSIONS: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "session", + description: "Currently active sessions", + links: &[], + }), }); pub static MZ_DEFAULT_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5724,10 +6495,15 @@ pub static MZ_DEFAULT_PRIVILEGES: LazyLock = LazyLock::new(|| Buil oid: oid::TABLE_MZ_DEFAULT_PRIVILEGES_OID, desc: RelationDesc::builder() .with_column("role_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column("database_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("DatabaseId") .with_column("schema_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("SchemaId") .with_column("object_type", SqlScalarType::String.nullable(false)) + .with_semantic_type("ObjectType") .with_column("grantee", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column("privileges", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -5755,7 +6531,27 @@ pub static MZ_DEFAULT_PRIVILEGES: LazyLock = LazyLock::new(|| Buil ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "default_privilege", + description: "A default privilege rule applied to newly created objects", + links: &[ + OntologyLink { + name: "default_priv_for_role", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "role_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "default_priv_in_database", + target: "database", + properties_json: r#"{"kind": "foreign_key", "source_column": "database_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + }, + OntologyLink { + name: "default_priv_in_schema", + target: "schema", + properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + }, + ], + }), }); pub static MZ_SYSTEM_PRIVILEGES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5771,7 +6567,11 @@ pub static MZ_SYSTEM_PRIVILEGES: LazyLock = LazyLock::new(|| Built )]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "system_privilege", + description: "A system-level privilege grant", + links: &[], + }), }); pub static MZ_COMMENTS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5780,7 +6580,9 @@ pub static MZ_COMMENTS: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_COMMENTS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("object_type", SqlScalarType::String.nullable(false)) + .with_semantic_type("ObjectType") .with_column("object_sub_id", SqlScalarType::Int32.nullable(true)) .with_column("comment", SqlScalarType::String.nullable(false)) .finish(), @@ -5801,7 +6603,15 @@ pub static MZ_COMMENTS: LazyLock = LazyLock::new(|| BuiltinTable { ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "comment", + description: "A COMMENT ON annotation for a catalog object or column", + links: &[OntologyLink { + name: "comment_on", + target: "object", + properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), }); pub static MZ_SOURCE_REFERENCES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5810,6 +6620,7 @@ pub static MZ_SOURCE_REFERENCES: LazyLock = LazyLock::new(|| Built oid: oid::TABLE_MZ_SOURCE_REFERENCES_OID, desc: RelationDesc::builder() .with_column("source_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("namespace", SqlScalarType::String.nullable(true)) .with_column("name", SqlScalarType::String.nullable(false)) .with_column( @@ -5824,7 +6635,11 @@ pub static MZ_SOURCE_REFERENCES: LazyLock = LazyLock::new(|| Built column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "source_reference", + description: "External references tracked by sources", + links: &[], + }), }); pub static MZ_WEBHOOKS_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5833,6 +6648,7 @@ pub static MZ_WEBHOOKS_SOURCES: LazyLock = LazyLock::new(|| Builti oid: oid::TABLE_MZ_WEBHOOK_SOURCES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("url", SqlScalarType::String.nullable(false)) .finish(), @@ -5849,7 +6665,11 @@ pub static MZ_WEBHOOKS_SOURCES: LazyLock = LazyLock::new(|| Builti ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "webhook_source", + description: "Webhook source configuration", + links: &[], + }), }); pub static MZ_HISTORY_RETENTION_STRATEGIES: LazyLock = LazyLock::new(|| { @@ -5859,6 +6679,7 @@ pub static MZ_HISTORY_RETENTION_STRATEGIES: LazyLock = LazyLock::n oid: oid::TABLE_MZ_HISTORY_RETENTION_STRATEGIES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("strategy", SqlScalarType::String.nullable(false)) .with_column("value", SqlScalarType::Jsonb.nullable(false)) .finish(), @@ -5875,7 +6696,11 @@ pub static MZ_HISTORY_RETENTION_STRATEGIES: LazyLock = LazyLock::n ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "history_retention", + description: "History retention strategy for an object", + links: &[], + }), } }); @@ -5885,6 +6710,7 @@ pub static MZ_LICENSE_KEYS: LazyLock = LazyLock::new(|| BuiltinTab oid: oid::TABLE_MZ_LICENSE_KEYS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("organization", SqlScalarType::String.nullable(false)) .with_column("environment_id", SqlScalarType::String.nullable(false)) .with_column( @@ -5917,7 +6743,11 @@ pub static MZ_LICENSE_KEYS: LazyLock = LazyLock::new(|| BuiltinTab ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "license_key", + description: "License key metadata", + links: &[], + }), }); pub static MZ_REPLACEMENTS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -5926,6 +6756,7 @@ pub static MZ_REPLACEMENTS: LazyLock = LazyLock::new(|| BuiltinTab oid: oid::TABLE_MZ_REPLACEMENTS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("target_id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -5940,7 +6771,11 @@ pub static MZ_REPLACEMENTS: LazyLock = LazyLock::new(|| BuiltinTab ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "replacement", + description: "A record of an object replacement (ALTER ... SWAP)", + links: &[], + }), }); // These will be replaced with per-replica tables once source/sink multiplexing on @@ -5975,12 +6810,22 @@ pub static MZ_STORAGE_SHARDS: LazyLock = LazyLock::new(|| Builtin data_source: IntrospectionType::ShardMapping.into(), desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("shard_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ShardId") .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "storage_shard", + description: "Persist shards used by storage objects", + links: &[OntologyLink { + name: "shard_of", + target: "object", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), }); pub static MZ_STORAGE_USAGE: LazyLock = LazyLock::new(|| BuiltinView { @@ -5989,11 +6834,14 @@ pub static MZ_STORAGE_USAGE: LazyLock = LazyLock::new(|| BuiltinVie oid: oid::VIEW_MZ_STORAGE_USAGE_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("size_bytes", SqlScalarType::UInt64.nullable(false)) + .with_semantic_type("ByteCount") .with_column( "collection_timestamp", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) + .with_semantic_type("WallclockTimestamp") .with_key(vec![0, 2]) .finish(), column_comments: BTreeMap::from_iter([ @@ -6020,7 +6868,15 @@ FROM JOIN mz_internal.mz_storage_usage_by_shard USING (shard_id) GROUP BY object_id, collection_timestamp", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "storage_usage", + description: "Historical storage usage per object over time", + links: &[OntologyLink { + name: "storage_usage_of", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), }); pub static MZ_RECENT_STORAGE_USAGE: LazyLock = LazyLock::new(|| { @@ -6030,7 +6886,9 @@ pub static MZ_RECENT_STORAGE_USAGE: LazyLock = LazyLock::new(|| { oid: oid::VIEW_MZ_RECENT_STORAGE_USAGE_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("size_bytes", SqlScalarType::UInt64.nullable(true)) + .with_semantic_type("ByteCount") .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -6065,7 +6923,13 @@ FROM AND most_recent_collection_timestamp_by_shard.collection_timestamp = recent_storage_usage_by_shard.collection_timestamp GROUP BY object_id", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "recent_storage", + description: "Most recent storage usage snapshot per object", + links: &[ + OntologyLink { name: "recent_storage_of", target: "object", properties_json: r#"{"kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "one_to_one"}"# }, + ], + }), } }); @@ -6084,12 +6948,18 @@ pub static MZ_RELATIONS: LazyLock = LazyLock::new(|| { oid: oid::VIEW_MZ_RELATIONS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("schema_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("SchemaId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) + .with_semantic_type("ObjectType") .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column("cluster_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("ClusterId") .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -6108,7 +6978,16 @@ UNION ALL SELECT id, oid, schema_id, name, 'source', owner_id, cluster_id, privi UNION ALL SELECT id, oid, schema_id, name, 'view', owner_id, NULL::text, privileges FROM mz_catalog.mz_views UNION ALL SELECT id, oid, schema_id, name, 'materialized-view', owner_id, cluster_id, privileges FROM mz_catalog.mz_materialized_views", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "relation", + description: "Union of all relation types: tables, sources, views, MVs (convenience view)", + links: &[ + OntologyLink { name: "union_includes", target: "table", properties_json: r#"{"kind": "union", "discriminator_column": "type", "discriminator_value": "table"}"# }, + OntologyLink { name: "union_includes", target: "source", properties_json: r#"{"kind": "union", "discriminator_column": "type", "discriminator_value": "source"}"# }, + OntologyLink { name: "union_includes", target: "view", properties_json: r#"{"kind": "union", "discriminator_column": "type", "discriminator_value": "view"}"# }, + OntologyLink { name: "union_includes", target: "mv", properties_json: r#"{"kind": "union", "discriminator_column": "type", "discriminator_value": "materialized-view"}"# }, + ], + }), } }); @@ -6176,12 +7055,18 @@ pub static MZ_OBJECTS: LazyLock = LazyLock::new(|| { oid: oid::VIEW_MZ_OBJECTS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_semantic_type("OID") .with_column("schema_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("SchemaId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) + .with_semantic_type("ObjectType") .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("RoleId") .with_column("cluster_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("ClusterId") .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ @@ -6211,7 +7096,17 @@ UNION ALL UNION ALL SELECT id, oid, schema_id, name, 'secret', owner_id, NULL::text, privileges FROM mz_catalog.mz_secrets", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "object", + description: "Union of all object types: relations, indexes, connections, etc. (convenience view)", + links: &[ + OntologyLink { name: "union_includes", target: "relation", properties_json: r#"{"kind": "union", "note": "mz_objects includes all relations plus indexes, connections, secrets, types, functions"}"# }, + OntologyLink { name: "union_includes", target: "index", properties_json: r#"{"kind": "union", "discriminator_column": "type", "discriminator_value": "index"}"# }, + OntologyLink { name: "union_includes", target: "connection", properties_json: r#"{"kind": "union", "discriminator_column": "type", "discriminator_value": "connection"}"# }, + OntologyLink { name: "union_includes", target: "secret", properties_json: r#"{"kind": "union", "discriminator_column": "type", "discriminator_value": "secret"}"# }, + OntologyLink { name: "maps_to_global_id", target: "object", properties_json: r#"{"kind": "maps_to", "via": "mz_internal.mz_object_global_ids", "from_type": "CatalogItemId", "to_type": "GlobalId", "note": "A CatalogItemId (SQL layer) maps to one or more GlobalIds (runtime layer)."}"# }, + ], + }), } }); @@ -6221,13 +7116,18 @@ pub static MZ_OBJECT_FULLY_QUALIFIED_NAMES: LazyLock = LazyLock::ne oid: oid::VIEW_MZ_OBJECT_FULLY_QUALIFIED_NAMES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("name", SqlScalarType::String.nullable(false)) .with_column("object_type", SqlScalarType::String.nullable(false)) + .with_semantic_type("ObjectType") .with_column("schema_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("SchemaId") .with_column("schema_name", SqlScalarType::String.nullable(false)) .with_column("database_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("DatabaseId") .with_column("database_name", SqlScalarType::String.nullable(true)) .with_column("cluster_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("ClusterId") .finish(), column_comments: BTreeMap::from_iter([ ("id", "Materialize's unique ID for the object."), @@ -6271,7 +7171,11 @@ pub static MZ_OBJECT_FULLY_QUALIFIED_NAMES: LazyLock = LazyLock::ne -- LEFT JOIN accounts for objects in the ambient database. LEFT JOIN mz_catalog.mz_databases db ON db.id = sc.database_id", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "object_fqn", + description: "Fully qualified name (database.schema.name) for objects", + links: &[], + }), }); pub static MZ_OBJECT_GLOBAL_IDS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -6280,7 +7184,9 @@ pub static MZ_OBJECT_GLOBAL_IDS: LazyLock = LazyLock::new(|| Built oid: oid::VIEW_MZ_OBJECT_GLOBAL_IDS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("global_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .finish(), column_comments: BTreeMap::from_iter([ ( @@ -6291,7 +7197,15 @@ pub static MZ_OBJECT_GLOBAL_IDS: LazyLock = LazyLock::new(|| Built ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "object_global_id", + description: "Mapping between CatalogItemId (SQL layer) and GlobalId (runtime layer)", + links: &[OntologyLink { + name: "has_global_id", + target: "object", + properties_json: r#"{"kind": "maps_to", "source_column": "id", "target_column": "id", "from_type": "CatalogItemId", "to_type": "GlobalId"}"#, + }], + }), }); // TODO (SangJunBak): Remove once mz_object_history is released and used in the Console https://github.com/MaterializeInc/console/issues/3342 @@ -6301,8 +7215,10 @@ pub static MZ_OBJECT_LIFETIMES: LazyLock = LazyLock::new(|| Builtin oid: oid::VIEW_MZ_OBJECT_LIFETIMES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(true)) + .with_semantic_type("CatalogItemId") .with_column("previous_id", SqlScalarType::String.nullable(true)) .with_column("object_type", SqlScalarType::String.nullable(false)) + .with_semantic_type("ObjectType") .with_column("event_type", SqlScalarType::String.nullable(false)) .with_column( "occurred_at", @@ -6338,7 +7254,15 @@ pub static MZ_OBJECT_LIFETIMES: LazyLock = LazyLock::new(|| Builtin FROM mz_catalog.mz_audit_events a WHERE a.event_type = 'create' OR a.event_type = 'drop'", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "object_lifetime", + description: "Computed lifetime span (created_at to dropped_at) for objects", + links: &[OntologyLink { + name: "lifetime_of", + target: "object", + properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], + }), }); pub static MZ_OBJECT_HISTORY: LazyLock = LazyLock::new(|| BuiltinView { @@ -6347,6 +7271,7 @@ pub static MZ_OBJECT_HISTORY: LazyLock = LazyLock::new(|| BuiltinVi oid: oid::VIEW_MZ_OBJECT_HISTORY_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(true)) + .with_semantic_type("CatalogItemId") .with_column("cluster_id", SqlScalarType::String.nullable(true)) .with_column("object_type", SqlScalarType::String.nullable(false)) .with_column( @@ -6424,7 +7349,15 @@ pub static MZ_OBJECT_HISTORY: LazyLock = LazyLock::new(|| BuiltinVi ) SELECT * FROM user_object_history UNION ALL (SELECT * FROM built_in_objects)"#, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "object_history", + description: "Historical record of object creation and drops", + links: &[OntologyLink { + name: "history_of", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), }); pub static MZ_DATAFLOWS_PER_WORKER: LazyLock = LazyLock::new(|| BuiltinView { @@ -6469,7 +7402,11 @@ SELECT id, name FROM mz_introspection.mz_dataflows_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "dataflow", + description: "Dataflow instances", + links: &[], + }), }); pub static MZ_DATAFLOW_ADDRESSES: LazyLock = LazyLock::new(|| BuiltinView { @@ -6503,7 +7440,15 @@ SELECT id, address FROM mz_introspection.mz_dataflow_addresses_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "dataflow_address", + description: "Address (scope path) of dataflow operators", + links: &[OntologyLink { + name: "address_of_operator", + target: "dataflow_operator", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], + }), }); pub static MZ_DATAFLOW_CHANNELS: LazyLock = LazyLock::new(|| BuiltinView { @@ -6538,7 +7483,15 @@ SELECT id, from_index, from_port, to_index, to_port, type FROM mz_introspection.mz_dataflow_channels_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "dataflow_channel", + description: "Communication channels between operators", + links: &[OntologyLink { + name: "channel_in_dataflow", + target: "dataflow", + properties_json: r#"{"kind": "maps_to", "via": "mz_introspection.mz_dataflow_operator_dataflows", "note": "Channels do not have a direct dataflow_id. Use mz_dataflow_addresses to find the parent scope, then correlate with mz_dataflow_operator_dataflows."}"#, + }], + }), }); pub static MZ_DATAFLOW_OPERATORS: LazyLock = LazyLock::new(|| BuiltinView { @@ -6559,7 +7512,11 @@ SELECT id, name FROM mz_introspection.mz_dataflow_operators_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "dataflow_operator", + description: "Operators within dataflows", + links: &[], + }), }); pub static MZ_DATAFLOW_GLOBAL_IDS: LazyLock = LazyLock::new(|| BuiltinView { @@ -6569,6 +7526,7 @@ pub static MZ_DATAFLOW_GLOBAL_IDS: LazyLock = LazyLock::new(|| Buil desc: RelationDesc::builder() .with_column("id", SqlScalarType::UInt64.nullable(false)) .with_column("global_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -6590,6 +7548,7 @@ pub static MZ_MAPPABLE_OBJECTS: LazyLock = LazyLock::new(|| Builtin desc: RelationDesc::builder() .with_column("name", SqlScalarType::String.nullable(false)) .with_column("global_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .finish(), column_comments: BTreeMap::from_iter([ ( @@ -6606,7 +7565,11 @@ FROM mz_catalog.mz_objects mo JOIN mz_introspection.mz_dataflow_global_ids mgi ON (mce.dataflow_id = mgi.id) LEFT JOIN mz_catalog.mz_databases md ON (ms.database_id = md.id);", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "mappable_object", + description: "Objects that can be mapped to dataflow operators", + links: &[], + }), }); pub static MZ_LIR_MAPPING: LazyLock = LazyLock::new(|| BuiltinView { @@ -6615,6 +7578,7 @@ pub static MZ_LIR_MAPPING: LazyLock = LazyLock::new(|| BuiltinView oid: oid::VIEW_MZ_LIR_MAPPING_OID, desc: RelationDesc::builder() .with_column("global_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("lir_id", SqlScalarType::UInt64.nullable(false)) .with_column("operator", SqlScalarType::String.nullable(false)) .with_column("parent_lir_id", SqlScalarType::UInt64.nullable(true)) @@ -6649,7 +7613,11 @@ SELECT global_id, lir_id, operator, parent_lir_id, nesting, operator_id_start, o FROM mz_introspection.mz_compute_lir_mapping_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "lir_mapping", + description: "LIR (low-level IR) to dataflow operator mapping", + links: &[], + }), }); pub static MZ_DATAFLOW_OPERATOR_DATAFLOWS_PER_WORKER: LazyLock = @@ -6714,7 +7682,15 @@ SELECT id, name, dataflow_id, dataflow_name FROM mz_introspection.mz_dataflow_operator_dataflows_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "dataflow_operator_dataflow", + description: "Mapping of operators to their parent dataflow", + links: &[OntologyLink { + name: "operator_in_dataflow", + target: "dataflow", + properties_json: r#"{"kind": "foreign_key", "source_column": "dataflow_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), }); pub static MZ_OBJECT_TRANSITIVE_DEPENDENCIES: LazyLock = LazyLock::new(|| { @@ -6724,10 +7700,12 @@ pub static MZ_OBJECT_TRANSITIVE_DEPENDENCIES: LazyLock = LazyLock:: oid: oid::VIEW_MZ_OBJECT_TRANSITIVE_DEPENDENCIES_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column( "referenced_object_id", SqlScalarType::String.nullable(false), ) + .with_semantic_type("CatalogItemId") .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -6749,7 +7727,22 @@ WITH MUTUALLY RECURSIVE ) SELECT object_id, referenced_object_id FROM reach;", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "transitive_dependency", + description: "Transitive closure of object dependencies — all direct and indirect dependencies", + links: &[ + OntologyLink { + name: "transitively_depends_on", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one", "source_id_type": "CatalogItemId"}"#, + }, + OntologyLink { + name: "transitively_depended_on_by", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "referenced_object_id", "target_column": "id", "cardinality": "many_to_one", "source_id_type": "CatalogItemId"}"#, + }, + ], + }), } }); @@ -6759,6 +7752,7 @@ pub static MZ_COMPUTE_EXPORTS: LazyLock = LazyLock::new(|| BuiltinV oid: oid::VIEW_MZ_COMPUTE_EXPORTS_OID, desc: RelationDesc::builder() .with_column("export_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false)) .with_key(vec![0]) .finish(), @@ -6777,7 +7771,22 @@ SELECT export_id, dataflow_id FROM mz_introspection.mz_compute_exports_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "compute_export", + description: "Compute exports (maintained collections)", + links: &[ + OntologyLink { + name: "export_of", + target: "object", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "export_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "introspection_uses_global_id", + target: "object_global_id", + properties_json: r#"{"kind": "maps_to", "note": "mz_introspection tables use GlobalId. To join with mz_catalog tables (which use CatalogItemId), go through mz_internal.mz_object_global_ids."}"#, + }, + ], + }), }); pub static MZ_COMPUTE_FRONTIERS: LazyLock = LazyLock::new(|| BuiltinView { @@ -6786,7 +7795,9 @@ pub static MZ_COMPUTE_FRONTIERS: LazyLock = LazyLock::new(|| Builti oid: oid::VIEW_MZ_COMPUTE_FRONTIERS_OID, desc: RelationDesc::builder() .with_column("export_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) + .with_semantic_type("MzTimestamp") .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -6804,7 +7815,15 @@ pub static MZ_COMPUTE_FRONTIERS: LazyLock = LazyLock::new(|| Builti FROM mz_introspection.mz_compute_frontiers_per_worker GROUP BY export_id", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "compute_frontier", + description: "Per-replica compute frontiers", + links: &[OntologyLink { + name: "compute_frontier_of", + target: "object", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "export_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), }); pub static MZ_DATAFLOW_CHANNEL_OPERATORS_PER_WORKER: LazyLock = @@ -6939,8 +7958,11 @@ pub static MZ_COMPUTE_IMPORT_FRONTIERS: LazyLock = LazyLock::new(|| oid: oid::VIEW_MZ_COMPUTE_IMPORT_FRONTIERS_OID, desc: RelationDesc::builder() .with_column("export_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("import_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) + .with_semantic_type("MzTimestamp") .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -6962,7 +7984,15 @@ pub static MZ_COMPUTE_IMPORT_FRONTIERS: LazyLock = LazyLock::new(|| FROM mz_introspection.mz_compute_import_frontiers_per_worker GROUP BY export_id, import_id", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "compute_import_frontier", + description: "Import frontiers for compute dependencies", + links: &[OntologyLink { + name: "compute_import_frontier_of", + target: "object", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "export_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], + }), }); pub static MZ_RECORDS_PER_DATAFLOW_OPERATOR_PER_WORKER: LazyLock = @@ -7144,7 +8174,11 @@ GROUP BY id, name", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "records_per_dataflow", + description: "Record counts aggregated per dataflow", + links: &[], + }), }); /// Peeled version of `PG_NAMESPACE`: @@ -8421,7 +9455,11 @@ SELECT FROM mz_introspection.mz_peek_durations_histogram_per_worker GROUP BY type, duration_ns", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "peek_duration", + description: "Histogram of SELECT query durations", + links: &[], + }), }); pub static MZ_SCHEDULING_ELAPSED_PER_WORKER: LazyLock = @@ -8478,7 +9516,15 @@ SELECT FROM mz_introspection.mz_scheduling_elapsed_per_worker GROUP BY id", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "scheduling_elapsed", + description: "CPU time spent per operator", + links: &[OntologyLink { + name: "elapsed_for_operator", + target: "dataflow_operator", + properties_json: r#"{"kind": "measures", "source_column": "id", "target_column": "id", "metric": "cpu_time_ns"}"#, + }], + }), }); pub static MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock = @@ -8607,7 +9653,11 @@ SELECT FROM mz_introspection.mz_scheduling_parks_histogram_per_worker GROUP BY slept_for_ns, requested_ns", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "scheduling_parks", + description: "Histogram of operator park durations", + links: &[], + }), }); pub static MZ_COMPUTE_ERROR_COUNTS_PER_WORKER: LazyLock = @@ -8660,6 +9710,7 @@ pub static MZ_COMPUTE_ERROR_COUNTS: LazyLock = LazyLock::new(|| Bui oid: oid::VIEW_MZ_COMPUTE_ERROR_COUNTS_OID, desc: RelationDesc::builder() .with_column("export_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column( "count", SqlScalarType::Numeric { @@ -8687,7 +9738,11 @@ FROM mz_introspection.mz_compute_error_counts_per_worker GROUP BY export_id HAVING pg_catalog.sum(count) != 0", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "compute_error_count", + description: "Error counts per compute collection", + links: &[], + }), }); pub static MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED: LazyLock = @@ -8700,7 +9755,9 @@ pub static MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED: LazyLock = oid: oid::SOURCE_MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED_OID, desc: RelationDesc::builder() .with_column("replica_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ReplicaId") .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column( "count", SqlScalarType::Numeric { max_scale: None }.nullable(false), @@ -8719,14 +9776,20 @@ pub static MZ_COMPUTE_HYDRATION_TIMES: LazyLock = LazyLock::new(| oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_TIMES_OID, desc: RelationDesc::builder() .with_column("replica_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ReplicaId") .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("time_ns", SqlScalarType::UInt64.nullable(true)) .finish(), data_source: IntrospectionType::ComputeHydrationTimes.into(), column_comments: BTreeMap::new(), is_retained_metrics_object: true, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "compute_hydration_time", + description: "Time to hydrate compute objects", + links: &[], + }), }); pub static MZ_COMPUTE_HYDRATION_TIMES_IND: LazyLock = @@ -8745,7 +9808,9 @@ pub static MZ_COMPUTE_HYDRATION_STATUSES: LazyLock = LazyLock::new( oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_STATUSES_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("replica_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ReplicaId") .with_column("hydrated", SqlScalarType::Bool.nullable(false)) .with_column("hydration_time", SqlScalarType::Interval.nullable(true)) .finish(), @@ -8792,7 +9857,11 @@ SELECT * FROM dataflows UNION ALL SELECT * FROM complete_mvs", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "compute_hydration_status_view", + description: "Computed hydration status per compute object", + links: &[], + }), }); pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES: LazyLock = LazyLock::new(|| { @@ -8802,7 +9871,9 @@ pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES: LazyLock = Laz oid: oid::SOURCE_MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_OID, desc: RelationDesc::builder() .with_column("replica_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ReplicaId") .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column( "physical_plan_node_id", SqlScalarType::UInt64.nullable(false), @@ -8825,7 +9896,11 @@ pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES: LazyLock = Laz ]), is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "compute_hydration_status", + description: "Hydration status per compute operator", + links: &[], + }), } }); @@ -8961,7 +10036,11 @@ SELECT FROM mz_introspection.mz_message_counts_per_worker GROUP BY channel_id", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "message_count", + description: "Inter-worker message counts", + links: &[], + }), }); pub static MZ_ACTIVE_PEEKS: LazyLock = LazyLock::new(|| BuiltinView { @@ -8971,8 +10050,10 @@ pub static MZ_ACTIVE_PEEKS: LazyLock = LazyLock::new(|| BuiltinView desc: RelationDesc::builder() .with_column("id", SqlScalarType::Uuid.nullable(false)) .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("type", SqlScalarType::String.nullable(false)) .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) + .with_semantic_type("MzTimestamp") .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -8992,7 +10073,11 @@ SELECT id, object_id, type, time FROM mz_introspection.mz_active_peeks_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "active_peek", + description: "Currently executing SELECT queries", + links: &[], + }), }); pub static MZ_DATAFLOW_OPERATOR_REACHABILITY_PER_WORKER: LazyLock = @@ -9270,7 +10355,15 @@ SELECT FROM mz_introspection.mz_arrangement_sizes_per_worker GROUP BY operator_id", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "arrangement_size", + description: "Aggregated arrangement sizes (records, batches, bytes)", + links: &[OntologyLink { + name: "arrangement_of_operator", + target: "dataflow_operator", + properties_json: r#"{"kind": "measures", "source_column": "operator_id", "target_column": "id", "metric": "arrangement_size", "note": "Both IDs are local uint64 operator IDs within a dataflow, not GlobalIds."}"#, + }], + }), }); pub static MZ_ARRANGEMENT_SHARING_PER_WORKER: LazyLock = @@ -9320,7 +10413,11 @@ SELECT operator_id, count FROM mz_introspection.mz_arrangement_sharing_per_worker WHERE worker_id = 0::uint8", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "arrangement_sharing", + description: "Arrangement sharing between operators", + links: &[], + }), }); pub static MZ_CLUSTER_REPLICA_UTILIZATION: LazyLock = LazyLock::new(|| BuiltinView { @@ -9329,6 +10426,7 @@ pub static MZ_CLUSTER_REPLICA_UTILIZATION: LazyLock = LazyLock::new oid: oid::VIEW_MZ_CLUSTER_REPLICA_UTILIZATION_OID, desc: RelationDesc::builder() .with_column("replica_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ReplicaId") .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("cpu_percent", SqlScalarType::Float64.nullable(true)) .with_column("memory_percent", SqlScalarType::Float64.nullable(true)) @@ -9368,7 +10466,15 @@ FROM JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size JOIN mz_internal.mz_cluster_replica_metrics AS m ON m.replica_id = r.id", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "replica_utilization", + description: "Computed utilization metrics per replica", + links: &[OntologyLink { + name: "utilization_of_replica", + target: "replica", + properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], + }), }); pub static MZ_CLUSTER_REPLICA_UTILIZATION_HISTORY: LazyLock = @@ -9728,7 +10834,11 @@ pub static MZ_EXPECTED_GROUP_SIZE_ADVICE: LazyLock = LazyLock::new( JOIN mz_introspection.mz_dataflow_operator_dataflows dod ON dod.dataflow_id = c.dataflow_id AND dod.id = c.region_id", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "group_size_advice", + description: "Advice on expected group sizes for reduce operators", + links: &[], + }), }); pub static MZ_INDEX_ADVICE: LazyLock = LazyLock::new(|| { @@ -12680,7 +13790,11 @@ pub static MZ_CLUSTER_REPLICA_HISTORY: LazyLock = LazyLock::new(|| mz_catalog.mz_cluster_replica_sizes ON mz_cluster_replica_sizes.size = creates.size"#, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "replica_history", + description: "Historical record of replica creation/drops", + links: &[], + }), }); pub static MZ_CLUSTER_REPLICA_NAME_HISTORY: LazyLock = LazyLock::new(|| BuiltinView { @@ -12693,6 +13807,7 @@ pub static MZ_CLUSTER_REPLICA_NAME_HISTORY: LazyLock = LazyLock::ne SqlScalarType::TimestampTz { precision: None }.nullable(true), ) .with_column("id", SqlScalarType::String.nullable(true)) + .with_semantic_type("CatalogItemId") .with_column("previous_name", SqlScalarType::String.nullable(true)) .with_column("new_name", SqlScalarType::String.nullable(true)) .finish(), @@ -12747,7 +13862,11 @@ UNION ALL SELECT * FROM system_replicas"#, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "replica_name_history", + description: "Historical replica names", + links: &[], + }), }); pub static MZ_HYDRATION_STATUSES: LazyLock = LazyLock::new(|| BuiltinView { @@ -12756,13 +13875,15 @@ pub static MZ_HYDRATION_STATUSES: LazyLock = LazyLock::new(|| Built oid: oid::VIEW_MZ_HYDRATION_STATUSES_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("replica_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("ReplicaId") .with_column("hydrated", SqlScalarType::Bool.nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ ( "object_id", - "The ID of a dataflow-powered object (CatalogItemId). Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, `mz_internal.mz_subscriptions`, `mz_catalog.mz_sources.id`, or `mz_catalog.mz_sinks.id`.", + "The ID of a dataflow-powered object. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, `mz_internal.mz_subscriptions`, `mz_catalog.mz_sources.id`, or `mz_catalog.mz_sinks.id`.", ), ("replica_id", "The ID of a cluster replica."), ("hydrated", "Whether the object is hydrated on the replica."), @@ -12833,7 +13954,22 @@ SELECT * FROM sources UNION ALL SELECT * FROM sinks"#, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "hydration_status", + description: "Overall hydration status per object", + links: &[ + OntologyLink { + name: "hydration_of", + target: "object", + properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "one_to_one"}"#, + }, + OntologyLink { + name: "hydration_on_replica", + target: "replica", + properties_json: r#"{"kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], + }), }); pub const MZ_HYDRATION_STATUSES_IND: BuiltinIndex = BuiltinIndex { @@ -12851,7 +13987,9 @@ pub static MZ_MATERIALIZATION_DEPENDENCIES: LazyLock = LazyLock::ne oid: oid::VIEW_MZ_MATERIALIZATION_DEPENDENCIES_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("dependency_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .finish(), column_comments: BTreeMap::from_iter([ ( @@ -12872,7 +14010,15 @@ FROM mz_internal.mz_object_dependencies d JOIN mz_catalog.mz_sinks s ON (s.id = d.object_id) JOIN mz_catalog.mz_relations r ON (r.id = d.referenced_object_id)", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "materialization_dep", + description: "Dependencies between materializations", + links: &[OntologyLink { + name: "materialization_depends_on", + target: "object", + properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "depends_on", "source_column": "object_id", "target_column": "id"}"#, + }], + }), }); pub static MZ_MATERIALIZATION_LAG: LazyLock = LazyLock::new(|| BuiltinView { @@ -12881,16 +14027,19 @@ pub static MZ_MATERIALIZATION_LAG: LazyLock = LazyLock::new(|| Buil oid: oid::VIEW_MZ_MATERIALIZATION_LAG_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("local_lag", SqlScalarType::Interval.nullable(true)) .with_column("global_lag", SqlScalarType::Interval.nullable(true)) .with_column( "slowest_local_input_id", SqlScalarType::String.nullable(false), ) + .with_semantic_type("CatalogItemId") .with_column( "slowest_global_input_id", SqlScalarType::String.nullable(false), ) + .with_semantic_type("CatalogItemId") .finish(), column_comments: BTreeMap::from_iter([ ( @@ -12996,7 +14145,15 @@ FROM materialization_times m JOIN input_times i USING (id) JOIN root_times r USING (id)", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "materialization_lag", + description: "Lag between a materialization and its inputs", + links: &[OntologyLink { + name: "measures_materialization_lag", + target: "object", + properties_json: r#"{"kind": "measures", "source_column": "object_id", "target_column": "id", "metric": "materialization_lag"}"#, + }], + }), }); /** @@ -13398,7 +14555,11 @@ dropped_clusters ( SELECT * FROM mz_cluster_deployment_lineage"#, access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "cluster_deployment", + description: "Cluster deployment lineage information", + links: &[], + }), }); pub const MZ_SHOW_DATABASES_IND: BuiltinIndex = BuiltinIndex { @@ -13865,13 +15026,21 @@ pub static MZ_SOURCE_STATISTICS: LazyLock = LazyLock::new(|| { // We need to add a redundant where clause for a new dataflow to be created. desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("replica_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("ReplicaId") .with_column("messages_received", SqlScalarType::UInt64.nullable(false)) + .with_semantic_type("RecordCount") .with_column("bytes_received", SqlScalarType::UInt64.nullable(false)) + .with_semantic_type("ByteCount") .with_column("updates_staged", SqlScalarType::UInt64.nullable(false)) + .with_semantic_type("RecordCount") .with_column("updates_committed", SqlScalarType::UInt64.nullable(false)) + .with_semantic_type("RecordCount") .with_column("records_indexed", SqlScalarType::UInt64.nullable(false)) + .with_semantic_type("RecordCount") .with_column("bytes_indexed", SqlScalarType::UInt64.nullable(false)) + .with_semantic_type("ByteCount") .with_column( "rehydration_latency", SqlScalarType::Interval.nullable(true), @@ -13880,10 +15049,12 @@ pub static MZ_SOURCE_STATISTICS: LazyLock = LazyLock::new(|| { "snapshot_records_known", SqlScalarType::UInt64.nullable(true), ) + .with_semantic_type("RecordCount") .with_column( "snapshot_records_staged", SqlScalarType::UInt64.nullable(true), ) + .with_semantic_type("RecordCount") .with_column("snapshot_committed", SqlScalarType::Bool.nullable(false)) .with_column("offset_known", SqlScalarType::UInt64.nullable(true)) .with_column("offset_committed", SqlScalarType::UInt64.nullable(true)) @@ -13949,7 +15120,15 @@ pub static MZ_SOURCE_STATISTICS: LazyLock = LazyLock::new(|| { ]), sql: "SELECT * FROM mz_internal.mz_source_statistics_with_history WHERE length(id) > 0", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "source_statistics", + description: "Aggregated source ingestion statistics", + links: &[OntologyLink { + name: "statistics_of_source", + target: "source", + properties_json: r#"{"kind": "measures", "source_column": "id", "target_column": "id", "metric": "ingestion_statistics"}"#, + }], + }), } }); @@ -13968,11 +15147,17 @@ pub static MZ_SINK_STATISTICS: LazyLock = LazyLock::new(|| BuiltinV oid: oid::VIEW_MZ_SINK_STATISTICS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") .with_column("replica_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("ReplicaId") .with_column("messages_staged", SqlScalarType::UInt64.nullable(false)) + .with_semantic_type("RecordCount") .with_column("messages_committed", SqlScalarType::UInt64.nullable(false)) + .with_semantic_type("RecordCount") .with_column("bytes_staged", SqlScalarType::UInt64.nullable(false)) + .with_semantic_type("ByteCount") .with_column("bytes_committed", SqlScalarType::UInt64.nullable(false)) + .with_semantic_type("ByteCount") .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -14012,7 +15197,15 @@ SELECT FROM mz_internal.mz_sink_statistics_raw GROUP BY id, replica_id", access: vec![PUBLIC_SELECT], - ontology: None, + ontology: Some(Ontology { + entity_name: "sink_statistics", + description: "Aggregated sink export statistics", + links: &[OntologyLink { + name: "statistics_of_sink", + target: "sink", + properties_json: r#"{"kind": "measures", "source_column": "id", "target_column": "id", "metric": "export_statistics"}"#, + }], + }), }); pub const MZ_SINK_STATISTICS_IND: BuiltinIndex = BuiltinIndex { diff --git a/src/storage-client/src/healthcheck.rs b/src/storage-client/src/healthcheck.rs index 1c164a2f24dd3..58520c7fe5760 100644 --- a/src/storage-client/src/healthcheck.rs +++ b/src/storage-client/src/healthcheck.rs @@ -44,6 +44,7 @@ pub static MZ_SESSION_HISTORY_DESC: LazyLock = LazyLock::new(|| { "connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) + .with_semantic_type("WallclockTimestamp") .with_column( "initial_application_name", SqlScalarType::String.nullable(false), @@ -111,11 +112,14 @@ pub static MZ_SOURCE_STATUS_HISTORY_DESC: LazyLock = LazyLock::new "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) + .with_semantic_type("WallclockTimestamp") .with_column("source_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) .with_column("details", SqlScalarType::Jsonb.nullable(true)) .with_column("replica_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("ReplicaId") .finish() }); @@ -125,11 +129,14 @@ pub static MZ_SINK_STATUS_HISTORY_DESC: LazyLock = LazyLock::new(| "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) + .with_semantic_type("WallclockTimestamp") .with_column("sink_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) .with_column("details", SqlScalarType::Jsonb.nullable(true)) .with_column("replica_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("ReplicaId") .finish() }); @@ -148,6 +155,7 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_DESC: LazyLock = LazyLock::new(|| { RelationDesc::builder() .with_column("replica_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("ReplicaId") .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("reason", SqlScalarType::String.nullable(true)) @@ -180,12 +188,15 @@ pub static REPLICA_METRICS_HISTORY_DESC: LazyLock = LazyLock::new( pub static WALLCLOCK_LAG_HISTORY_DESC: LazyLock = LazyLock::new(|| { RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_semantic_type("GlobalId") .with_column("replica_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("ReplicaId") .with_column("lag", SqlScalarType::Interval.nullable(true)) .with_column( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) + .with_semantic_type("WallclockTimestamp") .finish() }); From 8e6ce3fffe383ce73dfdbe938ea54a18cd925550 Mon Sep 17 00:00:00 2001 From: mtabebe Date: Fri, 17 Apr 2026 16:16:07 -0400 Subject: [PATCH 03/14] [ontology] add developer documentation for catalog ontology views Add documentation for the ontology module covering the four built-in views, their schema, link type properties and LLM usage guide --- .../generated/catalog/builtin/ontology.md | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 doc/developer/generated/catalog/builtin/ontology.md diff --git a/doc/developer/generated/catalog/builtin/ontology.md b/doc/developer/generated/catalog/builtin/ontology.md new file mode 100644 index 0000000000000..460d957df1e65 --- /dev/null +++ b/doc/developer/generated/catalog/builtin/ontology.md @@ -0,0 +1,117 @@ +--- +source: src/catalog/src/builtin/ontology.rs +--- + +# catalog::builtin::ontology + +Generates four built-in views in `mz_internal` that describe the structure and +relationships of the Materialize system catalog. Designed to help LLMs, +diagnostic tools, and developers discover the right tables, join paths, and ID +types when writing catalog queries. + +## Views + +| View | Columns | Purpose | +|---|---|---| +| `mz_internal.mz_ontology_entity_types` | `name, relation, properties, description` | What kinds of things exist. `properties` jsonb has `{"primary_key": ["id"]}`. | +| `mz_internal.mz_ontology_semantic_types` | `name, sql_type, description` | Typed ID domains and other semantic column types (CatalogItemId, GlobalId, ByteCount, etc.) | +| `mz_internal.mz_ontology_properties` | `entity_type, column_name, semantic_type, description` | Maps every column to its semantic type and describes what it means. | +| `mz_internal.mz_ontology_link_types` | `name, source_entity, target_entity, properties, description` | Named relationships between entity types. | + +The views are generated at startup by `generate_views()`, which enumerates all +builtins that have `ontology: Some(...)` annotations and extracts metadata from +their `RelationDesc`, column comments, and semantic type annotations. + +## How it works + +1. **Entity types** — one row per builtin with an `Ontology` annotation. The + `relation` column is `schema.table_name`, `properties` contains primary key + info extracted from `RelationDesc::typ().keys`. + +2. **Semantic types** — a static reference table of 20 ID/value domains + (e.g., `CatalogItemId`, `GlobalId`, `ReplicaId`, `ByteCount`). + +3. **Properties** — one row per column per annotated entity. Joins against + `mz_columns` at runtime to discover column names and types. Semantic type + annotations come from `RelationDesc::get_semantic_type()`. Column + descriptions come from `mz_comments`. + +4. **Link types** — one row per `OntologyLink` on each annotated entity. + The `properties` JSONB column contains structured relationship metadata + (kind, source_column, target_column, cardinality, source_id_type, etc.). + +## Link type properties + +The `properties` jsonb in `mz_ontology_link_types` uses a `"kind"` field: + +- `"foreign_key"` — column-level join with `source_column`, `target_column`, `cardinality` +- `"measures"` — a measurement/metric relationship +- `"depends_on"` — a dependency relationship +- `"maps_to"` — an ID mapping (e.g., CatalogItemId to GlobalId) +- `"union"` — a UNION view includes another entity type + +Common keys in the properties JSONB: + +| Key | Description | +|---|---| +| `kind` | Relationship kind: `foreign_key`, `measures`, `depends_on`, `maps_to`, or `union`. | +| `source_column` | Column name on the source entity used for the join. | +| `target_column` | Column name on the target entity used for the join. | +| `cardinality` | Join cardinality: `many_to_one`, `one_to_one`, `many_to_many`. | +| `nullable` | `true` if the FK column can be NULL (optional relationship). | +| `source_id_type` | Semantic ID type of the source column (e.g., `CatalogItemId`, `GlobalId`). | +| `requires_mapping` | Mapping table needed to bridge ID namespaces (e.g., `mz_internal.mz_object_global_ids`). | + +## For LLMs + +If connected to a Materialize instance, query these views **before** writing +catalog queries. They help find the right tables, correct join paths, and avoid +the GlobalId/CatalogItemId trap. + +### Key queries + +**Find all entities related to X:** +```sql +SELECT l.name, l.source_entity, l.target_entity, + l.properties->>'source_id_type' AS id_type +FROM mz_internal.mz_ontology_link_types l +WHERE l.source_entity = 'X' OR l.target_entity = 'X'; +``` + +**Discover columns and types for entity Z:** +```sql +SELECT p.column_name, p.semantic_type, p.description +FROM mz_internal.mz_ontology_properties p +WHERE p.entity_type = 'Z' +ORDER BY p.column_name; +``` + +**Look up the actual table name for an entity:** +```sql +SELECT name, relation FROM mz_internal.mz_ontology_entity_types WHERE name = 'mv'; +-- mv -> mz_catalog.mz_materialized_views +``` + +### GlobalId vs CatalogItemId + +Many `object_id` columns in `mz_internal` and `mz_introspection` use +**GlobalId**, not **CatalogItemId**. Both are `text`, both look like `u42`, +but they are different ID namespaces. A direct join to `mz_objects.id` +(CatalogItemId) will silently return wrong results after ALTER operations. + +Check `mz_ontology_properties.semantic_type` before writing joins. If the +types differ, bridge through `mz_internal.mz_object_global_ids`. + +## Stats + +- ~117 entity types (mz_catalog + mz_internal + mz_introspection) +- 20 semantic types +- ~450 column properties +- ~106 named relationships + +## Related files + +- `src/catalog/src/builtin.rs` — `Ontology` and `OntologyLink` struct definitions, per-builtin annotations +- `src/repr/src/relation.rs` — `semantic_types` field on `RelationDesc` +- `src/storage-client/src/healthcheck.rs` — semantic type annotations on status history tables +- `misc/ontology/` — SQL files for loading the same data as user-space tables From a5d72b4fc8cd4233795e75599516405c73585bf8 Mon Sep 17 00:00:00 2001 From: mtabebe Date: Fri, 17 Apr 2026 16:20:50 -0400 Subject: [PATCH 04/14] [ontology] tests for ontology Co-Authored-By: Claude Opus 4.6 (1M context) --- src/catalog/src/builtin.rs | 125 +++++++++++++++ src/catalog/src/builtin/ontology.rs | 2 +- src/repr/src/relation.rs | 59 +++++++ .../information_schema_tables.slt | 16 ++ test/sqllogictest/mz_ontology.slt | 148 ++++++++++++++++++ test/sqllogictest/oid.slt | 4 + test/testdrive/catalog.td | 4 + 7 files changed, 357 insertions(+), 1 deletion(-) create mode 100644 test/sqllogictest/mz_ontology.slt diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index 7d5d1fb94b647..97f3f4bfcac8f 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -16290,4 +16290,129 @@ mod tests { violations.join("\n"), ); } + + /// Validates ontology metadata consistency: + /// - Every link target references an entity that exists. + /// - Every semantic type annotation references a type in SEMANTIC_TYPE_DEFS. + /// - No duplicate entity names. + /// - Every annotated builtin has a non-empty entity_name and description. + #[mz_ore::test] + #[cfg_attr(miri, ignore)] + fn test_ontology_consistency() { + use super::ontology::SEMANTIC_TYPE_DEFS; + + let valid_semantic_types: BTreeSet<&str> = SEMANTIC_TYPE_DEFS + .iter() + .map(|(name, _, _)| *name) + .collect(); + + // Collect all entity names from builtins with ontology annotations. + let mut entity_names: BTreeSet = BTreeSet::new(); + let mut duplicate_entities = Vec::new(); + + for builtin in BUILTINS_STATIC.iter() { + let ontology = match builtin { + Builtin::Table(t) => t.ontology.as_ref(), + Builtin::View(v) => v.ontology.as_ref(), + Builtin::MaterializedView(mv) => mv.ontology.as_ref(), + Builtin::Source(s) => s.ontology.as_ref(), + _ => None, + }; + if let Some(ont) = ontology { + assert!( + !ont.entity_name.is_empty(), + "builtin {} has empty ontology entity_name", + builtin.name() + ); + assert!( + !ont.description.is_empty(), + "builtin {} ({}) has empty ontology description", + builtin.name(), + ont.entity_name + ); + if !entity_names.insert(ont.entity_name.to_string()) { + duplicate_entities.push(format!( + "duplicate entity_name {:?} on builtin {}", + ont.entity_name, + builtin.name() + )); + } + } + } + assert!( + duplicate_entities.is_empty(), + "ontology has duplicate entity names:\n{}", + duplicate_entities.join("\n"), + ); + + // Validate link targets reference existing entities. + let mut bad_targets = Vec::new(); + for builtin in BUILTINS_STATIC.iter() { + let ontology = match builtin { + Builtin::Table(t) => t.ontology.as_ref(), + Builtin::View(v) => v.ontology.as_ref(), + Builtin::MaterializedView(mv) => mv.ontology.as_ref(), + Builtin::Source(s) => s.ontology.as_ref(), + _ => None, + }; + if let Some(ont) = ontology { + for link in ont.links { + if !entity_names.contains(link.target) { + bad_targets.push(format!( + "entity {:?} link {:?} targets {:?} which is not a known entity", + ont.entity_name, link.name, link.target + )); + } + } + } + } + assert!( + bad_targets.is_empty(), + "ontology has links targeting unknown entities:\n{}", + bad_targets.join("\n"), + ); + + // Validate semantic type annotations use known types. + let mut bad_sem_types = Vec::new(); + for builtin in BUILTINS_STATIC.iter() { + let (name, desc, ontology) = match builtin { + Builtin::Table(t) => (t.name, &t.desc, t.ontology.as_ref()), + Builtin::View(v) => (v.name, &v.desc, v.ontology.as_ref()), + Builtin::MaterializedView(mv) => (mv.name, &mv.desc, mv.ontology.as_ref()), + Builtin::Source(s) => (s.name, &s.desc, s.ontology.as_ref()), + _ => continue, + }; + for (idx, _col) in desc.iter_names().enumerate() { + if let Some(sem) = desc.get_semantic_type(idx) { + if !valid_semantic_types.contains(sem) { + bad_sem_types.push(format!( + "builtin {} column {} has semantic type {:?} not in SEMANTIC_TYPE_DEFS", + name, + desc.get_name(idx), + sem + )); + } + } + } + // Also check: if a builtin has semantic types but no ontology, warn. + let has_sem = (0..desc.arity()).any(|i| desc.get_semantic_type(i).is_some()); + if has_sem && ontology.is_none() { + // This is not necessarily wrong (some builtins have semantic + // types for internal use without being ontology entities), + // but we track it for awareness. + } + } + assert!( + bad_sem_types.is_empty(), + "builtins have semantic types not in SEMANTIC_TYPE_DEFS:\n{}", + bad_sem_types.join("\n"), + ); + + // Sanity check: we have a reasonable number of annotated entities. + assert!( + entity_names.len() > 90, + "expected > 90 ontology entities, found {}", + entity_names.len() + ); + } } diff --git a/src/catalog/src/builtin/ontology.rs b/src/catalog/src/builtin/ontology.rs index 8e5225abd1e5a..52c8bc0b89862 100644 --- a/src/catalog/src/builtin/ontology.rs +++ b/src/catalog/src/builtin/ontology.rs @@ -271,7 +271,7 @@ fn link_types_view(infos: &[Info]) -> BuiltinView { // ── Semantic type reference data ───────────────────────────── -const SEMANTIC_TYPE_DEFS: &[(&str, &str, &str)] = &[ +pub(super) const SEMANTIC_TYPE_DEFS: &[(&str, &str, &str)] = &[ ( "CatalogItemId", "text", diff --git a/src/repr/src/relation.rs b/src/repr/src/relation.rs index 72658183e1b51..6b7ccdf044755 100644 --- a/src/repr/src/relation.rs +++ b/src/repr/src/relation.rs @@ -2403,4 +2403,63 @@ mod tests { testcase(desc); }); } + + #[mz_ore::test] + fn test_semantic_type_annotations() { + let desc = RelationDesc::builder() + .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") + .with_column("name", SqlScalarType::String.nullable(false)) + .with_column("cluster_id", SqlScalarType::String.nullable(true)) + .with_semantic_type("ClusterId") + .finish(); + + // Annotated columns return their semantic type. + assert_eq!(desc.get_semantic_type(0), Some("CatalogItemId")); + assert_eq!(desc.get_semantic_type(2), Some("ClusterId")); + + // Unannotated columns return None. + assert_eq!(desc.get_semantic_type(1), None); + + // Out-of-bounds returns None. + assert_eq!(desc.get_semantic_type(99), None); + } + + #[mz_ore::test] + fn test_semantic_types_excluded_from_eq_and_hash() { + let desc_a = RelationDesc::builder() + .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") + .finish(); + + let desc_b = RelationDesc::builder() + .with_column("id", SqlScalarType::String.nullable(false)) + .finish(); + + // semantic_types is excluded from Eq. + assert_eq!(desc_a, desc_b); + + // semantic_types is excluded from Hash. + use std::hash::{Hash, Hasher}; + let hash = |d: &RelationDesc| { + let mut h = std::collections::hash_map::DefaultHasher::new(); + d.hash(&mut h); + h.finish() + }; + assert_eq!(hash(&desc_a), hash(&desc_b)); + } + + #[mz_ore::test] + #[cfg_attr(miri, ignore)] + fn test_semantic_types_excluded_from_serialization() { + let desc = RelationDesc::builder() + .with_column("id", SqlScalarType::String.nullable(false)) + .with_semantic_type("CatalogItemId") + .finish(); + + // Roundtrip through protobuf should lose semantic types (serde skip). + let proto = desc.into_proto(); + let roundtripped = RelationDesc::from_proto(proto).unwrap(); + assert_eq!(roundtripped.get_semantic_type(0), None); + } } diff --git a/test/sqllogictest/information_schema_tables.slt b/test/sqllogictest/information_schema_tables.slt index a3d24064b5116..ea3473555eeca 100644 --- a/test/sqllogictest/information_schema_tables.slt +++ b/test/sqllogictest/information_schema_tables.slt @@ -477,6 +477,22 @@ mz_objects_id_namespace_types VIEW materialize mz_internal +mz_ontology_entity_types +VIEW +materialize +mz_internal +mz_ontology_link_types +VIEW +materialize +mz_internal +mz_ontology_properties +VIEW +materialize +mz_internal +mz_ontology_semantic_types +VIEW +materialize +mz_internal mz_optimizer_notices BASE TABLE materialize diff --git a/test/sqllogictest/mz_ontology.slt b/test/sqllogictest/mz_ontology.slt new file mode 100644 index 0000000000000..9f1470bfabbd0 --- /dev/null +++ b/test/sqllogictest/mz_ontology.slt @@ -0,0 +1,148 @@ +# Copyright Materialize, Inc. and contributors. All rights reserved. +# +# Use of this software is governed by the Business Source License +# included in the LICENSE file at the root of this repository. +# +# As of the Change Date specified in that file, in accordance with +# the Business Source License, use of this software will be governed +# by the Apache License, Version 2.0. + +# Smoke tests for the mz_ontology built-in views in mz_internal. + +mode cockroach + +# Verify the four ontology views exist and have the expected columns. + +query TTTT +SELECT name, relation, properties->>'primary_key', description +FROM mz_internal.mz_ontology_entity_types +WHERE name = 'cluster' +---- +cluster mz_catalog.mz_clusters ["id"] A␠compute␠cluster␠that␠runs␠dataflows␠for␠sources,␠sinks,␠MVs,␠and␠indexes + +query TTT +SELECT name, sql_type, description +FROM mz_internal.mz_ontology_semantic_types +WHERE name = 'CatalogItemId' +---- +CatalogItemId text SQL-layer␠object␠ID.␠Format:␠s{n}/u{n}. + +query TTTT +SELECT entity_type, column_name, semantic_type, description +FROM mz_internal.mz_ontology_properties +WHERE entity_type = 'cluster' AND column_name = 'id' +---- +cluster id ClusterId Materialize's␠unique␠ID␠for␠the␠cluster. + +query TTTTT +SELECT name, source_entity, target_entity, properties->>'kind', description +FROM mz_internal.mz_ontology_link_types +WHERE name = 'belongs_to_cluster' AND source_entity = 'replica' +---- +belongs_to_cluster replica cluster foreign_key NULL + +# Verify basic row counts are in expected ranges. + +query B +SELECT count(*) > 90 FROM mz_internal.mz_ontology_entity_types +---- +true + +query B +SELECT count(*) >= 15 FROM mz_internal.mz_ontology_semantic_types +---- +true + +query B +SELECT count(*) > 300 FROM mz_internal.mz_ontology_properties +---- +true + +query B +SELECT count(*) > 80 FROM mz_internal.mz_ontology_link_types +---- +true + +# Verify referential integrity: every entity_type in properties exists in entity_types. + +query I +SELECT count(*) +FROM mz_internal.mz_ontology_properties p +WHERE NOT EXISTS ( + SELECT 1 FROM mz_internal.mz_ontology_entity_types e + WHERE e.name = p.entity_type +) +---- +0 + +# Verify referential integrity: every semantic_type in properties exists in semantic_types. + +query I +SELECT count(*) +FROM mz_internal.mz_ontology_properties p +WHERE p.semantic_type IS NOT NULL + AND NOT EXISTS ( + SELECT 1 FROM mz_internal.mz_ontology_semantic_types s + WHERE s.name = p.semantic_type +) +---- +0 + +# Verify referential integrity: link type source/target entities exist in entity_types. + +query I +SELECT count(*) +FROM mz_internal.mz_ontology_link_types l +WHERE NOT EXISTS ( + SELECT 1 FROM mz_internal.mz_ontology_entity_types e + WHERE e.name = l.source_entity +) +---- +0 + +query I +SELECT count(*) +FROM mz_internal.mz_ontology_link_types l +WHERE NOT EXISTS ( + SELECT 1 FROM mz_internal.mz_ontology_entity_types e + WHERE e.name = l.target_entity +) +---- +0 + +# Verify link_types properties column has structured JSON (not empty). + +query B +SELECT count(*) > 0 +FROM mz_internal.mz_ontology_link_types +WHERE properties->>'kind' IS NOT NULL +---- +true + +# Verify semantic type annotations are populated in properties. + +query B +SELECT count(*) > 200 +FROM mz_internal.mz_ontology_properties +WHERE semantic_type IS NOT NULL +---- +true + +# Verify key entity types exist. + +query T rowsort +SELECT name FROM mz_internal.mz_ontology_entity_types +WHERE name IN ('database', 'schema', 'role', 'cluster', 'replica', 'table', 'source', 'view', 'mv', 'index', 'sink', 'connection') +---- +cluster +connection +database +index +mv +replica +role +schema +sink +source +table +view diff --git a/test/sqllogictest/oid.slt b/test/sqllogictest/oid.slt index 75443f5286fcf..2329f4b620ece 100644 --- a/test/sqllogictest/oid.slt +++ b/test/sqllogictest/oid.slt @@ -1181,3 +1181,7 @@ SELECT oid, name FROM mz_objects WHERE id LIKE 's%' AND oid < 20000 ORDER BY oid 17073 parse_catalog_create_sql 17074 redact_sql 17075 repeat_row_non_negative +17076 mz_ontology_entity_types +17077 mz_ontology_semantic_types +17078 mz_ontology_properties +17079 mz_ontology_link_types diff --git a/test/testdrive/catalog.td b/test/testdrive/catalog.td index 85e6ea6dfa101..7522066a62aef 100644 --- a/test/testdrive/catalog.td +++ b/test/testdrive/catalog.td @@ -653,6 +653,10 @@ mz_object_lifetimes "" mz_object_oid_alias "" mz_object_transitive_dependencies "" mz_objects_id_namespace_types "" +mz_ontology_entity_types "" +mz_ontology_link_types "" +mz_ontology_properties "" +mz_ontology_semantic_types "" mz_recent_activity_log "" mz_recent_activity_log_thinned "" mz_recent_activity_log_redacted "" From 1fb08020ce70f78ae9d257a7f210b0b2303443c7 Mon Sep 17 00:00:00 2001 From: mtabebe Date: Tue, 28 Apr 2026 14:28:06 -0400 Subject: [PATCH 05/14] [ontology] make the ontology annotations type-safe and internally consistent - Replace SemanticType &'static str with a typed enum; update all call sites in builtin.rs and healthcheck.rs - Rename OntologyLink names to noun phrases throughout: dependent_object, referenced_object, transitively_dependent_object/referenced_object, detail_of, group_role, member_role, default_parameter_setting_of - Add missing FK links on source-table detail tables and mz_operators (returns_type), plus a test for ontology_consistency - Improve SEMANTIC_TYPE_DEFS descriptions with examples and clearer wording (MzTimestamp, ObjectType, ConnectionType, SourceType) --- src/catalog/src/builtin.rs | 814 +++++++++++++++----------- src/catalog/src/builtin/ontology.rs | 100 +++- src/repr/src/lib.rs | 6 +- src/repr/src/relation.rs | 82 ++- src/storage-client/src/healthcheck.rs | 24 +- 5 files changed, 634 insertions(+), 392 deletions(-) diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index 97f3f4bfcac8f..d95fadd639ca3 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -41,7 +41,7 @@ use mz_repr::namespaces::{ MZ_UNSAFE_SCHEMA, PG_CATALOG_SCHEMA, }; use mz_repr::role_id::RoleId; -use mz_repr::{RelationDesc, SqlRelationType, SqlScalarType}; +use mz_repr::{RelationDesc, SemanticType, SqlRelationType, SqlScalarType}; use mz_sql::catalog::RoleAttributesRaw; use mz_sql::catalog::{ CatalogItemType, CatalogType, CatalogTypeDetails, CatalogTypePgMetadata, NameReference, @@ -2091,7 +2091,7 @@ pub static MZ_ICEBERG_SINKS: LazyLock = LazyLock::new(|| BuiltinTa oid: oid::TABLE_MZ_ICEBERG_SINKS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("namespace", SqlScalarType::String.nullable(false)) .with_column("table", SqlScalarType::String.nullable(false)) .finish(), @@ -2122,7 +2122,7 @@ pub static MZ_KAFKA_SINKS: LazyLock = LazyLock::new(|| BuiltinTabl oid: oid::TABLE_MZ_KAFKA_SINKS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("topic", SqlScalarType::String.nullable(false)) .with_key(vec![0]) .finish(), @@ -2151,7 +2151,7 @@ pub static MZ_KAFKA_CONNECTIONS: LazyLock = LazyLock::new(|| Built oid: oid::TABLE_MZ_KAFKA_CONNECTIONS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column( "brokers", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), @@ -2187,7 +2187,7 @@ pub static MZ_KAFKA_SOURCES: LazyLock = LazyLock::new(|| BuiltinTa oid: oid::TABLE_MZ_KAFKA_SOURCES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("group_id_prefix", SqlScalarType::String.nullable(false)) .with_column("topic", SqlScalarType::String.nullable(false)) .finish(), @@ -2223,7 +2223,7 @@ pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| Builti oid: oid::TABLE_MZ_POSTGRES_SOURCES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("replication_slot", SqlScalarType::String.nullable(false)) .with_column("timeline_id", SqlScalarType::UInt64.nullable(true)) .finish(), @@ -2255,7 +2255,7 @@ pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| oid: oid::TABLE_MZ_POSTGRES_SOURCE_TABLES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("schema_name", SqlScalarType::String.nullable(false)) .with_column("table_name", SqlScalarType::String.nullable(false)) .finish(), @@ -2278,7 +2278,11 @@ pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| ontology: Some(Ontology { entity_name: "postgres_source_table", description: "Postgres source table-level details", - links: &[], + links: &[OntologyLink { + name: "describes_source_table", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], }), }); pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2287,7 +2291,7 @@ pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui oid: oid::TABLE_MZ_MYSQL_SOURCE_TABLES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("schema_name", SqlScalarType::String.nullable(false)) .with_column("table_name", SqlScalarType::String.nullable(false)) .finish(), @@ -2310,7 +2314,11 @@ pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui ontology: Some(Ontology { entity_name: "mysql_source_table", description: "MySQL source table-level details", - links: &[], + links: &[OntologyLink { + name: "describes_source_table", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], }), }); pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2319,7 +2327,7 @@ pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(| oid: oid::TABLE_MZ_SQL_SERVER_SOURCE_TABLES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("schema_name", SqlScalarType::String.nullable(false)) .with_column("table_name", SqlScalarType::String.nullable(false)) .finish(), @@ -2342,7 +2350,11 @@ pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(| ontology: Some(Ontology { entity_name: "sql_server_source_table", description: "SQL Server source table-level details", - links: &[], + links: &[OntologyLink { + name: "describes_source_table", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], }), }); pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2351,7 +2363,7 @@ pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui oid: oid::TABLE_MZ_KAFKA_SOURCE_TABLES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("topic", SqlScalarType::String.nullable(false)) .with_column("envelope_type", SqlScalarType::String.nullable(true)) .with_column("key_format", SqlScalarType::String.nullable(true)) @@ -2381,7 +2393,11 @@ pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui ontology: Some(Ontology { entity_name: "kafka_source_table", description: "Kafka source table-level details", - links: &[], + links: &[OntologyLink { + name: "describes_source_table", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], }), }); pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2390,12 +2406,12 @@ pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| Bui oid: oid::TABLE_MZ_OBJECT_DEPENDENCIES_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column( "referenced_object_id", SqlScalarType::String.nullable(false), ) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -2414,12 +2430,12 @@ pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| Bui description: "A dependency edge: one object depends on another", links: &[ OntologyLink { - name: "depends_on", + name: "dependent_object", target: "object", properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one"}"#, }, OntologyLink { - name: "depended_on_by", + name: "referenced_object", target: "object", properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "referenced_object_id", "target_column": "id", "cardinality": "many_to_one"}"#, }, @@ -2433,9 +2449,9 @@ pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| B data_source: IntrospectionType::ComputeDependencies.into(), desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("dependency_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -2454,12 +2470,12 @@ pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| B description: "Dependency edges within compute dataflows", links: &[ OntologyLink { - name: "compute_depends_on", + name: "dependent_compute_object", target: "object", properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one"}"#, }, OntologyLink { - name: "compute_depended_by", + name: "compute_dependency_target", target: "object", properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "dependency_id", "target_column": "id", "cardinality": "many_to_one"}"#, }, @@ -2474,12 +2490,12 @@ pub static MZ_DATABASES: LazyLock = LazyLock::new(|| { oid: oid::MV_MZ_DATABASES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("DatabaseId") + .with_semantic_type(SemanticType::DatabaseId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -2535,14 +2551,14 @@ pub static MZ_SCHEMAS: LazyLock = LazyLock::new(|| { oid: oid::MV_MZ_SCHEMAS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("SchemaId") + .with_semantic_type(SemanticType::SchemaId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("database_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("DatabaseId") + .with_semantic_type(SemanticType::DatabaseId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -2611,14 +2627,14 @@ pub static MZ_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_COLUMNS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) // not a key - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("position", SqlScalarType::UInt64.nullable(false)) .with_column("nullable", SqlScalarType::Bool.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) .with_column("default", SqlScalarType::String.nullable(true)) .with_column("type_oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("type_mod", SqlScalarType::Int32.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -2658,20 +2674,20 @@ pub static MZ_INDEXES: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_INDEXES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("on_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("cluster_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ClusterId") + .with_semantic_type(SemanticType::ClusterId) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column("create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type("SqlDefinition") + .with_semantic_type(SemanticType::SqlDefinition) .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type("RedactedSqlDefinition") + .with_semantic_type(SemanticType::RedactedSqlDefinition) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -2727,7 +2743,7 @@ pub static MZ_INDEX_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTa oid: oid::TABLE_MZ_INDEX_COLUMNS_OID, desc: RelationDesc::builder() .with_column("index_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("index_position", SqlScalarType::UInt64.nullable(false)) .with_column("on_position", SqlScalarType::UInt64.nullable(true)) .with_column("on_expression", SqlScalarType::String.nullable(true)) @@ -2773,24 +2789,24 @@ pub static MZ_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_TABLES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("SchemaId") + .with_semantic_type(SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) .with_column("create_sql", SqlScalarType::String.nullable(true)) - .with_semantic_type("SqlDefinition") + .with_semantic_type(SemanticType::SqlDefinition) .with_column("redacted_create_sql", SqlScalarType::String.nullable(true)) - .with_semantic_type("RedactedSqlDefinition") + .with_semantic_type(SemanticType::RedactedSqlDefinition) .with_column("source_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -2849,24 +2865,24 @@ pub static MZ_CONNECTIONS: LazyLock = LazyLock::new(|| oid: oid::MV_MZ_CONNECTIONS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("SchemaId") + .with_semantic_type(SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) - .with_semantic_type("ConnectionType") + .with_semantic_type(SemanticType::ConnectionType) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) .with_column("create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type("SqlDefinition") + .with_semantic_type(SemanticType::SqlDefinition) .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type("RedactedSqlDefinition") + .with_semantic_type(SemanticType::RedactedSqlDefinition) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -2950,7 +2966,7 @@ pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock = LazyLock::new(|| oid: oid::TABLE_MZ_SSH_TUNNEL_CONNECTIONS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("public_key_1", SqlScalarType::String.nullable(false)) .with_column("public_key_2", SqlScalarType::String.nullable(false)) .finish(), @@ -2983,32 +2999,32 @@ pub static MZ_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_SOURCES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("SchemaId") + .with_semantic_type(SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) - .with_semantic_type("SourceType") + .with_semantic_type(SemanticType::SourceType) .with_column("connection_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("size", SqlScalarType::String.nullable(true)) .with_column("envelope_type", SqlScalarType::String.nullable(true)) .with_column("key_format", SqlScalarType::String.nullable(true)) .with_column("value_format", SqlScalarType::String.nullable(true)) .with_column("cluster_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("ClusterId") + .with_semantic_type(SemanticType::ClusterId) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) .with_column("create_sql", SqlScalarType::String.nullable(true)) - .with_semantic_type("SqlDefinition") + .with_semantic_type(SemanticType::SqlDefinition) .with_column("redacted_create_sql", SqlScalarType::String.nullable(true)) - .with_semantic_type("RedactedSqlDefinition") + .with_semantic_type(SemanticType::RedactedSqlDefinition) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3092,15 +3108,15 @@ pub static MZ_SINKS: LazyLock = LazyLock::new(|| { oid: oid::TABLE_MZ_SINKS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("SchemaId") + .with_semantic_type(SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) .with_column("connection_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("size", SqlScalarType::String.nullable(true)) .with_column("envelope_type", SqlScalarType::String.nullable(true)) // This `format` column is deprecated and replaced by the `key_format` and `value_format` columns @@ -3109,13 +3125,13 @@ pub static MZ_SINKS: LazyLock = LazyLock::new(|| { .with_column("key_format", SqlScalarType::String.nullable(true)) .with_column("value_format", SqlScalarType::String.nullable(true)) .with_column("cluster_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ClusterId") + .with_semantic_type(SemanticType::ClusterId) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column("create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type("SqlDefinition") + .with_semantic_type(SemanticType::SqlDefinition) .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type("RedactedSqlDefinition") + .with_semantic_type(SemanticType::RedactedSqlDefinition) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3184,6 +3200,11 @@ pub static MZ_SINKS: LazyLock = LazyLock::new(|| { target: "cluster", properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, }, + OntologyLink { + name: "uses_connection", + target: "connection", + properties_json: r#"{"kind": "foreign_key", "source_column": "connection_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + }, ], }), } @@ -3194,24 +3215,24 @@ pub static MZ_VIEWS: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_VIEWS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("SchemaId") + .with_semantic_type(SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("definition", SqlScalarType::String.nullable(false)) - .with_semantic_type("SqlDefinition") + .with_semantic_type(SemanticType::SqlDefinition) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) .with_column("create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type("SqlDefinition") + .with_semantic_type(SemanticType::SqlDefinition) .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type("RedactedSqlDefinition") + .with_semantic_type(SemanticType::RedactedSqlDefinition) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3262,26 +3283,26 @@ pub static MZ_MATERIALIZED_VIEWS: LazyLock = LazyLock:: oid: oid::MV_MZ_MATERIALIZED_VIEWS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("SchemaId") + .with_semantic_type(SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("cluster_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ClusterId") + .with_semantic_type(SemanticType::ClusterId) .with_column("definition", SqlScalarType::String.nullable(false)) - .with_semantic_type("SqlDefinition") + .with_semantic_type(SemanticType::SqlDefinition) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) .with_column("create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type("SqlDefinition") + .with_semantic_type(SemanticType::SqlDefinition) .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type("RedactedSqlDefinition") + .with_semantic_type(SemanticType::RedactedSqlDefinition) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3452,23 +3473,23 @@ pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("SchemaId") + .with_semantic_type(SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("category", SqlScalarType::String.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) .with_column("create_sql", SqlScalarType::String.nullable(true)) - .with_semantic_type("SqlDefinition") + .with_semantic_type(SemanticType::SqlDefinition) .with_column("redacted_create_sql", SqlScalarType::String.nullable(true)) - .with_semantic_type("RedactedSqlDefinition") + .with_semantic_type(SemanticType::RedactedSqlDefinition) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3519,16 +3540,16 @@ pub static MZ_NETWORK_POLICIES: LazyLock = LazyLock::ne oid: oid::MV_MZ_NETWORK_POLICIES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("NetworkPolicyId") + .with_semantic_type(SemanticType::NetworkPolicyId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_key(vec![0]) .with_key(vec![4]) .finish(), @@ -3640,11 +3661,11 @@ pub static MZ_TYPE_PG_METADATA: LazyLock = LazyLock::new(|| Builti oid: oid::TABLE_MZ_TYPE_PG_METADATA_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("typinput", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("typreceive", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, @@ -3657,9 +3678,9 @@ pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| BuiltinTabl oid: oid::TABLE_MZ_ARRAY_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("element_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .finish(), column_comments: BTreeMap::from_iter([ ("id", "The ID of the array type."), @@ -3672,7 +3693,7 @@ pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| BuiltinTabl description: "An array type with its element type", links: &[ OntologyLink { - name: "is_subtype_of", + name: "detail_of", target: "type", properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, }, @@ -3690,7 +3711,7 @@ pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinTable oid: oid::TABLE_MZ_BASE_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .finish(), column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]), is_retained_metrics_object: false, @@ -3707,9 +3728,9 @@ pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable oid: oid::TABLE_MZ_LIST_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("element_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column( "element_modifiers", SqlScalarType::List { @@ -3734,7 +3755,7 @@ pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable description: "A list type with its element type", links: &[ OntologyLink { - name: "is_subtype_of", + name: "detail_of", target: "type", properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, }, @@ -3752,11 +3773,11 @@ pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable oid: oid::TABLE_MZ_MAP_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("key_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("value_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column( "key_modifiers", SqlScalarType::List { @@ -3794,7 +3815,7 @@ pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable description: "A map type with its key and value types", links: &[ OntologyLink { - name: "is_subtype_of", + name: "detail_of", target: "type", properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, }, @@ -3817,9 +3838,9 @@ pub static MZ_ROLES: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_ROLES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("inherit", SqlScalarType::Bool.nullable(false)) .with_column("rolcanlogin", SqlScalarType::Bool.nullable(true)) @@ -3854,11 +3875,11 @@ pub static MZ_ROLE_MEMBERS: LazyLock = LazyLock::new(|| oid: oid::MV_MZ_ROLE_MEMBERS_OID, desc: RelationDesc::builder() .with_column("role_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column("member", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column("grantor", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -3892,16 +3913,16 @@ WHERE data->>'kind' = 'Role'", is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], ontology: Some(Ontology { - entity_name: "role_member", + entity_name: "role_membership", description: "A membership grant: one role is a member of another role", links: &[ OntologyLink { - name: "member_of_role", + name: "group_role", target: "role", properties_json: r#"{"kind": "foreign_key", "source_column": "role_id", "target_column": "id", "cardinality": "many_to_one"}"#, }, OntologyLink { - name: "has_member", + name: "member_role", target: "role", properties_json: r#"{"kind": "foreign_key", "source_column": "member", "target_column": "id", "cardinality": "many_to_one"}"#, }, @@ -3921,7 +3942,7 @@ pub static MZ_ROLE_PARAMETERS: LazyLock = LazyLock::new(|| Builtin oid: oid::TABLE_MZ_ROLE_PARAMETERS_OID, desc: RelationDesc::builder() .with_column("role_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column("parameter_name", SqlScalarType::String.nullable(false)) .with_column("parameter_value", SqlScalarType::String.nullable(false)) .finish(), @@ -3945,7 +3966,7 @@ pub static MZ_ROLE_PARAMETERS: LazyLock = LazyLock::new(|| Builtin entity_name: "role_parameter", description: "A session parameter default set for a role", links: &[OntologyLink { - name: "parameter_of", + name: "default_parameter_setting_of", target: "role", properties_json: r#"{"kind": "foreign_key", "source_column": "role_id", "target_column": "id", "cardinality": "many_to_one"}"#, }], @@ -3957,9 +3978,9 @@ pub static MZ_ROLE_AUTH: LazyLock = LazyLock::new(|| BuiltinTable oid: oid::TABLE_MZ_ROLE_AUTH_OID, desc: RelationDesc::builder() .with_column("role_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column("role_oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("password_hash", SqlScalarType::String.nullable(true)) .with_column( "updated_at", @@ -3991,7 +4012,7 @@ pub static MZ_PSEUDO_TYPES: LazyLock = LazyLock::new(|| BuiltinTab oid: oid::TABLE_MZ_PSEUDO_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .finish(), column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]), is_retained_metrics_object: false, @@ -4009,11 +4030,11 @@ pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { oid: oid::TABLE_MZ_FUNCTIONS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) // not a key! - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("SchemaId") + .with_semantic_type(SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column( "argument_type_ids", @@ -4023,12 +4044,12 @@ pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { "variadic_argument_type_id", SqlScalarType::String.nullable(true), ) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("return_type_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("returns_set", SqlScalarType::Bool.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .finish(), column_comments: BTreeMap::from_iter([ ("id", "Materialize's unique ID for the function."), @@ -4080,6 +4101,11 @@ pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { target: "type", properties_json: r#"{"kind": "foreign_key", "source_column": "return_type_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, }, + OntologyLink { + name: "has_variadic_arg_type", + target: "type", + properties_json: r#"{"kind": "foreign_key", "source_column": "variadic_argument_type_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + }, ], }), } @@ -4090,14 +4116,14 @@ pub static MZ_OPERATORS: LazyLock = LazyLock::new(|| BuiltinTable oid: oid::TABLE_MZ_OPERATORS_OID, desc: RelationDesc::builder() .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("name", SqlScalarType::String.nullable(false)) .with_column( "argument_type_ids", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), ) .with_column("return_type_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, @@ -4105,7 +4131,11 @@ pub static MZ_OPERATORS: LazyLock = LazyLock::new(|| BuiltinTable ontology: Some(Ontology { entity_name: "operator", description: "A built-in SQL operator", - links: &[], + links: &[OntologyLink { + name: "returns_type", + target: "type", + properties_json: r#"{"kind": "foreign_key", "source_column": "return_type_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + }], }), }); pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4114,7 +4144,7 @@ pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinTable oid: oid::TABLE_MZ_AGGREGATES_OID, desc: RelationDesc::builder() .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("agg_kind", SqlScalarType::String.nullable(false)) .with_column("agg_num_direct_args", SqlScalarType::Int16.nullable(false)) .finish(), @@ -4134,10 +4164,10 @@ pub static MZ_CLUSTERS: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_CLUSTERS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ClusterId") + .with_semantic_type(SemanticType::ClusterId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -4228,7 +4258,7 @@ pub static MZ_CLUSTER_WORKLOAD_CLASSES: LazyLock = oid: oid::MV_MZ_CLUSTER_WORKLOAD_CLASSES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ClusterId") + .with_semantic_type(SemanticType::ClusterId) .with_column("workload_class", SqlScalarType::String.nullable(true)) .with_key(vec![0]) .finish(), @@ -4265,7 +4295,7 @@ pub static MZ_CLUSTER_SCHEDULES: LazyLock = LazyLock::new(|| Built oid: oid::TABLE_MZ_CLUSTER_SCHEDULES_OID, desc: RelationDesc::builder() .with_column("cluster_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ClusterId") + .with_semantic_type(SemanticType::ClusterId) .with_column("type", SqlScalarType::String.nullable(false)) .with_column( "refresh_hydration_time_estimate", @@ -4299,14 +4329,14 @@ pub static MZ_SECRETS: LazyLock = LazyLock::new(|| { oid: oid::MV_MZ_SECRETS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("SchemaId") + .with_semantic_type(SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -4374,16 +4404,16 @@ pub static MZ_CLUSTER_REPLICAS: LazyLock = LazyLock::new(|| Builti oid: oid::TABLE_MZ_CLUSTER_REPLICAS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("cluster_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ClusterId") + .with_semantic_type(SemanticType::ClusterId) .with_column("size", SqlScalarType::String.nullable(true)) // `NULL` for un-orchestrated clusters and for replicas where the user // hasn't specified them. .with_column("availability_zone", SqlScalarType::String.nullable(true)) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column("disk", SqlScalarType::Bool.nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ @@ -4467,7 +4497,7 @@ pub static MZ_PENDING_CLUSTER_REPLICAS: LazyLock = oid: oid::MV_MZ_PENDING_CLUSTER_REPLICAS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([( @@ -4532,7 +4562,7 @@ pub static MZ_CLUSTER_REPLICA_STATUSES: LazyLock = LazyLock::new(|| oid: oid::VIEW_MZ_CLUSTER_REPLICA_STATUSES_OID, desc: RelationDesc::builder() .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("reason", SqlScalarType::String.nullable(true)) @@ -4540,7 +4570,7 @@ pub static MZ_CLUSTER_REPLICA_STATUSES: LazyLock = LazyLock::new(|| "updated_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -4598,14 +4628,14 @@ pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock = LazyLock::new(|| B .with_column("workers", SqlScalarType::UInt64.nullable(false)) .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(false)) .with_column("memory_bytes", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type("ByteCount") + .with_semantic_type(SemanticType::ByteCount) .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true)) - .with_semantic_type("ByteCount") + .with_semantic_type(SemanticType::ByteCount) .with_column( "credits_per_hour", SqlScalarType::Numeric { max_scale: None }.nullable(false), ) - .with_semantic_type("CreditRate") + .with_semantic_type(SemanticType::CreditRate) .finish(), column_comments: BTreeMap::from_iter([ ("size", "The human-readable replica size."), @@ -4645,14 +4675,14 @@ pub static MZ_AUDIT_EVENTS: LazyLock = LazyLock::new(|| BuiltinTab .with_column("id", SqlScalarType::UInt64.nullable(false)) .with_column("event_type", SqlScalarType::String.nullable(false)) .with_column("object_type", SqlScalarType::String.nullable(false)) - .with_semantic_type("ObjectType") + .with_semantic_type(SemanticType::ObjectType) .with_column("details", SqlScalarType::Jsonb.nullable(false)) .with_column("user", SqlScalarType::String.nullable(true)) .with_column( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -4727,11 +4757,18 @@ pub static MZ_SOURCE_STATUS_HISTORY: LazyLock = LazyLock::new(|| ontology: Some(Ontology { entity_name: "source_status_history", description: "Historical source status events", - links: &[OntologyLink { - name: "status_history_of_source", - target: "source", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "source_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + links: &[ + OntologyLink { + name: "status_history_of_source", + target: "source", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "source_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "on_replica", + target: "replica", + properties_json: r#"{"kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + }, + ], }), }); @@ -4768,7 +4805,7 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUSES: LazyLock = LazyL oid: oid::VIEW_MZ_AWS_PRIVATELINK_CONNECTION_STATUSES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column( "last_status_change_at", @@ -4943,7 +4980,7 @@ pub static MZ_RECENT_SQL_TEXT: LazyLock = LazyLock::new(|| { desc: RelationDesc::builder() .with_column("sql_hash", SqlScalarType::Bytes.nullable(false)) .with_column("sql", SqlScalarType::String.nullable(false)) - .with_semantic_type("SqlDefinition") + .with_semantic_type(SemanticType::SqlDefinition) .with_column("redacted_sql", SqlScalarType::String.nullable(false)) .with_key(vec![0, 1, 2]) .finish(), @@ -5129,7 +5166,7 @@ pub static MZ_RECENT_ACTIVITY_LOG: LazyLock = LazyLock::new(|| Buil .with_column("execution_id", SqlScalarType::Uuid.nullable(false)) .with_column("sample_rate", SqlScalarType::Float64.nullable(false)) .with_column("cluster_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("ClusterId") + .with_semantic_type(SemanticType::ClusterId) .with_column("application_name", SqlScalarType::String.nullable(false)) .with_column("cluster_name", SqlScalarType::String.nullable(true)) .with_column("database_name", SqlScalarType::String.nullable(false)) @@ -5146,9 +5183,9 @@ pub static MZ_RECENT_ACTIVITY_LOG: LazyLock = LazyLock::new(|| Buil SqlScalarType::String.nullable(false), ) .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true)) - .with_semantic_type("MzTimestamp") + .with_semantic_type(SemanticType::MzTimestamp) .with_column("transient_index_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column( "params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), @@ -5158,12 +5195,12 @@ pub static MZ_RECENT_ACTIVITY_LOG: LazyLock = LazyLock::new(|| Buil "began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .with_column( "finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .with_column("finished_status", SqlScalarType::String.nullable(true)) .with_column("error_message", SqlScalarType::String.nullable(true)) .with_column("result_size", SqlScalarType::Int64.nullable(true)) @@ -5181,21 +5218,21 @@ pub static MZ_RECENT_ACTIVITY_LOG: LazyLock = LazyLock::new(|| Buil "prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .with_column("statement_type", SqlScalarType::String.nullable(true)) .with_column("throttled_count", SqlScalarType::UInt64.nullable(false)) .with_column( "connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .with_column( "initial_application_name", SqlScalarType::String.nullable(false), ) .with_column("authenticated_user", SqlScalarType::String.nullable(false)) .with_column("sql", SqlScalarType::String.nullable(false)) - .with_semantic_type("SqlDefinition") + .with_semantic_type(SemanticType::SqlDefinition) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -5328,11 +5365,18 @@ WHERE mralt.sql_hash = mrst.sql_hash", ontology: Some(Ontology { entity_name: "activity_log", description: "Recent query activity with execution stats", - links: &[OntologyLink { - name: "session_on_cluster", - target: "cluster", - properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + links: &[ + OntologyLink { + name: "session_on_cluster", + target: "cluster", + properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "used_transient_index", + target: "object", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "transient_index_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + }, + ], }), }); @@ -5438,15 +5482,15 @@ pub static MZ_SOURCE_STATUSES: LazyLock = LazyLock::new(|| BuiltinV oid: oid::VIEW_MZ_SOURCE_STATUSES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) - .with_semantic_type("SourceType") + .with_semantic_type(SemanticType::SourceType) .with_column( "last_status_change_at", SqlScalarType::TimestampTz { precision: None }.nullable(true), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) .with_column("details", SqlScalarType::Jsonb.nullable(true)) @@ -5662,11 +5706,18 @@ pub static MZ_SINK_STATUS_HISTORY: LazyLock = LazyLock::new(|| Bu ontology: Some(Ontology { entity_name: "sink_status_history", description: "Historical sink status events", - links: &[OntologyLink { - name: "status_history_of_sink", - target: "sink", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "sink_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + links: &[ + OntologyLink { + name: "status_history_of_sink", + target: "sink", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "sink_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "on_replica", + target: "replica", + properties_json: r#"{"kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + }, + ], }), }); @@ -5676,14 +5727,14 @@ pub static MZ_SINK_STATUSES: LazyLock = LazyLock::new(|| BuiltinVie oid: oid::VIEW_MZ_SINK_STATUSES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) .with_column( "last_status_change_at", SqlScalarType::TimestampTz { precision: None }.nullable(true), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) .with_column("details", SqlScalarType::Jsonb.nullable(true)) @@ -5800,14 +5851,14 @@ pub static MZ_STORAGE_USAGE_BY_SHARD: LazyLock = LazyLock::new(|| desc: RelationDesc::builder() .with_column("id", SqlScalarType::UInt64.nullable(false)) .with_column("shard_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("ShardId") + .with_semantic_type(SemanticType::ShardId) .with_column("size_bytes", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type("ByteCount") + .with_semantic_type(SemanticType::ByteCount) .with_column( "collection_timestamp", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, @@ -5852,7 +5903,7 @@ pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock = LazyLock::ne oid: oid::TABLE_MZ_AWS_PRIVATELINK_CONNECTIONS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("principal", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -5998,17 +6049,17 @@ pub static MZ_CLUSTER_REPLICA_METRICS: LazyLock = LazyLock::new(|| oid: oid::VIEW_MZ_CLUSTER_REPLICA_METRICS_OID, desc: RelationDesc::builder() .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(true)) .with_column("memory_bytes", SqlScalarType::UInt64.nullable(true)) - .with_semantic_type("ByteCount") + .with_semantic_type(SemanticType::ByteCount) .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true)) - .with_semantic_type("ByteCount") + .with_semantic_type(SemanticType::ByteCount) .with_column("heap_bytes", SqlScalarType::UInt64.nullable(true)) - .with_semantic_type("ByteCount") + .with_semantic_type(SemanticType::ByteCount) .with_column("heap_limit", SqlScalarType::UInt64.nullable(true)) - .with_semantic_type("ByteCount") + .with_semantic_type(SemanticType::ByteCount) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -6059,11 +6110,11 @@ pub static MZ_CLUSTER_REPLICA_FRONTIERS: LazyLock = data_source: IntrospectionType::ReplicaFrontiers.into(), desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true)) - .with_semantic_type("MzTimestamp") + .with_semantic_type(SemanticType::MzTimestamp) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -6097,11 +6148,11 @@ pub static MZ_FRONTIERS: LazyLock = LazyLock::new(|| BuiltinSourc data_source: IntrospectionType::Frontiers.into(), desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("read_frontier", SqlScalarType::MzTimestamp.nullable(true)) - .with_semantic_type("MzTimestamp") + .with_semantic_type(SemanticType::MzTimestamp) .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true)) - .with_semantic_type("MzTimestamp") + .with_semantic_type(SemanticType::MzTimestamp) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -6137,9 +6188,9 @@ pub static MZ_GLOBAL_FRONTIERS: LazyLock = LazyLock::new(|| Builtin oid: oid::VIEW_MZ_GLOBAL_FRONTIERS_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) - .with_semantic_type("MzTimestamp") + .with_semantic_type(SemanticType::MzTimestamp) .finish(), column_comments: BTreeMap::new(), sql: " @@ -6179,11 +6230,18 @@ pub static MZ_WALLCLOCK_LAG_HISTORY: LazyLock = LazyLock::new(|| ontology: Some(Ontology { entity_name: "wallclock_lag_history", description: "Historical wallclock lag per object", - links: &[OntologyLink { - name: "measures_lag_of", - target: "object", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "measures", "source_column": "object_id", "target_column": "id", "metric": "wallclock_lag"}"#, - }], + links: &[ + OntologyLink { + name: "measures_lag_of", + target: "object", + properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "measures", "source_column": "object_id", "target_column": "id", "metric": "wallclock_lag"}"#, + }, + OntologyLink { + name: "on_replica", + target: "replica", + properties_json: r#"{"kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + }, + ], }), }); @@ -6193,13 +6251,13 @@ pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTORY: LazyLock = LazyLock::ne oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_HISTORY_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("lag", SqlScalarType::Interval.nullable(true)) .with_column( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .with_key(vec![0, 2]) .finish(), column_comments: BTreeMap::from_iter([ @@ -6246,7 +6304,7 @@ pub static MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY: LazyLock = LazyL oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("lag", SqlScalarType::Interval.nullable(true)) .with_column( "occurred_at", @@ -6283,7 +6341,7 @@ pub static MZ_WALLCLOCK_GLOBAL_LAG: LazyLock = LazyLock::new(|| Bui oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("lag", SqlScalarType::Interval.nullable(true)) .with_key(vec![0]) .finish(), @@ -6401,10 +6459,10 @@ pub static MZ_SUBSCRIPTIONS: LazyLock = LazyLock::new(|| BuiltinTa oid: oid::TABLE_MZ_SUBSCRIPTIONS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("session_id", SqlScalarType::Uuid.nullable(false)) .with_column("cluster_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ClusterId") + .with_semantic_type(SemanticType::ClusterId) .with_column( "created_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), @@ -6454,7 +6512,7 @@ pub static MZ_SESSIONS: LazyLock = LazyLock::new(|| BuiltinTable { .with_column("id", SqlScalarType::Uuid.nullable(false)) .with_column("connection_id", SqlScalarType::UInt32.nullable(false)) .with_column("role_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column("client_ip", SqlScalarType::String.nullable(true)) .with_column( "connected_at", @@ -6495,15 +6553,15 @@ pub static MZ_DEFAULT_PRIVILEGES: LazyLock = LazyLock::new(|| Buil oid: oid::TABLE_MZ_DEFAULT_PRIVILEGES_OID, desc: RelationDesc::builder() .with_column("role_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column("database_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("DatabaseId") + .with_semantic_type(SemanticType::DatabaseId) .with_column("schema_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("SchemaId") + .with_semantic_type(SemanticType::SchemaId) .with_column("object_type", SqlScalarType::String.nullable(false)) - .with_semantic_type("ObjectType") + .with_semantic_type(SemanticType::ObjectType) .with_column("grantee", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column("privileges", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -6550,6 +6608,11 @@ pub static MZ_DEFAULT_PRIVILEGES: LazyLock = LazyLock::new(|| Buil target: "schema", properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, }, + OntologyLink { + name: "default_priv_granted_to", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "grantee", "target_column": "id", "cardinality": "many_to_one"}"#, + }, ], }), }); @@ -6580,9 +6643,9 @@ pub static MZ_COMMENTS: LazyLock = LazyLock::new(|| BuiltinTable { oid: oid::TABLE_MZ_COMMENTS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("object_type", SqlScalarType::String.nullable(false)) - .with_semantic_type("ObjectType") + .with_semantic_type(SemanticType::ObjectType) .with_column("object_sub_id", SqlScalarType::Int32.nullable(true)) .with_column("comment", SqlScalarType::String.nullable(false)) .finish(), @@ -6620,7 +6683,7 @@ pub static MZ_SOURCE_REFERENCES: LazyLock = LazyLock::new(|| Built oid: oid::TABLE_MZ_SOURCE_REFERENCES_OID, desc: RelationDesc::builder() .with_column("source_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("namespace", SqlScalarType::String.nullable(true)) .with_column("name", SqlScalarType::String.nullable(false)) .with_column( @@ -6648,7 +6711,7 @@ pub static MZ_WEBHOOKS_SOURCES: LazyLock = LazyLock::new(|| Builti oid: oid::TABLE_MZ_WEBHOOK_SOURCES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("url", SqlScalarType::String.nullable(false)) .finish(), @@ -6679,7 +6742,7 @@ pub static MZ_HISTORY_RETENTION_STRATEGIES: LazyLock = LazyLock::n oid: oid::TABLE_MZ_HISTORY_RETENTION_STRATEGIES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("strategy", SqlScalarType::String.nullable(false)) .with_column("value", SqlScalarType::Jsonb.nullable(false)) .finish(), @@ -6710,7 +6773,7 @@ pub static MZ_LICENSE_KEYS: LazyLock = LazyLock::new(|| BuiltinTab oid: oid::TABLE_MZ_LICENSE_KEYS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("organization", SqlScalarType::String.nullable(false)) .with_column("environment_id", SqlScalarType::String.nullable(false)) .with_column( @@ -6756,7 +6819,7 @@ pub static MZ_REPLACEMENTS: LazyLock = LazyLock::new(|| BuiltinTab oid: oid::TABLE_MZ_REPLACEMENTS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("target_id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -6810,9 +6873,9 @@ pub static MZ_STORAGE_SHARDS: LazyLock = LazyLock::new(|| Builtin data_source: IntrospectionType::ShardMapping.into(), desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("shard_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ShardId") + .with_semantic_type(SemanticType::ShardId) .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, @@ -6834,14 +6897,14 @@ pub static MZ_STORAGE_USAGE: LazyLock = LazyLock::new(|| BuiltinVie oid: oid::VIEW_MZ_STORAGE_USAGE_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("size_bytes", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type("ByteCount") + .with_semantic_type(SemanticType::ByteCount) .with_column( "collection_timestamp", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .with_key(vec![0, 2]) .finish(), column_comments: BTreeMap::from_iter([ @@ -6886,9 +6949,9 @@ pub static MZ_RECENT_STORAGE_USAGE: LazyLock = LazyLock::new(|| { oid: oid::VIEW_MZ_RECENT_STORAGE_USAGE_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("size_bytes", SqlScalarType::UInt64.nullable(true)) - .with_semantic_type("ByteCount") + .with_semantic_type(SemanticType::ByteCount) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -6948,18 +7011,18 @@ pub static MZ_RELATIONS: LazyLock = LazyLock::new(|| { oid: oid::VIEW_MZ_RELATIONS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("SchemaId") + .with_semantic_type(SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) - .with_semantic_type("ObjectType") + .with_semantic_type(SemanticType::ObjectType) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column("cluster_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("ClusterId") + .with_semantic_type(SemanticType::ClusterId) .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -7055,18 +7118,18 @@ pub static MZ_OBJECTS: LazyLock = LazyLock::new(|| { oid: oid::VIEW_MZ_OBJECTS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type("OID") + .with_semantic_type(SemanticType::OID) .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("SchemaId") + .with_semantic_type(SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) - .with_semantic_type("ObjectType") + .with_semantic_type(SemanticType::ObjectType) .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("RoleId") + .with_semantic_type(SemanticType::RoleId) .with_column("cluster_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("ClusterId") + .with_semantic_type(SemanticType::ClusterId) .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ @@ -7116,18 +7179,18 @@ pub static MZ_OBJECT_FULLY_QUALIFIED_NAMES: LazyLock = LazyLock::ne oid: oid::VIEW_MZ_OBJECT_FULLY_QUALIFIED_NAMES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("object_type", SqlScalarType::String.nullable(false)) - .with_semantic_type("ObjectType") + .with_semantic_type(SemanticType::ObjectType) .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("SchemaId") + .with_semantic_type(SemanticType::SchemaId) .with_column("schema_name", SqlScalarType::String.nullable(false)) .with_column("database_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("DatabaseId") + .with_semantic_type(SemanticType::DatabaseId) .with_column("database_name", SqlScalarType::String.nullable(true)) .with_column("cluster_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("ClusterId") + .with_semantic_type(SemanticType::ClusterId) .finish(), column_comments: BTreeMap::from_iter([ ("id", "Materialize's unique ID for the object."), @@ -7184,9 +7247,8 @@ pub static MZ_OBJECT_GLOBAL_IDS: LazyLock = LazyLock::new(|| Built oid: oid::VIEW_MZ_OBJECT_GLOBAL_IDS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("global_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") .finish(), column_comments: BTreeMap::from_iter([ ( @@ -7215,10 +7277,10 @@ pub static MZ_OBJECT_LIFETIMES: LazyLock = LazyLock::new(|| Builtin oid: oid::VIEW_MZ_OBJECT_LIFETIMES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(true)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("previous_id", SqlScalarType::String.nullable(true)) .with_column("object_type", SqlScalarType::String.nullable(false)) - .with_semantic_type("ObjectType") + .with_semantic_type(SemanticType::ObjectType) .with_column("event_type", SqlScalarType::String.nullable(false)) .with_column( "occurred_at", @@ -7271,7 +7333,7 @@ pub static MZ_OBJECT_HISTORY: LazyLock = LazyLock::new(|| BuiltinVi oid: oid::VIEW_MZ_OBJECT_HISTORY_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(true)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("cluster_id", SqlScalarType::String.nullable(true)) .with_column("object_type", SqlScalarType::String.nullable(false)) .with_column( @@ -7526,7 +7588,7 @@ pub static MZ_DATAFLOW_GLOBAL_IDS: LazyLock = LazyLock::new(|| Buil desc: RelationDesc::builder() .with_column("id", SqlScalarType::UInt64.nullable(false)) .with_column("global_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -7548,7 +7610,7 @@ pub static MZ_MAPPABLE_OBJECTS: LazyLock = LazyLock::new(|| Builtin desc: RelationDesc::builder() .with_column("name", SqlScalarType::String.nullable(false)) .with_column("global_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -7578,7 +7640,7 @@ pub static MZ_LIR_MAPPING: LazyLock = LazyLock::new(|| BuiltinView oid: oid::VIEW_MZ_LIR_MAPPING_OID, desc: RelationDesc::builder() .with_column("global_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("lir_id", SqlScalarType::UInt64.nullable(false)) .with_column("operator", SqlScalarType::String.nullable(false)) .with_column("parent_lir_id", SqlScalarType::UInt64.nullable(true)) @@ -7700,12 +7762,12 @@ pub static MZ_OBJECT_TRANSITIVE_DEPENDENCIES: LazyLock = LazyLock:: oid: oid::VIEW_MZ_OBJECT_TRANSITIVE_DEPENDENCIES_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column( "referenced_object_id", SqlScalarType::String.nullable(false), ) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -7732,12 +7794,12 @@ SELECT object_id, referenced_object_id FROM reach;", description: "Transitive closure of object dependencies — all direct and indirect dependencies", links: &[ OntologyLink { - name: "transitively_depends_on", + name: "transitively_dependent_object", target: "object", properties_json: r#"{"kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one", "source_id_type": "CatalogItemId"}"#, }, OntologyLink { - name: "transitively_depended_on_by", + name: "transitively_referenced_object", target: "object", properties_json: r#"{"kind": "foreign_key", "source_column": "referenced_object_id", "target_column": "id", "cardinality": "many_to_one", "source_id_type": "CatalogItemId"}"#, }, @@ -7752,7 +7814,7 @@ pub static MZ_COMPUTE_EXPORTS: LazyLock = LazyLock::new(|| BuiltinV oid: oid::VIEW_MZ_COMPUTE_EXPORTS_OID, desc: RelationDesc::builder() .with_column("export_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false)) .with_key(vec![0]) .finish(), @@ -7795,9 +7857,9 @@ pub static MZ_COMPUTE_FRONTIERS: LazyLock = LazyLock::new(|| Builti oid: oid::VIEW_MZ_COMPUTE_FRONTIERS_OID, desc: RelationDesc::builder() .with_column("export_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) - .with_semantic_type("MzTimestamp") + .with_semantic_type(SemanticType::MzTimestamp) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -7958,11 +8020,11 @@ pub static MZ_COMPUTE_IMPORT_FRONTIERS: LazyLock = LazyLock::new(|| oid: oid::VIEW_MZ_COMPUTE_IMPORT_FRONTIERS_OID, desc: RelationDesc::builder() .with_column("export_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("import_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) - .with_semantic_type("MzTimestamp") + .with_semantic_type(SemanticType::MzTimestamp) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -9710,7 +9772,7 @@ pub static MZ_COMPUTE_ERROR_COUNTS: LazyLock = LazyLock::new(|| Bui oid: oid::VIEW_MZ_COMPUTE_ERROR_COUNTS_OID, desc: RelationDesc::builder() .with_column("export_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column( "count", SqlScalarType::Numeric { @@ -9755,9 +9817,9 @@ pub static MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED: LazyLock = oid: oid::SOURCE_MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED_OID, desc: RelationDesc::builder() .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column( "count", SqlScalarType::Numeric { max_scale: None }.nullable(false), @@ -9776,9 +9838,9 @@ pub static MZ_COMPUTE_HYDRATION_TIMES: LazyLock = LazyLock::new(| oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_TIMES_OID, desc: RelationDesc::builder() .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("time_ns", SqlScalarType::UInt64.nullable(true)) .finish(), data_source: IntrospectionType::ComputeHydrationTimes.into(), @@ -9808,9 +9870,9 @@ pub static MZ_COMPUTE_HYDRATION_STATUSES: LazyLock = LazyLock::new( oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_STATUSES_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_column("hydrated", SqlScalarType::Bool.nullable(false)) .with_column("hydration_time", SqlScalarType::Interval.nullable(true)) .finish(), @@ -9871,9 +9933,9 @@ pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES: LazyLock = Laz oid: oid::SOURCE_MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_OID, desc: RelationDesc::builder() .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column( "physical_plan_node_id", SqlScalarType::UInt64.nullable(false), @@ -10050,10 +10112,10 @@ pub static MZ_ACTIVE_PEEKS: LazyLock = LazyLock::new(|| BuiltinView desc: RelationDesc::builder() .with_column("id", SqlScalarType::Uuid.nullable(false)) .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("type", SqlScalarType::String.nullable(false)) .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) - .with_semantic_type("MzTimestamp") + .with_semantic_type(SemanticType::MzTimestamp) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -10426,7 +10488,7 @@ pub static MZ_CLUSTER_REPLICA_UTILIZATION: LazyLock = LazyLock::new oid: oid::VIEW_MZ_CLUSTER_REPLICA_UTILIZATION_OID, desc: RelationDesc::builder() .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("cpu_percent", SqlScalarType::Float64.nullable(true)) .with_column("memory_percent", SqlScalarType::Float64.nullable(true)) @@ -13807,7 +13869,7 @@ pub static MZ_CLUSTER_REPLICA_NAME_HISTORY: LazyLock = LazyLock::ne SqlScalarType::TimestampTz { precision: None }.nullable(true), ) .with_column("id", SqlScalarType::String.nullable(true)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("previous_name", SqlScalarType::String.nullable(true)) .with_column("new_name", SqlScalarType::String.nullable(true)) .finish(), @@ -13875,9 +13937,9 @@ pub static MZ_HYDRATION_STATUSES: LazyLock = LazyLock::new(|| Built oid: oid::VIEW_MZ_HYDRATION_STATUSES_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("replica_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_column("hydrated", SqlScalarType::Bool.nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ @@ -13987,9 +14049,9 @@ pub static MZ_MATERIALIZATION_DEPENDENCIES: LazyLock = LazyLock::ne oid: oid::VIEW_MZ_MATERIALIZATION_DEPENDENCIES_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("dependency_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -14013,11 +14075,18 @@ JOIN mz_catalog.mz_relations r ON (r.id = d.referenced_object_id)", ontology: Some(Ontology { entity_name: "materialization_dep", description: "Dependencies between materializations", - links: &[OntologyLink { - name: "materialization_depends_on", - target: "object", - properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "depends_on", "source_column": "object_id", "target_column": "id"}"#, - }], + links: &[ + OntologyLink { + name: "materialization_depends_on", + target: "object", + properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "depends_on", "source_column": "object_id", "target_column": "id"}"#, + }, + OntologyLink { + name: "materialization_dependency", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "dependency_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], }), }); @@ -14027,19 +14096,19 @@ pub static MZ_MATERIALIZATION_LAG: LazyLock = LazyLock::new(|| Buil oid: oid::VIEW_MZ_MATERIALIZATION_LAG_OID, desc: RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("local_lag", SqlScalarType::Interval.nullable(true)) .with_column("global_lag", SqlScalarType::Interval.nullable(true)) .with_column( "slowest_local_input_id", SqlScalarType::String.nullable(false), ) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column( "slowest_global_input_id", SqlScalarType::String.nullable(false), ) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -14148,11 +14217,23 @@ JOIN root_times r USING (id)", ontology: Some(Ontology { entity_name: "materialization_lag", description: "Lag between a materialization and its inputs", - links: &[OntologyLink { - name: "measures_materialization_lag", - target: "object", - properties_json: r#"{"kind": "measures", "source_column": "object_id", "target_column": "id", "metric": "materialization_lag"}"#, - }], + links: &[ + OntologyLink { + name: "measures_materialization_lag", + target: "object", + properties_json: r#"{"kind": "measures", "source_column": "object_id", "target_column": "id", "metric": "materialization_lag"}"#, + }, + OntologyLink { + name: "slowest_local_input", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "slowest_local_input_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "slowest_global_input", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "slowest_global_input_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], }), }); @@ -15026,21 +15107,21 @@ pub static MZ_SOURCE_STATISTICS: LazyLock = LazyLock::new(|| { // We need to add a redundant where clause for a new dataflow to be created. desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("replica_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_column("messages_received", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type("RecordCount") + .with_semantic_type(SemanticType::RecordCount) .with_column("bytes_received", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type("ByteCount") + .with_semantic_type(SemanticType::ByteCount) .with_column("updates_staged", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type("RecordCount") + .with_semantic_type(SemanticType::RecordCount) .with_column("updates_committed", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type("RecordCount") + .with_semantic_type(SemanticType::RecordCount) .with_column("records_indexed", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type("RecordCount") + .with_semantic_type(SemanticType::RecordCount) .with_column("bytes_indexed", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type("ByteCount") + .with_semantic_type(SemanticType::ByteCount) .with_column( "rehydration_latency", SqlScalarType::Interval.nullable(true), @@ -15049,12 +15130,12 @@ pub static MZ_SOURCE_STATISTICS: LazyLock = LazyLock::new(|| { "snapshot_records_known", SqlScalarType::UInt64.nullable(true), ) - .with_semantic_type("RecordCount") + .with_semantic_type(SemanticType::RecordCount) .with_column( "snapshot_records_staged", SqlScalarType::UInt64.nullable(true), ) - .with_semantic_type("RecordCount") + .with_semantic_type(SemanticType::RecordCount) .with_column("snapshot_committed", SqlScalarType::Bool.nullable(false)) .with_column("offset_known", SqlScalarType::UInt64.nullable(true)) .with_column("offset_committed", SqlScalarType::UInt64.nullable(true)) @@ -15147,17 +15228,17 @@ pub static MZ_SINK_STATISTICS: LazyLock = LazyLock::new(|| BuiltinV oid: oid::VIEW_MZ_SINK_STATISTICS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("replica_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_column("messages_staged", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type("RecordCount") + .with_semantic_type(SemanticType::RecordCount) .with_column("messages_committed", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type("RecordCount") + .with_semantic_type(SemanticType::RecordCount) .with_column("bytes_staged", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type("ByteCount") + .with_semantic_type(SemanticType::ByteCount) .with_column("bytes_committed", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type("ByteCount") + .with_semantic_type(SemanticType::ByteCount) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -16293,19 +16374,11 @@ mod tests { /// Validates ontology metadata consistency: /// - Every link target references an entity that exists. - /// - Every semantic type annotation references a type in SEMANTIC_TYPE_DEFS. /// - No duplicate entity names. /// - Every annotated builtin has a non-empty entity_name and description. #[mz_ore::test] #[cfg_attr(miri, ignore)] fn test_ontology_consistency() { - use super::ontology::SEMANTIC_TYPE_DEFS; - - let valid_semantic_types: BTreeSet<&str> = SEMANTIC_TYPE_DEFS - .iter() - .map(|(name, _, _)| *name) - .collect(); - // Collect all entity names from builtins with ontology annotations. let mut entity_names: BTreeSet = BTreeSet::new(); let mut duplicate_entities = Vec::new(); @@ -16372,8 +16445,38 @@ mod tests { bad_targets.join("\n"), ); - // Validate semantic type annotations use known types. - let mut bad_sem_types = Vec::new(); + // Semantic type annotations are typed (SemanticType enum), so validity + // is guaranteed at compile time — no runtime check needed. + + // Validate that every "reference" column (one whose semantic type implies + // a FK relationship) is covered by an OntologyLink on entities that + // already have at least one FK-style link. + // + // Scope: only entities that have started FK annotation (at least one + // link with "source_column" in properties_json). Entities with only + // union/maps_to links, or no links at all, are not yet fully annotated + // and are skipped to avoid noise. + // + // Exemptions: + // - Column at index 0 named "id": almost always the entity's own PK, + // not a FK (e.g. mz_objects.id, mz_functions.id). + // - Columns in the relation's declared key set. + // + // "Reference" types are ID types that imply a FK. Discriminators + // (ObjectType, ConnectionType, SourceType), OID, and metric types + // (ByteCount, etc.) are excluded. + let reference_sem_types: BTreeSet = BTreeSet::from([ + SemanticType::CatalogItemId, + SemanticType::GlobalId, + SemanticType::ClusterId, + SemanticType::ReplicaId, + SemanticType::SchemaId, + SemanticType::DatabaseId, + SemanticType::RoleId, + SemanticType::NetworkPolicyId, + ]); + + let mut uncovered_fk_cols = Vec::new(); for builtin in BUILTINS_STATIC.iter() { let (name, desc, ontology) = match builtin { Builtin::Table(t) => (t.name, &t.desc, t.ontology.as_ref()), @@ -16382,30 +16485,61 @@ mod tests { Builtin::Source(s) => (s.name, &s.desc, s.ontology.as_ref()), _ => continue, }; - for (idx, _col) in desc.iter_names().enumerate() { - if let Some(sem) = desc.get_semantic_type(idx) { - if !valid_semantic_types.contains(sem) { - bad_sem_types.push(format!( - "builtin {} column {} has semantic type {:?} not in SEMANTIC_TYPE_DEFS", - name, - desc.get_name(idx), - sem - )); - } - } + let Some(ont) = ontology else { continue }; + + // Collect all source_column values declared by existing FK links. + // The format is always: "source_column": "colname" + let linked_cols: BTreeSet<&str> = ont + .links + .iter() + .filter_map(|link| { + let json = link.properties_json; + let key = "\"source_column\": \""; + let start = json.find(key)? + key.len(); + let end = json[start..].find('"')? + start; + Some(&json[start..end]) + }) + .collect(); + + // Skip entities that have no FK-style links yet — they are either + // unannotated or use only union/maps_to links. Only enforce + // coverage on entities that have started FK annotation. + if linked_cols.is_empty() { + continue; } - // Also check: if a builtin has semantic types but no ontology, warn. - let has_sem = (0..desc.arity()).any(|i| desc.get_semantic_type(i).is_some()); - if has_sem && ontology.is_none() { - // This is not necessarily wrong (some builtins have semantic - // types for internal use without being ontology entities), - // but we track it for awareness. + + // Column indices that are part of the declared key set. + let pk_indices: BTreeSet = desc.typ().keys.iter().flatten().copied().collect(); + + for (idx, col) in desc.iter_names().enumerate() { + let Some(sem) = desc.get_semantic_type(idx) else { + continue; + }; + if !reference_sem_types.contains(&sem) { + continue; + } + // Exempt the entity's own primary identifier: column 0 named + // "id" is by convention the entity's own PK (not a FK), even + // when no explicit with_key() is declared on the relation. + if idx == 0 && col.as_str() == "id" { + continue; + } + if pk_indices.contains(&idx) { + continue; + } + if linked_cols.contains(col.as_str()) { + continue; + } + uncovered_fk_cols.push(format!( + "entity {:?} (builtin {}) column {:?} has semantic type {:?} but no OntologyLink covers it (add a link with source_column: {:?})", + ont.entity_name, name, col.as_str(), sem, col.as_str() + )); } } assert!( - bad_sem_types.is_empty(), - "builtins have semantic types not in SEMANTIC_TYPE_DEFS:\n{}", - bad_sem_types.join("\n"), + uncovered_fk_cols.is_empty(), + "ontology entities have FK-typed columns with no OntologyLink:\n{}", + uncovered_fk_cols.join("\n"), ); // Sanity check: we have a reasonable number of annotated entities. diff --git a/src/catalog/src/builtin/ontology.rs b/src/catalog/src/builtin/ontology.rs index 52c8bc0b89862..b3d821ffe46c2 100644 --- a/src/catalog/src/builtin/ontology.rs +++ b/src/catalog/src/builtin/ontology.rs @@ -19,7 +19,7 @@ use std::collections::BTreeMap; use mz_pgrepr::oid; use mz_repr::namespaces::MZ_INTERNAL_SCHEMA; -use mz_repr::{RelationDesc, SqlScalarType}; +use mz_repr::{RelationDesc, SemanticType, SqlScalarType}; use mz_sql::catalog::NameReference; use super::{Builtin, BuiltinView, Ontology, PUBLIC_SELECT}; @@ -82,7 +82,7 @@ fn esc(s: &str) -> String { /// Build a simple ontology view from a name, OID, column defs, and SQL. fn view( name: &'static str, - o: u32, + oid: u32, cols: &[(&'static str, SqlScalarType, bool)], keys: &[Vec], sql: String, @@ -98,7 +98,7 @@ fn view( BuiltinView { name, schema: MZ_INTERNAL_SCHEMA, - oid: o, + oid, desc, column_comments: BTreeMap::new(), sql: Box::leak(sql.into_boxed_str()), @@ -157,7 +157,7 @@ fn entity_types_view(infos: &[Info]) -> BuiltinView { fn semantic_types_view() -> BuiltinView { let vals: Vec<_> = SEMANTIC_TYPE_DEFS .iter() - .map(|(n, t, d)| format!("('{}','{}','{}')", esc(n), esc(t), esc(d))) + .map(|(n, t, d)| format!("('{}','{}','{}')", esc(&n.to_string()), esc(t), esc(d))) .collect(); view( "mz_ontology_semantic_types", @@ -271,52 +271,100 @@ fn link_types_view(infos: &[Info]) -> BuiltinView { // ── Semantic type reference data ───────────────────────────── -pub(super) const SEMANTIC_TYPE_DEFS: &[(&str, &str, &str)] = &[ +pub(super) const SEMANTIC_TYPE_DEFS: &[(SemanticType, &str, &str)] = &[ ( - "CatalogItemId", + SemanticType::CatalogItemId, "text", "SQL-layer object ID. Format: s{n}/u{n}.", ), ( - "GlobalId", + SemanticType::GlobalId, "text", "Runtime ID used by compute/storage. Format: s{n}/u{n}/si{n}.", ), - ("ClusterId", "text", "Cluster ID. Format: s{n}/u{n}."), ( - "ReplicaId", + SemanticType::ClusterId, + "text", + "Cluster ID. Format: s{n}/u{n}.", + ), + ( + SemanticType::ReplicaId, "text", "Cluster replica ID. Format: s{n}/u{n}.", ), - ("SchemaId", "text", "Schema ID. Format: s{n}/u{n}."), - ("DatabaseId", "text", "Database ID. Format: s{n}/u{n}."), - ("RoleId", "text", "Role ID. Format: s{n}/g{n}/u{n}/p."), ( - "NetworkPolicyId", + SemanticType::SchemaId, + "text", + "Schema ID. Format: s{n}/u{n}.", + ), + ( + SemanticType::DatabaseId, + "text", + "Database ID. Format: s{n}/u{n}.", + ), + ( + SemanticType::RoleId, + "text", + "Role ID. Format: s{n}/g{n}/u{n}/p.", + ), + ( + SemanticType::NetworkPolicyId, "text", "Network policy ID. Format: s{n}/u{n}.", ), - ("ShardId", "text", "Persist shard ID. Format: s{uuid}."), - ("OID", "oid", "PostgreSQL-compatible object identifier."), - ("ObjectType", "text", "Catalog object type discriminator."), - ("ConnectionType", "text", "Connection type discriminator."), - ("SourceType", "text", "Source type discriminator."), ( - "MzTimestamp", + SemanticType::ShardId, + "text", + "Persist shard ID. Format: s{uuid}.", + ), + ( + SemanticType::OID, + "oid", + "PostgreSQL-compatible object identifier.", + ), + ( + SemanticType::ObjectType, + "text", + "Catalog object type discriminator (e.g., table, view, source, sink, index, materialized-view).", + ), + ( + SemanticType::ConnectionType, + "text", + "Connection type discriminator (e.g., kafka, postgres, mysql, ssh-tunnel).", + ), + ( + SemanticType::SourceType, + "text", + "Source type discriminator (e.g., kafka, postgres, mysql, webhook).", + ), + ( + SemanticType::MzTimestamp, "mz_timestamp", - "Internal logical timestamp (uint64).", + "Internal logical timestamp (8-byte unsigned integer).", ), ( - "WallclockTimestamp", + SemanticType::WallclockTimestamp, "timestamp with time zone", "Wall clock timestamp.", ), - ("ByteCount", "uint8", "A count of bytes."), - ("RecordCount", "uint8", "A count of records/rows."), - ("CreditRate", "numeric", "Credits consumed per hour."), - ("SqlDefinition", "text", "A SQL CREATE statement."), + (SemanticType::ByteCount, "uint8", "A count of bytes."), + ( + SemanticType::RecordCount, + "uint8", + "A count of records/rows.", + ), + ( + SemanticType::CreditRate, + "numeric", + "Credits consumed per hour.", + ), + ( + SemanticType::SqlDefinition, + "text", + "A SQL CREATE statement.", + ), ( - "RedactedSqlDefinition", + SemanticType::RedactedSqlDefinition, "text", "A redacted SQL CREATE statement.", ), diff --git a/src/repr/src/lib.rs b/src/repr/src/lib.rs index 3ad159243e42a..32f98521eece2 100644 --- a/src/repr/src/lib.rs +++ b/src/repr/src/lib.rs @@ -56,9 +56,9 @@ pub use crate::relation::{ ColumnDiff, ColumnIndex, ColumnName, KeyDiff, NotNullViolation, PropRelationDescDiff, ProtoColumnName, ProtoColumnType, ProtoRelationDesc, ProtoRelationType, RelationDesc, RelationDescBuilder, RelationDescDiff, RelationVersion, RelationVersionSelector, - ReprColumnType, ReprRelationType, SqlColumnType, SqlRelationType, UNKNOWN_COLUMN_NAME, - VersionedRelationDesc, arb_relation_desc_diff, arb_relation_desc_projection, - arb_row_for_relation, + ReprColumnType, ReprRelationType, SemanticType, SqlColumnType, SqlRelationType, + UNKNOWN_COLUMN_NAME, VersionedRelationDesc, arb_relation_desc_diff, + arb_relation_desc_projection, arb_row_for_relation, }; pub use crate::row::encode::{RowColumnarDecoder, RowColumnarEncoder, preserves_order}; pub use crate::row::iter::{IntoRowIterator, RowIterator}; diff --git a/src/repr/src/relation.rs b/src/repr/src/relation.rs index 6b7ccdf044755..b0044f406a616 100644 --- a/src/repr/src/relation.rs +++ b/src/repr/src/relation.rs @@ -822,6 +822,64 @@ impl RustType for RelationVersion { } } +/// Semantic type annotation for a column in a builtin catalog relation. +/// +/// These are compile-time metadata used by the catalog ontology layer to +/// describe the meaning of a column (e.g., that it contains a catalog item ID +/// or a role ID). Possible values correspond to the entries in +/// `SEMANTIC_TYPE_DEFS` in the `mz-catalog` crate. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub enum SemanticType { + CatalogItemId, + GlobalId, + ClusterId, + ReplicaId, + SchemaId, + DatabaseId, + RoleId, + NetworkPolicyId, + ShardId, + OID, + ObjectType, + ConnectionType, + SourceType, + MzTimestamp, + WallclockTimestamp, + ByteCount, + RecordCount, + CreditRate, + SqlDefinition, + RedactedSqlDefinition, +} + +impl fmt::Display for SemanticType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let s = match self { + SemanticType::CatalogItemId => "CatalogItemId", + SemanticType::GlobalId => "GlobalId", + SemanticType::ClusterId => "ClusterId", + SemanticType::ReplicaId => "ReplicaId", + SemanticType::SchemaId => "SchemaId", + SemanticType::DatabaseId => "DatabaseId", + SemanticType::RoleId => "RoleId", + SemanticType::NetworkPolicyId => "NetworkPolicyId", + SemanticType::ShardId => "ShardId", + SemanticType::OID => "OID", + SemanticType::ObjectType => "ObjectType", + SemanticType::ConnectionType => "ConnectionType", + SemanticType::SourceType => "SourceType", + SemanticType::MzTimestamp => "MzTimestamp", + SemanticType::WallclockTimestamp => "WallclockTimestamp", + SemanticType::ByteCount => "ByteCount", + SemanticType::RecordCount => "RecordCount", + SemanticType::CreditRate => "CreditRate", + SemanticType::SqlDefinition => "SqlDefinition", + SemanticType::RedactedSqlDefinition => "RedactedSqlDefinition", + }; + f.write_str(s) + } +} + /// Metadata (other than type) for a column in a [`RelationDesc`]. #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash, MzReflect)] struct ColumnMetadata { @@ -906,11 +964,11 @@ struct ColumnMetadata { pub struct RelationDesc { typ: SqlRelationType, metadata: BTreeMap, - /// Optional semantic type annotations for columns (e.g., "CatalogItemId", "RoleId"). + /// Optional semantic type annotations for columns. /// Keyed by column index. Only populated for builtin catalog objects. /// Excluded from Eq/Hash/serialization — it's ontology metadata, not schema. #[serde(skip)] - semantic_types: BTreeMap, + semantic_types: BTreeMap, } impl PartialEq for RelationDesc { @@ -1227,7 +1285,7 @@ impl RelationDesc { } /// Gets the semantic type annotation for column `i`, if any. - pub fn get_semantic_type(&self, i: usize) -> Option<&'static str> { + pub fn get_semantic_type(&self, i: usize) -> Option { self.semantic_types.get(&i).copied() } @@ -1552,7 +1610,7 @@ pub struct RelationDescBuilder { /// Sets of indices that are "keys" for the collection. keys: Vec>, /// Semantic type annotations for columns. - semantic_types: BTreeMap, + semantic_types: BTreeMap, } impl RelationDescBuilder { @@ -1589,7 +1647,9 @@ impl RelationDescBuilder { } /// Annotates the most recently added column with a semantic type. - pub fn with_semantic_type(mut self, semantic_type: &'static str) -> RelationDescBuilder { + /// + /// Possible values are enumerated in [`SemanticType`]. + pub fn with_semantic_type(mut self, semantic_type: SemanticType) -> RelationDescBuilder { let idx = self .columns .len() @@ -2408,15 +2468,15 @@ mod tests { fn test_semantic_type_annotations() { let desc = RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("cluster_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("ClusterId") + .with_semantic_type(SemanticType::ClusterId) .finish(); // Annotated columns return their semantic type. - assert_eq!(desc.get_semantic_type(0), Some("CatalogItemId")); - assert_eq!(desc.get_semantic_type(2), Some("ClusterId")); + assert_eq!(desc.get_semantic_type(0), Some(SemanticType::CatalogItemId)); + assert_eq!(desc.get_semantic_type(2), Some(SemanticType::ClusterId)); // Unannotated columns return None. assert_eq!(desc.get_semantic_type(1), None); @@ -2429,7 +2489,7 @@ mod tests { fn test_semantic_types_excluded_from_eq_and_hash() { let desc_a = RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .finish(); let desc_b = RelationDesc::builder() @@ -2454,7 +2514,7 @@ mod tests { fn test_semantic_types_excluded_from_serialization() { let desc = RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type("CatalogItemId") + .with_semantic_type(SemanticType::CatalogItemId) .finish(); // Roundtrip through protobuf should lose semantic types (serde skip). diff --git a/src/storage-client/src/healthcheck.rs b/src/storage-client/src/healthcheck.rs index 58520c7fe5760..31f96afe83165 100644 --- a/src/storage-client/src/healthcheck.rs +++ b/src/storage-client/src/healthcheck.rs @@ -7,7 +7,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -use mz_repr::{RelationDesc, SqlScalarType}; +use mz_repr::{RelationDesc, SemanticType, SqlScalarType}; use std::sync::LazyLock; pub static MZ_PREPARED_STATEMENT_HISTORY_DESC: LazyLock = LazyLock::new(|| { @@ -44,7 +44,7 @@ pub static MZ_SESSION_HISTORY_DESC: LazyLock = LazyLock::new(|| { "connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .with_column( "initial_application_name", SqlScalarType::String.nullable(false), @@ -112,14 +112,14 @@ pub static MZ_SOURCE_STATUS_HISTORY_DESC: LazyLock = LazyLock::new "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .with_column("source_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) .with_column("details", SqlScalarType::Jsonb.nullable(true)) .with_column("replica_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .finish() }); @@ -129,14 +129,14 @@ pub static MZ_SINK_STATUS_HISTORY_DESC: LazyLock = LazyLock::new(| "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .with_column("sink_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) .with_column("details", SqlScalarType::Jsonb.nullable(true)) .with_column("replica_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .finish() }); @@ -155,7 +155,7 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_DESC: LazyLock = LazyLock::new(|| { RelationDesc::builder() .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("reason", SqlScalarType::String.nullable(true)) @@ -188,15 +188,15 @@ pub static REPLICA_METRICS_HISTORY_DESC: LazyLock = LazyLock::new( pub static WALLCLOCK_LAG_HISTORY_DESC: LazyLock = LazyLock::new(|| { RelationDesc::builder() .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type("GlobalId") + .with_semantic_type(SemanticType::GlobalId) .with_column("replica_id", SqlScalarType::String.nullable(true)) - .with_semantic_type("ReplicaId") + .with_semantic_type(SemanticType::ReplicaId) .with_column("lag", SqlScalarType::Interval.nullable(true)) .with_column( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), ) - .with_semantic_type("WallclockTimestamp") + .with_semantic_type(SemanticType::WallclockTimestamp) .finish() }); From ab6fccc53c39e318c60ba485f07018909b7a58f3 Mon Sep 17 00:00:00 2001 From: mtabebe Date: Wed, 29 Apr 2026 15:14:48 -0400 Subject: [PATCH 06/14] [ontology] fill in more missing OntologyLink entries for builtin entities Nineteen annotated builtin relations had empty links columns that point to other annotated entities --- .../generated/catalog/builtin/ontology.md | 9 +- .../reference/system-catalog/mz_internal.md | 2 +- src/catalog/src/builtin.rs | 154 +++++++++++++++--- .../autogenerated/mz_internal.slt | 2 +- test/sqllogictest/oid.slt | 8 +- 5 files changed, 148 insertions(+), 27 deletions(-) diff --git a/doc/developer/generated/catalog/builtin/ontology.md b/doc/developer/generated/catalog/builtin/ontology.md index 460d957df1e65..12bc1c9eff7d3 100644 --- a/doc/developer/generated/catalog/builtin/ontology.md +++ b/doc/developer/generated/catalog/builtin/ontology.md @@ -61,6 +61,13 @@ Common keys in the properties JSONB: | `nullable` | `true` if the FK column can be NULL (optional relationship). | | `source_id_type` | Semantic ID type of the source column (e.g., `CatalogItemId`, `GlobalId`). | | `requires_mapping` | Mapping table needed to bridge ID namespaces (e.g., `mz_internal.mz_object_global_ids`). | +| `from_type` | Source semantic ID type for `maps_to` links (e.g., `CatalogItemId`). | +| `to_type` | Target semantic ID type for `maps_to` links (e.g., `GlobalId`). | +| `via` | Intermediate table or view used to perform a mapping or indirect join. | +| `metric` | Name of the metric or statistic measured by a `measures` link (e.g., `cpu_time_ns`, `materialization_lag`). | +| `discriminator_column` | Column on the `union` view that identifies the member type (e.g., `type`). | +| `discriminator_value` | Value in `discriminator_column` that selects the specific member entity. | +| `note` | Free-text clarification for unusual join semantics or caveats. | ## For LLMs @@ -107,7 +114,7 @@ types differ, bridge through `mz_internal.mz_object_global_ids`. - ~117 entity types (mz_catalog + mz_internal + mz_introspection) - 20 semantic types - ~450 column properties -- ~106 named relationships +- ~150 named relationships ## Related files diff --git a/doc/user/content/reference/system-catalog/mz_internal.md b/doc/user/content/reference/system-catalog/mz_internal.md index c9124e86abbab..8fbd92decfdf1 100644 --- a/doc/user/content/reference/system-catalog/mz_internal.md +++ b/doc/user/content/reference/system-catalog/mz_internal.md @@ -839,7 +839,7 @@ in the system. | Field | Type | Meaning | | -----------------| ----------------------| -------- | | `name` | [`text`] | The name of the network policy rule. Can be combined with `policy_id` to form a unique identifier. | -| `policy_id` | [`text`] | The ID the network policy the rule is part of. Corresponds to [`mz_network_policy_rules.id`](#mz_network_policy_rules). | +| `policy_id` | [`text`] | The ID the network policy the rule is part of. Corresponds to [`mz_internal.mz_network_policies.id`](#mz_network_policies). | | `action` | [`text`] | The action of the rule. `allow` is the only supported action. | | `address` | [`text`] | The address the rule will take action on. | | `direction` | [`text`] | The direction of traffic the rule applies to. `ingress` is the only supported direction. | diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index d95fadd639ca3..5f97f542df925 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -2246,7 +2246,11 @@ pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| Builti ontology: Some(Ontology { entity_name: "postgres_source", description: "Postgres source-level details", - links: &[], + links: &[OntologyLink { + name: "details_of", + target: "source", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], }), }); pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3588,7 +3592,11 @@ WHERE data->>'kind' = 'NetworkPolicy'", ontology: Some(Ontology { entity_name: "network_policy", description: "Network access policies", - links: &[], + links: &[OntologyLink { + name: "owned_by", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], }), } }); @@ -3612,7 +3620,7 @@ pub static MZ_NETWORK_POLICY_RULES: LazyLock = LazyLock ), ( "policy_id", - "The ID the network policy the rule is part of. Corresponds to `mz_network_policy_rules.id`.", + "The ID the network policy the rule is part of. Corresponds to `mz_internal.mz_network_policies.id`.", ), ( "action", @@ -3648,7 +3656,11 @@ WHERE data->>'kind' = 'NetworkPolicy'", ontology: Some(Ontology { entity_name: "network_policy_rule", description: "Individual rules within a network policy", - links: &[], + links: &[OntologyLink { + name: "belongs_to_policy", + target: "network_policy", + properties_json: r#"{"kind": "foreign_key", "source_column": "policy_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], }), } }); @@ -4318,7 +4330,11 @@ pub static MZ_CLUSTER_SCHEDULES: LazyLock = LazyLock::new(|| Built ontology: Some(Ontology { entity_name: "cluster_schedule", description: "Cluster scheduling configuration", - links: &[], + links: &[OntologyLink { + name: "belongs_to_cluster", + target: "cluster", + properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], }), }); @@ -4858,7 +4874,11 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUSES: LazyLock = LazyL ontology: Some(Ontology { entity_name: "privatelink_status", description: "PrivateLink connection health status", - links: &[], + links: &[OntologyLink { + name: "status_of", + target: "connection", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], }), } }); @@ -5051,7 +5071,11 @@ pub static MZ_SESSION_HISTORY: LazyLock = LazyLock::new(|| Builti ontology: Some(Ontology { entity_name: "session_history", description: "Historical session connection events", - links: &[], + links: &[OntologyLink { + name: "history_of", + target: "session", + properties_json: r#"{"kind": "foreign_key", "source_column": "session_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], }), }); @@ -6008,7 +6032,11 @@ pub static MZ_AWS_CONNECTIONS: LazyLock = LazyLock::new(|| Builtin ontology: Some(Ontology { entity_name: "aws_connection", description: "AWS connection configuration details", - links: &[], + links: &[OntologyLink { + name: "details_of", + target: "connection", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], }), }); @@ -6293,7 +6321,11 @@ OPTIONS (AGGREGATE INPUT GROUP SIZE = 1)", ontology: Some(Ontology { entity_name: "wallclock_global_lag_history", description: "Historical global wallclock lag", - links: &[], + links: &[OntologyLink { + name: "lag_of", + target: "object_global_id", + properties_json: r#"{"kind": "foreign_key", "source_column": "object_id", "target_column": "global_id", "cardinality": "many_to_one"}"#, + }], }), }); @@ -6500,7 +6532,18 @@ pub static MZ_SUBSCRIPTIONS: LazyLock = LazyLock::new(|| BuiltinTa ontology: Some(Ontology { entity_name: "subscription", description: "Active SUBSCRIBE operations", - links: &[], + links: &[ + OntologyLink { + name: "uses_session", + target: "session", + properties_json: r#"{"kind": "foreign_key", "source_column": "session_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "belongs_to_cluster", + target: "cluster", + properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], }), }); @@ -6543,7 +6586,11 @@ pub static MZ_SESSIONS: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "session", description: "Currently active sessions", - links: &[], + links: &[OntologyLink { + name: "logged_in_as", + target: "role", + properties_json: r#"{"kind": "foreign_key", "source_column": "role_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], }), }); @@ -6701,7 +6748,11 @@ pub static MZ_SOURCE_REFERENCES: LazyLock = LazyLock::new(|| Built ontology: Some(Ontology { entity_name: "source_reference", description: "External references tracked by sources", - links: &[], + links: &[OntologyLink { + name: "references_source", + target: "source", + properties_json: r#"{"kind": "foreign_key", "source_column": "source_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }], }), }); @@ -6731,7 +6782,11 @@ pub static MZ_WEBHOOKS_SOURCES: LazyLock = LazyLock::new(|| Builti ontology: Some(Ontology { entity_name: "webhook_source", description: "Webhook source configuration", - links: &[], + links: &[OntologyLink { + name: "details_of", + target: "source", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], }), }); @@ -6837,7 +6892,18 @@ pub static MZ_REPLACEMENTS: LazyLock = LazyLock::new(|| BuiltinTab ontology: Some(Ontology { entity_name: "replacement", description: "A record of an object replacement (ALTER ... SWAP)", - links: &[], + links: &[ + OntologyLink { + name: "replacement_object", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "replacement_target", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "target_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], }), }); @@ -7237,7 +7303,28 @@ pub static MZ_OBJECT_FULLY_QUALIFIED_NAMES: LazyLock = LazyLock::ne ontology: Some(Ontology { entity_name: "object_fqn", description: "Fully qualified name (database.schema.name) for objects", - links: &[], + links: &[ + OntologyLink { + name: "details_of", + target: "object", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }, + OntologyLink { + name: "in_schema", + target: "schema", + properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "in_database", + target: "database", + properties_json: r#"{"kind": "foreign_key", "source_column": "database_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "belongs_to_cluster", + target: "cluster", + properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], }), }); @@ -8239,7 +8326,11 @@ GROUP BY ontology: Some(Ontology { entity_name: "records_per_dataflow", description: "Record counts aggregated per dataflow", - links: &[], + links: &[OntologyLink { + name: "details_of", + target: "dataflow", + properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], }), }); @@ -9803,7 +9894,11 @@ HAVING pg_catalog.sum(count) != 0", ontology: Some(Ontology { entity_name: "compute_error_count", description: "Error counts per compute collection", - links: &[], + links: &[OntologyLink { + name: "errors_in", + target: "compute_export", + properties_json: r#"{"kind": "foreign_key", "source_column": "export_id", "target_column": "export_id", "cardinality": "one_to_one"}"#, + }], }), }); @@ -10101,7 +10196,11 @@ GROUP BY channel_id", ontology: Some(Ontology { entity_name: "message_count", description: "Inter-worker message counts", - links: &[], + links: &[OntologyLink { + name: "counts_for", + target: "dataflow_channel", + properties_json: r#"{"kind": "foreign_key", "source_column": "channel_id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], }), }); @@ -10478,7 +10577,11 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "arrangement_sharing", description: "Arrangement sharing between operators", - links: &[], + links: &[OntologyLink { + name: "shared_by", + target: "dataflow_operator", + properties_json: r#"{"kind": "foreign_key", "source_column": "operator_id", "target_column": "id", "cardinality": "one_to_one"}"#, + }], }), }); @@ -14639,7 +14742,18 @@ FROM mz_cluster_deployment_lineage"#, ontology: Some(Ontology { entity_name: "cluster_deployment", description: "Cluster deployment lineage information", - links: &[], + links: &[ + OntologyLink { + name: "deployment_of", + target: "cluster", + properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + OntologyLink { + name: "current_deployment", + target: "cluster", + properties_json: r#"{"kind": "foreign_key", "source_column": "current_deployment_cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + }, + ], }), }); diff --git a/test/sqllogictest/autogenerated/mz_internal.slt b/test/sqllogictest/autogenerated/mz_internal.slt index e3cee6579873c..77af2f126ff6f 100644 --- a/test/sqllogictest/autogenerated/mz_internal.slt +++ b/test/sqllogictest/autogenerated/mz_internal.slt @@ -464,7 +464,7 @@ query TTT SELECT name, type, comment FROM objects WHERE schema = 'mz_internal' AND object = 'mz_network_policy_rules' ORDER BY position ---- name text The␠name␠of␠the␠network␠policy␠rule.␠Can␠be␠combined␠with␠`policy_id`␠to␠form␠a␠unique␠identifier. -policy_id text The␠ID␠the␠network␠policy␠the␠rule␠is␠part␠of.␠Corresponds␠to␠`mz_network_policy_rules.id`. +policy_id text The␠ID␠the␠network␠policy␠the␠rule␠is␠part␠of.␠Corresponds␠to␠`mz_internal.mz_network_policies.id`. action text The␠action␠of␠the␠rule.␠`allow`␠is␠the␠only␠supported␠action. address text The␠address␠the␠rule␠will␠take␠action␠on. direction text The␠direction␠of␠traffic␠the␠rule␠applies␠to.␠`ingress`␠is␠the␠only␠supported␠direction. diff --git a/test/sqllogictest/oid.slt b/test/sqllogictest/oid.slt index 2329f4b620ece..a9190b231a8e0 100644 --- a/test/sqllogictest/oid.slt +++ b/test/sqllogictest/oid.slt @@ -1181,7 +1181,7 @@ SELECT oid, name FROM mz_objects WHERE id LIKE 's%' AND oid < 20000 ORDER BY oid 17073 parse_catalog_create_sql 17074 redact_sql 17075 repeat_row_non_negative -17076 mz_ontology_entity_types -17077 mz_ontology_semantic_types -17078 mz_ontology_properties -17079 mz_ontology_link_types +17077 mz_ontology_entity_types +17078 mz_ontology_semantic_types +17079 mz_ontology_properties +17080 mz_ontology_link_types From 5c909e656653b7f1bda1bb78dcce31c4e229198b Mon Sep 17 00:00:00 2001 From: mtabebe Date: Thu, 30 Apr 2026 10:26:33 -0400 Subject: [PATCH 07/14] [ontology] rename with_semantic_type to with_column_semantic_type; fix RelationDesc Hash/Eq --- .../ontology.md => catalog-ontology.md} | 6 +- src/catalog/src/builtin.rs | 1714 ++++++++++++----- src/catalog/src/builtin/ontology.rs | 34 +- src/repr/src/relation.rs | 93 +- src/storage-client/src/healthcheck.rs | 65 +- 5 files changed, 1284 insertions(+), 628 deletions(-) rename doc/developer/{generated/catalog/builtin/ontology.md => catalog-ontology.md} (98%) diff --git a/doc/developer/generated/catalog/builtin/ontology.md b/doc/developer/catalog-ontology.md similarity index 98% rename from doc/developer/generated/catalog/builtin/ontology.md rename to doc/developer/catalog-ontology.md index 12bc1c9eff7d3..e351370746a19 100644 --- a/doc/developer/generated/catalog/builtin/ontology.md +++ b/doc/developer/catalog-ontology.md @@ -1,8 +1,4 @@ ---- -source: src/catalog/src/builtin/ontology.rs ---- - -# catalog::builtin::ontology +# Catalog Ontology Views Generates four built-in views in `mz_internal` that describe the structure and relationships of the Materialize system catalog. Designed to help LLMs, diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index 5f97f542df925..64eb98e32df12 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -166,7 +166,7 @@ pub struct BuiltinLog { /// /// When present on a builtin, it marks it as an ontology entity with an explicit /// `entity_name` and `description`. Column-level semantic types are annotated -/// separately via `RelationDescBuilder::with_semantic_type()`. +/// via `RelationDescBuilder::with_column_semantic_type()`. #[derive(Clone, Hash, Debug, PartialEq, Eq)] pub struct Ontology { /// The ontology entity name (e.g., "database", "table", "mv"). @@ -177,15 +177,85 @@ pub struct Ontology { pub links: &'static [OntologyLink], } -/// A foreign key / relationship link in the ontology. -#[derive(Clone, Hash, Debug, PartialEq, Eq)] +/// Cardinality of an ontology link. +#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, serde::Serialize)] +#[serde(rename_all = "snake_case")] +pub enum Cardinality { + OneToOne, + ManyToOne, +} + +/// Helper used by serde to skip serializing `false` boolean fields. +fn is_false(v: &bool) -> bool { + !v +} + +/// Typed properties for an ontology link. Serialized to the `properties` JSONB +/// column in `mz_ontology_link_types`. The `kind` field is inlined from the +/// enum variant name via `#[serde(tag = "kind")]`. +#[derive(Clone, Debug, Hash, PartialEq, Eq, serde::Serialize)] +#[serde(tag = "kind", rename_all = "snake_case")] +pub enum LinkProperties { + /// A foreign-key relationship: the source column references the target column. + ForeignKey { + source_column: &'static str, + target_column: &'static str, + cardinality: Cardinality, + #[serde(skip_serializing_if = "Option::is_none")] + source_id_type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + requires_mapping: Option<&'static str>, + #[serde(default, skip_serializing_if = "is_false")] + nullable: bool, + #[serde(skip_serializing_if = "Option::is_none")] + note: Option<&'static str>, + }, + /// A union relationship: the source entity is a superset that includes the + /// target entity, optionally filtered by a discriminator column/value. + Union { + #[serde(skip_serializing_if = "Option::is_none")] + discriminator_column: Option<&'static str>, + #[serde(skip_serializing_if = "Option::is_none")] + discriminator_value: Option<&'static str>, + #[serde(skip_serializing_if = "Option::is_none")] + note: Option<&'static str>, + }, + /// A mapping relationship: the source entity maps to the target entity via + /// an intermediate table, optionally changing ID type. + MapsTo { + #[serde(skip_serializing_if = "Option::is_none")] + via: Option<&'static str>, + #[serde(skip_serializing_if = "Option::is_none")] + from_type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + to_type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + note: Option<&'static str>, + }, + /// A metric relationship: the source entity measures a named metric on the + /// target entity. + Measures { + source_column: &'static str, + target_column: &'static str, + metric: &'static str, + #[serde(skip_serializing_if = "Option::is_none")] + source_id_type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + requires_mapping: Option<&'static str>, + #[serde(skip_serializing_if = "Option::is_none")] + note: Option<&'static str>, + }, +} + +/// A relationship link in the ontology. +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct OntologyLink { /// Relationship name (e.g., "owned_by", "in_schema"). pub name: &'static str, /// Target entity name (e.g., "role", "schema"). pub target: &'static str, - /// JSON for the `properties` JSONB column (kind, source_column, target_column, etc.). - pub properties_json: &'static str, + /// Typed properties for the `properties` JSONB column. + pub properties: LinkProperties, } #[derive(Clone, Hash, Debug, PartialEq, Eq)] @@ -2090,8 +2160,11 @@ pub static MZ_ICEBERG_SINKS: LazyLock = LazyLock::new(|| BuiltinTa schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_ICEBERG_SINKS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("namespace", SqlScalarType::String.nullable(false)) .with_column("table", SqlScalarType::String.nullable(false)) .finish(), @@ -2121,8 +2194,11 @@ pub static MZ_KAFKA_SINKS: LazyLock = LazyLock::new(|| BuiltinTabl schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_KAFKA_SINKS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("topic", SqlScalarType::String.nullable(false)) .with_key(vec![0]) .finish(), @@ -2150,8 +2226,11 @@ pub static MZ_KAFKA_CONNECTIONS: LazyLock = LazyLock::new(|| Built schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_KAFKA_CONNECTIONS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column( "brokers", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), @@ -2186,8 +2265,11 @@ pub static MZ_KAFKA_SOURCES: LazyLock = LazyLock::new(|| BuiltinTa schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_KAFKA_SOURCES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("group_id_prefix", SqlScalarType::String.nullable(false)) .with_column("topic", SqlScalarType::String.nullable(false)) .finish(), @@ -2222,8 +2304,11 @@ pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| Builti schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_POSTGRES_SOURCES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("replication_slot", SqlScalarType::String.nullable(false)) .with_column("timeline_id", SqlScalarType::UInt64.nullable(true)) .finish(), @@ -2258,8 +2343,11 @@ pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_POSTGRES_SOURCE_TABLES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("schema_name", SqlScalarType::String.nullable(false)) .with_column("table_name", SqlScalarType::String.nullable(false)) .finish(), @@ -2284,7 +2372,7 @@ pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| description: "Postgres source table-level details", links: &[OntologyLink { name: "describes_source_table", - target: "object", + target: "table", properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, }], }), @@ -2294,8 +2382,11 @@ pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_MYSQL_SOURCE_TABLES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("schema_name", SqlScalarType::String.nullable(false)) .with_column("table_name", SqlScalarType::String.nullable(false)) .finish(), @@ -2320,7 +2411,7 @@ pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui description: "MySQL source table-level details", links: &[OntologyLink { name: "describes_source_table", - target: "object", + target: "table", properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, }], }), @@ -2330,8 +2421,11 @@ pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(| schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_SQL_SERVER_SOURCE_TABLES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("schema_name", SqlScalarType::String.nullable(false)) .with_column("table_name", SqlScalarType::String.nullable(false)) .finish(), @@ -2356,7 +2450,7 @@ pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(| description: "SQL Server source table-level details", links: &[OntologyLink { name: "describes_source_table", - target: "object", + target: "table", properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, }], }), @@ -2366,8 +2460,11 @@ pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_KAFKA_SOURCE_TABLES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("topic", SqlScalarType::String.nullable(false)) .with_column("envelope_type", SqlScalarType::String.nullable(true)) .with_column("key_format", SqlScalarType::String.nullable(true)) @@ -2399,7 +2496,7 @@ pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui description: "Kafka source table-level details", links: &[OntologyLink { name: "describes_source_table", - target: "object", + target: "table", properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, }], }), @@ -2409,13 +2506,16 @@ pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| Bui schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_OBJECT_DEPENDENCIES_OID, desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column( + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( "referenced_object_id", SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, ) - .with_semantic_type(SemanticType::CatalogItemId) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -2452,15 +2552,21 @@ pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| B oid: oid::SOURCE_MZ_COMPUTE_DEPENDENCIES_OID, data_source: IntrospectionType::ComputeDependencies.into(), desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) - .with_column("dependency_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) + .with_column_semantic_type( + "dependency_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) .finish(), column_comments: BTreeMap::from_iter([ ( "object_id", - "The ID of a compute object. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, or `mz_internal.mz_subscriptions`.", + "The ID of a compute object. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, or `mz_internal.mz_subscriptions.id`.", ), ( "dependency_id", @@ -2471,7 +2577,7 @@ pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| B access: vec![PUBLIC_SELECT], ontology: Some(Ontology { entity_name: "compute_dependency", - description: "Dependency edges within compute dataflows", + description: "Dependency edge within compute dataflows", links: &[ OntologyLink { name: "dependent_compute_object", @@ -2493,13 +2599,18 @@ pub static MZ_DATABASES: LazyLock = LazyLock::new(|| { schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_DATABASES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::DatabaseId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::DatabaseId, + ) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type( + "owner_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -2554,15 +2665,23 @@ pub static MZ_SCHEMAS: LazyLock = LazyLock::new(|| { schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_SCHEMAS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SchemaId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) - .with_column("database_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::DatabaseId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::SchemaId, + ) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column_semantic_type( + "database_id", + SqlScalarType::String.nullable(true), + SemanticType::DatabaseId, + ) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type( + "owner_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -2630,15 +2749,21 @@ pub static MZ_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_COLUMNS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) // not a key - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) // not a key .with_column("name", SqlScalarType::String.nullable(false)) .with_column("position", SqlScalarType::UInt64.nullable(false)) .with_column("nullable", SqlScalarType::Bool.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) .with_column("default", SqlScalarType::String.nullable(true)) - .with_column("type_oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) + .with_column_semantic_type( + "type_oid", + SqlScalarType::Oid.nullable(false), + SemanticType::OID, + ) .with_column("type_mod", SqlScalarType::Int32.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -2677,21 +2802,38 @@ pub static MZ_INDEXES: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_INDEXES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("on_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("cluster_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ClusterId) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) - .with_column("create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SqlDefinition) - .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RedactedSqlDefinition) + .with_column_semantic_type( + "on_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( + "cluster_id", + SqlScalarType::String.nullable(false), + SemanticType::ClusterId, + ) + .with_column_semantic_type( + "owner_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) + .with_column_semantic_type( + "create_sql", + SqlScalarType::String.nullable(false), + SemanticType::SqlDefinition, + ) + .with_column_semantic_type( + "redacted_create_sql", + SqlScalarType::String.nullable(false), + SemanticType::RedactedSqlDefinition, + ) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -2746,8 +2888,11 @@ pub static MZ_INDEX_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTa schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_INDEX_COLUMNS_OID, desc: RelationDesc::builder() - .with_column("index_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "index_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("index_position", SqlScalarType::UInt64.nullable(false)) .with_column("on_position", SqlScalarType::UInt64.nullable(true)) .with_column("on_expression", SqlScalarType::String.nullable(true)) @@ -2792,25 +2937,42 @@ pub static MZ_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_TABLES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) - .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SchemaId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column_semantic_type( + "schema_id", + SqlScalarType::String.nullable(false), + SemanticType::SchemaId, + ) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type( + "owner_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) - .with_column("create_sql", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::SqlDefinition) - .with_column("redacted_create_sql", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::RedactedSqlDefinition) - .with_column("source_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "create_sql", + SqlScalarType::String.nullable(true), + SemanticType::SqlDefinition, + ) + .with_column_semantic_type( + "redacted_create_sql", + SqlScalarType::String.nullable(true), + SemanticType::RedactedSqlDefinition, + ) + .with_column_semantic_type( + "source_id", + SqlScalarType::String.nullable(true), + SemanticType::CatalogItemId, + ) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -2868,25 +3030,18 @@ pub static MZ_CONNECTIONS: LazyLock = LazyLock::new(|| schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_CONNECTIONS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) - .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SchemaId) + .with_column_semantic_type("id", SqlScalarType::String.nullable(false), SemanticType::CatalogItemId) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column_semantic_type("schema_id", SqlScalarType::String.nullable(false), SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("type", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ConnectionType) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type("type", SqlScalarType::String.nullable(false), SemanticType::ConnectionType) + .with_column_semantic_type("owner_id", SqlScalarType::String.nullable(false), SemanticType::RoleId) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) - .with_column("create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SqlDefinition) - .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RedactedSqlDefinition) + .with_column_semantic_type("create_sql", SqlScalarType::String.nullable(false), SemanticType::SqlDefinition) + .with_column_semantic_type("redacted_create_sql", SqlScalarType::String.nullable(false), SemanticType::RedactedSqlDefinition) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -2969,8 +3124,11 @@ pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock = LazyLock::new(|| schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_SSH_TUNNEL_CONNECTIONS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("public_key_1", SqlScalarType::String.nullable(false)) .with_column("public_key_2", SqlScalarType::String.nullable(false)) .finish(), @@ -3002,33 +3160,56 @@ pub static MZ_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_SOURCES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) - .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SchemaId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column_semantic_type( + "schema_id", + SqlScalarType::String.nullable(false), + SemanticType::SchemaId, + ) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("type", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SourceType) - .with_column("connection_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "type", + SqlScalarType::String.nullable(false), + SemanticType::SourceType, + ) + .with_column_semantic_type( + "connection_id", + SqlScalarType::String.nullable(true), + SemanticType::CatalogItemId, + ) .with_column("size", SqlScalarType::String.nullable(true)) .with_column("envelope_type", SqlScalarType::String.nullable(true)) .with_column("key_format", SqlScalarType::String.nullable(true)) .with_column("value_format", SqlScalarType::String.nullable(true)) - .with_column("cluster_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::ClusterId) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type( + "cluster_id", + SqlScalarType::String.nullable(true), + SemanticType::ClusterId, + ) + .with_column_semantic_type( + "owner_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) - .with_column("create_sql", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::SqlDefinition) - .with_column("redacted_create_sql", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::RedactedSqlDefinition) + .with_column_semantic_type( + "create_sql", + SqlScalarType::String.nullable(true), + SemanticType::SqlDefinition, + ) + .with_column_semantic_type( + "redacted_create_sql", + SqlScalarType::String.nullable(true), + SemanticType::RedactedSqlDefinition, + ) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3111,16 +3292,24 @@ pub static MZ_SINKS: LazyLock = LazyLock::new(|| { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_SINKS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) - .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SchemaId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column_semantic_type( + "schema_id", + SqlScalarType::String.nullable(false), + SemanticType::SchemaId, + ) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) - .with_column("connection_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "connection_id", + SqlScalarType::String.nullable(true), + SemanticType::CatalogItemId, + ) .with_column("size", SqlScalarType::String.nullable(true)) .with_column("envelope_type", SqlScalarType::String.nullable(true)) // This `format` column is deprecated and replaced by the `key_format` and `value_format` columns @@ -3128,14 +3317,26 @@ pub static MZ_SINKS: LazyLock = LazyLock::new(|| { .with_column("format", SqlScalarType::String.nullable(true)) .with_column("key_format", SqlScalarType::String.nullable(true)) .with_column("value_format", SqlScalarType::String.nullable(true)) - .with_column("cluster_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ClusterId) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) - .with_column("create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SqlDefinition) - .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RedactedSqlDefinition) + .with_column_semantic_type( + "cluster_id", + SqlScalarType::String.nullable(false), + SemanticType::ClusterId, + ) + .with_column_semantic_type( + "owner_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) + .with_column_semantic_type( + "create_sql", + SqlScalarType::String.nullable(false), + SemanticType::SqlDefinition, + ) + .with_column_semantic_type( + "redacted_create_sql", + SqlScalarType::String.nullable(false), + SemanticType::RedactedSqlDefinition, + ) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3218,25 +3419,42 @@ pub static MZ_VIEWS: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_VIEWS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) - .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SchemaId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column_semantic_type( + "schema_id", + SqlScalarType::String.nullable(false), + SemanticType::SchemaId, + ) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("definition", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SqlDefinition) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type( + "definition", + SqlScalarType::String.nullable(false), + SemanticType::SqlDefinition, + ) + .with_column_semantic_type( + "owner_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) - .with_column("create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SqlDefinition) - .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RedactedSqlDefinition) + .with_column_semantic_type( + "create_sql", + SqlScalarType::String.nullable(false), + SemanticType::SqlDefinition, + ) + .with_column_semantic_type( + "redacted_create_sql", + SqlScalarType::String.nullable(false), + SemanticType::RedactedSqlDefinition, + ) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3286,27 +3504,19 @@ pub static MZ_MATERIALIZED_VIEWS: LazyLock = LazyLock:: schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_MATERIALIZED_VIEWS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) - .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SchemaId) + .with_column_semantic_type("id", SqlScalarType::String.nullable(false), SemanticType::CatalogItemId) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column_semantic_type("schema_id", SqlScalarType::String.nullable(false), SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("cluster_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ClusterId) - .with_column("definition", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SqlDefinition) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type("cluster_id", SqlScalarType::String.nullable(false), SemanticType::ClusterId) + .with_column_semantic_type("definition", SqlScalarType::String.nullable(false), SemanticType::SqlDefinition) + .with_column_semantic_type("owner_id", SqlScalarType::String.nullable(false), SemanticType::RoleId) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) - .with_column("create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SqlDefinition) - .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RedactedSqlDefinition) + .with_column_semantic_type("create_sql", SqlScalarType::String.nullable(false), SemanticType::SqlDefinition) + .with_column_semantic_type("redacted_create_sql", SqlScalarType::String.nullable(false), SemanticType::RedactedSqlDefinition) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3476,24 +3686,38 @@ pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_TYPES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) - .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SchemaId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column_semantic_type( + "schema_id", + SqlScalarType::String.nullable(false), + SemanticType::SchemaId, + ) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("category", SqlScalarType::String.nullable(false)) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type( + "owner_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) - .with_column("create_sql", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::SqlDefinition) - .with_column("redacted_create_sql", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::RedactedSqlDefinition) + .with_column_semantic_type( + "create_sql", + SqlScalarType::String.nullable(true), + SemanticType::SqlDefinition, + ) + .with_column_semantic_type( + "redacted_create_sql", + SqlScalarType::String.nullable(true), + SemanticType::RedactedSqlDefinition, + ) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3543,17 +3767,22 @@ pub static MZ_NETWORK_POLICIES: LazyLock = LazyLock::ne schema: MZ_INTERNAL_SCHEMA, oid: oid::MV_MZ_NETWORK_POLICIES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::NetworkPolicyId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::NetworkPolicyId, + ) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type( + "owner_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) .with_key(vec![0]) .with_key(vec![4]) .finish(), @@ -3672,12 +3901,21 @@ pub static MZ_TYPE_PG_METADATA: LazyLock = LazyLock::new(|| Builti schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_TYPE_PG_METADATA_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("typinput", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) - .with_column("typreceive", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( + "typinput", + SqlScalarType::Oid.nullable(false), + SemanticType::OID, + ) + .with_column_semantic_type( + "typreceive", + SqlScalarType::Oid.nullable(false), + SemanticType::OID, + ) .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, @@ -3689,10 +3927,16 @@ pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| BuiltinTabl schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_ARRAY_TYPES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("element_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( + "element_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .finish(), column_comments: BTreeMap::from_iter([ ("id", "The ID of the array type."), @@ -3722,8 +3966,11 @@ pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinTable schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_BASE_TYPES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .finish(), column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]), is_retained_metrics_object: false, @@ -3739,10 +3986,16 @@ pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_LIST_TYPES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("element_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( + "element_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column( "element_modifiers", SqlScalarType::List { @@ -3784,12 +4037,21 @@ pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_MAP_TYPES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("key_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("value_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( + "key_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( + "value_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column( "key_modifiers", SqlScalarType::List { @@ -3849,10 +4111,12 @@ pub static MZ_ROLES: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_ROLES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("inherit", SqlScalarType::Bool.nullable(false)) .with_column("rolcanlogin", SqlScalarType::Bool.nullable(true)) @@ -3886,12 +4150,21 @@ pub static MZ_ROLE_MEMBERS: LazyLock = LazyLock::new(|| schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_ROLE_MEMBERS_OID, desc: RelationDesc::builder() - .with_column("role_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) - .with_column("member", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) - .with_column("grantor", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type( + "role_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) + .with_column_semantic_type( + "member", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) + .with_column_semantic_type( + "grantor", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -3953,8 +4226,11 @@ pub static MZ_ROLE_PARAMETERS: LazyLock = LazyLock::new(|| Builtin schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_ROLE_PARAMETERS_OID, desc: RelationDesc::builder() - .with_column("role_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type( + "role_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) .with_column("parameter_name", SqlScalarType::String.nullable(false)) .with_column("parameter_value", SqlScalarType::String.nullable(false)) .finish(), @@ -3989,10 +4265,16 @@ pub static MZ_ROLE_AUTH: LazyLock = LazyLock::new(|| BuiltinTable schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_ROLE_AUTH_OID, desc: RelationDesc::builder() - .with_column("role_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) - .with_column("role_oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) + .with_column_semantic_type( + "role_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) + .with_column_semantic_type( + "role_oid", + SqlScalarType::Oid.nullable(false), + SemanticType::OID, + ) .with_column("password_hash", SqlScalarType::String.nullable(true)) .with_column( "updated_at", @@ -4023,8 +4305,11 @@ pub static MZ_PSEUDO_TYPES: LazyLock = LazyLock::new(|| BuiltinTab schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_PSEUDO_TYPES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .finish(), column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]), is_retained_metrics_object: false, @@ -4041,27 +4326,38 @@ pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_FUNCTIONS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) // not a key! - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) - .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SchemaId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) // not a key! + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column_semantic_type( + "schema_id", + SqlScalarType::String.nullable(false), + SemanticType::SchemaId, + ) .with_column("name", SqlScalarType::String.nullable(false)) .with_column( "argument_type_ids", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), ) - .with_column( + .with_column_semantic_type( "variadic_argument_type_id", SqlScalarType::String.nullable(true), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( + "return_type_id", + SqlScalarType::String.nullable(true), + SemanticType::CatalogItemId, ) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("return_type_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::CatalogItemId) .with_column("returns_set", SqlScalarType::Bool.nullable(false)) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type( + "owner_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) .finish(), column_comments: BTreeMap::from_iter([ ("id", "Materialize's unique ID for the function."), @@ -4127,15 +4423,17 @@ pub static MZ_OPERATORS: LazyLock = LazyLock::new(|| BuiltinTable schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_OPERATORS_OID, desc: RelationDesc::builder() - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) .with_column("name", SqlScalarType::String.nullable(false)) .with_column( "argument_type_ids", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), ) - .with_column("return_type_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "return_type_id", + SqlScalarType::String.nullable(true), + SemanticType::CatalogItemId, + ) .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, @@ -4155,8 +4453,7 @@ pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinTable schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_AGGREGATES_OID, desc: RelationDesc::builder() - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) .with_column("agg_kind", SqlScalarType::String.nullable(false)) .with_column("agg_num_direct_args", SqlScalarType::Int16.nullable(false)) .finish(), @@ -4175,11 +4472,17 @@ pub static MZ_CLUSTERS: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_CLUSTERS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ClusterId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::ClusterId, + ) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type( + "owner_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -4269,8 +4572,11 @@ pub static MZ_CLUSTER_WORKLOAD_CLASSES: LazyLock = schema: MZ_INTERNAL_SCHEMA, oid: oid::MV_MZ_CLUSTER_WORKLOAD_CLASSES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ClusterId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::ClusterId, + ) .with_column("workload_class", SqlScalarType::String.nullable(true)) .with_key(vec![0]) .finish(), @@ -4306,8 +4612,11 @@ pub static MZ_CLUSTER_SCHEDULES: LazyLock = LazyLock::new(|| Built schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_CLUSTER_SCHEDULES_OID, desc: RelationDesc::builder() - .with_column("cluster_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ClusterId) + .with_column_semantic_type( + "cluster_id", + SqlScalarType::String.nullable(false), + SemanticType::ClusterId, + ) .with_column("type", SqlScalarType::String.nullable(false)) .with_column( "refresh_hydration_time_estimate", @@ -4344,15 +4653,11 @@ pub static MZ_SECRETS: LazyLock = LazyLock::new(|| { schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_SECRETS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) - .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SchemaId) + .with_column_semantic_type("id", SqlScalarType::String.nullable(false), SemanticType::CatalogItemId) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column_semantic_type("schema_id", SqlScalarType::String.nullable(false), SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type("owner_id", SqlScalarType::String.nullable(false), SemanticType::RoleId) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -4419,17 +4724,26 @@ pub static MZ_CLUSTER_REPLICAS: LazyLock = LazyLock::new(|| Builti schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_CLUSTER_REPLICAS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ReplicaId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::ReplicaId, + ) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("cluster_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ClusterId) + .with_column_semantic_type( + "cluster_id", + SqlScalarType::String.nullable(false), + SemanticType::ClusterId, + ) .with_column("size", SqlScalarType::String.nullable(true)) // `NULL` for un-orchestrated clusters and for replicas where the user // hasn't specified them. .with_column("availability_zone", SqlScalarType::String.nullable(true)) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type( + "owner_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) .with_column("disk", SqlScalarType::Bool.nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ @@ -4512,8 +4826,11 @@ pub static MZ_PENDING_CLUSTER_REPLICAS: LazyLock = schema: MZ_INTERNAL_SCHEMA, oid: oid::MV_MZ_PENDING_CLUSTER_REPLICAS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ReplicaId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::ReplicaId, + ) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([( @@ -4577,16 +4894,19 @@ pub static MZ_CLUSTER_REPLICA_STATUSES: LazyLock = LazyLock::new(|| schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_CLUSTER_REPLICA_STATUSES_OID, desc: RelationDesc::builder() - .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ReplicaId) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(false), + SemanticType::ReplicaId, + ) .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("reason", SqlScalarType::String.nullable(true)) - .with_column( + .with_column_semantic_type( "updated_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), + SemanticType::WallclockTimestamp, ) - .with_semantic_type(SemanticType::WallclockTimestamp) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -4643,15 +4963,21 @@ pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock = LazyLock::new(|| B .with_column("processes", SqlScalarType::UInt64.nullable(false)) .with_column("workers", SqlScalarType::UInt64.nullable(false)) .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(false)) - .with_column("memory_bytes", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type(SemanticType::ByteCount) - .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true)) - .with_semantic_type(SemanticType::ByteCount) - .with_column( + .with_column_semantic_type( + "memory_bytes", + SqlScalarType::UInt64.nullable(false), + SemanticType::ByteCount, + ) + .with_column_semantic_type( + "disk_bytes", + SqlScalarType::UInt64.nullable(true), + SemanticType::ByteCount, + ) + .with_column_semantic_type( "credits_per_hour", SqlScalarType::Numeric { max_scale: None }.nullable(false), + SemanticType::CreditRate, ) - .with_semantic_type(SemanticType::CreditRate) .finish(), column_comments: BTreeMap::from_iter([ ("size", "The human-readable replica size."), @@ -4690,15 +5016,18 @@ pub static MZ_AUDIT_EVENTS: LazyLock = LazyLock::new(|| BuiltinTab desc: RelationDesc::builder() .with_column("id", SqlScalarType::UInt64.nullable(false)) .with_column("event_type", SqlScalarType::String.nullable(false)) - .with_column("object_type", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ObjectType) + .with_column_semantic_type( + "object_type", + SqlScalarType::String.nullable(false), + SemanticType::ObjectType, + ) .with_column("details", SqlScalarType::Jsonb.nullable(false)) .with_column("user", SqlScalarType::String.nullable(true)) - .with_column( + .with_column_semantic_type( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), + SemanticType::WallclockTimestamp, ) - .with_semantic_type(SemanticType::WallclockTimestamp) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -4820,8 +5149,11 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUSES: LazyLock = LazyL schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_AWS_PRIVATELINK_CONNECTION_STATUSES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("name", SqlScalarType::String.nullable(false)) .with_column( "last_status_change_at", @@ -4999,8 +5331,11 @@ pub static MZ_RECENT_SQL_TEXT: LazyLock = LazyLock::new(|| { // could have a `prepared day` anywhere from 3 to 4 days back. desc: RelationDesc::builder() .with_column("sql_hash", SqlScalarType::Bytes.nullable(false)) - .with_column("sql", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SqlDefinition) + .with_column_semantic_type( + "sql", + SqlScalarType::String.nullable(false), + SemanticType::SqlDefinition, + ) .with_column("redacted_sql", SqlScalarType::String.nullable(false)) .with_key(vec![0, 1, 2]) .finish(), @@ -5189,8 +5524,11 @@ pub static MZ_RECENT_ACTIVITY_LOG: LazyLock = LazyLock::new(|| Buil desc: RelationDesc::builder() .with_column("execution_id", SqlScalarType::Uuid.nullable(false)) .with_column("sample_rate", SqlScalarType::Float64.nullable(false)) - .with_column("cluster_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::ClusterId) + .with_column_semantic_type( + "cluster_id", + SqlScalarType::String.nullable(true), + SemanticType::ClusterId, + ) .with_column("application_name", SqlScalarType::String.nullable(false)) .with_column("cluster_name", SqlScalarType::String.nullable(true)) .with_column("database_name", SqlScalarType::String.nullable(false)) @@ -5206,25 +5544,31 @@ pub static MZ_RECENT_ACTIVITY_LOG: LazyLock = LazyLock::new(|| Buil "transaction_isolation", SqlScalarType::String.nullable(false), ) - .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true)) - .with_semantic_type(SemanticType::MzTimestamp) - .with_column("transient_index_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::GlobalId) + .with_column_semantic_type( + "execution_timestamp", + SqlScalarType::UInt64.nullable(true), + SemanticType::MzTimestamp, + ) + .with_column_semantic_type( + "transient_index_id", + SqlScalarType::String.nullable(true), + SemanticType::GlobalId, + ) .with_column( "params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), ) .with_column("mz_version", SqlScalarType::String.nullable(false)) - .with_column( + .with_column_semantic_type( "began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), + SemanticType::WallclockTimestamp, ) - .with_semantic_type(SemanticType::WallclockTimestamp) - .with_column( + .with_column_semantic_type( "finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true), + SemanticType::WallclockTimestamp, ) - .with_semantic_type(SemanticType::WallclockTimestamp) .with_column("finished_status", SqlScalarType::String.nullable(true)) .with_column("error_message", SqlScalarType::String.nullable(true)) .with_column("result_size", SqlScalarType::Int64.nullable(true)) @@ -5238,25 +5582,28 @@ pub static MZ_RECENT_ACTIVITY_LOG: LazyLock = LazyLock::new(|| Buil SqlScalarType::String.nullable(false), ) .with_column("session_id", SqlScalarType::Uuid.nullable(false)) - .with_column( + .with_column_semantic_type( "prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), + SemanticType::WallclockTimestamp, ) - .with_semantic_type(SemanticType::WallclockTimestamp) .with_column("statement_type", SqlScalarType::String.nullable(true)) .with_column("throttled_count", SqlScalarType::UInt64.nullable(false)) - .with_column( + .with_column_semantic_type( "connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), + SemanticType::WallclockTimestamp, ) - .with_semantic_type(SemanticType::WallclockTimestamp) .with_column( "initial_application_name", SqlScalarType::String.nullable(false), ) .with_column("authenticated_user", SqlScalarType::String.nullable(false)) - .with_column("sql", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SqlDefinition) + .with_column_semantic_type( + "sql", + SqlScalarType::String.nullable(false), + SemanticType::SqlDefinition, + ) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -5505,16 +5852,22 @@ pub static MZ_SOURCE_STATUSES: LazyLock = LazyLock::new(|| BuiltinV schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_SOURCE_STATUSES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("type", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SourceType) - .with_column( + .with_column_semantic_type( + "type", + SqlScalarType::String.nullable(false), + SemanticType::SourceType, + ) + .with_column_semantic_type( "last_status_change_at", SqlScalarType::TimestampTz { precision: None }.nullable(true), + SemanticType::WallclockTimestamp, ) - .with_semantic_type(SemanticType::WallclockTimestamp) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) .with_column("details", SqlScalarType::Jsonb.nullable(true)) @@ -5750,15 +6103,18 @@ pub static MZ_SINK_STATUSES: LazyLock = LazyLock::new(|| BuiltinVie schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_SINK_STATUSES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) - .with_column( + .with_column_semantic_type( "last_status_change_at", SqlScalarType::TimestampTz { precision: None }.nullable(true), + SemanticType::WallclockTimestamp, ) - .with_semantic_type(SemanticType::WallclockTimestamp) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) .with_column("details", SqlScalarType::Jsonb.nullable(true)) @@ -5874,15 +6230,21 @@ pub static MZ_STORAGE_USAGE_BY_SHARD: LazyLock = LazyLock::new(|| oid: oid::TABLE_MZ_STORAGE_USAGE_BY_SHARD_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::UInt64.nullable(false)) - .with_column("shard_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::ShardId) - .with_column("size_bytes", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type(SemanticType::ByteCount) - .with_column( + .with_column_semantic_type( + "shard_id", + SqlScalarType::String.nullable(true), + SemanticType::ShardId, + ) + .with_column_semantic_type( + "size_bytes", + SqlScalarType::UInt64.nullable(false), + SemanticType::ByteCount, + ) + .with_column_semantic_type( "collection_timestamp", SqlScalarType::TimestampTz { precision: None }.nullable(false), + SemanticType::WallclockTimestamp, ) - .with_semantic_type(SemanticType::WallclockTimestamp) .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, @@ -5926,8 +6288,11 @@ pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock = LazyLock::ne schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_AWS_PRIVATELINK_CONNECTIONS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("principal", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -6076,18 +6441,33 @@ pub static MZ_CLUSTER_REPLICA_METRICS: LazyLock = LazyLock::new(|| schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_CLUSTER_REPLICA_METRICS_OID, desc: RelationDesc::builder() - .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ReplicaId) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(false), + SemanticType::ReplicaId, + ) .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(true)) - .with_column("memory_bytes", SqlScalarType::UInt64.nullable(true)) - .with_semantic_type(SemanticType::ByteCount) - .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true)) - .with_semantic_type(SemanticType::ByteCount) - .with_column("heap_bytes", SqlScalarType::UInt64.nullable(true)) - .with_semantic_type(SemanticType::ByteCount) - .with_column("heap_limit", SqlScalarType::UInt64.nullable(true)) - .with_semantic_type(SemanticType::ByteCount) + .with_column_semantic_type( + "memory_bytes", + SqlScalarType::UInt64.nullable(true), + SemanticType::ByteCount, + ) + .with_column_semantic_type( + "disk_bytes", + SqlScalarType::UInt64.nullable(true), + SemanticType::ByteCount, + ) + .with_column_semantic_type( + "heap_bytes", + SqlScalarType::UInt64.nullable(true), + SemanticType::ByteCount, + ) + .with_column_semantic_type( + "heap_limit", + SqlScalarType::UInt64.nullable(true), + SemanticType::ByteCount, + ) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -6137,12 +6517,21 @@ pub static MZ_CLUSTER_REPLICA_FRONTIERS: LazyLock = oid: oid::SOURCE_MZ_CLUSTER_REPLICA_FRONTIERS_OID, data_source: IntrospectionType::ReplicaFrontiers.into(), desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) - .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ReplicaId) - .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true)) - .with_semantic_type(SemanticType::MzTimestamp) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(false), + SemanticType::ReplicaId, + ) + .with_column_semantic_type( + "write_frontier", + SqlScalarType::MzTimestamp.nullable(true), + SemanticType::MzTimestamp, + ) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -6175,12 +6564,21 @@ pub static MZ_FRONTIERS: LazyLock = LazyLock::new(|| BuiltinSourc oid: oid::SOURCE_MZ_FRONTIERS_OID, data_source: IntrospectionType::Frontiers.into(), desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) - .with_column("read_frontier", SqlScalarType::MzTimestamp.nullable(true)) - .with_semantic_type(SemanticType::MzTimestamp) - .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true)) - .with_semantic_type(SemanticType::MzTimestamp) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) + .with_column_semantic_type( + "read_frontier", + SqlScalarType::MzTimestamp.nullable(true), + SemanticType::MzTimestamp, + ) + .with_column_semantic_type( + "write_frontier", + SqlScalarType::MzTimestamp.nullable(true), + SemanticType::MzTimestamp, + ) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -6215,10 +6613,16 @@ pub static MZ_GLOBAL_FRONTIERS: LazyLock = LazyLock::new(|| Builtin schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_GLOBAL_FRONTIERS_OID, desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) - .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) - .with_semantic_type(SemanticType::MzTimestamp) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) + .with_column_semantic_type( + "time", + SqlScalarType::MzTimestamp.nullable(false), + SemanticType::MzTimestamp, + ) .finish(), column_comments: BTreeMap::new(), sql: " @@ -6278,14 +6682,17 @@ pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTORY: LazyLock = LazyLock::ne schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_HISTORY_OID, desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) .with_column("lag", SqlScalarType::Interval.nullable(true)) - .with_column( + .with_column_semantic_type( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), + SemanticType::WallclockTimestamp, ) - .with_semantic_type(SemanticType::WallclockTimestamp) .with_key(vec![0, 2]) .finish(), column_comments: BTreeMap::from_iter([ @@ -6335,8 +6742,11 @@ pub static MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY: LazyLock = LazyL schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_OID, desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) .with_column("lag", SqlScalarType::Interval.nullable(true)) .with_column( "occurred_at", @@ -6372,8 +6782,11 @@ pub static MZ_WALLCLOCK_GLOBAL_LAG: LazyLock = LazyLock::new(|| Bui schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_OID, desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) .with_column("lag", SqlScalarType::Interval.nullable(true)) .with_key(vec![0]) .finish(), @@ -6490,11 +6903,17 @@ pub static MZ_SUBSCRIPTIONS: LazyLock = LazyLock::new(|| BuiltinTa schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_SUBSCRIPTIONS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("session_id", SqlScalarType::Uuid.nullable(false)) - .with_column("cluster_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ClusterId) + .with_column_semantic_type( + "cluster_id", + SqlScalarType::String.nullable(false), + SemanticType::ClusterId, + ) .with_column( "created_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), @@ -6554,8 +6973,11 @@ pub static MZ_SESSIONS: LazyLock = LazyLock::new(|| BuiltinTable { desc: RelationDesc::builder() .with_column("id", SqlScalarType::Uuid.nullable(false)) .with_column("connection_id", SqlScalarType::UInt32.nullable(false)) - .with_column("role_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type( + "role_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) .with_column("client_ip", SqlScalarType::String.nullable(true)) .with_column( "connected_at", @@ -6599,16 +7021,31 @@ pub static MZ_DEFAULT_PRIVILEGES: LazyLock = LazyLock::new(|| Buil schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_DEFAULT_PRIVILEGES_OID, desc: RelationDesc::builder() - .with_column("role_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) - .with_column("database_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::DatabaseId) - .with_column("schema_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::SchemaId) - .with_column("object_type", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ObjectType) - .with_column("grantee", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) + .with_column_semantic_type( + "role_id", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) + .with_column_semantic_type( + "database_id", + SqlScalarType::String.nullable(true), + SemanticType::DatabaseId, + ) + .with_column_semantic_type( + "schema_id", + SqlScalarType::String.nullable(true), + SemanticType::SchemaId, + ) + .with_column_semantic_type( + "object_type", + SqlScalarType::String.nullable(false), + SemanticType::ObjectType, + ) + .with_column_semantic_type( + "grantee", + SqlScalarType::String.nullable(false), + SemanticType::RoleId, + ) .with_column("privileges", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -6689,10 +7126,16 @@ pub static MZ_COMMENTS: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_COMMENTS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("object_type", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ObjectType) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( + "object_type", + SqlScalarType::String.nullable(false), + SemanticType::ObjectType, + ) .with_column("object_sub_id", SqlScalarType::Int32.nullable(true)) .with_column("comment", SqlScalarType::String.nullable(false)) .finish(), @@ -6729,8 +7172,11 @@ pub static MZ_SOURCE_REFERENCES: LazyLock = LazyLock::new(|| Built schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_SOURCE_REFERENCES_OID, desc: RelationDesc::builder() - .with_column("source_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "source_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("namespace", SqlScalarType::String.nullable(true)) .with_column("name", SqlScalarType::String.nullable(false)) .with_column( @@ -6761,8 +7207,11 @@ pub static MZ_WEBHOOKS_SOURCES: LazyLock = LazyLock::new(|| Builti schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_WEBHOOK_SOURCES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("url", SqlScalarType::String.nullable(false)) .finish(), @@ -6796,8 +7245,11 @@ pub static MZ_HISTORY_RETENTION_STRATEGIES: LazyLock = LazyLock::n schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_HISTORY_RETENTION_STRATEGIES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("strategy", SqlScalarType::String.nullable(false)) .with_column("value", SqlScalarType::Jsonb.nullable(false)) .finish(), @@ -6827,8 +7279,11 @@ pub static MZ_LICENSE_KEYS: LazyLock = LazyLock::new(|| BuiltinTab schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_LICENSE_KEYS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("organization", SqlScalarType::String.nullable(false)) .with_column("environment_id", SqlScalarType::String.nullable(false)) .with_column( @@ -6873,8 +7328,11 @@ pub static MZ_REPLACEMENTS: LazyLock = LazyLock::new(|| BuiltinTab schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_REPLACEMENTS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("target_id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -6938,10 +7396,16 @@ pub static MZ_STORAGE_SHARDS: LazyLock = LazyLock::new(|| Builtin oid: oid::SOURCE_MZ_STORAGE_SHARDS_OID, data_source: IntrospectionType::ShardMapping.into(), desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) - .with_column("shard_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ShardId) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) + .with_column_semantic_type( + "shard_id", + SqlScalarType::String.nullable(false), + SemanticType::ShardId, + ) .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, @@ -6962,15 +7426,21 @@ pub static MZ_STORAGE_USAGE: LazyLock = LazyLock::new(|| BuiltinVie schema: MZ_CATALOG_SCHEMA, oid: oid::VIEW_MZ_STORAGE_USAGE_OID, desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("size_bytes", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type(SemanticType::ByteCount) - .with_column( + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( + "size_bytes", + SqlScalarType::UInt64.nullable(false), + SemanticType::ByteCount, + ) + .with_column_semantic_type( "collection_timestamp", SqlScalarType::TimestampTz { precision: None }.nullable(false), + SemanticType::WallclockTimestamp, ) - .with_semantic_type(SemanticType::WallclockTimestamp) .with_key(vec![0, 2]) .finish(), column_comments: BTreeMap::from_iter([ @@ -7014,10 +7484,8 @@ pub static MZ_RECENT_STORAGE_USAGE: LazyLock = LazyLock::new(|| { schema: MZ_CATALOG_SCHEMA, oid: oid::VIEW_MZ_RECENT_STORAGE_USAGE_OID, desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("size_bytes", SqlScalarType::UInt64.nullable(true)) - .with_semantic_type(SemanticType::ByteCount) + .with_column_semantic_type("object_id", SqlScalarType::String.nullable(false), SemanticType::CatalogItemId) + .with_column_semantic_type("size_bytes", SqlScalarType::UInt64.nullable(true), SemanticType::ByteCount) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -7076,19 +7544,13 @@ pub static MZ_RELATIONS: LazyLock = LazyLock::new(|| { schema: MZ_CATALOG_SCHEMA, oid: oid::VIEW_MZ_RELATIONS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) - .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SchemaId) + .with_column_semantic_type("id", SqlScalarType::String.nullable(false), SemanticType::CatalogItemId) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column_semantic_type("schema_id", SqlScalarType::String.nullable(false), SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("type", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ObjectType) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) - .with_column("cluster_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::ClusterId) + .with_column_semantic_type("type", SqlScalarType::String.nullable(false), SemanticType::ObjectType) + .with_column_semantic_type("owner_id", SqlScalarType::String.nullable(false), SemanticType::RoleId) + .with_column_semantic_type("cluster_id", SqlScalarType::String.nullable(true), SemanticType::ClusterId) .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -7183,19 +7645,13 @@ pub static MZ_OBJECTS: LazyLock = LazyLock::new(|| { schema: MZ_CATALOG_SCHEMA, oid: oid::VIEW_MZ_OBJECTS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_semantic_type(SemanticType::OID) - .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SchemaId) + .with_column_semantic_type("id", SqlScalarType::String.nullable(false), SemanticType::CatalogItemId) + .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column_semantic_type("schema_id", SqlScalarType::String.nullable(false), SemanticType::SchemaId) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("type", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ObjectType) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::RoleId) - .with_column("cluster_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::ClusterId) + .with_column_semantic_type("type", SqlScalarType::String.nullable(false), SemanticType::ObjectType) + .with_column_semantic_type("owner_id", SqlScalarType::String.nullable(false), SemanticType::RoleId) + .with_column_semantic_type("cluster_id", SqlScalarType::String.nullable(true), SemanticType::ClusterId) .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ @@ -7244,19 +7700,34 @@ pub static MZ_OBJECT_FULLY_QUALIFIED_NAMES: LazyLock = LazyLock::ne schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_OBJECT_FULLY_QUALIFIED_NAMES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("object_type", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ObjectType) - .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::SchemaId) + .with_column_semantic_type( + "object_type", + SqlScalarType::String.nullable(false), + SemanticType::ObjectType, + ) + .with_column_semantic_type( + "schema_id", + SqlScalarType::String.nullable(false), + SemanticType::SchemaId, + ) .with_column("schema_name", SqlScalarType::String.nullable(false)) - .with_column("database_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::DatabaseId) + .with_column_semantic_type( + "database_id", + SqlScalarType::String.nullable(true), + SemanticType::DatabaseId, + ) .with_column("database_name", SqlScalarType::String.nullable(true)) - .with_column("cluster_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::ClusterId) + .with_column_semantic_type( + "cluster_id", + SqlScalarType::String.nullable(true), + SemanticType::ClusterId, + ) .finish(), column_comments: BTreeMap::from_iter([ ("id", "Materialize's unique ID for the object."), @@ -7333,8 +7804,11 @@ pub static MZ_OBJECT_GLOBAL_IDS: LazyLock = LazyLock::new(|| Built schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_OBJECT_GLOBAL_IDS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("global_id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -7363,11 +7837,17 @@ pub static MZ_OBJECT_LIFETIMES: LazyLock = LazyLock::new(|| Builtin schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_OBJECT_LIFETIMES_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(true), + SemanticType::CatalogItemId, + ) .with_column("previous_id", SqlScalarType::String.nullable(true)) - .with_column("object_type", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ObjectType) + .with_column_semantic_type( + "object_type", + SqlScalarType::String.nullable(false), + SemanticType::ObjectType, + ) .with_column("event_type", SqlScalarType::String.nullable(false)) .with_column( "occurred_at", @@ -7419,8 +7899,11 @@ pub static MZ_OBJECT_HISTORY: LazyLock = LazyLock::new(|| BuiltinVi schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_OBJECT_HISTORY_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(true), + SemanticType::CatalogItemId, + ) .with_column("cluster_id", SqlScalarType::String.nullable(true)) .with_column("object_type", SqlScalarType::String.nullable(false)) .with_column( @@ -7674,8 +8157,11 @@ pub static MZ_DATAFLOW_GLOBAL_IDS: LazyLock = LazyLock::new(|| Buil oid: oid::VIEW_MZ_DATAFLOW_GLOBAL_IDS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::UInt64.nullable(false)) - .with_column("global_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) + .with_column_semantic_type( + "global_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -7696,8 +8182,11 @@ pub static MZ_MAPPABLE_OBJECTS: LazyLock = LazyLock::new(|| Builtin oid: oid::VIEW_MZ_MAPPABLE_OBJECTS_OID, desc: RelationDesc::builder() .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("global_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) + .with_column_semantic_type( + "global_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -7726,8 +8215,11 @@ pub static MZ_LIR_MAPPING: LazyLock = LazyLock::new(|| BuiltinView schema: MZ_INTROSPECTION_SCHEMA, oid: oid::VIEW_MZ_LIR_MAPPING_OID, desc: RelationDesc::builder() - .with_column("global_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) + .with_column_semantic_type( + "global_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) .with_column("lir_id", SqlScalarType::UInt64.nullable(false)) .with_column("operator", SqlScalarType::String.nullable(false)) .with_column("parent_lir_id", SqlScalarType::UInt64.nullable(true)) @@ -7848,13 +8340,16 @@ pub static MZ_OBJECT_TRANSITIVE_DEPENDENCIES: LazyLock = LazyLock:: schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_OBJECT_TRANSITIVE_DEPENDENCIES_OID, desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column( + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( "referenced_object_id", SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, ) - .with_semantic_type(SemanticType::CatalogItemId) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -7900,15 +8395,18 @@ pub static MZ_COMPUTE_EXPORTS: LazyLock = LazyLock::new(|| BuiltinV schema: MZ_INTROSPECTION_SCHEMA, oid: oid::VIEW_MZ_COMPUTE_EXPORTS_OID, desc: RelationDesc::builder() - .with_column("export_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) + .with_column_semantic_type( + "export_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false)) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ ( "export_id", - "The ID of the index, materialized view, or subscription exported by the dataflow. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, or `mz_internal.mz_subscriptions`.", + "The ID of the index, materialized view, or subscription exported by the dataflow. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, or `mz_internal.mz_subscriptions.id`.", ), ( "dataflow_id", @@ -7943,10 +8441,16 @@ pub static MZ_COMPUTE_FRONTIERS: LazyLock = LazyLock::new(|| Builti schema: MZ_INTROSPECTION_SCHEMA, oid: oid::VIEW_MZ_COMPUTE_FRONTIERS_OID, desc: RelationDesc::builder() - .with_column("export_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) - .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) - .with_semantic_type(SemanticType::MzTimestamp) + .with_column_semantic_type( + "export_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) + .with_column_semantic_type( + "time", + SqlScalarType::MzTimestamp.nullable(false), + SemanticType::MzTimestamp, + ) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -8106,12 +8610,21 @@ pub static MZ_COMPUTE_IMPORT_FRONTIERS: LazyLock = LazyLock::new(|| schema: MZ_INTROSPECTION_SCHEMA, oid: oid::VIEW_MZ_COMPUTE_IMPORT_FRONTIERS_OID, desc: RelationDesc::builder() - .with_column("export_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) - .with_column("import_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) - .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) - .with_semantic_type(SemanticType::MzTimestamp) + .with_column_semantic_type( + "export_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) + .with_column_semantic_type( + "import_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) + .with_column_semantic_type( + "time", + SqlScalarType::MzTimestamp.nullable(false), + SemanticType::MzTimestamp, + ) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -9862,8 +10375,11 @@ pub static MZ_COMPUTE_ERROR_COUNTS: LazyLock = LazyLock::new(|| Bui schema: MZ_INTROSPECTION_SCHEMA, oid: oid::VIEW_MZ_COMPUTE_ERROR_COUNTS_OID, desc: RelationDesc::builder() - .with_column("export_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) + .with_column_semantic_type( + "export_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) .with_column( "count", SqlScalarType::Numeric { @@ -9911,10 +10427,16 @@ pub static MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED: LazyLock = schema: MZ_INTERNAL_SCHEMA, oid: oid::SOURCE_MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED_OID, desc: RelationDesc::builder() - .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ReplicaId) - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(false), + SemanticType::ReplicaId, + ) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column( "count", SqlScalarType::Numeric { max_scale: None }.nullable(false), @@ -9932,10 +10454,16 @@ pub static MZ_COMPUTE_HYDRATION_TIMES: LazyLock = LazyLock::new(| schema: MZ_INTERNAL_SCHEMA, oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_TIMES_OID, desc: RelationDesc::builder() - .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ReplicaId) - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(false), + SemanticType::ReplicaId, + ) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("time_ns", SqlScalarType::UInt64.nullable(true)) .finish(), data_source: IntrospectionType::ComputeHydrationTimes.into(), @@ -9964,10 +10492,16 @@ pub static MZ_COMPUTE_HYDRATION_STATUSES: LazyLock = LazyLock::new( schema: MZ_INTERNAL_SCHEMA, oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_STATUSES_OID, desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) - .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ReplicaId) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(false), + SemanticType::ReplicaId, + ) .with_column("hydrated", SqlScalarType::Bool.nullable(false)) .with_column("hydration_time", SqlScalarType::Interval.nullable(true)) .finish(), @@ -10027,10 +10561,16 @@ pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES: LazyLock = Laz schema: MZ_INTERNAL_SCHEMA, oid: oid::SOURCE_MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_OID, desc: RelationDesc::builder() - .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ReplicaId) - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(false), + SemanticType::ReplicaId, + ) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column( "physical_plan_node_id", SqlScalarType::UInt64.nullable(false), @@ -10210,11 +10750,17 @@ pub static MZ_ACTIVE_PEEKS: LazyLock = LazyLock::new(|| BuiltinView oid: oid::VIEW_MZ_ACTIVE_PEEKS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::Uuid.nullable(false)) - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) .with_column("type", SqlScalarType::String.nullable(false)) - .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) - .with_semantic_type(SemanticType::MzTimestamp) + .with_column_semantic_type( + "time", + SqlScalarType::MzTimestamp.nullable(false), + SemanticType::MzTimestamp, + ) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -10590,8 +11136,11 @@ pub static MZ_CLUSTER_REPLICA_UTILIZATION: LazyLock = LazyLock::new schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_CLUSTER_REPLICA_UTILIZATION_OID, desc: RelationDesc::builder() - .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ReplicaId) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(false), + SemanticType::ReplicaId, + ) .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("cpu_percent", SqlScalarType::Float64.nullable(true)) .with_column("memory_percent", SqlScalarType::Float64.nullable(true)) @@ -13971,8 +14520,11 @@ pub static MZ_CLUSTER_REPLICA_NAME_HISTORY: LazyLock = LazyLock::ne "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(true), ) - .with_column("id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(true), + SemanticType::CatalogItemId, + ) .with_column("previous_name", SqlScalarType::String.nullable(true)) .with_column("new_name", SqlScalarType::String.nullable(true)) .finish(), @@ -14039,10 +14591,16 @@ pub static MZ_HYDRATION_STATUSES: LazyLock = LazyLock::new(|| Built schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_HYDRATION_STATUSES_OID, desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("replica_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::ReplicaId) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(true), + SemanticType::ReplicaId, + ) .with_column("hydrated", SqlScalarType::Bool.nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ @@ -14151,10 +14709,16 @@ pub static MZ_MATERIALIZATION_DEPENDENCIES: LazyLock = LazyLock::ne schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_MATERIALIZATION_DEPENDENCIES_OID, desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("dependency_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( + "dependency_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -14198,20 +14762,23 @@ pub static MZ_MATERIALIZATION_LAG: LazyLock = LazyLock::new(|| Buil schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_MATERIALIZATION_LAG_OID, desc: RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("local_lag", SqlScalarType::Interval.nullable(true)) .with_column("global_lag", SqlScalarType::Interval.nullable(true)) - .with_column( + .with_column_semantic_type( "slowest_local_input_id", SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, ) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column( + .with_column_semantic_type( "slowest_global_input_id", SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, ) - .with_semantic_type(SemanticType::CatalogItemId) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -15220,36 +15787,60 @@ pub static MZ_SOURCE_STATISTICS: LazyLock = LazyLock::new(|| { oid: oid::VIEW_MZ_SOURCE_STATISTICS_OID, // We need to add a redundant where clause for a new dataflow to be created. desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("replica_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::ReplicaId) - .with_column("messages_received", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type(SemanticType::RecordCount) - .with_column("bytes_received", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type(SemanticType::ByteCount) - .with_column("updates_staged", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type(SemanticType::RecordCount) - .with_column("updates_committed", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type(SemanticType::RecordCount) - .with_column("records_indexed", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type(SemanticType::RecordCount) - .with_column("bytes_indexed", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type(SemanticType::ByteCount) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(true), + SemanticType::ReplicaId, + ) + .with_column_semantic_type( + "messages_received", + SqlScalarType::UInt64.nullable(false), + SemanticType::RecordCount, + ) + .with_column_semantic_type( + "bytes_received", + SqlScalarType::UInt64.nullable(false), + SemanticType::ByteCount, + ) + .with_column_semantic_type( + "updates_staged", + SqlScalarType::UInt64.nullable(false), + SemanticType::RecordCount, + ) + .with_column_semantic_type( + "updates_committed", + SqlScalarType::UInt64.nullable(false), + SemanticType::RecordCount, + ) + .with_column_semantic_type( + "records_indexed", + SqlScalarType::UInt64.nullable(false), + SemanticType::RecordCount, + ) + .with_column_semantic_type( + "bytes_indexed", + SqlScalarType::UInt64.nullable(false), + SemanticType::ByteCount, + ) .with_column( "rehydration_latency", SqlScalarType::Interval.nullable(true), ) - .with_column( + .with_column_semantic_type( "snapshot_records_known", SqlScalarType::UInt64.nullable(true), + SemanticType::RecordCount, ) - .with_semantic_type(SemanticType::RecordCount) - .with_column( + .with_column_semantic_type( "snapshot_records_staged", SqlScalarType::UInt64.nullable(true), + SemanticType::RecordCount, ) - .with_semantic_type(SemanticType::RecordCount) .with_column("snapshot_committed", SqlScalarType::Bool.nullable(false)) .with_column("offset_known", SqlScalarType::UInt64.nullable(true)) .with_column("offset_committed", SqlScalarType::UInt64.nullable(true)) @@ -15341,18 +15932,36 @@ pub static MZ_SINK_STATISTICS: LazyLock = LazyLock::new(|| BuiltinV schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_SINK_STATISTICS_OID, desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .with_column("replica_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::ReplicaId) - .with_column("messages_staged", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type(SemanticType::RecordCount) - .with_column("messages_committed", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type(SemanticType::RecordCount) - .with_column("bytes_staged", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type(SemanticType::ByteCount) - .with_column("bytes_committed", SqlScalarType::UInt64.nullable(false)) - .with_semantic_type(SemanticType::ByteCount) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(true), + SemanticType::ReplicaId, + ) + .with_column_semantic_type( + "messages_staged", + SqlScalarType::UInt64.nullable(false), + SemanticType::RecordCount, + ) + .with_column_semantic_type( + "messages_committed", + SqlScalarType::UInt64.nullable(false), + SemanticType::RecordCount, + ) + .with_column_semantic_type( + "bytes_staged", + SqlScalarType::UInt64.nullable(false), + SemanticType::ByteCount, + ) + .with_column_semantic_type( + "bytes_committed", + SqlScalarType::UInt64.nullable(false), + SemanticType::ByteCount, + ) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -16656,6 +17265,47 @@ mod tests { uncovered_fk_cols.join("\n"), ); + // Validate that every source_column referenced in properties_json + // actually names a column in the entity's RelationDesc. This catches + // stale link annotations after column renames or removals. + let mut bad_source_cols = Vec::new(); + for builtin in BUILTINS_STATIC.iter() { + let (name, desc, ontology) = match builtin { + Builtin::Table(t) => (t.name, &t.desc, t.ontology.as_ref()), + Builtin::View(v) => (v.name, &v.desc, v.ontology.as_ref()), + Builtin::MaterializedView(mv) => (mv.name, &mv.desc, mv.ontology.as_ref()), + Builtin::Source(s) => (s.name, &s.desc, s.ontology.as_ref()), + _ => continue, + }; + let Some(ont) = ontology else { continue }; + + let col_names: BTreeSet<&str> = + desc.iter_names().map(|c| c.as_str()).collect(); + + for link in ont.links { + let json = link.properties_json; + let key = "\"source_column\": \""; + let Some(start) = json.find(key).map(|i| i + key.len()) else { + continue; + }; + let Some(end) = json[start..].find('"').map(|i| i + start) else { + continue; + }; + let col = &json[start..end]; + if !col_names.contains(col) { + bad_source_cols.push(format!( + "entity {:?} (builtin {}) link {:?} references source_column {:?} which does not exist in the relation", + ont.entity_name, name, link.name, col + )); + } + } + } + assert!( + bad_source_cols.is_empty(), + "ontology links reference non-existent source_columns:\n{}", + bad_source_cols.join("\n"), + ); + // Sanity check: we have a reasonable number of annotated entities. assert!( entity_names.len() > 90, diff --git a/src/catalog/src/builtin/ontology.rs b/src/catalog/src/builtin/ontology.rs index b3d821ffe46c2..f6a63cd1f7fd6 100644 --- a/src/catalog/src/builtin/ontology.rs +++ b/src/catalog/src/builtin/ontology.rs @@ -107,16 +107,30 @@ fn view( } } -/// Extract the first primary key from a `RelationDesc` and format it as a -/// JSON object, e.g. `{"primary_key": ["id", "schema_id"]}`. Returns `None` -/// if the relation has no keys defined. +/// Extract all keys from a `RelationDesc` and format them as a JSON object: +/// `{"primary_key": ["id"], "alternate_keys": [["oid"]]}`. +/// `primary_key` is the first declared key; `alternate_keys` contains any +/// additional unique keys (e.g. OID). Returns `None` if no keys are defined. fn pk_json(desc: &RelationDesc) -> Option { - let keys = desc.typ().keys.first()?; - let cols: Vec<_> = keys - .iter() - .map(|&i| format!("\"{}\"", desc.get_name(i))) - .collect(); - Some(format!("{{\"primary_key\": [{}]}}", cols.join(", "))) + let all_keys = &desc.typ().keys; + let (first, rest) = all_keys.split_first()?; + let fmt_key = |key: &Vec| -> String { + let cols: Vec<_> = key + .iter() + .map(|&i| serde_json::to_string(desc.get_name(i).as_str()).expect("valid utf-8")) + .collect(); + format!("[{}]", cols.join(", ")) + }; + let primary = fmt_key(first); + if rest.is_empty() { + Some(format!("{{\"primary_key\": {primary}}}")) + } else { + let alts: Vec<_> = rest.iter().map(fmt_key).collect(); + Some(format!( + "{{\"primary_key\": {primary}, \"alternate_keys\": [{}]}}", + alts.join(", ") + )) + } } // ── View builders ──────────────────────────────────────────── @@ -246,7 +260,7 @@ fn link_types_view(infos: &[Info]) -> BuiltinView { esc(l.name), esc(&i.entity_name), esc(l.target), - esc(l.properties_json), + esc(&serde_json::to_string(&l.properties).expect("valid")), ) }) }) diff --git a/src/repr/src/relation.rs b/src/repr/src/relation.rs index b0044f406a616..ea31ea1bf5689 100644 --- a/src/repr/src/relation.rs +++ b/src/repr/src/relation.rs @@ -828,7 +828,7 @@ impl RustType for RelationVersion { /// describe the meaning of a column (e.g., that it contains a catalog item ID /// or a role ID). Possible values correspond to the entries in /// `SEMANTIC_TYPE_DEFS` in the `mz-catalog` crate. -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize)] pub enum SemanticType { CatalogItemId, GlobalId, @@ -960,32 +960,16 @@ struct ColumnMetadata { /// the index in [`SqlRelationType`] that corresponds to a given column, and the /// version at which this column was added or dropped. /// -#[derive(Clone, Debug, Serialize, Deserialize, MzReflect)] +#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, MzReflect)] pub struct RelationDesc { typ: SqlRelationType, metadata: BTreeMap, /// Optional semantic type annotations for columns. /// Keyed by column index. Only populated for builtin catalog objects. - /// Excluded from Eq/Hash/serialization — it's ontology metadata, not schema. #[serde(skip)] semantic_types: BTreeMap, } -impl PartialEq for RelationDesc { - fn eq(&self, other: &Self) -> bool { - self.typ == other.typ && self.metadata == other.metadata - } -} - -impl Eq for RelationDesc {} - -impl std::hash::Hash for RelationDesc { - fn hash(&self, state: &mut H) { - self.typ.hash(state); - self.metadata.hash(state); - } -} - impl RustType for RelationDesc { fn into_proto(&self) -> ProtoRelationDesc { let (names, metadata): (Vec<_>, Vec<_>) = self @@ -1646,15 +1630,17 @@ impl RelationDescBuilder { self } - /// Annotates the most recently added column with a semantic type. - /// - /// Possible values are enumerated in [`SemanticType`]. - pub fn with_semantic_type(mut self, semantic_type: SemanticType) -> RelationDescBuilder { - let idx = self - .columns - .len() - .checked_sub(1) - .expect("no column to annotate"); + /// Appends a column with the specified name and type, and annotates it with + /// a semantic type. Use this instead of chaining [`with_column`] + + /// `with_semantic_type` — it is explicit about which column is annotated. + pub fn with_column_semantic_type>( + mut self, + name: N, + ty: SqlColumnType, + semantic_type: SemanticType, + ) -> RelationDescBuilder { + let idx = self.columns.len(); + self.columns.push((name.into(), ty)); self.semantic_types.insert(idx, semantic_type); self } @@ -2467,59 +2453,48 @@ mod tests { #[mz_ore::test] fn test_semantic_type_annotations() { let desc = RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("cluster_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::ClusterId) + .with_column_semantic_type( + "cluster_id", + SqlScalarType::String.nullable(true), + SemanticType::ClusterId, + ) .finish(); - // Annotated columns return their semantic type. assert_eq!(desc.get_semantic_type(0), Some(SemanticType::CatalogItemId)); assert_eq!(desc.get_semantic_type(2), Some(SemanticType::ClusterId)); - - // Unannotated columns return None. assert_eq!(desc.get_semantic_type(1), None); - - // Out-of-bounds returns None. assert_eq!(desc.get_semantic_type(99), None); } #[mz_ore::test] - fn test_semantic_types_excluded_from_eq_and_hash() { - let desc_a = RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) + fn test_semantic_types_included_in_eq_and_hash() { + let desc_with = RelationDesc::builder() + .with_column_semantic_type( + "id", + SqlScalarType::String.nullable(false), + SemanticType::CatalogItemId, + ) .finish(); - let desc_b = RelationDesc::builder() + let desc_without = RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) .finish(); - // semantic_types is excluded from Eq. - assert_eq!(desc_a, desc_b); + // semantic_types is now included in Eq and Hash. + assert_ne!(desc_with, desc_without); - // semantic_types is excluded from Hash. use std::hash::{Hash, Hasher}; let hash = |d: &RelationDesc| { let mut h = std::collections::hash_map::DefaultHasher::new(); d.hash(&mut h); h.finish() }; - assert_eq!(hash(&desc_a), hash(&desc_b)); - } - - #[mz_ore::test] - #[cfg_attr(miri, ignore)] - fn test_semantic_types_excluded_from_serialization() { - let desc = RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::CatalogItemId) - .finish(); - - // Roundtrip through protobuf should lose semantic types (serde skip). - let proto = desc.into_proto(); - let roundtripped = RelationDesc::from_proto(proto).unwrap(); - assert_eq!(roundtripped.get_semantic_type(0), None); + assert_ne!(hash(&desc_with), hash(&desc_without)); } } diff --git a/src/storage-client/src/healthcheck.rs b/src/storage-client/src/healthcheck.rs index 31f96afe83165..e2fdb6ebd8fad 100644 --- a/src/storage-client/src/healthcheck.rs +++ b/src/storage-client/src/healthcheck.rs @@ -40,11 +40,11 @@ pub static MZ_SQL_TEXT_DESC: LazyLock = LazyLock::new(|| { pub static MZ_SESSION_HISTORY_DESC: LazyLock = LazyLock::new(|| { RelationDesc::builder() .with_column("session_id", SqlScalarType::Uuid.nullable(false)) - .with_column( + .with_column_semantic_type( "connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), + SemanticType::WallclockTimestamp, ) - .with_semantic_type(SemanticType::WallclockTimestamp) .with_column( "initial_application_name", SqlScalarType::String.nullable(false), @@ -108,35 +108,47 @@ pub static MZ_STATEMENT_EXECUTION_HISTORY_DESC: LazyLock = LazyLoc pub static MZ_SOURCE_STATUS_HISTORY_DESC: LazyLock = LazyLock::new(|| { RelationDesc::builder() - .with_column( + .with_column_semantic_type( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), + SemanticType::WallclockTimestamp, + ) + .with_column_semantic_type( + "source_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, ) - .with_semantic_type(SemanticType::WallclockTimestamp) - .with_column("source_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) .with_column("details", SqlScalarType::Jsonb.nullable(true)) - .with_column("replica_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::ReplicaId) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(true), + SemanticType::ReplicaId, + ) .finish() }); pub static MZ_SINK_STATUS_HISTORY_DESC: LazyLock = LazyLock::new(|| { RelationDesc::builder() - .with_column( + .with_column_semantic_type( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), + SemanticType::WallclockTimestamp, + ) + .with_column_semantic_type( + "sink_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, ) - .with_semantic_type(SemanticType::WallclockTimestamp) - .with_column("sink_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) .with_column("details", SqlScalarType::Jsonb.nullable(true)) - .with_column("replica_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::ReplicaId) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(true), + SemanticType::ReplicaId, + ) .finish() }); @@ -154,8 +166,11 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_DESC: LazyLock = LazyLock::new(|| { RelationDesc::builder() - .with_column("replica_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::ReplicaId) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(false), + SemanticType::ReplicaId, + ) .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("reason", SqlScalarType::String.nullable(true)) @@ -187,16 +202,22 @@ pub static REPLICA_METRICS_HISTORY_DESC: LazyLock = LazyLock::new( pub static WALLCLOCK_LAG_HISTORY_DESC: LazyLock = LazyLock::new(|| { RelationDesc::builder() - .with_column("object_id", SqlScalarType::String.nullable(false)) - .with_semantic_type(SemanticType::GlobalId) - .with_column("replica_id", SqlScalarType::String.nullable(true)) - .with_semantic_type(SemanticType::ReplicaId) + .with_column_semantic_type( + "object_id", + SqlScalarType::String.nullable(false), + SemanticType::GlobalId, + ) + .with_column_semantic_type( + "replica_id", + SqlScalarType::String.nullable(true), + SemanticType::ReplicaId, + ) .with_column("lag", SqlScalarType::Interval.nullable(true)) - .with_column( + .with_column_semantic_type( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), + SemanticType::WallclockTimestamp, ) - .with_semantic_type(SemanticType::WallclockTimestamp) .finish() }); From 9cd4125f94a0030153fcc85fec271d3deaabb6eb Mon Sep 17 00:00:00 2001 From: mtabebe Date: Thu, 30 Apr 2026 11:32:00 -0400 Subject: [PATCH 08/14] [ontology] strongly type OntologyLink::properties with LinkProperties enum Replace properties_json (raw JSON blob) with a typed LinkProperties enum that has 5 variants (ForeignKey, Union, MapsTo, DependsOn, Measures), each with documented fields and serde::Serialize so the JSONB output is identical to the old hand-written strings. --- src/catalog/src/builtin.rs | 1059 +++++++++++++++++++++++------------- 1 file changed, 677 insertions(+), 382 deletions(-) diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index 64eb98e32df12..8cc5b57503fa1 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -178,7 +178,7 @@ pub struct Ontology { } /// Cardinality of an ontology link. -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, serde::Serialize)] +#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "snake_case")] pub enum Cardinality { OneToOne, @@ -193,60 +193,225 @@ fn is_false(v: &bool) -> bool { /// Typed properties for an ontology link. Serialized to the `properties` JSONB /// column in `mz_ontology_link_types`. The `kind` field is inlined from the /// enum variant name via `#[serde(tag = "kind")]`. -#[derive(Clone, Debug, Hash, PartialEq, Eq, serde::Serialize)] +#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, serde::Serialize)] #[serde(tag = "kind", rename_all = "snake_case")] pub enum LinkProperties { - /// A foreign-key relationship: the source column references the target column. + /// A foreign-key relationship: `source_column` in the source entity + /// references `target_column` in the target entity. ForeignKey { + /// Column in the source entity that holds the reference. source_column: &'static str, + /// Column in the target entity being referenced (usually `id`). target_column: &'static str, + /// How many source rows may reference a single target row. cardinality: Cardinality, + /// Semantic type of the source column, if it carries an ID that + /// requires type-aware resolution (e.g. `CatalogItemId`, `GlobalId`). #[serde(skip_serializing_if = "Option::is_none")] source_id_type: Option, + /// Intermediate mapping relation needed when `source_id_type` does not + /// directly match the target entity's ID type (e.g. + /// `mz_internal.mz_object_global_ids` to go from `GlobalId` to catalog + /// object). #[serde(skip_serializing_if = "Option::is_none")] requires_mapping: Option<&'static str>, + /// True when the source column may be NULL (the reference is optional). #[serde(default, skip_serializing_if = "is_false")] nullable: bool, + /// Free-form annotation for cases that need extra context. #[serde(skip_serializing_if = "Option::is_none")] note: Option<&'static str>, }, - /// A union relationship: the source entity is a superset that includes the - /// target entity, optionally filtered by a discriminator column/value. + /// A union relationship: the source entity is a superset view that includes + /// the target entity, optionally filtered by a discriminator column/value. Union { + /// Column used to discriminate between subtypes (e.g. `type`). #[serde(skip_serializing_if = "Option::is_none")] discriminator_column: Option<&'static str>, + /// Value of `discriminator_column` that selects the target entity. #[serde(skip_serializing_if = "Option::is_none")] discriminator_value: Option<&'static str>, + /// Free-form annotation for cases that need extra context. #[serde(skip_serializing_if = "Option::is_none")] note: Option<&'static str>, }, - /// A mapping relationship: the source entity maps to the target entity via - /// an intermediate table, optionally changing ID type. + /// A mapping relationship: the source entity maps to the target entity, + /// optionally via an intermediate table and/or with an ID-type conversion. MapsTo { + /// Column in the source entity that holds the ID to map from. + #[serde(skip_serializing_if = "Option::is_none")] + source_column: Option<&'static str>, + /// Column in the target entity being mapped to. + #[serde(skip_serializing_if = "Option::is_none")] + target_column: Option<&'static str>, + /// Intermediate relation used to perform the mapping. #[serde(skip_serializing_if = "Option::is_none")] via: Option<&'static str>, + /// Semantic type of the source ID before mapping. #[serde(skip_serializing_if = "Option::is_none")] from_type: Option, + /// Semantic type of the target ID after mapping. #[serde(skip_serializing_if = "Option::is_none")] to_type: Option, + /// Free-form annotation for cases that need extra context. #[serde(skip_serializing_if = "Option::is_none")] note: Option<&'static str>, }, - /// A metric relationship: the source entity measures a named metric on the - /// target entity. + /// A dependency relationship: the source entity directly depends on the + /// target entity (e.g. a materialization that references an object). + DependsOn { + /// Column in the source entity that holds the dependency ID. + source_column: &'static str, + /// Column in the target entity being depended upon (usually `id`). + target_column: &'static str, + /// Semantic type of the source column. + #[serde(skip_serializing_if = "Option::is_none")] + source_id_type: Option, + }, + /// A metric relationship: the source entity records measurements of a named + /// metric on the target entity. Measures { + /// Column in the source entity that references the target entity. source_column: &'static str, + /// Column in the target entity being measured (usually `id`). target_column: &'static str, + /// Name of the metric being measured (e.g. `cpu_time_ns`). metric: &'static str, + /// Semantic type of the source column, if ID-type resolution is needed. #[serde(skip_serializing_if = "Option::is_none")] source_id_type: Option, + /// Intermediate mapping relation needed when the source ID type differs + /// from the target entity's ID type. #[serde(skip_serializing_if = "Option::is_none")] requires_mapping: Option<&'static str>, + /// Free-form annotation for cases that need extra context. #[serde(skip_serializing_if = "Option::is_none")] note: Option<&'static str>, }, } +impl LinkProperties { + /// Basic foreign-key link with no optional fields set. + pub const fn fk( + source_column: &'static str, + target_column: &'static str, + cardinality: Cardinality, + ) -> Self { + Self::ForeignKey { + source_column, + target_column, + cardinality, + source_id_type: None, + requires_mapping: None, + nullable: false, + note: None, + } + } + + /// Foreign-key link where the source column may be NULL. + pub const fn fk_nullable( + source_column: &'static str, + target_column: &'static str, + cardinality: Cardinality, + ) -> Self { + Self::ForeignKey { + source_column, + target_column, + cardinality, + source_id_type: None, + requires_mapping: None, + nullable: true, + note: None, + } + } + + /// Foreign-key link whose source column carries a typed ID (e.g. + /// `CatalogItemId`) but does not require an intermediate mapping table. + pub const fn fk_typed( + source_column: &'static str, + target_column: &'static str, + cardinality: Cardinality, + source_id_type: mz_repr::SemanticType, + ) -> Self { + Self::ForeignKey { + source_column, + target_column, + cardinality, + source_id_type: Some(source_id_type), + requires_mapping: None, + nullable: false, + note: None, + } + } + + /// Foreign-key link whose source column carries a typed ID that requires + /// an intermediate mapping table to resolve (e.g. `GlobalId` → + /// `mz_internal.mz_object_global_ids`). + pub const fn fk_mapped( + source_column: &'static str, + target_column: &'static str, + cardinality: Cardinality, + source_id_type: mz_repr::SemanticType, + requires_mapping: &'static str, + ) -> Self { + Self::ForeignKey { + source_column, + target_column, + cardinality, + source_id_type: Some(source_id_type), + requires_mapping: Some(requires_mapping), + nullable: false, + note: None, + } + } + + /// Union link filtered by a discriminator column/value pair. + pub const fn union_disc( + discriminator_column: &'static str, + discriminator_value: &'static str, + ) -> Self { + Self::Union { + discriminator_column: Some(discriminator_column), + discriminator_value: Some(discriminator_value), + note: None, + } + } + + /// Basic measures link with no optional fields set. + pub const fn measures( + source_column: &'static str, + target_column: &'static str, + metric: &'static str, + ) -> Self { + Self::Measures { + source_column, + target_column, + metric, + source_id_type: None, + requires_mapping: None, + note: None, + } + } + + /// Measures link whose source ID requires an intermediate mapping table. + pub const fn measures_mapped( + source_column: &'static str, + target_column: &'static str, + metric: &'static str, + source_id_type: mz_repr::SemanticType, + requires_mapping: &'static str, + ) -> Self { + Self::Measures { + source_column, + target_column, + metric, + source_id_type: Some(source_id_type), + requires_mapping: Some(requires_mapping), + note: None, + } + } +} + /// A relationship link in the ontology. #[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct OntologyLink { @@ -2181,11 +2346,11 @@ pub static MZ_ICEBERG_SINKS: LazyLock = LazyLock::new(|| BuiltinTa ontology: Some(Ontology { entity_name: "iceberg_sink", description: "Iceberg-specific sink configuration (namespace, table)", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "details_of", target: "sink", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); @@ -2214,11 +2379,11 @@ pub static MZ_KAFKA_SINKS: LazyLock = LazyLock::new(|| BuiltinTabl ontology: Some(Ontology { entity_name: "kafka_sink", description: "Kafka-specific sink configuration (topic)", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "details_of", target: "sink", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); pub static MZ_KAFKA_CONNECTIONS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2253,11 +2418,11 @@ pub static MZ_KAFKA_CONNECTIONS: LazyLock = LazyLock::new(|| Built ontology: Some(Ontology { entity_name: "kafka_connection", description: "Kafka-specific connection configuration (brokers, progress topic)", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "details_of", target: "connection", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); pub static MZ_KAFKA_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2292,11 +2457,11 @@ pub static MZ_KAFKA_SOURCES: LazyLock = LazyLock::new(|| BuiltinTa ontology: Some(Ontology { entity_name: "kafka_source", description: "Kafka-specific source configuration (topic, group ID)", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "details_of", target: "source", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2331,11 +2496,11 @@ pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| Builti ontology: Some(Ontology { entity_name: "postgres_source", description: "Postgres source-level details", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "details_of", target: "source", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2370,11 +2535,11 @@ pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| ontology: Some(Ontology { entity_name: "postgres_source_table", description: "Postgres source table-level details", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "describes_source_table", target: "table", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2409,11 +2574,11 @@ pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui ontology: Some(Ontology { entity_name: "mysql_source_table", description: "MySQL source table-level details", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "describes_source_table", target: "table", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2448,11 +2613,11 @@ pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(| ontology: Some(Ontology { entity_name: "sql_server_source_table", description: "SQL Server source table-level details", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "describes_source_table", target: "table", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2494,11 +2659,11 @@ pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui ontology: Some(Ontology { entity_name: "kafka_source_table", description: "Kafka source table-level details", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "describes_source_table", target: "table", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2532,18 +2697,18 @@ pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| Bui ontology: Some(Ontology { entity_name: "object_dependency", description: "A dependency edge: one object depends on another", - links: &[ + links: &const { [ OntologyLink { name: "dependent_object", target: "object", - properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk_typed("object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), }, OntologyLink { name: "referenced_object", target: "object", - properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "referenced_object_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk_typed("referenced_object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), }, - ], + ] }, }), }); pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| BuiltinSource { @@ -2578,18 +2743,18 @@ pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| B ontology: Some(Ontology { entity_name: "compute_dependency", description: "Dependency edge within compute dataflows", - links: &[ + links: &const { [ OntologyLink { name: "dependent_compute_object", target: "object", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk_mapped("object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), }, OntologyLink { name: "compute_dependency_target", target: "object", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "dependency_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk_mapped("dependency_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), }, - ], + ] }, }), }); @@ -2650,11 +2815,11 @@ WHERE data->>'kind' = 'Database'", ontology: Some(Ontology { entity_name: "database", description: "A top-level namespace that contains schemas", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "owned_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }] }, }), } }); @@ -2728,18 +2893,18 @@ WHERE data->>'kind' = 'Schema'", ontology: Some(Ontology { entity_name: "schema", description: "A namespace within a database that contains objects", - links: &[ + links: &const { [ OntologyLink { name: "in_database", target: "database", - properties_json: r#"{"kind": "foreign_key", "source_column": "database_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::fk_nullable("database_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "owned_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), } }); @@ -2790,11 +2955,19 @@ pub static MZ_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "column", description: "A column of a relation, with its name, position, type, and nullability", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "belongs_to_relation", target: "object", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "many_to_one", "note": "id in mz_columns is the relation ID, not a unique column ID"}"#, - }], + properties: LinkProperties::ForeignKey { + source_column: "id", + target_column: "id", + cardinality: Cardinality::ManyToOne, + source_id_type: None, + requires_mapping: None, + nullable: false, + note: Some("id in mz_columns is the relation ID, not a unique column ID"), + }, + }] }, }), }); pub static MZ_INDEXES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2864,23 +3037,23 @@ pub static MZ_INDEXES: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "index", description: "An in-memory index on a relation for fast lookups", - links: &[ + links: &const { [ OntologyLink { name: "owned_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "runs_on_cluster", target: "cluster", - properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "indexes_relation", target: "relation", - properties_json: r#"{"kind": "foreign_key", "source_column": "on_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("on_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); pub static MZ_INDEX_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2925,11 +3098,11 @@ pub static MZ_INDEX_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTa ontology: Some(Ontology { entity_name: "index_column", description: "A column or expression in an index, with its position", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "belongs_to_index", target: "index", - properties_json: r#"{"kind": "foreign_key", "source_column": "index_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk("index_id", "id", Cardinality::ManyToOne), + }] }, }), }); pub static MZ_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3004,23 +3177,23 @@ pub static MZ_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "table", description: "A user-writable table that can be inserted into and updated", - links: &[ + links: &const { [ OntologyLink { name: "in_schema", target: "schema", - properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "owned_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "created_by_source", target: "source", - properties_json: r#"{"kind": "foreign_key", "source_column": "source_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::fk_nullable("source_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -3103,18 +3276,18 @@ WHERE ontology: Some(Ontology { entity_name: "connection", description: "A reusable connection configuration to an external system", - links: &[ + links: &const { [ OntologyLink { name: "in_schema", target: "schema", - properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "owned_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), } }); @@ -3148,11 +3321,11 @@ pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock = LazyLock::new(|| ontology: Some(Ontology { entity_name: "ssh_tunnel", description: "SSH tunnel connection with public keys", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "details_of", target: "connection", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); pub static MZ_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3262,28 +3435,28 @@ pub static MZ_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "source", description: "An external data source ingested into Materialize (e.g., Kafka, Postgres)", - links: &[ + links: &const { [ OntologyLink { name: "in_schema", target: "schema", - properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "owned_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "runs_on_cluster", target: "cluster", - properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::fk_nullable("cluster_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "uses_connection", target: "connection", - properties_json: r#"{"kind": "foreign_key", "source_column": "connection_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::fk_nullable("connection_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); pub static MZ_SINKS: LazyLock = LazyLock::new(|| { @@ -3389,28 +3562,28 @@ pub static MZ_SINKS: LazyLock = LazyLock::new(|| { ontology: Some(Ontology { entity_name: "sink", description: "An export of data from Materialize to an external system", - links: &[ + links: &const { [ OntologyLink { name: "in_schema", target: "schema", - properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "owned_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "runs_on_cluster", target: "cluster", - properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "uses_connection", target: "connection", - properties_json: r#"{"kind": "foreign_key", "source_column": "connection_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::fk_nullable("connection_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), } }); @@ -3483,18 +3656,18 @@ pub static MZ_VIEWS: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "view", description: "A non-materialized view defined by a SQL query", - links: &[ + links: &const { [ OntologyLink { name: "in_schema", target: "schema", - properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "owned_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -3624,11 +3797,11 @@ SELECT * FROM builtin_mvs").into_boxed_str()), ontology: Some(Ontology { entity_name: "mv", description: "A materialized view maintained incrementally on a cluster", - links: &[ - OntologyLink { name: "in_schema", target: "schema", properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"# }, - OntologyLink { name: "owned_by", target: "role", properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"# }, - OntologyLink { name: "runs_on_cluster", target: "cluster", properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"# }, - ], + links: &const { [ + OntologyLink { name: "in_schema", target: "schema", properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne) }, + OntologyLink { name: "owned_by", target: "role", properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne) }, + OntologyLink { name: "runs_on_cluster", target: "cluster", properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne) }, + ] }, }), } }); @@ -3746,18 +3919,18 @@ pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "type", description: "A named data type (base, array, list, map, or pseudo)", - links: &[ + links: &const { [ OntologyLink { name: "in_schema", target: "schema", - properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "owned_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -3821,11 +3994,11 @@ WHERE data->>'kind' = 'NetworkPolicy'", ontology: Some(Ontology { entity_name: "network_policy", description: "Network access policies", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "owned_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }] }, }), } }); @@ -3885,11 +4058,11 @@ WHERE data->>'kind' = 'NetworkPolicy'", ontology: Some(Ontology { entity_name: "network_policy_rule", description: "Individual rules within a network policy", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "belongs_to_policy", target: "network_policy", - properties_json: r#"{"kind": "foreign_key", "source_column": "policy_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk("policy_id", "id", Cardinality::ManyToOne), + }] }, }), } }); @@ -3947,18 +4120,18 @@ pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| BuiltinTabl ontology: Some(Ontology { entity_name: "array_type", description: "An array type with its element type", - links: &[ + links: &const { [ OntologyLink { name: "detail_of", target: "type", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }, OntologyLink { name: "has_element_type", target: "type", - properties_json: r#"{"kind": "foreign_key", "source_column": "element_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("element_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3978,7 +4151,7 @@ pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinTable ontology: Some(Ontology { entity_name: "base_type", description: "A primitive/base data type", - links: &[], + links: &const { [] }, }), }); pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4018,18 +4191,18 @@ pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable ontology: Some(Ontology { entity_name: "list_type", description: "A list type with its element type", - links: &[ + links: &const { [ OntologyLink { name: "detail_of", target: "type", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }, OntologyLink { name: "has_element_type", target: "type", - properties_json: r#"{"kind": "foreign_key", "source_column": "element_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("element_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4087,23 +4260,23 @@ pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable ontology: Some(Ontology { entity_name: "map_type", description: "A map type with its key and value types", - links: &[ + links: &const { [ OntologyLink { name: "detail_of", target: "type", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }, OntologyLink { name: "has_key_type", target: "type", - properties_json: r#"{"kind": "foreign_key", "source_column": "key_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("key_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "has_value_type", target: "type", - properties_json: r#"{"kind": "foreign_key", "source_column": "value_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("value_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); pub static MZ_ROLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4140,7 +4313,7 @@ pub static MZ_ROLES: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "role", description: "A user or role for authentication and access control", - links: &[], + links: &const { [] }, }), }); @@ -4200,23 +4373,23 @@ WHERE data->>'kind' = 'Role'", ontology: Some(Ontology { entity_name: "role_membership", description: "A membership grant: one role is a member of another role", - links: &[ + links: &const { [ OntologyLink { name: "group_role", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "role_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "member_role", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "member", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("member", "id", Cardinality::ManyToOne), }, OntologyLink { name: "granted_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "grantor", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("grantor", "id", Cardinality::ManyToOne), }, - ], + ] }, }), } }); @@ -4253,11 +4426,11 @@ pub static MZ_ROLE_PARAMETERS: LazyLock = LazyLock::new(|| Builtin ontology: Some(Ontology { entity_name: "role_parameter", description: "A session parameter default set for a role", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "default_parameter_setting_of", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "role_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne), + }] }, }), }); pub static MZ_ROLE_AUTH: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4317,7 +4490,7 @@ pub static MZ_PSEUDO_TYPES: LazyLock = LazyLock::new(|| BuiltinTab ontology: Some(Ontology { entity_name: "pseudo_type", description: "A pseudo-type used in function signatures", - links: &[], + links: &const { [] }, }), }); pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { @@ -4393,28 +4566,28 @@ pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { ontology: Some(Ontology { entity_name: "function", description: "A built-in or user-defined function", - links: &[ + links: &const { [ OntologyLink { name: "in_schema", target: "schema", - properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "owned_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "returns_type", target: "type", - properties_json: r#"{"kind": "foreign_key", "source_column": "return_type_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::fk_nullable("return_type_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "has_variadic_arg_type", target: "type", - properties_json: r#"{"kind": "foreign_key", "source_column": "variadic_argument_type_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::fk_nullable("variadic_argument_type_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), } }); @@ -4441,11 +4614,11 @@ pub static MZ_OPERATORS: LazyLock = LazyLock::new(|| BuiltinTable ontology: Some(Ontology { entity_name: "operator", description: "A built-in SQL operator", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "returns_type", target: "type", - properties_json: r#"{"kind": "foreign_key", "source_column": "return_type_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, - }], + properties: LinkProperties::fk_nullable("return_type_id", "id", Cardinality::ManyToOne), + }] }, }), }); pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4463,7 +4636,7 @@ pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinTable ontology: Some(Ontology { entity_name: "aggregate", description: "Aggregate function metadata", - links: &[], + links: &const { [] }, }), }); @@ -4551,18 +4724,18 @@ pub static MZ_CLUSTERS: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "cluster", description: "A compute cluster that runs dataflows for sources, sinks, MVs, and indexes", - links: &[ + links: &const { [ OntologyLink { name: "owned_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "has_size", target: "replica_size", - properties_json: r#"{"kind": "foreign_key", "source_column": "size", "target_column": "size", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::fk_nullable("size", "size", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -4639,11 +4812,11 @@ pub static MZ_CLUSTER_SCHEDULES: LazyLock = LazyLock::new(|| Built ontology: Some(Ontology { entity_name: "cluster_schedule", description: "Cluster scheduling configuration", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "belongs_to_cluster", target: "cluster", - properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), + }] }, }), }); @@ -4703,18 +4876,18 @@ WHERE ontology: Some(Ontology { entity_name: "secret", description: "An encrypted secret value used by connections", - links: &[ + links: &const { [ OntologyLink { name: "in_schema", target: "schema", - properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "owned_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), } }); @@ -4772,23 +4945,23 @@ pub static MZ_CLUSTER_REPLICAS: LazyLock = LazyLock::new(|| Builti ontology: Some(Ontology { entity_name: "replica", description: "A physical replica of a cluster providing fault tolerance", - links: &[ + links: &const { [ OntologyLink { name: "owned_by", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "owner_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "belongs_to_cluster", target: "cluster", - properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "has_size", target: "replica_size", - properties_json: r#"{"kind": "foreign_key", "source_column": "size", "target_column": "size", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::fk_nullable("size", "size", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -4880,11 +5053,11 @@ pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY: LazyLock = LazyLock ontology: Some(Ontology { entity_name: "replica_status_history", description: "Historical replica status events (ready, not-ready, etc.)", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "status_history_of_replica", target: "replica", - properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk_typed("replica_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), + }] }, }), } }); @@ -4946,11 +5119,11 @@ ORDER BY replica_id, process_id, occurred_at DESC", ontology: Some(Ontology { entity_name: "replica_status", description: "Current status of each replica", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "status_of_replica", target: "replica", - properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk_typed("replica_id", "id", Cardinality::OneToOne, mz_repr::SemanticType::CatalogItemId), + }] }, }), }); @@ -5005,7 +5178,7 @@ pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock = LazyLock::new(|| B ontology: Some(Ontology { entity_name: "replica_size", description: "Available cluster replica sizes with CPU, memory, and credit cost", - links: &[], + links: &const { [] }, }), }); @@ -5061,7 +5234,7 @@ pub static MZ_AUDIT_EVENTS: LazyLock = LazyLock::new(|| BuiltinTab ontology: Some(Ontology { entity_name: "audit_event", description: "An audit log entry recording a DDL operation", - links: &[], + links: &const { [] }, }), }); @@ -5102,18 +5275,18 @@ pub static MZ_SOURCE_STATUS_HISTORY: LazyLock = LazyLock::new(|| ontology: Some(Ontology { entity_name: "source_status_history", description: "Historical source status events", - links: &[ + links: &const { [ OntologyLink { name: "status_history_of_source", target: "source", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "source_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk_mapped("source_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), }, OntologyLink { name: "on_replica", target: "replica", - properties_json: r#"{"kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::fk_nullable("replica_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -5206,11 +5379,11 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUSES: LazyLock = LazyL ontology: Some(Ontology { entity_name: "privatelink_status", description: "PrivateLink connection health status", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "status_of", target: "connection", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), } }); @@ -5297,7 +5470,7 @@ pub static MZ_SQL_TEXT: LazyLock = LazyLock::new(|| BuiltinSource ontology: Some(Ontology { entity_name: "sql_text", description: "Raw SQL text of executed statements", - links: &[], + links: &const { [] }, }), }); @@ -5345,7 +5518,7 @@ pub static MZ_RECENT_SQL_TEXT: LazyLock = LazyLock::new(|| { ontology: Some(Ontology { entity_name: "recent_sql_text", description: "Recent SQL text (indexed, last 3 days)", - links: &[], + links: &const { [] }, }), } }); @@ -5406,11 +5579,11 @@ pub static MZ_SESSION_HISTORY: LazyLock = LazyLock::new(|| Builti ontology: Some(Ontology { entity_name: "session_history", description: "Historical session connection events", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "history_of", target: "session", - properties_json: r#"{"kind": "foreign_key", "source_column": "session_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk("session_id", "id", Cardinality::ManyToOne), + }] }, }), }); @@ -5736,18 +5909,26 @@ WHERE mralt.sql_hash = mrst.sql_hash", ontology: Some(Ontology { entity_name: "activity_log", description: "Recent query activity with execution stats", - links: &[ + links: &const { [ OntologyLink { name: "session_on_cluster", target: "cluster", - properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "used_transient_index", target: "object", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "transient_index_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::ForeignKey { + source_column: "transient_index_id", + target_column: "id", + cardinality: Cardinality::ManyToOne, + source_id_type: Some(mz_repr::SemanticType::GlobalId), + requires_mapping: Some("mz_internal.mz_object_global_ids"), + nullable: true, + note: None, + }, }, - ], + ] }, }), }); @@ -5842,7 +6023,7 @@ pub static MZ_STATEMENT_LIFECYCLE_HISTORY: LazyLock = LazyLock::n ontology: Some(Ontology { entity_name: "statement_lifecycle", description: "Statement lifecycle events (parse, bind, execute)", - links: &[], + links: &const { [] }, }), } }); @@ -6038,11 +6219,11 @@ WHERE id NOT LIKE 's%';", ontology: Some(Ontology { entity_name: "source_status", description: "Current source status (running, stalled, etc.)", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "status_of_source", target: "source", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); @@ -6083,18 +6264,18 @@ pub static MZ_SINK_STATUS_HISTORY: LazyLock = LazyLock::new(|| Bu ontology: Some(Ontology { entity_name: "sink_status_history", description: "Historical sink status events", - links: &[ + links: &const { [ OntologyLink { name: "status_history_of_sink", target: "sink", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "sink_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk_mapped("sink_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), }, OntologyLink { name: "on_replica", target: "replica", - properties_json: r#"{"kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::fk_nullable("replica_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -6209,11 +6390,11 @@ WHERE ontology: Some(Ontology { entity_name: "sink_status", description: "Current sink status", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "status_of_sink", target: "sink", - properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk_typed("id", "id", Cardinality::OneToOne, mz_repr::SemanticType::CatalogItemId), + }] }, }), }); @@ -6252,7 +6433,7 @@ pub static MZ_STORAGE_USAGE_BY_SHARD: LazyLock = LazyLock::new(|| ontology: Some(Ontology { entity_name: "storage_usage_by_shard", description: "Storage usage broken down by shard", - links: &[], + links: &const { [] }, }), }); @@ -6278,7 +6459,7 @@ pub static MZ_EGRESS_IPS: LazyLock = LazyLock::new(|| BuiltinTable ontology: Some(Ontology { entity_name: "egress_ip", description: "IP addresses used for outbound connections from Materialize", - links: &[], + links: &const { [] }, }), }); @@ -6307,11 +6488,11 @@ pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock = LazyLock::ne ontology: Some(Ontology { entity_name: "aws_privatelink", description: "AWS PrivateLink connection configuration", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "details_of", target: "connection", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), } }); @@ -6397,11 +6578,11 @@ pub static MZ_AWS_CONNECTIONS: LazyLock = LazyLock::new(|| Builtin ontology: Some(Ontology { entity_name: "aws_connection", description: "AWS connection configuration details", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "details_of", target: "connection", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); @@ -6502,11 +6683,11 @@ ORDER BY replica_id, process_id, occurred_at DESC", ontology: Some(Ontology { entity_name: "replica_metrics", description: "CPU and memory metrics per replica", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "metrics_of_replica", target: "replica", - properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk_typed("replica_id", "id", Cardinality::OneToOne, mz_repr::SemanticType::CatalogItemId), + }] }, }), }); @@ -6599,11 +6780,11 @@ pub static MZ_FRONTIERS: LazyLock = LazyLock::new(|| BuiltinSourc ontology: Some(Ontology { entity_name: "frontier", description: "Current read/write frontiers per object (source)", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "frontier_of", target: "object", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk_mapped("object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), + }] }, }), }); @@ -6662,18 +6843,18 @@ pub static MZ_WALLCLOCK_LAG_HISTORY: LazyLock = LazyLock::new(|| ontology: Some(Ontology { entity_name: "wallclock_lag_history", description: "Historical wallclock lag per object", - links: &[ + links: &const { [ OntologyLink { name: "measures_lag_of", target: "object", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "measures", "source_column": "object_id", "target_column": "id", "metric": "wallclock_lag"}"#, + properties: LinkProperties::measures_mapped("object_id", "id", "wallclock_lag", mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), }, OntologyLink { name: "on_replica", target: "replica", - properties_json: r#"{"kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::fk_nullable("replica_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -6728,11 +6909,11 @@ OPTIONS (AGGREGATE INPUT GROUP SIZE = 1)", ontology: Some(Ontology { entity_name: "wallclock_global_lag_history", description: "Historical global wallclock lag", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "lag_of", target: "object_global_id", - properties_json: r#"{"kind": "foreign_key", "source_column": "object_id", "target_column": "global_id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk("object_id", "global_id", Cardinality::ManyToOne), + }] }, }), }); @@ -6809,11 +6990,11 @@ ORDER BY object_id, occurred_at DESC", ontology: Some(Ontology { entity_name: "wallclock_global_lag", description: "Current wallclock lag aggregated across replicas", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "measures_global_lag_of", target: "object", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "measures", "source_column": "object_id", "target_column": "id", "metric": "wallclock_lag_global"}"#, - }], + properties: LinkProperties::measures_mapped("object_id", "id", "wallclock_lag_global", mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), + }] }, }), }); @@ -6951,18 +7132,18 @@ pub static MZ_SUBSCRIPTIONS: LazyLock = LazyLock::new(|| BuiltinTa ontology: Some(Ontology { entity_name: "subscription", description: "Active SUBSCRIBE operations", - links: &[ + links: &const { [ OntologyLink { name: "uses_session", target: "session", - properties_json: r#"{"kind": "foreign_key", "source_column": "session_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("session_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "belongs_to_cluster", target: "cluster", - properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -7008,11 +7189,11 @@ pub static MZ_SESSIONS: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "session", description: "Currently active sessions", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "logged_in_as", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "role_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne), + }] }, }), }); @@ -7076,28 +7257,28 @@ pub static MZ_DEFAULT_PRIVILEGES: LazyLock = LazyLock::new(|| Buil ontology: Some(Ontology { entity_name: "default_privilege", description: "A default privilege rule applied to newly created objects", - links: &[ + links: &const { [ OntologyLink { name: "default_priv_for_role", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "role_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "default_priv_in_database", target: "database", - properties_json: r#"{"kind": "foreign_key", "source_column": "database_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::fk_nullable("database_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "default_priv_in_schema", target: "schema", - properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one", "nullable": true}"#, + properties: LinkProperties::fk_nullable("schema_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "default_priv_granted_to", target: "role", - properties_json: r#"{"kind": "foreign_key", "source_column": "grantee", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("grantee", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -7117,7 +7298,7 @@ pub static MZ_SYSTEM_PRIVILEGES: LazyLock = LazyLock::new(|| Built ontology: Some(Ontology { entity_name: "system_privilege", description: "A system-level privilege grant", - links: &[], + links: &const { [] }, }), }); @@ -7159,11 +7340,11 @@ pub static MZ_COMMENTS: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "comment", description: "A COMMENT ON annotation for a catalog object or column", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "comment_on", target: "object", - properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk_typed("id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), + }] }, }), }); @@ -7194,11 +7375,11 @@ pub static MZ_SOURCE_REFERENCES: LazyLock = LazyLock::new(|| Built ontology: Some(Ontology { entity_name: "source_reference", description: "External references tracked by sources", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "references_source", target: "source", - properties_json: r#"{"kind": "foreign_key", "source_column": "source_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk("source_id", "id", Cardinality::ManyToOne), + }] }, }), }); @@ -7231,11 +7412,11 @@ pub static MZ_WEBHOOKS_SOURCES: LazyLock = LazyLock::new(|| Builti ontology: Some(Ontology { entity_name: "webhook_source", description: "Webhook source configuration", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "details_of", target: "source", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); @@ -7269,7 +7450,7 @@ pub static MZ_HISTORY_RETENTION_STRATEGIES: LazyLock = LazyLock::n ontology: Some(Ontology { entity_name: "history_retention", description: "History retention strategy for an object", - links: &[], + links: &const { [] }, }), } }); @@ -7319,7 +7500,7 @@ pub static MZ_LICENSE_KEYS: LazyLock = LazyLock::new(|| BuiltinTab ontology: Some(Ontology { entity_name: "license_key", description: "License key metadata", - links: &[], + links: &const { [] }, }), }); @@ -7350,18 +7531,18 @@ pub static MZ_REPLACEMENTS: LazyLock = LazyLock::new(|| BuiltinTab ontology: Some(Ontology { entity_name: "replacement", description: "A record of an object replacement (ALTER ... SWAP)", - links: &[ + links: &const { [ OntologyLink { name: "replacement_object", target: "object", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "replacement_target", target: "object", - properties_json: r#"{"kind": "foreign_key", "source_column": "target_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("target_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -7413,11 +7594,11 @@ pub static MZ_STORAGE_SHARDS: LazyLock = LazyLock::new(|| Builtin ontology: Some(Ontology { entity_name: "storage_shard", description: "Persist shards used by storage objects", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "shard_of", target: "object", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk_mapped("object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), + }] }, }), }); @@ -7470,11 +7651,11 @@ GROUP BY object_id, collection_timestamp", ontology: Some(Ontology { entity_name: "storage_usage", description: "Historical storage usage per object over time", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "storage_usage_of", target: "object", - properties_json: r#"{"kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk("object_id", "id", Cardinality::ManyToOne), + }] }, }), }); @@ -7523,9 +7704,9 @@ GROUP BY object_id", ontology: Some(Ontology { entity_name: "recent_storage", description: "Most recent storage usage snapshot per object", - links: &[ - OntologyLink { name: "recent_storage_of", target: "object", properties_json: r#"{"kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "one_to_one"}"# }, - ], + links: &const { [ + OntologyLink { name: "recent_storage_of", target: "object", properties: LinkProperties::fk("object_id", "id", Cardinality::OneToOne) }, + ] }, }), } }); @@ -7572,12 +7753,12 @@ UNION ALL SELECT id, oid, schema_id, name, 'materialized-view', owner_id, cluste ontology: Some(Ontology { entity_name: "relation", description: "Union of all relation types: tables, sources, views, MVs (convenience view)", - links: &[ - OntologyLink { name: "union_includes", target: "table", properties_json: r#"{"kind": "union", "discriminator_column": "type", "discriminator_value": "table"}"# }, - OntologyLink { name: "union_includes", target: "source", properties_json: r#"{"kind": "union", "discriminator_column": "type", "discriminator_value": "source"}"# }, - OntologyLink { name: "union_includes", target: "view", properties_json: r#"{"kind": "union", "discriminator_column": "type", "discriminator_value": "view"}"# }, - OntologyLink { name: "union_includes", target: "mv", properties_json: r#"{"kind": "union", "discriminator_column": "type", "discriminator_value": "materialized-view"}"# }, - ], + links: &const { [ + OntologyLink { name: "union_includes", target: "table", properties: LinkProperties::union_disc("type", "table") }, + OntologyLink { name: "union_includes", target: "source", properties: LinkProperties::union_disc("type", "source") }, + OntologyLink { name: "union_includes", target: "view", properties: LinkProperties::union_disc("type", "view") }, + OntologyLink { name: "union_includes", target: "mv", properties: LinkProperties::union_disc("type", "materialized-view") }, + ] }, }), } }); @@ -7684,13 +7865,24 @@ UNION ALL ontology: Some(Ontology { entity_name: "object", description: "Union of all object types: relations, indexes, connections, etc. (convenience view)", - links: &[ - OntologyLink { name: "union_includes", target: "relation", properties_json: r#"{"kind": "union", "note": "mz_objects includes all relations plus indexes, connections, secrets, types, functions"}"# }, - OntologyLink { name: "union_includes", target: "index", properties_json: r#"{"kind": "union", "discriminator_column": "type", "discriminator_value": "index"}"# }, - OntologyLink { name: "union_includes", target: "connection", properties_json: r#"{"kind": "union", "discriminator_column": "type", "discriminator_value": "connection"}"# }, - OntologyLink { name: "union_includes", target: "secret", properties_json: r#"{"kind": "union", "discriminator_column": "type", "discriminator_value": "secret"}"# }, - OntologyLink { name: "maps_to_global_id", target: "object", properties_json: r#"{"kind": "maps_to", "via": "mz_internal.mz_object_global_ids", "from_type": "CatalogItemId", "to_type": "GlobalId", "note": "A CatalogItemId (SQL layer) maps to one or more GlobalIds (runtime layer)."}"# }, - ], + links: &const { [ + OntologyLink { name: "union_includes", target: "relation", properties: LinkProperties::Union { + discriminator_column: None, + discriminator_value: None, + note: Some("mz_objects includes all relations plus indexes, connections, secrets, types, functions"), + } }, + OntologyLink { name: "union_includes", target: "index", properties: LinkProperties::union_disc("type", "index") }, + OntologyLink { name: "union_includes", target: "connection", properties: LinkProperties::union_disc("type", "connection") }, + OntologyLink { name: "union_includes", target: "secret", properties: LinkProperties::union_disc("type", "secret") }, + OntologyLink { name: "maps_to_global_id", target: "object", properties: LinkProperties::MapsTo { + source_column: None, + target_column: None, + via: Some("mz_internal.mz_object_global_ids"), + from_type: Some(mz_repr::SemanticType::CatalogItemId), + to_type: Some(mz_repr::SemanticType::GlobalId), + note: Some("A CatalogItemId (SQL layer) maps to one or more GlobalIds (runtime layer)."), + } }, + ] }, }), } }); @@ -7774,28 +7966,28 @@ pub static MZ_OBJECT_FULLY_QUALIFIED_NAMES: LazyLock = LazyLock::ne ontology: Some(Ontology { entity_name: "object_fqn", description: "Fully qualified name (database.schema.name) for objects", - links: &[ + links: &const { [ OntologyLink { name: "details_of", target: "object", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }, OntologyLink { name: "in_schema", target: "schema", - properties_json: r#"{"kind": "foreign_key", "source_column": "schema_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "in_database", target: "database", - properties_json: r#"{"kind": "foreign_key", "source_column": "database_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("database_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "belongs_to_cluster", target: "cluster", - properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -7823,11 +8015,18 @@ pub static MZ_OBJECT_GLOBAL_IDS: LazyLock = LazyLock::new(|| Built ontology: Some(Ontology { entity_name: "object_global_id", description: "Mapping between CatalogItemId (SQL layer) and GlobalId (runtime layer)", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "has_global_id", target: "object", - properties_json: r#"{"kind": "maps_to", "source_column": "id", "target_column": "id", "from_type": "CatalogItemId", "to_type": "GlobalId"}"#, - }], + properties: LinkProperties::MapsTo { + source_column: Some("id"), + target_column: Some("id"), + via: None, + from_type: Some(mz_repr::SemanticType::CatalogItemId), + to_type: Some(mz_repr::SemanticType::GlobalId), + note: None, + }, + }] }, }), }); @@ -7886,11 +8085,11 @@ pub static MZ_OBJECT_LIFETIMES: LazyLock = LazyLock::new(|| Builtin ontology: Some(Ontology { entity_name: "object_lifetime", description: "Computed lifetime span (created_at to dropped_at) for objects", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "lifetime_of", target: "object", - properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk_typed("id", "id", Cardinality::OneToOne, mz_repr::SemanticType::CatalogItemId), + }] }, }), }); @@ -7984,11 +8183,11 @@ pub static MZ_OBJECT_HISTORY: LazyLock = LazyLock::new(|| BuiltinVi ontology: Some(Ontology { entity_name: "object_history", description: "Historical record of object creation and drops", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "history_of", target: "object", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::ManyToOne), + }] }, }), }); @@ -8037,7 +8236,7 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "dataflow", description: "Dataflow instances", - links: &[], + links: &const { [] }, }), }); @@ -8075,11 +8274,11 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "dataflow_address", description: "Address (scope path) of dataflow operators", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "address_of_operator", target: "dataflow_operator", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); @@ -8118,11 +8317,18 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "dataflow_channel", description: "Communication channels between operators", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "channel_in_dataflow", target: "dataflow", - properties_json: r#"{"kind": "maps_to", "via": "mz_introspection.mz_dataflow_operator_dataflows", "note": "Channels do not have a direct dataflow_id. Use mz_dataflow_addresses to find the parent scope, then correlate with mz_dataflow_operator_dataflows."}"#, - }], + properties: LinkProperties::MapsTo { + source_column: None, + target_column: None, + via: Some("mz_introspection.mz_dataflow_operator_dataflows"), + from_type: None, + to_type: None, + note: Some("Channels do not have a direct dataflow_id. Use mz_dataflow_addresses to find the parent scope, then correlate with mz_dataflow_operator_dataflows."), + }, + }] }, }), }); @@ -8147,7 +8353,7 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "dataflow_operator", description: "Operators within dataflows", - links: &[], + links: &const { [] }, }), }); @@ -8206,7 +8412,7 @@ FROM mz_catalog.mz_objects mo ontology: Some(Ontology { entity_name: "mappable_object", description: "Objects that can be mapped to dataflow operators", - links: &[], + links: &const { [] }, }), }); @@ -8257,7 +8463,7 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "lir_mapping", description: "LIR (low-level IR) to dataflow operator mapping", - links: &[], + links: &const { [] }, }), }); @@ -8326,11 +8532,11 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "dataflow_operator_dataflow", description: "Mapping of operators to their parent dataflow", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "operator_in_dataflow", target: "dataflow", - properties_json: r#"{"kind": "foreign_key", "source_column": "dataflow_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk("dataflow_id", "id", Cardinality::ManyToOne), + }] }, }), }); @@ -8374,18 +8580,18 @@ SELECT object_id, referenced_object_id FROM reach;", ontology: Some(Ontology { entity_name: "transitive_dependency", description: "Transitive closure of object dependencies — all direct and indirect dependencies", - links: &[ + links: &const { [ OntologyLink { name: "transitively_dependent_object", target: "object", - properties_json: r#"{"kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "many_to_one", "source_id_type": "CatalogItemId"}"#, + properties: LinkProperties::fk_typed("object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), }, OntologyLink { name: "transitively_referenced_object", target: "object", - properties_json: r#"{"kind": "foreign_key", "source_column": "referenced_object_id", "target_column": "id", "cardinality": "many_to_one", "source_id_type": "CatalogItemId"}"#, + properties: LinkProperties::fk_typed("referenced_object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), }, - ], + ] }, }), } }); @@ -8421,18 +8627,25 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "compute_export", description: "Compute exports (maintained collections)", - links: &[ + links: &const { [ OntologyLink { name: "export_of", target: "object", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "export_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk_mapped("export_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), }, OntologyLink { name: "introspection_uses_global_id", target: "object_global_id", - properties_json: r#"{"kind": "maps_to", "note": "mz_introspection tables use GlobalId. To join with mz_catalog tables (which use CatalogItemId), go through mz_internal.mz_object_global_ids."}"#, + properties: LinkProperties::MapsTo { + source_column: None, + target_column: None, + via: None, + from_type: None, + to_type: None, + note: Some("mz_introspection tables use GlobalId. To join with mz_catalog tables (which use CatalogItemId), go through mz_internal.mz_object_global_ids."), + }, }, - ], + ] }, }), }); @@ -8471,11 +8684,11 @@ GROUP BY export_id", ontology: Some(Ontology { entity_name: "compute_frontier", description: "Per-replica compute frontiers", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "compute_frontier_of", target: "object", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "export_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk_mapped("export_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), + }] }, }), }); @@ -8649,11 +8862,11 @@ GROUP BY export_id, import_id", ontology: Some(Ontology { entity_name: "compute_import_frontier", description: "Import frontiers for compute dependencies", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "compute_import_frontier_of", target: "object", - properties_json: r#"{"source_id_type": "GlobalId", "requires_mapping": "mz_internal.mz_object_global_ids", "kind": "foreign_key", "source_column": "export_id", "target_column": "id", "cardinality": "many_to_one"}"#, - }], + properties: LinkProperties::fk_mapped("export_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), + }] }, }), }); @@ -8839,11 +9052,11 @@ GROUP BY ontology: Some(Ontology { entity_name: "records_per_dataflow", description: "Record counts aggregated per dataflow", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "details_of", target: "dataflow", - properties_json: r#"{"kind": "foreign_key", "source_column": "id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] }, }), }); @@ -10124,7 +10337,7 @@ GROUP BY type, duration_ns", ontology: Some(Ontology { entity_name: "peek_duration", description: "Histogram of SELECT query durations", - links: &[], + links: &const { [] }, }), }); @@ -10185,11 +10398,11 @@ GROUP BY id", ontology: Some(Ontology { entity_name: "scheduling_elapsed", description: "CPU time spent per operator", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "elapsed_for_operator", target: "dataflow_operator", - properties_json: r#"{"kind": "measures", "source_column": "id", "target_column": "id", "metric": "cpu_time_ns"}"#, - }], + properties: LinkProperties::measures("id", "id", "cpu_time_ns"), + }] }, }), }); @@ -10322,7 +10535,7 @@ GROUP BY slept_for_ns, requested_ns", ontology: Some(Ontology { entity_name: "scheduling_parks", description: "Histogram of operator park durations", - links: &[], + links: &const { [] }, }), }); @@ -10410,11 +10623,11 @@ HAVING pg_catalog.sum(count) != 0", ontology: Some(Ontology { entity_name: "compute_error_count", description: "Error counts per compute collection", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "errors_in", target: "compute_export", - properties_json: r#"{"kind": "foreign_key", "source_column": "export_id", "target_column": "export_id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("export_id", "export_id", Cardinality::OneToOne), + }] }, }), }); @@ -10473,7 +10686,7 @@ pub static MZ_COMPUTE_HYDRATION_TIMES: LazyLock = LazyLock::new(| ontology: Some(Ontology { entity_name: "compute_hydration_time", description: "Time to hydrate compute objects", - links: &[], + links: &const { [] }, }), }); @@ -10551,7 +10764,7 @@ SELECT * FROM complete_mvs", ontology: Some(Ontology { entity_name: "compute_hydration_status_view", description: "Computed hydration status per compute object", - links: &[], + links: &const { [] }, }), }); @@ -10596,7 +10809,7 @@ pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES: LazyLock = Laz ontology: Some(Ontology { entity_name: "compute_hydration_status", description: "Hydration status per compute operator", - links: &[], + links: &const { [] }, }), } }); @@ -10736,11 +10949,11 @@ GROUP BY channel_id", ontology: Some(Ontology { entity_name: "message_count", description: "Inter-worker message counts", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "counts_for", target: "dataflow_channel", - properties_json: r#"{"kind": "foreign_key", "source_column": "channel_id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("channel_id", "id", Cardinality::OneToOne), + }] }, }), }); @@ -10783,7 +10996,7 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "active_peek", description: "Currently executing SELECT queries", - links: &[], + links: &const { [] }, }), }); @@ -11065,11 +11278,18 @@ GROUP BY operator_id", ontology: Some(Ontology { entity_name: "arrangement_size", description: "Aggregated arrangement sizes (records, batches, bytes)", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "arrangement_of_operator", target: "dataflow_operator", - properties_json: r#"{"kind": "measures", "source_column": "operator_id", "target_column": "id", "metric": "arrangement_size", "note": "Both IDs are local uint64 operator IDs within a dataflow, not GlobalIds."}"#, - }], + properties: LinkProperties::Measures { + source_column: "operator_id", + target_column: "id", + metric: "arrangement_size", + source_id_type: None, + requires_mapping: None, + note: Some("Both IDs are local uint64 operator IDs within a dataflow, not GlobalIds."), + }, + }] }, }), }); @@ -11123,11 +11343,11 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "arrangement_sharing", description: "Arrangement sharing between operators", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "shared_by", target: "dataflow_operator", - properties_json: r#"{"kind": "foreign_key", "source_column": "operator_id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk("operator_id", "id", Cardinality::OneToOne), + }] }, }), }); @@ -11183,11 +11403,11 @@ FROM ontology: Some(Ontology { entity_name: "replica_utilization", description: "Computed utilization metrics per replica", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "utilization_of_replica", target: "replica", - properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "one_to_one"}"#, - }], + properties: LinkProperties::fk_typed("replica_id", "id", Cardinality::OneToOne, mz_repr::SemanticType::CatalogItemId), + }] }, }), }); @@ -11551,7 +11771,7 @@ pub static MZ_EXPECTED_GROUP_SIZE_ADVICE: LazyLock = LazyLock::new( ontology: Some(Ontology { entity_name: "group_size_advice", description: "Advice on expected group sizes for reduce operators", - links: &[], + links: &const { [] }, }), }); @@ -14507,7 +14727,7 @@ pub static MZ_CLUSTER_REPLICA_HISTORY: LazyLock = LazyLock::new(|| ontology: Some(Ontology { entity_name: "replica_history", description: "Historical record of replica creation/drops", - links: &[], + links: &const { [] }, }), }); @@ -14582,7 +14802,7 @@ FROM system_replicas"#, ontology: Some(Ontology { entity_name: "replica_name_history", description: "Historical replica names", - links: &[], + links: &const { [] }, }), }); @@ -14680,18 +14900,18 @@ SELECT * FROM sinks"#, ontology: Some(Ontology { entity_name: "hydration_status", description: "Overall hydration status per object", - links: &[ + links: &const { [ OntologyLink { name: "hydration_of", target: "object", - properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "foreign_key", "source_column": "object_id", "target_column": "id", "cardinality": "one_to_one"}"#, + properties: LinkProperties::fk_typed("object_id", "id", Cardinality::OneToOne, mz_repr::SemanticType::CatalogItemId), }, OntologyLink { name: "hydration_on_replica", target: "replica", - properties_json: r#"{"kind": "foreign_key", "source_column": "replica_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("replica_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -14742,18 +14962,22 @@ JOIN mz_catalog.mz_relations r ON (r.id = d.referenced_object_id)", ontology: Some(Ontology { entity_name: "materialization_dep", description: "Dependencies between materializations", - links: &[ + links: &const { [ OntologyLink { name: "materialization_depends_on", target: "object", - properties_json: r#"{"source_id_type": "CatalogItemId", "kind": "depends_on", "source_column": "object_id", "target_column": "id"}"#, + properties: LinkProperties::DependsOn { + source_column: "object_id", + target_column: "id", + source_id_type: Some(mz_repr::SemanticType::CatalogItemId), + }, }, OntologyLink { name: "materialization_dependency", target: "object", - properties_json: r#"{"kind": "foreign_key", "source_column": "dependency_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("dependency_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -14887,23 +15111,23 @@ JOIN root_times r USING (id)", ontology: Some(Ontology { entity_name: "materialization_lag", description: "Lag between a materialization and its inputs", - links: &[ + links: &const { [ OntologyLink { name: "measures_materialization_lag", target: "object", - properties_json: r#"{"kind": "measures", "source_column": "object_id", "target_column": "id", "metric": "materialization_lag"}"#, + properties: LinkProperties::measures("object_id", "id", "materialization_lag"), }, OntologyLink { name: "slowest_local_input", target: "object", - properties_json: r#"{"kind": "foreign_key", "source_column": "slowest_local_input_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("slowest_local_input_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "slowest_global_input", target: "object", - properties_json: r#"{"kind": "foreign_key", "source_column": "slowest_global_input_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("slowest_global_input_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -15309,18 +15533,18 @@ FROM mz_cluster_deployment_lineage"#, ontology: Some(Ontology { entity_name: "cluster_deployment", description: "Cluster deployment lineage information", - links: &[ + links: &const { [ OntologyLink { name: "deployment_of", target: "cluster", - properties_json: r#"{"kind": "foreign_key", "source_column": "cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "current_deployment", target: "cluster", - properties_json: r#"{"kind": "foreign_key", "source_column": "current_deployment_cluster_id", "target_column": "id", "cardinality": "many_to_one"}"#, + properties: LinkProperties::fk("current_deployment_cluster_id", "id", Cardinality::ManyToOne), }, - ], + ] }, }), }); @@ -15909,11 +16133,11 @@ pub static MZ_SOURCE_STATISTICS: LazyLock = LazyLock::new(|| { ontology: Some(Ontology { entity_name: "source_statistics", description: "Aggregated source ingestion statistics", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "statistics_of_source", target: "source", - properties_json: r#"{"kind": "measures", "source_column": "id", "target_column": "id", "metric": "ingestion_statistics"}"#, - }], + properties: LinkProperties::measures("id", "id", "ingestion_statistics"), + }] }, }), } }); @@ -16004,11 +16228,11 @@ GROUP BY id, replica_id", ontology: Some(Ontology { entity_name: "sink_statistics", description: "Aggregated sink export statistics", - links: &[OntologyLink { + links: &const { [OntologyLink { name: "statistics_of_sink", target: "sink", - properties_json: r#"{"kind": "measures", "source_column": "id", "target_column": "id", "metric": "export_statistics"}"#, - }], + properties: LinkProperties::measures("id", "id", "export_statistics"), + }] }, }), }); @@ -17176,9 +17400,9 @@ mod tests { // already have at least one FK-style link. // // Scope: only entities that have started FK annotation (at least one - // link with "source_column" in properties_json). Entities with only - // union/maps_to links, or no links at all, are not yet fully annotated - // and are skipped to avoid noise. + // link with a source_column). Entities with only union/maps_to links, + // or no links at all, are not yet fully annotated and are skipped to + // avoid noise. // // Exemptions: // - Column at index 0 named "id": almost always the entity's own PK, @@ -17210,17 +17434,16 @@ mod tests { }; let Some(ont) = ontology else { continue }; - // Collect all source_column values declared by existing FK links. - // The format is always: "source_column": "colname" + // Collect all source_column values declared by existing links. let linked_cols: BTreeSet<&str> = ont .links .iter() - .filter_map(|link| { - let json = link.properties_json; - let key = "\"source_column\": \""; - let start = json.find(key)? + key.len(); - let end = json[start..].find('"')? + start; - Some(&json[start..end]) + .filter_map(|link| match &link.properties { + LinkProperties::ForeignKey { source_column, .. } => Some(*source_column), + LinkProperties::Measures { source_column, .. } => Some(*source_column), + LinkProperties::DependsOn { source_column, .. } => Some(*source_column), + LinkProperties::MapsTo { source_column: Some(sc), .. } => Some(*sc), + _ => None, }) .collect(); @@ -17265,9 +17488,11 @@ mod tests { uncovered_fk_cols.join("\n"), ); - // Validate that every source_column referenced in properties_json - // actually names a column in the entity's RelationDesc. This catches - // stale link annotations after column renames or removals. + // Validate that every source_column in a link actually names a column + // in the entity's RelationDesc. This catches stale annotations after + // column renames or removals. With typed LinkProperties this is mostly + // belt-and-suspenders since the type system enforces field presence, but + // we still need to verify the string value matches a real column. let mut bad_source_cols = Vec::new(); for builtin in BUILTINS_STATIC.iter() { let (name, desc, ontology) = match builtin { @@ -17283,15 +17508,14 @@ mod tests { desc.iter_names().map(|c| c.as_str()).collect(); for link in ont.links { - let json = link.properties_json; - let key = "\"source_column\": \""; - let Some(start) = json.find(key).map(|i| i + key.len()) else { - continue; + let source_col = match &link.properties { + LinkProperties::ForeignKey { source_column, .. } => Some(*source_column), + LinkProperties::Measures { source_column, .. } => Some(*source_column), + LinkProperties::DependsOn { source_column, .. } => Some(*source_column), + LinkProperties::MapsTo { source_column: Some(sc), .. } => Some(*sc), + _ => None, }; - let Some(end) = json[start..].find('"').map(|i| i + start) else { - continue; - }; - let col = &json[start..end]; + let Some(col) = source_col else { continue }; if !col_names.contains(col) { bad_source_cols.push(format!( "entity {:?} (builtin {}) link {:?} references source_column {:?} which does not exist in the relation", @@ -17313,4 +17537,75 @@ mod tests { entity_names.len() ); } + + /// Verify that `LinkProperties` serializes to the same JSON that the old + /// hand-written `properties_json` strings contained. One representative + /// case per constructor/variant is enough — the important thing is that + /// field names, enum tag values, and skip-if-None/false behaviour are all + /// correct. + #[mz_ore::test] + fn test_link_properties_serialization() { + let check = |props: LinkProperties, expected: &str| { + let got = serde_json::to_string(&props).expect("serialize"); + let got_val: serde_json::Value = serde_json::from_str(&got).expect("parse got"); + let exp_val: serde_json::Value = serde_json::from_str(expected).expect("parse expected"); + assert_eq!(got_val, exp_val, "mismatch for {expected}"); + }; + + // fk — basic, no optional fields + check( + LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + r#"{"kind":"foreign_key","source_column":"owner_id","target_column":"id","cardinality":"many_to_one"}"#, + ); + // fk — one_to_one cardinality + check( + LinkProperties::fk("id", "id", Cardinality::OneToOne), + r#"{"kind":"foreign_key","source_column":"id","target_column":"id","cardinality":"one_to_one"}"#, + ); + // fk_nullable — nullable field present and true + check( + LinkProperties::fk_nullable("database_id", "id", Cardinality::ManyToOne), + r#"{"kind":"foreign_key","source_column":"database_id","target_column":"id","cardinality":"many_to_one","nullable":true}"#, + ); + // fk_typed — source_id_type present, requires_mapping absent + check( + LinkProperties::fk_typed("replica_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), + r#"{"kind":"foreign_key","source_column":"replica_id","target_column":"id","cardinality":"many_to_one","source_id_type":"CatalogItemId"}"#, + ); + // fk_mapped — source_id_type + requires_mapping both present + check( + LinkProperties::fk_mapped("object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), + r#"{"kind":"foreign_key","source_column":"object_id","target_column":"id","cardinality":"many_to_one","source_id_type":"GlobalId","requires_mapping":"mz_internal.mz_object_global_ids"}"#, + ); + // union_disc — discriminator fields present, note absent + check( + LinkProperties::union_disc("type", "table"), + r#"{"kind":"union","discriminator_column":"type","discriminator_value":"table"}"#, + ); + // Union — note only, discriminator absent + check( + LinkProperties::Union { discriminator_column: None, discriminator_value: None, note: Some("example note") }, + r#"{"kind":"union","note":"example note"}"#, + ); + // measures — basic + check( + LinkProperties::measures("id", "id", "cpu_time_ns"), + r#"{"kind":"measures","source_column":"id","target_column":"id","metric":"cpu_time_ns"}"#, + ); + // measures_mapped — source_id_type + requires_mapping present + check( + LinkProperties::measures_mapped("object_id", "id", "wallclock_lag", mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), + r#"{"kind":"measures","source_column":"object_id","target_column":"id","metric":"wallclock_lag","source_id_type":"GlobalId","requires_mapping":"mz_internal.mz_object_global_ids"}"#, + ); + // DependsOn + check( + LinkProperties::DependsOn { source_column: "object_id", target_column: "id", source_id_type: Some(mz_repr::SemanticType::CatalogItemId) }, + r#"{"kind":"depends_on","source_column":"object_id","target_column":"id","source_id_type":"CatalogItemId"}"#, + ); + // MapsTo — via + from_type + to_type + check( + LinkProperties::MapsTo { source_column: None, target_column: None, via: Some("mz_internal.mz_object_global_ids"), from_type: Some(mz_repr::SemanticType::CatalogItemId), to_type: Some(mz_repr::SemanticType::GlobalId), note: None }, + r#"{"kind":"maps_to","via":"mz_internal.mz_object_global_ids","from_type":"CatalogItemId","to_type":"GlobalId"}"#, + ); + } } From 068f5b4b55a2e28efd9720c731e7bd1254534c83 Mon Sep 17 00:00:00 2001 From: mtabebe Date: Thu, 30 Apr 2026 12:34:36 -0400 Subject: [PATCH 09/14] [ontology] fix entity name consistency and unify view builders Introduce Lit enum (Str/Json/Null), values_sql(), and values_view() helpers in ontology.rs so all SQL literal escaping is centralized in Lit::render(). The three static view builders (entity_types, semantic_types, link_types) and the two inline VALUES lists in properties_view now use Lit instead of direct esc() calls at each site. --- src/catalog/src/builtin.rs | 4 +- src/catalog/src/builtin/ontology.rs | 231 ++++++++++++++++++---------- 2 files changed, 155 insertions(+), 80 deletions(-) diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index 8cc5b57503fa1..654cdbf9889d8 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -3319,7 +3319,7 @@ pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock = LazyLock::new(|| is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], ontology: Some(Ontology { - entity_name: "ssh_tunnel", + entity_name: "ssh_tunnel_connection", description: "SSH tunnel connection with public keys", links: &const { [OntologyLink { name: "details_of", @@ -6486,7 +6486,7 @@ pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock = LazyLock::ne is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], ontology: Some(Ontology { - entity_name: "aws_privatelink", + entity_name: "aws_privatelink_connection", description: "AWS PrivateLink connection configuration", links: &const { [OntologyLink { name: "details_of", diff --git a/src/catalog/src/builtin/ontology.rs b/src/catalog/src/builtin/ontology.rs index f6a63cd1f7fd6..ad2afba5e68db 100644 --- a/src/catalog/src/builtin/ontology.rs +++ b/src/catalog/src/builtin/ontology.rs @@ -72,6 +72,40 @@ struct Info<'a> { ontology: &'a Ontology, } +/// A single typed SQL literal for use inside a VALUES list. +enum Lit { + /// A text string: rendered as `'escaped'`. + Str(String), + /// A JSONB value: rendered as `'escaped'::jsonb`. + Json(String), + /// SQL NULL. + Null, +} + +impl Lit { + fn render(&self) -> String { + match self { + Lit::Str(s) => format!("'{}'", esc(s)), + Lit::Json(s) => format!("'{}'::jsonb", esc(s)), + Lit::Null => "NULL".to_string(), + } + } +} + +/// Map a `SqlScalarType` to the SQL type name used in cast expressions. +fn sql_type_name(ty: &SqlScalarType) -> &'static str { + match ty { + SqlScalarType::String => "text", + SqlScalarType::Jsonb => "jsonb", + SqlScalarType::Oid => "oid", + SqlScalarType::UInt64 => "uint8", + SqlScalarType::Numeric { .. } => "numeric", + SqlScalarType::MzTimestamp => "mz_timestamp", + SqlScalarType::TimestampTz { .. } => "timestamp with time zone", + other => panic!("unsupported SqlScalarType in ontology view: {other:?}"), + } +} + /// Escape single quotes for SQL string literals. Only safe for trusted /// compile-time constants (entity names, descriptions, link JSON from /// `Ontology` annotations) — never use with user-supplied input. @@ -79,14 +113,50 @@ fn esc(s: &str) -> String { s.replace('\'', "''") } -/// Build a simple ontology view from a name, OID, column defs, and SQL. -fn view( +/// Render rows into a SQL `VALUES (r1c1,r1c2,...),(r2c1,...)` fragment. +/// Used when a VALUES list appears as a subquery inside a larger SQL string +/// rather than as the top-level source of a `values_view`. +fn values_sql(rows: &[Vec]) -> String { + rows.iter() + .map(|row| { + let lits: Vec = row.iter().map(Lit::render).collect(); + format!("({})", lits.join(",")) + }) + .collect::>() + .join(",") +} + +/// Build an ontology view from a static VALUES list. Each row is a `Vec`; +/// all escaping and type-casting is handled here so callers never touch SQL +/// string formatting directly. +fn values_view( name: &'static str, oid: u32, cols: &[(&'static str, SqlScalarType, bool)], keys: &[Vec], - sql: String, + rows: Vec>, ) -> BuiltinView { + let col_names: Vec<&str> = cols.iter().map(|(n, _, _)| *n).collect(); + let cast_exprs: Vec = cols + .iter() + .map(|(n, ty, _)| format!("{n}::{}", sql_type_name(ty))) + .collect(); + + let vals: Vec = rows + .iter() + .map(|row| { + let lits: Vec = row.iter().map(Lit::render).collect(); + format!("({})", lits.join(",")) + }) + .collect(); + + let sql = format!( + "SELECT {casts} FROM (VALUES {vals}) AS t({cols})", + casts = cast_exprs.join(","), + vals = vals.join(","), + cols = col_names.join(","), + ); + let mut b = RelationDesc::builder(); for (n, ty, nullable) in cols { b = b.with_column(*n, ty.clone().nullable(*nullable)); @@ -107,13 +177,15 @@ fn view( } } -/// Extract all keys from a `RelationDesc` and format them as a JSON object: +/// Extract all keys from a `RelationDesc` and return a `Lit::Json` with shape: /// `{"primary_key": ["id"], "alternate_keys": [["oid"]]}`. /// `primary_key` is the first declared key; `alternate_keys` contains any -/// additional unique keys (e.g. OID). Returns `None` if no keys are defined. -fn pk_json(desc: &RelationDesc) -> Option { +/// additional unique keys. Returns `Lit::Null` if no keys are defined. +fn pk_lit(desc: &RelationDesc) -> Lit { let all_keys = &desc.typ().keys; - let (first, rest) = all_keys.split_first()?; + let Some((first, rest)) = all_keys.split_first() else { + return Lit::Null; + }; let fmt_key = |key: &Vec| -> String { let cols: Vec<_> = key .iter() @@ -122,36 +194,33 @@ fn pk_json(desc: &RelationDesc) -> Option { format!("[{}]", cols.join(", ")) }; let primary = fmt_key(first); - if rest.is_empty() { - Some(format!("{{\"primary_key\": {primary}}}")) + let json = if rest.is_empty() { + format!("{{\"primary_key\": {primary}}}") } else { let alts: Vec<_> = rest.iter().map(fmt_key).collect(); - Some(format!( + format!( "{{\"primary_key\": {primary}, \"alternate_keys\": [{}]}}", alts.join(", ") - )) - } + ) + }; + Lit::Json(json) } // ── View builders ──────────────────────────────────────────── fn entity_types_view(infos: &[Info]) -> BuiltinView { - let vals: Vec<_> = infos + let rows = infos .iter() .map(|i| { - let pk = pk_json(i.desc) - .map_or_else(|| "NULL::jsonb".into(), |j| format!("'{}'::jsonb", esc(&j))); - format!( - "('{}','{}.{}',{},'{}')", - esc(&i.entity_name), - esc(i.schema_name), - esc(i.table_name), - pk, - esc(i.ontology.description) - ) + vec![ + Lit::Str(i.entity_name.clone()), + Lit::Str(format!("{}.{}", i.schema_name, i.table_name)), + pk_lit(i.desc), + Lit::Str(i.ontology.description.to_string()), + ] }) .collect(); - view( + values_view( "mz_ontology_entity_types", oid::VIEW_MZ_ONTOLOGY_ENTITY_TYPES_OID, &[ @@ -161,19 +230,22 @@ fn entity_types_view(infos: &[Info]) -> BuiltinView { ("description", SqlScalarType::String, false), ], &[vec![0], vec![1], vec![3]], - format!( - "SELECT name::text,relation::text,properties::jsonb,description::text FROM (VALUES {}) AS t(name,relation,properties,description)", - vals.join(",") - ), + rows, ) } fn semantic_types_view() -> BuiltinView { - let vals: Vec<_> = SEMANTIC_TYPE_DEFS + let rows = SEMANTIC_TYPE_DEFS .iter() - .map(|(n, t, d)| format!("('{}','{}','{}')", esc(&n.to_string()), esc(t), esc(d))) + .map(|(n, t, d)| { + vec![ + Lit::Str(n.to_string()), + Lit::Str(t.to_string()), + Lit::Str(d.to_string()), + ] + }) .collect(); - view( + values_view( "mz_ontology_semantic_types", oid::VIEW_MZ_ONTOLOGY_SEMANTIC_TYPES_OID, &[ @@ -182,10 +254,7 @@ fn semantic_types_view() -> BuiltinView { ("description", SqlScalarType::String, false), ], &[vec![0], vec![2]], - format!( - "SELECT name::text,sql_type::text,description::text FROM (VALUES {}) AS t(name,sql_type,description)", - vals.join(",") - ), + rows, ) } @@ -204,38 +273,26 @@ fn semantic_types_view() -> BuiltinView { /// Column descriptions come from `mz_comments`. Both are LEFT JOINed so /// columns without annotations or comments still appear (with NULLs). fn properties_view(infos: &[Info]) -> BuiltinView { - let mut ent = Vec::new(); - let mut ann = Vec::new(); + let mut ent: Vec> = Vec::new(); + let mut ann: Vec> = Vec::new(); for i in infos { - ent.push(format!( - "('{}','{}','{}')", - esc(i.schema_name), - esc(i.table_name), - esc(&i.entity_name) - )); + ent.push(vec![ + Lit::Str(i.schema_name.to_string()), + Lit::Str(i.table_name.to_string()), + Lit::Str(i.entity_name.clone()), + ]); for (idx, col) in i.desc.iter_names().enumerate() { if let Some(sem) = i.desc.get_semantic_type(idx) { - ann.push(format!( - "('{}','{}','{}')", - esc(&i.entity_name), - esc(col.as_str()), - sem - )); + ann.push(vec![ + Lit::Str(i.entity_name.clone()), + Lit::Str(col.as_str().to_string()), + Lit::Str(sem.to_string()), + ]); } } } - view( - "mz_ontology_properties", - oid::VIEW_MZ_ONTOLOGY_PROPERTIES_OID, - &[ - ("entity_type", SqlScalarType::String, false), - ("column_name", SqlScalarType::String, false), - ("semantic_type", SqlScalarType::String, true), - ("description", SqlScalarType::String, true), - ], - &[], - format!( - "SELECT ent.entity_name AS entity_type,col.name AS column_name,\ + let sql = format!( + "SELECT ent.entity_name AS entity_type,col.name AS column_name,\ ann.semantic_type::text AS semantic_type,cmt.comment AS description \ FROM (VALUES {ent}) AS ent(schema_name,table_name,entity_name) \ JOIN mz_catalog.mz_schemas s ON s.name=ent.schema_name \ @@ -244,28 +301,49 @@ fn properties_view(infos: &[Info]) -> BuiltinView { LEFT JOIN mz_internal.mz_comments cmt ON cmt.id=o.id AND cmt.object_sub_id=col.position \ LEFT JOIN (VALUES {ann}) AS ann(entity_name,column_name,semantic_type) \ ON ann.entity_name=ent.entity_name AND ann.column_name=col.name", - ent = ent.join(","), - ann = ann.join(","), - ), - ) + ent = values_sql(&ent), + ann = values_sql(&ann), + ); + + let mut b = RelationDesc::builder(); + for (n, ty, nullable) in &[ + ("entity_type", SqlScalarType::String, false), + ("column_name", SqlScalarType::String, false), + ("semantic_type", SqlScalarType::String, true), + ("description", SqlScalarType::String, true), + ] { + b = b.with_column(*n, ty.clone().nullable(*nullable)); + } + BuiltinView { + name: "mz_ontology_properties", + schema: MZ_INTERNAL_SCHEMA, + oid: oid::VIEW_MZ_ONTOLOGY_PROPERTIES_OID, + desc: b.finish(), + column_comments: BTreeMap::new(), + sql: Box::leak(sql.into_boxed_str()), + access: vec![PUBLIC_SELECT], + ontology: None, + } } fn link_types_view(infos: &[Info]) -> BuiltinView { - let vals: Vec<_> = infos + let rows = infos .iter() .flat_map(|i| { i.ontology.links.iter().map(move |l| { - format!( - "('{}','{}','{}','{}'::jsonb,NULL::text)", - esc(l.name), - esc(&i.entity_name), - esc(l.target), - esc(&serde_json::to_string(&l.properties).expect("valid")), - ) + vec![ + Lit::Str(l.name.to_string()), + Lit::Str(i.entity_name.clone()), + Lit::Str(l.target.to_string()), + Lit::Json( + serde_json::to_string(&l.properties).expect("LinkProperties is serializable"), + ), + Lit::Null, + ] }) }) .collect(); - view( + values_view( "mz_ontology_link_types", oid::VIEW_MZ_ONTOLOGY_LINK_TYPES_OID, &[ @@ -276,10 +354,7 @@ fn link_types_view(infos: &[Info]) -> BuiltinView { ("description", SqlScalarType::String, true), ], &[], - format!( - "SELECT name::text,source_entity::text,target_entity::text,properties::jsonb,description::text FROM (VALUES {}) AS t(name,source_entity,target_entity,properties,description)", - vals.join(",") - ), + rows, ) } From 503125429c5b6ee52f6e8dd4ffe56c6d65daca7c Mon Sep 17 00:00:00 2001 From: mtabebe Date: Thu, 30 Apr 2026 13:41:37 -0400 Subject: [PATCH 10/14] address ontology review feedback (entity names, descriptions, link fixes) --- src/catalog/src/builtin.rs | 113 +++++++++++++++++++++++++++---------- src/repr/src/relation.rs | 20 +++++-- 2 files changed, 98 insertions(+), 35 deletions(-) diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index 654cdbf9889d8..0a9b76c09d9c7 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -169,16 +169,28 @@ pub struct BuiltinLog { /// via `RelationDescBuilder::with_column_semantic_type()`. #[derive(Clone, Hash, Debug, PartialEq, Eq)] pub struct Ontology { - /// The ontology entity name (e.g., "database", "table", "mv"). + /// The ontology entity name (e.g., "database", "table", "mv"). Names a + /// single row of this relation, so prefer singular event/object nouns + /// (e.g., "replica_status_event" not "replica_status_history"). pub entity_name: &'static str, /// One-line description of this entity. pub description: &'static str, - /// FK relationships originating from this entity. + /// Relationships originating from this entity (foreign keys, unions, + /// mappings, dependencies, metrics). pub links: &'static [OntologyLink], } /// Cardinality of an ontology link. -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive( + Clone, + Copy, + Debug, + Hash, + PartialEq, + Eq, + serde::Serialize, + serde::Deserialize +)] #[serde(rename_all = "snake_case")] pub enum Cardinality { OneToOne, @@ -412,7 +424,29 @@ impl LinkProperties { } } -/// A relationship link in the ontology. +/// A directed relationship from one ontology entity to another. +/// +/// Each link has a `name` (the relationship label, e.g. `"owned_by"`), a +/// `target` entity name, and a `properties` variant that captures the +/// *kind* of relationship. Choosing the right variant matters: +/// +/// - [`LinkProperties::ForeignKey`]: the source entity has a column whose +/// value is an ID that directly references a row in the target entity. +/// Use this when there is an explicit FK column (e.g. `schema_id` -> +/// `schema`). +/// - [`LinkProperties::DependsOn`]: the source entity logically depends on +/// the target entity, but the relationship is a graph edge rather than a +/// simple column reference (e.g. `mz_compute_dependencies` records that a +/// dataflow depends on an object). Use this for dependency-graph tables, +/// **not** `ForeignKey`. +/// - [`LinkProperties::Union`]: the source entity is a superset view that +/// contains the target entity as a subset, optionally filtered by a +/// discriminator column. +/// - [`LinkProperties::MapsTo`]: the source entity provides an ID translation +/// to the target entity, possibly via an intermediate table or across ID +/// namespaces. +/// - [`LinkProperties::Measures`]: the source entity records metric +/// measurements about the target entity. #[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct OntologyLink { /// Relationship name (e.g., "owned_by", "in_schema"). @@ -2742,7 +2776,7 @@ pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| B access: vec![PUBLIC_SELECT], ontology: Some(Ontology { entity_name: "compute_dependency", - description: "Dependency edge within compute dataflows", + description: "Dependency edge from a compute object (index, materialized view, or subscription) to one of the sources of its data", links: &const { [ OntologyLink { name: "dependent_compute_object", @@ -4875,7 +4909,7 @@ WHERE access: vec![PUBLIC_SELECT], ontology: Some(Ontology { entity_name: "secret", - description: "An encrypted secret value used by connections", + description: "A user-defined secret containing sensitive configuration (e.g., credentials)", links: &const { [ OntologyLink { name: "in_schema", @@ -5051,10 +5085,10 @@ pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY: LazyLock = LazyLock is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], ontology: Some(Ontology { - entity_name: "replica_status_history", + entity_name: "replica_status_event", description: "Historical replica status events (ready, not-ready, etc.)", links: &const { [OntologyLink { - name: "status_history_of_replica", + name: "status_event_of_replica", target: "replica", properties: LinkProperties::fk_typed("replica_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), }] }, @@ -5122,7 +5156,7 @@ ORDER BY replica_id, process_id, occurred_at DESC", links: &const { [OntologyLink { name: "status_of_replica", target: "replica", - properties: LinkProperties::fk_typed("replica_id", "id", Cardinality::OneToOne, mz_repr::SemanticType::CatalogItemId), + properties: LinkProperties::fk_typed("replica_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::ReplicaId), }] }, }), }); @@ -5273,11 +5307,11 @@ pub static MZ_SOURCE_STATUS_HISTORY: LazyLock = LazyLock::new(|| is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], ontology: Some(Ontology { - entity_name: "source_status_history", + entity_name: "source_status_event", description: "Historical source status events", links: &const { [ OntologyLink { - name: "status_history_of_source", + name: "status_event_of_source", target: "source", properties: LinkProperties::fk_mapped("source_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), }, @@ -5517,7 +5551,7 @@ pub static MZ_RECENT_SQL_TEXT: LazyLock = LazyLock::new(|| { access: vec![MONITOR_SELECT], ontology: Some(Ontology { entity_name: "recent_sql_text", - description: "Recent SQL text (indexed, last 3 days)", + description: "Recent SQL text (indexed, last ~3-4 days)", links: &const { [] }, }), } @@ -5577,12 +5611,12 @@ pub static MZ_SESSION_HISTORY: LazyLock = LazyLock::new(|| Builti is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], ontology: Some(Ontology { - entity_name: "session_history", + entity_name: "session", description: "Historical session connection events", links: &const { [OntologyLink { - name: "history_of", - target: "session", - properties: LinkProperties::fk("session_id", "id", Cardinality::ManyToOne), + name: "active_as", + target: "active_session", + properties: LinkProperties::fk_nullable("session_id", "id", Cardinality::ManyToOne), }] }, }), }); @@ -5911,9 +5945,19 @@ WHERE mralt.sql_hash = mrst.sql_hash", description: "Recent query activity with execution stats", links: &const { [ OntologyLink { - name: "session_on_cluster", + name: "in_session", + target: "session", + properties: LinkProperties::fk("session_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "in_active_session", + target: "active_session", + properties: LinkProperties::fk_nullable("session_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "ran_on_cluster", target: "cluster", - properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), + properties: LinkProperties::fk_nullable("cluster_id", "id", Cardinality::ManyToOne), }, OntologyLink { name: "used_transient_index", @@ -6021,9 +6065,13 @@ pub static MZ_STATEMENT_LIFECYCLE_HISTORY: LazyLock = LazyLock::n MONITOR_SELECT, ], ontology: Some(Ontology { - entity_name: "statement_lifecycle", + entity_name: "statement_lifecycle_event", description: "Statement lifecycle events (parse, bind, execute)", - links: &const { [] }, + links: &const { [OntologyLink { + name: "for_execution", + target: "activity_log", + properties: LinkProperties::fk("statement_id", "execution_id", Cardinality::ManyToOne), + }] }, }), } }); @@ -6262,11 +6310,11 @@ pub static MZ_SINK_STATUS_HISTORY: LazyLock = LazyLock::new(|| Bu is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], ontology: Some(Ontology { - entity_name: "sink_status_history", + entity_name: "sink_status_event", description: "Historical sink status events", links: &const { [ OntologyLink { - name: "status_history_of_sink", + name: "status_event_of_sink", target: "sink", properties: LinkProperties::fk_mapped("sink_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), }, @@ -6779,7 +6827,7 @@ pub static MZ_FRONTIERS: LazyLock = LazyLock::new(|| BuiltinSourc access: vec![PUBLIC_SELECT], ontology: Some(Ontology { entity_name: "frontier", - description: "Current read/write frontiers per object (source)", + description: "Current read/write frontiers for sources, sinks, tables, materialized views, indexes, and subscriptions", links: &const { [OntologyLink { name: "frontier_of", target: "object", @@ -6841,7 +6889,7 @@ pub static MZ_WALLCLOCK_LAG_HISTORY: LazyLock = LazyLock::new(|| is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], ontology: Some(Ontology { - entity_name: "wallclock_lag_history", + entity_name: "wallclock_lag_event", description: "Historical wallclock lag per object", links: &const { [ OntologyLink { @@ -6907,7 +6955,7 @@ GROUP BY object_id, occurred_at OPTIONS (AGGREGATE INPUT GROUP SIZE = 1)", access: vec![PUBLIC_SELECT], ontology: Some(Ontology { - entity_name: "wallclock_global_lag_history", + entity_name: "wallclock_global_lag_event", description: "Historical global wallclock lag", links: &const { [OntologyLink { name: "lag_of", @@ -7138,6 +7186,11 @@ pub static MZ_SUBSCRIPTIONS: LazyLock = LazyLock::new(|| BuiltinTa target: "session", properties: LinkProperties::fk("session_id", "id", Cardinality::ManyToOne), }, + OntologyLink { + name: "in_active_session", + target: "active_session", + properties: LinkProperties::fk_nullable("session_id", "id", Cardinality::ManyToOne), + }, OntologyLink { name: "belongs_to_cluster", target: "cluster", @@ -7187,7 +7240,7 @@ pub static MZ_SESSIONS: LazyLock = LazyLock::new(|| BuiltinTable { is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], ontology: Some(Ontology { - entity_name: "session", + entity_name: "active_session", description: "Currently active sessions", links: &const { [OntologyLink { name: "logged_in_as", @@ -8083,12 +8136,12 @@ pub static MZ_OBJECT_LIFETIMES: LazyLock = LazyLock::new(|| Builtin WHERE a.event_type = 'create' OR a.event_type = 'drop'", access: vec![PUBLIC_SELECT], ontology: Some(Ontology { - entity_name: "object_lifetime", - description: "Computed lifetime span (created_at to dropped_at) for objects", + entity_name: "object_lifetime_event", + description: "Create or drop lifecycle event for a catalog object", links: &const { [OntologyLink { - name: "lifetime_of", + name: "lifetime_event_of", target: "object", - properties: LinkProperties::fk_typed("id", "id", Cardinality::OneToOne, mz_repr::SemanticType::CatalogItemId), + properties: LinkProperties::fk_typed("id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), }] }, }), }); diff --git a/src/repr/src/relation.rs b/src/repr/src/relation.rs index ea31ea1bf5689..82fc510525a11 100644 --- a/src/repr/src/relation.rs +++ b/src/repr/src/relation.rs @@ -828,7 +828,17 @@ impl RustType for RelationVersion { /// describe the meaning of a column (e.g., that it contains a catalog item ID /// or a role ID). Possible values correspond to the entries in /// `SEMANTIC_TYPE_DEFS` in the `mz-catalog` crate. -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize)] +#[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + serde::Serialize +)] pub enum SemanticType { CatalogItemId, GlobalId, @@ -967,7 +977,7 @@ pub struct RelationDesc { /// Optional semantic type annotations for columns. /// Keyed by column index. Only populated for builtin catalog objects. #[serde(skip)] - semantic_types: BTreeMap, + semantic_types: BTreeMap, } impl RustType for RelationDesc { @@ -1270,7 +1280,7 @@ impl RelationDesc { /// Gets the semantic type annotation for column `i`, if any. pub fn get_semantic_type(&self, i: usize) -> Option { - self.semantic_types.get(&i).copied() + self.semantic_types.get(&ColumnIndex(i)).copied() } /// Gets the name of the column at `idx`. @@ -1594,7 +1604,7 @@ pub struct RelationDescBuilder { /// Sets of indices that are "keys" for the collection. keys: Vec>, /// Semantic type annotations for columns. - semantic_types: BTreeMap, + semantic_types: BTreeMap, } impl RelationDescBuilder { @@ -1641,7 +1651,7 @@ impl RelationDescBuilder { ) -> RelationDescBuilder { let idx = self.columns.len(); self.columns.push((name.into(), ty)); - self.semantic_types.insert(idx, semantic_type); + self.semantic_types.insert(ColumnIndex(idx), semantic_type); self } From 057397bee4a6ba77b1d630d11a11f53c79dda73f Mon Sep 17 00:00:00 2001 From: mtabebe Date: Thu, 30 Apr 2026 13:52:34 -0400 Subject: [PATCH 11/14] Add semantic_types in proto roundtrip and builtin catalog item construction --- .../reference/system-catalog/mz_internal.md | 2 +- .../system-catalog/mz_introspection.md | 2 +- src/adapter/src/catalog/apply.rs | 30 +- src/catalog/src/builtin.rs | 2001 ++++++++++------- src/catalog/src/builtin/ontology.rs | 3 +- src/repr/src/relation.rs | 120 +- src/repr/src/relation_and_scalar.proto | 25 + .../autogenerated/mz_internal.slt | 2 +- .../autogenerated/mz_introspection.slt | 2 +- 9 files changed, 1376 insertions(+), 811 deletions(-) diff --git a/doc/user/content/reference/system-catalog/mz_internal.md b/doc/user/content/reference/system-catalog/mz_internal.md index 8fbd92decfdf1..549fd37728c11 100644 --- a/doc/user/content/reference/system-catalog/mz_internal.md +++ b/doc/user/content/reference/system-catalog/mz_internal.md @@ -338,7 +338,7 @@ SQL objects that don't exist in the compute layer (such as views) are omitted. | Field | Type | Meaning | | ----------- | -------- | -------- | -| `object_id` | [`text`] | The ID of a compute object. Corresponds to [`mz_catalog.mz_indexes.id`](../mz_catalog#mz_indexes), [`mz_catalog.mz_materialized_views.id`](../mz_catalog#mz_materialized_views), or [`mz_internal.mz_subscriptions`](#mz_subscriptions). | +| `object_id` | [`text`] | The ID of a compute object. Corresponds to [`mz_catalog.mz_indexes.id`](../mz_catalog#mz_indexes), [`mz_catalog.mz_materialized_views.id`](../mz_catalog#mz_materialized_views), or [`mz_internal.mz_subscriptions.id`](#mz_subscriptions). | | `dependency_id` | [`text`] | The ID of a compute dependency. Corresponds to [`mz_catalog.mz_indexes.id`](../mz_catalog#mz_indexes), [`mz_catalog.mz_materialized_views.id`](../mz_catalog#mz_materialized_views), [`mz_catalog.mz_sources.id`](../mz_catalog#mz_sources), or [`mz_catalog.mz_tables.id`](../mz_catalog#mz_tables). | ## `mz_compute_hydration_statuses` diff --git a/doc/user/content/reference/system-catalog/mz_introspection.md b/doc/user/content/reference/system-catalog/mz_introspection.md index f4b189cc04c67..f238ce5e8240b 100644 --- a/doc/user/content/reference/system-catalog/mz_introspection.md +++ b/doc/user/content/reference/system-catalog/mz_introspection.md @@ -107,7 +107,7 @@ The `mz_compute_exports` view describes the objects exported by [dataflows][data | Field | Type | Meaning | | -------------- |-----------| -------- | -| `export_id` | [`text`] | The ID of the index, materialized view, or subscription exported by the dataflow. Corresponds to [`mz_catalog.mz_indexes.id`](../mz_catalog#mz_indexes), [`mz_catalog.mz_materialized_views.id`](../mz_catalog#mz_materialized_views), or [`mz_internal.mz_subscriptions`](../mz_internal#mz_subscriptions). | +| `export_id` | [`text`] | The ID of the index, materialized view, or subscription exported by the dataflow. Corresponds to [`mz_catalog.mz_indexes.id`](../mz_catalog#mz_indexes), [`mz_catalog.mz_materialized_views.id`](../mz_catalog#mz_materialized_views), or [`mz_internal.mz_subscriptions.id`](../mz_internal#mz_subscriptions). | | `dataflow_id` | [`uint8`] | The ID of the dataflow. Corresponds to [`mz_dataflows.id`](#mz_dataflows). | diff --git a/src/adapter/src/catalog/apply.rs b/src/adapter/src/catalog/apply.rs index 184eb14a8dcf7..af52bcfaeb339 100644 --- a/src/adapter/src/catalog/apply.rs +++ b/src/adapter/src/catalog/apply.rs @@ -46,7 +46,9 @@ use mz_ore::{instrument, soft_assert_eq_or_log, soft_assert_no_log, soft_assert_ use mz_pgrepr::oid::INVALID_OID; use mz_repr::adt::mz_acl_item::{MzAclItem, PrivilegeMap}; use mz_repr::role_id::RoleId; -use mz_repr::{CatalogItemId, Diff, GlobalId, RelationVersion, Timestamp, VersionedRelationDesc}; +use mz_repr::{ + CatalogItemId, ColumnIndex, Diff, GlobalId, RelationVersion, Timestamp, VersionedRelationDesc, +}; use mz_sql::catalog::CatalogError as SqlCatalogError; use mz_sql::catalog::{CatalogItem as SqlCatalogItem, CatalogItemType, CatalogSchema, CatalogType}; use mz_sql::names::{ @@ -981,6 +983,15 @@ impl CatalogState { for key in &mv.desc.typ().keys { desc = desc.with_key(key.clone()); } + // Copy semantic type annotations from the static builtin definition. + let semantic_types = (0..desc.arity()) + .filter_map(|i| { + mv.desc + .get_semantic_type(i) + .map(|st| (ColumnIndex::from_raw(i), st)) + }) + .collect(); + desc = desc.with_semantic_types(semantic_types); catalog_mv.desc = VersionedRelationDesc::new(desc); self.insert_item( @@ -1762,7 +1773,7 @@ impl CatalogState { } }; match res { - Ok((item, uncached_expr)) => { + Ok((mut item, uncached_expr)) => { if let Some((uncached_expr, optimizer_features)) = uncached_expr { local_expression_cache.insert_uncached_expression( global_id, @@ -1789,6 +1800,21 @@ impl CatalogState { )]; acl_items.extend_from_slice(&view.access); + // Copy semantic type annotations from the static builtin definition. + if let CatalogItem::View(catalog_view) = &mut item { + let semantic_types = (0..catalog_view.desc.arity()) + .filter_map(|i| { + view.desc + .get_semantic_type(i) + .map(|st| (ColumnIndex::from_raw(i), st)) + }) + .collect(); + catalog_view.desc = catalog_view + .desc + .clone() + .with_semantic_types(semantic_types); + } + state.insert_item( id, view.oid, diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index 0a9b76c09d9c7..d55bf8e836941 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -2380,11 +2380,13 @@ pub static MZ_ICEBERG_SINKS: LazyLock = LazyLock::new(|| BuiltinTa ontology: Some(Ontology { entity_name: "iceberg_sink", description: "Iceberg-specific sink configuration (namespace, table)", - links: &const { [OntologyLink { - name: "details_of", - target: "sink", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "details_of", + target: "sink", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); @@ -2413,11 +2415,13 @@ pub static MZ_KAFKA_SINKS: LazyLock = LazyLock::new(|| BuiltinTabl ontology: Some(Ontology { entity_name: "kafka_sink", description: "Kafka-specific sink configuration (topic)", - links: &const { [OntologyLink { - name: "details_of", - target: "sink", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "details_of", + target: "sink", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); pub static MZ_KAFKA_CONNECTIONS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2452,11 +2456,13 @@ pub static MZ_KAFKA_CONNECTIONS: LazyLock = LazyLock::new(|| Built ontology: Some(Ontology { entity_name: "kafka_connection", description: "Kafka-specific connection configuration (brokers, progress topic)", - links: &const { [OntologyLink { - name: "details_of", - target: "connection", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "details_of", + target: "connection", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); pub static MZ_KAFKA_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2491,11 +2497,13 @@ pub static MZ_KAFKA_SOURCES: LazyLock = LazyLock::new(|| BuiltinTa ontology: Some(Ontology { entity_name: "kafka_source", description: "Kafka-specific source configuration (topic, group ID)", - links: &const { [OntologyLink { - name: "details_of", - target: "source", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "details_of", + target: "source", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2530,11 +2538,13 @@ pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| Builti ontology: Some(Ontology { entity_name: "postgres_source", description: "Postgres source-level details", - links: &const { [OntologyLink { - name: "details_of", - target: "source", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "details_of", + target: "source", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2569,11 +2579,13 @@ pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| ontology: Some(Ontology { entity_name: "postgres_source_table", description: "Postgres source table-level details", - links: &const { [OntologyLink { - name: "describes_source_table", - target: "table", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "describes_source_table", + target: "table", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2608,11 +2620,13 @@ pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui ontology: Some(Ontology { entity_name: "mysql_source_table", description: "MySQL source table-level details", - links: &const { [OntologyLink { - name: "describes_source_table", - target: "table", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "describes_source_table", + target: "table", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2647,11 +2661,13 @@ pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(| ontology: Some(Ontology { entity_name: "sql_server_source_table", description: "SQL Server source table-level details", - links: &const { [OntologyLink { - name: "describes_source_table", - target: "table", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "describes_source_table", + target: "table", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2693,11 +2709,13 @@ pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui ontology: Some(Ontology { entity_name: "kafka_source_table", description: "Kafka source table-level details", - links: &const { [OntologyLink { - name: "describes_source_table", - target: "table", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "describes_source_table", + target: "table", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2731,18 +2749,30 @@ pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| Bui ontology: Some(Ontology { entity_name: "object_dependency", description: "A dependency edge: one object depends on another", - links: &const { [ - OntologyLink { - name: "dependent_object", - target: "object", - properties: LinkProperties::fk_typed("object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), - }, - OntologyLink { - name: "referenced_object", - target: "object", - properties: LinkProperties::fk_typed("referenced_object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "dependent_object", + target: "object", + properties: LinkProperties::fk_typed( + "object_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::CatalogItemId, + ), + }, + OntologyLink { + name: "referenced_object", + target: "object", + properties: LinkProperties::fk_typed( + "referenced_object_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::CatalogItemId, + ), + }, + ] + }, }), }); pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| BuiltinSource { @@ -2777,23 +2807,37 @@ pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| B ontology: Some(Ontology { entity_name: "compute_dependency", description: "Dependency edge from a compute object (index, materialized view, or subscription) to one of the sources of its data", - links: &const { [ - OntologyLink { - name: "dependent_compute_object", - target: "object", - properties: LinkProperties::fk_mapped("object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), - }, - OntologyLink { - name: "compute_dependency_target", - target: "object", - properties: LinkProperties::fk_mapped("dependency_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "dependent_compute_object", + target: "object", + properties: LinkProperties::fk_mapped( + "object_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::GlobalId, + "mz_internal.mz_object_global_ids", + ), + }, + OntologyLink { + name: "compute_dependency_target", + target: "object", + properties: LinkProperties::fk_mapped( + "dependency_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::GlobalId, + "mz_internal.mz_object_global_ids", + ), + }, + ] + }, }), }); -pub static MZ_DATABASES: LazyLock = LazyLock::new(|| { - BuiltinMaterializedView { +pub static MZ_DATABASES: LazyLock = + LazyLock::new(|| BuiltinMaterializedView { name: "mz_databases", schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_DATABASES_OID, @@ -2849,17 +2893,18 @@ WHERE data->>'kind' = 'Database'", ontology: Some(Ontology { entity_name: "database", description: "A top-level namespace that contains schemas", - links: &const { [OntologyLink { - name: "owned_by", - target: "role", - properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "owned_by", + target: "role", + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }] + }, }), - } -}); + }); -pub static MZ_SCHEMAS: LazyLock = LazyLock::new(|| { - BuiltinMaterializedView { +pub static MZ_SCHEMAS: LazyLock = + LazyLock::new(|| BuiltinMaterializedView { name: "mz_schemas", schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_SCHEMAS_OID, @@ -2927,21 +2972,26 @@ WHERE data->>'kind' = 'Schema'", ontology: Some(Ontology { entity_name: "schema", description: "A namespace within a database that contains objects", - links: &const { [ - OntologyLink { - name: "in_database", - target: "database", - properties: LinkProperties::fk_nullable("database_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "owned_by", - target: "role", - properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "in_database", + target: "database", + properties: LinkProperties::fk_nullable( + "database_id", + "id", + Cardinality::ManyToOne, + ), + }, + OntologyLink { + name: "owned_by", + target: "role", + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }, + ] + }, }), - } -}); + }); pub static MZ_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_columns", @@ -2989,19 +3039,21 @@ pub static MZ_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "column", description: "A column of a relation, with its name, position, type, and nullability", - links: &const { [OntologyLink { - name: "belongs_to_relation", - target: "object", - properties: LinkProperties::ForeignKey { - source_column: "id", - target_column: "id", - cardinality: Cardinality::ManyToOne, - source_id_type: None, - requires_mapping: None, - nullable: false, - note: Some("id in mz_columns is the relation ID, not a unique column ID"), - }, - }] }, + links: &const { + [OntologyLink { + name: "belongs_to_relation", + target: "object", + properties: LinkProperties::ForeignKey { + source_column: "id", + target_column: "id", + cardinality: Cardinality::ManyToOne, + source_id_type: None, + requires_mapping: None, + nullable: false, + note: Some("id in mz_columns is the relation ID, not a unique column ID"), + }, + }] + }, }), }); pub static MZ_INDEXES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3071,23 +3123,25 @@ pub static MZ_INDEXES: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "index", description: "An in-memory index on a relation for fast lookups", - links: &const { [ - OntologyLink { - name: "owned_by", - target: "role", - properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "runs_on_cluster", - target: "cluster", - properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "indexes_relation", - target: "relation", - properties: LinkProperties::fk("on_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "owned_by", + target: "role", + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "runs_on_cluster", + target: "cluster", + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "indexes_relation", + target: "relation", + properties: LinkProperties::fk("on_id", "id", Cardinality::ManyToOne), + }, + ] + }, }), }); pub static MZ_INDEX_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3132,11 +3186,13 @@ pub static MZ_INDEX_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTa ontology: Some(Ontology { entity_name: "index_column", description: "A column or expression in an index, with its position", - links: &const { [OntologyLink { - name: "belongs_to_index", - target: "index", - properties: LinkProperties::fk("index_id", "id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "belongs_to_index", + target: "index", + properties: LinkProperties::fk("index_id", "id", Cardinality::ManyToOne), + }] + }, }), }); pub static MZ_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3211,23 +3267,29 @@ pub static MZ_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "table", description: "A user-writable table that can be inserted into and updated", - links: &const { [ - OntologyLink { - name: "in_schema", - target: "schema", - properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "owned_by", - target: "role", - properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "created_by_source", - target: "source", - properties: LinkProperties::fk_nullable("source_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "in_schema", + target: "schema", + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "owned_by", + target: "role", + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "created_by_source", + target: "source", + properties: LinkProperties::fk_nullable( + "source_id", + "id", + Cardinality::ManyToOne, + ), + }, + ] + }, }), }); @@ -3355,11 +3417,13 @@ pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock = LazyLock::new(|| ontology: Some(Ontology { entity_name: "ssh_tunnel_connection", description: "SSH tunnel connection with public keys", - links: &const { [OntologyLink { - name: "details_of", - target: "connection", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "details_of", + target: "connection", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); pub static MZ_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3469,28 +3533,38 @@ pub static MZ_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "source", description: "An external data source ingested into Materialize (e.g., Kafka, Postgres)", - links: &const { [ - OntologyLink { - name: "in_schema", - target: "schema", - properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "owned_by", - target: "role", - properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "runs_on_cluster", - target: "cluster", - properties: LinkProperties::fk_nullable("cluster_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "uses_connection", - target: "connection", - properties: LinkProperties::fk_nullable("connection_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "in_schema", + target: "schema", + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "owned_by", + target: "role", + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "runs_on_cluster", + target: "cluster", + properties: LinkProperties::fk_nullable( + "cluster_id", + "id", + Cardinality::ManyToOne, + ), + }, + OntologyLink { + name: "uses_connection", + target: "connection", + properties: LinkProperties::fk_nullable( + "connection_id", + "id", + Cardinality::ManyToOne, + ), + }, + ] + }, }), }); pub static MZ_SINKS: LazyLock = LazyLock::new(|| { @@ -3596,28 +3670,34 @@ pub static MZ_SINKS: LazyLock = LazyLock::new(|| { ontology: Some(Ontology { entity_name: "sink", description: "An export of data from Materialize to an external system", - links: &const { [ - OntologyLink { - name: "in_schema", - target: "schema", - properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "owned_by", - target: "role", - properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "runs_on_cluster", - target: "cluster", - properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "uses_connection", - target: "connection", - properties: LinkProperties::fk_nullable("connection_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "in_schema", + target: "schema", + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "owned_by", + target: "role", + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "runs_on_cluster", + target: "cluster", + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "uses_connection", + target: "connection", + properties: LinkProperties::fk_nullable( + "connection_id", + "id", + Cardinality::ManyToOne, + ), + }, + ] + }, }), } }); @@ -3690,18 +3770,20 @@ pub static MZ_VIEWS: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "view", description: "A non-materialized view defined by a SQL query", - links: &const { [ - OntologyLink { - name: "in_schema", - target: "schema", - properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "owned_by", - target: "role", - properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "in_schema", + target: "schema", + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "owned_by", + target: "role", + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }, + ] + }, }), }); @@ -3953,18 +4035,20 @@ pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "type", description: "A named data type (base, array, list, map, or pseudo)", - links: &const { [ - OntologyLink { - name: "in_schema", - target: "schema", - properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "owned_by", - target: "role", - properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "in_schema", + target: "schema", + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "owned_by", + target: "role", + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }, + ] + }, }), }); @@ -4028,11 +4112,13 @@ WHERE data->>'kind' = 'NetworkPolicy'", ontology: Some(Ontology { entity_name: "network_policy", description: "Network access policies", - links: &const { [OntologyLink { - name: "owned_by", - target: "role", - properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "owned_by", + target: "role", + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }] + }, }), } }); @@ -4092,11 +4178,13 @@ WHERE data->>'kind' = 'NetworkPolicy'", ontology: Some(Ontology { entity_name: "network_policy_rule", description: "Individual rules within a network policy", - links: &const { [OntologyLink { - name: "belongs_to_policy", - target: "network_policy", - properties: LinkProperties::fk("policy_id", "id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "belongs_to_policy", + target: "network_policy", + properties: LinkProperties::fk("policy_id", "id", Cardinality::ManyToOne), + }] + }, }), } }); @@ -4154,18 +4242,20 @@ pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| BuiltinTabl ontology: Some(Ontology { entity_name: "array_type", description: "An array type with its element type", - links: &const { [ - OntologyLink { - name: "detail_of", - target: "type", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }, - OntologyLink { - name: "has_element_type", - target: "type", - properties: LinkProperties::fk("element_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "detail_of", + target: "type", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }, + OntologyLink { + name: "has_element_type", + target: "type", + properties: LinkProperties::fk("element_id", "id", Cardinality::ManyToOne), + }, + ] + }, }), }); pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4225,18 +4315,20 @@ pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable ontology: Some(Ontology { entity_name: "list_type", description: "A list type with its element type", - links: &const { [ - OntologyLink { - name: "detail_of", - target: "type", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }, - OntologyLink { - name: "has_element_type", - target: "type", - properties: LinkProperties::fk("element_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "detail_of", + target: "type", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }, + OntologyLink { + name: "has_element_type", + target: "type", + properties: LinkProperties::fk("element_id", "id", Cardinality::ManyToOne), + }, + ] + }, }), }); pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4294,23 +4386,25 @@ pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable ontology: Some(Ontology { entity_name: "map_type", description: "A map type with its key and value types", - links: &const { [ - OntologyLink { - name: "detail_of", - target: "type", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }, - OntologyLink { - name: "has_key_type", - target: "type", - properties: LinkProperties::fk("key_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "has_value_type", - target: "type", - properties: LinkProperties::fk("value_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "detail_of", + target: "type", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }, + OntologyLink { + name: "has_key_type", + target: "type", + properties: LinkProperties::fk("key_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "has_value_type", + target: "type", + properties: LinkProperties::fk("value_id", "id", Cardinality::ManyToOne), + }, + ] + }, }), }); pub static MZ_ROLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4407,23 +4501,25 @@ WHERE data->>'kind' = 'Role'", ontology: Some(Ontology { entity_name: "role_membership", description: "A membership grant: one role is a member of another role", - links: &const { [ - OntologyLink { - name: "group_role", - target: "role", - properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "member_role", - target: "role", - properties: LinkProperties::fk("member", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "granted_by", - target: "role", - properties: LinkProperties::fk("grantor", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "group_role", + target: "role", + properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "member_role", + target: "role", + properties: LinkProperties::fk("member", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "granted_by", + target: "role", + properties: LinkProperties::fk("grantor", "id", Cardinality::ManyToOne), + }, + ] + }, }), } }); @@ -4460,11 +4556,13 @@ pub static MZ_ROLE_PARAMETERS: LazyLock = LazyLock::new(|| Builtin ontology: Some(Ontology { entity_name: "role_parameter", description: "A session parameter default set for a role", - links: &const { [OntologyLink { - name: "default_parameter_setting_of", - target: "role", - properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "default_parameter_setting_of", + target: "role", + properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne), + }] + }, }), }); pub static MZ_ROLE_AUTH: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4600,28 +4698,38 @@ pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { ontology: Some(Ontology { entity_name: "function", description: "A built-in or user-defined function", - links: &const { [ - OntologyLink { - name: "in_schema", - target: "schema", - properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "owned_by", - target: "role", - properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "returns_type", - target: "type", - properties: LinkProperties::fk_nullable("return_type_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "has_variadic_arg_type", - target: "type", - properties: LinkProperties::fk_nullable("variadic_argument_type_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "in_schema", + target: "schema", + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "owned_by", + target: "role", + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "returns_type", + target: "type", + properties: LinkProperties::fk_nullable( + "return_type_id", + "id", + Cardinality::ManyToOne, + ), + }, + OntologyLink { + name: "has_variadic_arg_type", + target: "type", + properties: LinkProperties::fk_nullable( + "variadic_argument_type_id", + "id", + Cardinality::ManyToOne, + ), + }, + ] + }, }), } }); @@ -4648,11 +4756,17 @@ pub static MZ_OPERATORS: LazyLock = LazyLock::new(|| BuiltinTable ontology: Some(Ontology { entity_name: "operator", description: "A built-in SQL operator", - links: &const { [OntologyLink { - name: "returns_type", - target: "type", - properties: LinkProperties::fk_nullable("return_type_id", "id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "returns_type", + target: "type", + properties: LinkProperties::fk_nullable( + "return_type_id", + "id", + Cardinality::ManyToOne, + ), + }] + }, }), }); pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4758,18 +4872,20 @@ pub static MZ_CLUSTERS: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "cluster", description: "A compute cluster that runs dataflows for sources, sinks, MVs, and indexes", - links: &const { [ - OntologyLink { - name: "owned_by", - target: "role", - properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "has_size", - target: "replica_size", - properties: LinkProperties::fk_nullable("size", "size", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "owned_by", + target: "role", + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "has_size", + target: "replica_size", + properties: LinkProperties::fk_nullable("size", "size", Cardinality::ManyToOne), + }, + ] + }, }), }); @@ -4846,11 +4962,13 @@ pub static MZ_CLUSTER_SCHEDULES: LazyLock = LazyLock::new(|| Built ontology: Some(Ontology { entity_name: "cluster_schedule", description: "Cluster scheduling configuration", - links: &const { [OntologyLink { - name: "belongs_to_cluster", - target: "cluster", - properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "belongs_to_cluster", + target: "cluster", + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), + }] + }, }), }); @@ -4979,23 +5097,25 @@ pub static MZ_CLUSTER_REPLICAS: LazyLock = LazyLock::new(|| Builti ontology: Some(Ontology { entity_name: "replica", description: "A physical replica of a cluster providing fault tolerance", - links: &const { [ - OntologyLink { - name: "owned_by", - target: "role", - properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "belongs_to_cluster", - target: "cluster", - properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "has_size", - target: "replica_size", - properties: LinkProperties::fk_nullable("size", "size", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "owned_by", + target: "role", + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "belongs_to_cluster", + target: "cluster", + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "has_size", + target: "replica_size", + properties: LinkProperties::fk_nullable("size", "size", Cardinality::ManyToOne), + }, + ] + }, }), }); @@ -5087,11 +5207,18 @@ pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY: LazyLock = LazyLock ontology: Some(Ontology { entity_name: "replica_status_event", description: "Historical replica status events (ready, not-ready, etc.)", - links: &const { [OntologyLink { - name: "status_event_of_replica", - target: "replica", - properties: LinkProperties::fk_typed("replica_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), - }] }, + links: &const { + [OntologyLink { + name: "status_event_of_replica", + target: "replica", + properties: LinkProperties::fk_typed( + "replica_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::CatalogItemId, + ), + }] + }, }), } }); @@ -5153,11 +5280,18 @@ ORDER BY replica_id, process_id, occurred_at DESC", ontology: Some(Ontology { entity_name: "replica_status", description: "Current status of each replica", - links: &const { [OntologyLink { - name: "status_of_replica", - target: "replica", - properties: LinkProperties::fk_typed("replica_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::ReplicaId), - }] }, + links: &const { + [OntologyLink { + name: "status_of_replica", + target: "replica", + properties: LinkProperties::fk_typed( + "replica_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::ReplicaId, + ), + }] + }, }), }); @@ -5309,18 +5443,30 @@ pub static MZ_SOURCE_STATUS_HISTORY: LazyLock = LazyLock::new(|| ontology: Some(Ontology { entity_name: "source_status_event", description: "Historical source status events", - links: &const { [ - OntologyLink { - name: "status_event_of_source", - target: "source", - properties: LinkProperties::fk_mapped("source_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), - }, - OntologyLink { - name: "on_replica", - target: "replica", - properties: LinkProperties::fk_nullable("replica_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "status_event_of_source", + target: "source", + properties: LinkProperties::fk_mapped( + "source_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::GlobalId, + "mz_internal.mz_object_global_ids", + ), + }, + OntologyLink { + name: "on_replica", + target: "replica", + properties: LinkProperties::fk_nullable( + "replica_id", + "id", + Cardinality::ManyToOne, + ), + }, + ] + }, }), }); @@ -5413,11 +5559,13 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUSES: LazyLock = LazyL ontology: Some(Ontology { entity_name: "privatelink_status", description: "PrivateLink connection health status", - links: &const { [OntologyLink { - name: "status_of", - target: "connection", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "status_of", + target: "connection", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), } }); @@ -5613,11 +5761,13 @@ pub static MZ_SESSION_HISTORY: LazyLock = LazyLock::new(|| Builti ontology: Some(Ontology { entity_name: "session", description: "Historical session connection events", - links: &const { [OntologyLink { - name: "active_as", - target: "active_session", - properties: LinkProperties::fk_nullable("session_id", "id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "active_as", + target: "active_session", + properties: LinkProperties::fk_nullable("session_id", "id", Cardinality::ManyToOne), + }] + }, }), }); @@ -5943,36 +6093,46 @@ WHERE mralt.sql_hash = mrst.sql_hash", ontology: Some(Ontology { entity_name: "activity_log", description: "Recent query activity with execution stats", - links: &const { [ - OntologyLink { - name: "in_session", - target: "session", - properties: LinkProperties::fk("session_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "in_active_session", - target: "active_session", - properties: LinkProperties::fk_nullable("session_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "ran_on_cluster", - target: "cluster", - properties: LinkProperties::fk_nullable("cluster_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "used_transient_index", - target: "object", - properties: LinkProperties::ForeignKey { - source_column: "transient_index_id", - target_column: "id", - cardinality: Cardinality::ManyToOne, - source_id_type: Some(mz_repr::SemanticType::GlobalId), - requires_mapping: Some("mz_internal.mz_object_global_ids"), - nullable: true, - note: None, + links: &const { + [ + OntologyLink { + name: "in_session", + target: "session", + properties: LinkProperties::fk("session_id", "id", Cardinality::ManyToOne), }, - }, - ] }, + OntologyLink { + name: "in_active_session", + target: "active_session", + properties: LinkProperties::fk_nullable( + "session_id", + "id", + Cardinality::ManyToOne, + ), + }, + OntologyLink { + name: "ran_on_cluster", + target: "cluster", + properties: LinkProperties::fk_nullable( + "cluster_id", + "id", + Cardinality::ManyToOne, + ), + }, + OntologyLink { + name: "used_transient_index", + target: "object", + properties: LinkProperties::ForeignKey { + source_column: "transient_index_id", + target_column: "id", + cardinality: Cardinality::ManyToOne, + source_id_type: Some(mz_repr::SemanticType::GlobalId), + requires_mapping: Some("mz_internal.mz_object_global_ids"), + nullable: true, + note: None, + }, + }, + ] + }, }), }); @@ -6067,11 +6227,17 @@ pub static MZ_STATEMENT_LIFECYCLE_HISTORY: LazyLock = LazyLock::n ontology: Some(Ontology { entity_name: "statement_lifecycle_event", description: "Statement lifecycle events (parse, bind, execute)", - links: &const { [OntologyLink { - name: "for_execution", - target: "activity_log", - properties: LinkProperties::fk("statement_id", "execution_id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "for_execution", + target: "activity_log", + properties: LinkProperties::fk( + "statement_id", + "execution_id", + Cardinality::ManyToOne, + ), + }] + }, }), } }); @@ -6267,11 +6433,13 @@ WHERE id NOT LIKE 's%';", ontology: Some(Ontology { entity_name: "source_status", description: "Current source status (running, stalled, etc.)", - links: &const { [OntologyLink { - name: "status_of_source", - target: "source", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "status_of_source", + target: "source", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); @@ -6312,18 +6480,30 @@ pub static MZ_SINK_STATUS_HISTORY: LazyLock = LazyLock::new(|| Bu ontology: Some(Ontology { entity_name: "sink_status_event", description: "Historical sink status events", - links: &const { [ - OntologyLink { - name: "status_event_of_sink", - target: "sink", - properties: LinkProperties::fk_mapped("sink_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), - }, - OntologyLink { - name: "on_replica", - target: "replica", - properties: LinkProperties::fk_nullable("replica_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "status_event_of_sink", + target: "sink", + properties: LinkProperties::fk_mapped( + "sink_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::GlobalId, + "mz_internal.mz_object_global_ids", + ), + }, + OntologyLink { + name: "on_replica", + target: "replica", + properties: LinkProperties::fk_nullable( + "replica_id", + "id", + Cardinality::ManyToOne, + ), + }, + ] + }, }), }); @@ -6438,11 +6618,18 @@ WHERE ontology: Some(Ontology { entity_name: "sink_status", description: "Current sink status", - links: &const { [OntologyLink { - name: "status_of_sink", - target: "sink", - properties: LinkProperties::fk_typed("id", "id", Cardinality::OneToOne, mz_repr::SemanticType::CatalogItemId), - }] }, + links: &const { + [OntologyLink { + name: "status_of_sink", + target: "sink", + properties: LinkProperties::fk_typed( + "id", + "id", + Cardinality::OneToOne, + mz_repr::SemanticType::CatalogItemId, + ), + }] + }, }), }); @@ -6511,8 +6698,8 @@ pub static MZ_EGRESS_IPS: LazyLock = LazyLock::new(|| BuiltinTable }), }); -pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock = LazyLock::new(|| { - BuiltinTable { +pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock = + LazyLock::new(|| BuiltinTable { name: "mz_aws_privatelink_connections", schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_AWS_PRIVATELINK_CONNECTIONS_OID, @@ -6536,14 +6723,15 @@ pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock = LazyLock::ne ontology: Some(Ontology { entity_name: "aws_privatelink_connection", description: "AWS PrivateLink connection configuration", - links: &const { [OntologyLink { - name: "details_of", - target: "connection", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "details_of", + target: "connection", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), - } -}); + }); pub static MZ_AWS_CONNECTIONS: LazyLock = LazyLock::new(|| BuiltinTable { name: "mz_aws_connections", @@ -6626,11 +6814,13 @@ pub static MZ_AWS_CONNECTIONS: LazyLock = LazyLock::new(|| Builtin ontology: Some(Ontology { entity_name: "aws_connection", description: "AWS connection configuration details", - links: &const { [OntologyLink { - name: "details_of", - target: "connection", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "details_of", + target: "connection", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); @@ -6731,11 +6921,18 @@ ORDER BY replica_id, process_id, occurred_at DESC", ontology: Some(Ontology { entity_name: "replica_metrics", description: "CPU and memory metrics per replica", - links: &const { [OntologyLink { - name: "metrics_of_replica", - target: "replica", - properties: LinkProperties::fk_typed("replica_id", "id", Cardinality::OneToOne, mz_repr::SemanticType::CatalogItemId), - }] }, + links: &const { + [OntologyLink { + name: "metrics_of_replica", + target: "replica", + properties: LinkProperties::fk_typed( + "replica_id", + "id", + Cardinality::OneToOne, + mz_repr::SemanticType::CatalogItemId, + ), + }] + }, }), }); @@ -6828,11 +7025,19 @@ pub static MZ_FRONTIERS: LazyLock = LazyLock::new(|| BuiltinSourc ontology: Some(Ontology { entity_name: "frontier", description: "Current read/write frontiers for sources, sinks, tables, materialized views, indexes, and subscriptions", - links: &const { [OntologyLink { - name: "frontier_of", - target: "object", - properties: LinkProperties::fk_mapped("object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), - }] }, + links: &const { + [OntologyLink { + name: "frontier_of", + target: "object", + properties: LinkProperties::fk_mapped( + "object_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::GlobalId, + "mz_internal.mz_object_global_ids", + ), + }] + }, }), }); @@ -6891,18 +7096,30 @@ pub static MZ_WALLCLOCK_LAG_HISTORY: LazyLock = LazyLock::new(|| ontology: Some(Ontology { entity_name: "wallclock_lag_event", description: "Historical wallclock lag per object", - links: &const { [ - OntologyLink { - name: "measures_lag_of", - target: "object", - properties: LinkProperties::measures_mapped("object_id", "id", "wallclock_lag", mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), - }, - OntologyLink { - name: "on_replica", - target: "replica", - properties: LinkProperties::fk_nullable("replica_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "measures_lag_of", + target: "object", + properties: LinkProperties::measures_mapped( + "object_id", + "id", + "wallclock_lag", + mz_repr::SemanticType::GlobalId, + "mz_internal.mz_object_global_ids", + ), + }, + OntologyLink { + name: "on_replica", + target: "replica", + properties: LinkProperties::fk_nullable( + "replica_id", + "id", + Cardinality::ManyToOne, + ), + }, + ] + }, }), }); @@ -6957,11 +7174,13 @@ OPTIONS (AGGREGATE INPUT GROUP SIZE = 1)", ontology: Some(Ontology { entity_name: "wallclock_global_lag_event", description: "Historical global wallclock lag", - links: &const { [OntologyLink { - name: "lag_of", - target: "object_global_id", - properties: LinkProperties::fk("object_id", "global_id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "lag_of", + target: "object_global_id", + properties: LinkProperties::fk("object_id", "global_id", Cardinality::ManyToOne), + }] + }, }), }); @@ -7038,11 +7257,19 @@ ORDER BY object_id, occurred_at DESC", ontology: Some(Ontology { entity_name: "wallclock_global_lag", description: "Current wallclock lag aggregated across replicas", - links: &const { [OntologyLink { - name: "measures_global_lag_of", - target: "object", - properties: LinkProperties::measures_mapped("object_id", "id", "wallclock_lag_global", mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), - }] }, + links: &const { + [OntologyLink { + name: "measures_global_lag_of", + target: "object", + properties: LinkProperties::measures_mapped( + "object_id", + "id", + "wallclock_lag_global", + mz_repr::SemanticType::GlobalId, + "mz_internal.mz_object_global_ids", + ), + }] + }, }), }); @@ -7180,23 +7407,29 @@ pub static MZ_SUBSCRIPTIONS: LazyLock = LazyLock::new(|| BuiltinTa ontology: Some(Ontology { entity_name: "subscription", description: "Active SUBSCRIBE operations", - links: &const { [ - OntologyLink { - name: "uses_session", - target: "session", - properties: LinkProperties::fk("session_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "in_active_session", - target: "active_session", - properties: LinkProperties::fk_nullable("session_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "belongs_to_cluster", - target: "cluster", - properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "uses_session", + target: "session", + properties: LinkProperties::fk("session_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "in_active_session", + target: "active_session", + properties: LinkProperties::fk_nullable( + "session_id", + "id", + Cardinality::ManyToOne, + ), + }, + OntologyLink { + name: "belongs_to_cluster", + target: "cluster", + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), + }, + ] + }, }), }); @@ -7242,11 +7475,13 @@ pub static MZ_SESSIONS: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "active_session", description: "Currently active sessions", - links: &const { [OntologyLink { - name: "logged_in_as", - target: "role", - properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "logged_in_as", + target: "role", + properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne), + }] + }, }), }); @@ -7310,28 +7545,38 @@ pub static MZ_DEFAULT_PRIVILEGES: LazyLock = LazyLock::new(|| Buil ontology: Some(Ontology { entity_name: "default_privilege", description: "A default privilege rule applied to newly created objects", - links: &const { [ - OntologyLink { - name: "default_priv_for_role", - target: "role", - properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "default_priv_in_database", - target: "database", - properties: LinkProperties::fk_nullable("database_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "default_priv_in_schema", - target: "schema", - properties: LinkProperties::fk_nullable("schema_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "default_priv_granted_to", - target: "role", - properties: LinkProperties::fk("grantee", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "default_priv_for_role", + target: "role", + properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "default_priv_in_database", + target: "database", + properties: LinkProperties::fk_nullable( + "database_id", + "id", + Cardinality::ManyToOne, + ), + }, + OntologyLink { + name: "default_priv_in_schema", + target: "schema", + properties: LinkProperties::fk_nullable( + "schema_id", + "id", + Cardinality::ManyToOne, + ), + }, + OntologyLink { + name: "default_priv_granted_to", + target: "role", + properties: LinkProperties::fk("grantee", "id", Cardinality::ManyToOne), + }, + ] + }, }), }); @@ -7393,11 +7638,18 @@ pub static MZ_COMMENTS: LazyLock = LazyLock::new(|| BuiltinTable { ontology: Some(Ontology { entity_name: "comment", description: "A COMMENT ON annotation for a catalog object or column", - links: &const { [OntologyLink { - name: "comment_on", - target: "object", - properties: LinkProperties::fk_typed("id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), - }] }, + links: &const { + [OntologyLink { + name: "comment_on", + target: "object", + properties: LinkProperties::fk_typed( + "id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::CatalogItemId, + ), + }] + }, }), }); @@ -7428,11 +7680,13 @@ pub static MZ_SOURCE_REFERENCES: LazyLock = LazyLock::new(|| Built ontology: Some(Ontology { entity_name: "source_reference", description: "External references tracked by sources", - links: &const { [OntologyLink { - name: "references_source", - target: "source", - properties: LinkProperties::fk("source_id", "id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "references_source", + target: "source", + properties: LinkProperties::fk("source_id", "id", Cardinality::ManyToOne), + }] + }, }), }); @@ -7465,11 +7719,13 @@ pub static MZ_WEBHOOKS_SOURCES: LazyLock = LazyLock::new(|| Builti ontology: Some(Ontology { entity_name: "webhook_source", description: "Webhook source configuration", - links: &const { [OntologyLink { - name: "details_of", - target: "source", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "details_of", + target: "source", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); @@ -7584,18 +7840,20 @@ pub static MZ_REPLACEMENTS: LazyLock = LazyLock::new(|| BuiltinTab ontology: Some(Ontology { entity_name: "replacement", description: "A record of an object replacement (ALTER ... SWAP)", - links: &const { [ - OntologyLink { - name: "replacement_object", - target: "object", - properties: LinkProperties::fk("id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "replacement_target", - target: "object", - properties: LinkProperties::fk("target_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "replacement_object", + target: "object", + properties: LinkProperties::fk("id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "replacement_target", + target: "object", + properties: LinkProperties::fk("target_id", "id", Cardinality::ManyToOne), + }, + ] + }, }), }); @@ -7647,11 +7905,19 @@ pub static MZ_STORAGE_SHARDS: LazyLock = LazyLock::new(|| Builtin ontology: Some(Ontology { entity_name: "storage_shard", description: "Persist shards used by storage objects", - links: &const { [OntologyLink { - name: "shard_of", - target: "object", - properties: LinkProperties::fk_mapped("object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), - }] }, + links: &const { + [OntologyLink { + name: "shard_of", + target: "object", + properties: LinkProperties::fk_mapped( + "object_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::GlobalId, + "mz_internal.mz_object_global_ids", + ), + }] + }, }), }); @@ -7704,11 +7970,13 @@ GROUP BY object_id, collection_timestamp", ontology: Some(Ontology { entity_name: "storage_usage", description: "Historical storage usage per object over time", - links: &const { [OntologyLink { - name: "storage_usage_of", - target: "object", - properties: LinkProperties::fk("object_id", "id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "storage_usage_of", + target: "object", + properties: LinkProperties::fk("object_id", "id", Cardinality::ManyToOne), + }] + }, }), }); @@ -8019,28 +8287,30 @@ pub static MZ_OBJECT_FULLY_QUALIFIED_NAMES: LazyLock = LazyLock::ne ontology: Some(Ontology { entity_name: "object_fqn", description: "Fully qualified name (database.schema.name) for objects", - links: &const { [ - OntologyLink { - name: "details_of", - target: "object", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }, - OntologyLink { - name: "in_schema", - target: "schema", - properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "in_database", - target: "database", - properties: LinkProperties::fk("database_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "belongs_to_cluster", - target: "cluster", - properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "details_of", + target: "object", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }, + OntologyLink { + name: "in_schema", + target: "schema", + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "in_database", + target: "database", + properties: LinkProperties::fk("database_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "belongs_to_cluster", + target: "cluster", + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), + }, + ] + }, }), }); @@ -8068,18 +8338,20 @@ pub static MZ_OBJECT_GLOBAL_IDS: LazyLock = LazyLock::new(|| Built ontology: Some(Ontology { entity_name: "object_global_id", description: "Mapping between CatalogItemId (SQL layer) and GlobalId (runtime layer)", - links: &const { [OntologyLink { - name: "has_global_id", - target: "object", - properties: LinkProperties::MapsTo { - source_column: Some("id"), - target_column: Some("id"), - via: None, - from_type: Some(mz_repr::SemanticType::CatalogItemId), - to_type: Some(mz_repr::SemanticType::GlobalId), - note: None, - }, - }] }, + links: &const { + [OntologyLink { + name: "has_global_id", + target: "object", + properties: LinkProperties::MapsTo { + source_column: Some("id"), + target_column: Some("id"), + via: None, + from_type: Some(mz_repr::SemanticType::CatalogItemId), + to_type: Some(mz_repr::SemanticType::GlobalId), + note: None, + }, + }] + }, }), }); @@ -8138,11 +8410,18 @@ pub static MZ_OBJECT_LIFETIMES: LazyLock = LazyLock::new(|| Builtin ontology: Some(Ontology { entity_name: "object_lifetime_event", description: "Create or drop lifecycle event for a catalog object", - links: &const { [OntologyLink { - name: "lifetime_event_of", - target: "object", - properties: LinkProperties::fk_typed("id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), - }] }, + links: &const { + [OntologyLink { + name: "lifetime_event_of", + target: "object", + properties: LinkProperties::fk_typed( + "id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::CatalogItemId, + ), + }] + }, }), }); @@ -8236,11 +8515,13 @@ pub static MZ_OBJECT_HISTORY: LazyLock = LazyLock::new(|| BuiltinVi ontology: Some(Ontology { entity_name: "object_history", description: "Historical record of object creation and drops", - links: &const { [OntologyLink { - name: "history_of", - target: "object", - properties: LinkProperties::fk("id", "id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "history_of", + target: "object", + properties: LinkProperties::fk("id", "id", Cardinality::ManyToOne), + }] + }, }), }); @@ -8327,11 +8608,13 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "dataflow_address", description: "Address (scope path) of dataflow operators", - links: &const { [OntologyLink { - name: "address_of_operator", - target: "dataflow_operator", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "address_of_operator", + target: "dataflow_operator", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); @@ -8370,18 +8653,22 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "dataflow_channel", description: "Communication channels between operators", - links: &const { [OntologyLink { - name: "channel_in_dataflow", - target: "dataflow", - properties: LinkProperties::MapsTo { - source_column: None, - target_column: None, - via: Some("mz_introspection.mz_dataflow_operator_dataflows"), - from_type: None, - to_type: None, - note: Some("Channels do not have a direct dataflow_id. Use mz_dataflow_addresses to find the parent scope, then correlate with mz_dataflow_operator_dataflows."), - }, - }] }, + links: &const { + [OntologyLink { + name: "channel_in_dataflow", + target: "dataflow", + properties: LinkProperties::MapsTo { + source_column: None, + target_column: None, + via: Some("mz_introspection.mz_dataflow_operator_dataflows"), + from_type: None, + to_type: None, + note: Some( + "Channels do not have a direct dataflow_id. Use mz_dataflow_addresses to find the parent scope, then correlate with mz_dataflow_operator_dataflows.", + ), + }, + }] + }, }), }); @@ -8585,11 +8872,13 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "dataflow_operator_dataflow", description: "Mapping of operators to their parent dataflow", - links: &const { [OntologyLink { - name: "operator_in_dataflow", - target: "dataflow", - properties: LinkProperties::fk("dataflow_id", "id", Cardinality::ManyToOne), - }] }, + links: &const { + [OntologyLink { + name: "operator_in_dataflow", + target: "dataflow", + properties: LinkProperties::fk("dataflow_id", "id", Cardinality::ManyToOne), + }] + }, }), }); @@ -8633,18 +8922,30 @@ SELECT object_id, referenced_object_id FROM reach;", ontology: Some(Ontology { entity_name: "transitive_dependency", description: "Transitive closure of object dependencies — all direct and indirect dependencies", - links: &const { [ - OntologyLink { - name: "transitively_dependent_object", - target: "object", - properties: LinkProperties::fk_typed("object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), - }, - OntologyLink { - name: "transitively_referenced_object", - target: "object", - properties: LinkProperties::fk_typed("referenced_object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "transitively_dependent_object", + target: "object", + properties: LinkProperties::fk_typed( + "object_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::CatalogItemId, + ), + }, + OntologyLink { + name: "transitively_referenced_object", + target: "object", + properties: LinkProperties::fk_typed( + "referenced_object_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::CatalogItemId, + ), + }, + ] + }, }), } }); @@ -8680,25 +8981,35 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "compute_export", description: "Compute exports (maintained collections)", - links: &const { [ - OntologyLink { - name: "export_of", - target: "object", - properties: LinkProperties::fk_mapped("export_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), - }, - OntologyLink { - name: "introspection_uses_global_id", - target: "object_global_id", - properties: LinkProperties::MapsTo { - source_column: None, - target_column: None, - via: None, - from_type: None, - to_type: None, - note: Some("mz_introspection tables use GlobalId. To join with mz_catalog tables (which use CatalogItemId), go through mz_internal.mz_object_global_ids."), + links: &const { + [ + OntologyLink { + name: "export_of", + target: "object", + properties: LinkProperties::fk_mapped( + "export_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::GlobalId, + "mz_internal.mz_object_global_ids", + ), }, - }, - ] }, + OntologyLink { + name: "introspection_uses_global_id", + target: "object_global_id", + properties: LinkProperties::MapsTo { + source_column: None, + target_column: None, + via: None, + from_type: None, + to_type: None, + note: Some( + "mz_introspection tables use GlobalId. To join with mz_catalog tables (which use CatalogItemId), go through mz_internal.mz_object_global_ids.", + ), + }, + }, + ] + }, }), }); @@ -8737,11 +9048,19 @@ GROUP BY export_id", ontology: Some(Ontology { entity_name: "compute_frontier", description: "Per-replica compute frontiers", - links: &const { [OntologyLink { - name: "compute_frontier_of", - target: "object", - properties: LinkProperties::fk_mapped("export_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), - }] }, + links: &const { + [OntologyLink { + name: "compute_frontier_of", + target: "object", + properties: LinkProperties::fk_mapped( + "export_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::GlobalId, + "mz_internal.mz_object_global_ids", + ), + }] + }, }), }); @@ -8915,11 +9234,19 @@ GROUP BY export_id, import_id", ontology: Some(Ontology { entity_name: "compute_import_frontier", description: "Import frontiers for compute dependencies", - links: &const { [OntologyLink { - name: "compute_import_frontier_of", - target: "object", - properties: LinkProperties::fk_mapped("export_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), - }] }, + links: &const { + [OntologyLink { + name: "compute_import_frontier_of", + target: "object", + properties: LinkProperties::fk_mapped( + "export_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::GlobalId, + "mz_internal.mz_object_global_ids", + ), + }] + }, }), }); @@ -9105,11 +9432,13 @@ GROUP BY ontology: Some(Ontology { entity_name: "records_per_dataflow", description: "Record counts aggregated per dataflow", - links: &const { [OntologyLink { - name: "details_of", - target: "dataflow", - properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "details_of", + target: "dataflow", + properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), + }] + }, }), }); @@ -10451,11 +10780,13 @@ GROUP BY id", ontology: Some(Ontology { entity_name: "scheduling_elapsed", description: "CPU time spent per operator", - links: &const { [OntologyLink { - name: "elapsed_for_operator", - target: "dataflow_operator", - properties: LinkProperties::measures("id", "id", "cpu_time_ns"), - }] }, + links: &const { + [OntologyLink { + name: "elapsed_for_operator", + target: "dataflow_operator", + properties: LinkProperties::measures("id", "id", "cpu_time_ns"), + }] + }, }), }); @@ -10676,11 +11007,13 @@ HAVING pg_catalog.sum(count) != 0", ontology: Some(Ontology { entity_name: "compute_error_count", description: "Error counts per compute collection", - links: &const { [OntologyLink { - name: "errors_in", - target: "compute_export", - properties: LinkProperties::fk("export_id", "export_id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "errors_in", + target: "compute_export", + properties: LinkProperties::fk("export_id", "export_id", Cardinality::OneToOne), + }] + }, }), }); @@ -11002,11 +11335,13 @@ GROUP BY channel_id", ontology: Some(Ontology { entity_name: "message_count", description: "Inter-worker message counts", - links: &const { [OntologyLink { - name: "counts_for", - target: "dataflow_channel", - properties: LinkProperties::fk("channel_id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "counts_for", + target: "dataflow_channel", + properties: LinkProperties::fk("channel_id", "id", Cardinality::OneToOne), + }] + }, }), }); @@ -11331,18 +11666,22 @@ GROUP BY operator_id", ontology: Some(Ontology { entity_name: "arrangement_size", description: "Aggregated arrangement sizes (records, batches, bytes)", - links: &const { [OntologyLink { - name: "arrangement_of_operator", - target: "dataflow_operator", - properties: LinkProperties::Measures { - source_column: "operator_id", - target_column: "id", - metric: "arrangement_size", - source_id_type: None, - requires_mapping: None, - note: Some("Both IDs are local uint64 operator IDs within a dataflow, not GlobalIds."), - }, - }] }, + links: &const { + [OntologyLink { + name: "arrangement_of_operator", + target: "dataflow_operator", + properties: LinkProperties::Measures { + source_column: "operator_id", + target_column: "id", + metric: "arrangement_size", + source_id_type: None, + requires_mapping: None, + note: Some( + "Both IDs are local uint64 operator IDs within a dataflow, not GlobalIds.", + ), + }, + }] + }, }), }); @@ -11396,11 +11735,13 @@ WHERE worker_id = 0::uint8", ontology: Some(Ontology { entity_name: "arrangement_sharing", description: "Arrangement sharing between operators", - links: &const { [OntologyLink { - name: "shared_by", - target: "dataflow_operator", - properties: LinkProperties::fk("operator_id", "id", Cardinality::OneToOne), - }] }, + links: &const { + [OntologyLink { + name: "shared_by", + target: "dataflow_operator", + properties: LinkProperties::fk("operator_id", "id", Cardinality::OneToOne), + }] + }, }), }); @@ -11456,11 +11797,18 @@ FROM ontology: Some(Ontology { entity_name: "replica_utilization", description: "Computed utilization metrics per replica", - links: &const { [OntologyLink { - name: "utilization_of_replica", - target: "replica", - properties: LinkProperties::fk_typed("replica_id", "id", Cardinality::OneToOne, mz_repr::SemanticType::CatalogItemId), - }] }, + links: &const { + [OntologyLink { + name: "utilization_of_replica", + target: "replica", + properties: LinkProperties::fk_typed( + "replica_id", + "id", + Cardinality::OneToOne, + mz_repr::SemanticType::CatalogItemId, + ), + }] + }, }), }); @@ -14953,18 +15301,25 @@ SELECT * FROM sinks"#, ontology: Some(Ontology { entity_name: "hydration_status", description: "Overall hydration status per object", - links: &const { [ - OntologyLink { - name: "hydration_of", - target: "object", - properties: LinkProperties::fk_typed("object_id", "id", Cardinality::OneToOne, mz_repr::SemanticType::CatalogItemId), - }, - OntologyLink { - name: "hydration_on_replica", - target: "replica", - properties: LinkProperties::fk("replica_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "hydration_of", + target: "object", + properties: LinkProperties::fk_typed( + "object_id", + "id", + Cardinality::OneToOne, + mz_repr::SemanticType::CatalogItemId, + ), + }, + OntologyLink { + name: "hydration_on_replica", + target: "replica", + properties: LinkProperties::fk("replica_id", "id", Cardinality::ManyToOne), + }, + ] + }, }), }); @@ -15015,22 +15370,24 @@ JOIN mz_catalog.mz_relations r ON (r.id = d.referenced_object_id)", ontology: Some(Ontology { entity_name: "materialization_dep", description: "Dependencies between materializations", - links: &const { [ - OntologyLink { - name: "materialization_depends_on", - target: "object", - properties: LinkProperties::DependsOn { - source_column: "object_id", - target_column: "id", - source_id_type: Some(mz_repr::SemanticType::CatalogItemId), + links: &const { + [ + OntologyLink { + name: "materialization_depends_on", + target: "object", + properties: LinkProperties::DependsOn { + source_column: "object_id", + target_column: "id", + source_id_type: Some(mz_repr::SemanticType::CatalogItemId), + }, }, - }, - OntologyLink { - name: "materialization_dependency", - target: "object", - properties: LinkProperties::fk("dependency_id", "id", Cardinality::ManyToOne), - }, - ] }, + OntologyLink { + name: "materialization_dependency", + target: "object", + properties: LinkProperties::fk("dependency_id", "id", Cardinality::ManyToOne), + }, + ] + }, }), }); @@ -15164,23 +15521,33 @@ JOIN root_times r USING (id)", ontology: Some(Ontology { entity_name: "materialization_lag", description: "Lag between a materialization and its inputs", - links: &const { [ - OntologyLink { - name: "measures_materialization_lag", - target: "object", - properties: LinkProperties::measures("object_id", "id", "materialization_lag"), - }, - OntologyLink { - name: "slowest_local_input", - target: "object", - properties: LinkProperties::fk("slowest_local_input_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "slowest_global_input", - target: "object", - properties: LinkProperties::fk("slowest_global_input_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "measures_materialization_lag", + target: "object", + properties: LinkProperties::measures("object_id", "id", "materialization_lag"), + }, + OntologyLink { + name: "slowest_local_input", + target: "object", + properties: LinkProperties::fk( + "slowest_local_input_id", + "id", + Cardinality::ManyToOne, + ), + }, + OntologyLink { + name: "slowest_global_input", + target: "object", + properties: LinkProperties::fk( + "slowest_global_input_id", + "id", + Cardinality::ManyToOne, + ), + }, + ] + }, }), }); @@ -15586,18 +15953,24 @@ FROM mz_cluster_deployment_lineage"#, ontology: Some(Ontology { entity_name: "cluster_deployment", description: "Cluster deployment lineage information", - links: &const { [ - OntologyLink { - name: "deployment_of", - target: "cluster", - properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "current_deployment", - target: "cluster", - properties: LinkProperties::fk("current_deployment_cluster_id", "id", Cardinality::ManyToOne), - }, - ] }, + links: &const { + [ + OntologyLink { + name: "deployment_of", + target: "cluster", + properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "current_deployment", + target: "cluster", + properties: LinkProperties::fk( + "current_deployment_cluster_id", + "id", + Cardinality::ManyToOne, + ), + }, + ] + }, }), }); @@ -16186,11 +16559,13 @@ pub static MZ_SOURCE_STATISTICS: LazyLock = LazyLock::new(|| { ontology: Some(Ontology { entity_name: "source_statistics", description: "Aggregated source ingestion statistics", - links: &const { [OntologyLink { - name: "statistics_of_source", - target: "source", - properties: LinkProperties::measures("id", "id", "ingestion_statistics"), - }] }, + links: &const { + [OntologyLink { + name: "statistics_of_source", + target: "source", + properties: LinkProperties::measures("id", "id", "ingestion_statistics"), + }] + }, }), } }); @@ -16281,11 +16656,13 @@ GROUP BY id, replica_id", ontology: Some(Ontology { entity_name: "sink_statistics", description: "Aggregated sink export statistics", - links: &const { [OntologyLink { - name: "statistics_of_sink", - target: "sink", - properties: LinkProperties::measures("id", "id", "export_statistics"), - }] }, + links: &const { + [OntologyLink { + name: "statistics_of_sink", + target: "sink", + properties: LinkProperties::measures("id", "id", "export_statistics"), + }] + }, }), }); @@ -17495,7 +17872,10 @@ mod tests { LinkProperties::ForeignKey { source_column, .. } => Some(*source_column), LinkProperties::Measures { source_column, .. } => Some(*source_column), LinkProperties::DependsOn { source_column, .. } => Some(*source_column), - LinkProperties::MapsTo { source_column: Some(sc), .. } => Some(*sc), + LinkProperties::MapsTo { + source_column: Some(sc), + .. + } => Some(*sc), _ => None, }) .collect(); @@ -17557,15 +17937,17 @@ mod tests { }; let Some(ont) = ontology else { continue }; - let col_names: BTreeSet<&str> = - desc.iter_names().map(|c| c.as_str()).collect(); + let col_names: BTreeSet<&str> = desc.iter_names().map(|c| c.as_str()).collect(); for link in ont.links { let source_col = match &link.properties { LinkProperties::ForeignKey { source_column, .. } => Some(*source_column), LinkProperties::Measures { source_column, .. } => Some(*source_column), LinkProperties::DependsOn { source_column, .. } => Some(*source_column), - LinkProperties::MapsTo { source_column: Some(sc), .. } => Some(*sc), + LinkProperties::MapsTo { + source_column: Some(sc), + .. + } => Some(*sc), _ => None, }; let Some(col) = source_col else { continue }; @@ -17601,7 +17983,8 @@ mod tests { let check = |props: LinkProperties, expected: &str| { let got = serde_json::to_string(&props).expect("serialize"); let got_val: serde_json::Value = serde_json::from_str(&got).expect("parse got"); - let exp_val: serde_json::Value = serde_json::from_str(expected).expect("parse expected"); + let exp_val: serde_json::Value = + serde_json::from_str(expected).expect("parse expected"); assert_eq!(got_val, exp_val, "mismatch for {expected}"); }; @@ -17622,12 +18005,23 @@ mod tests { ); // fk_typed — source_id_type present, requires_mapping absent check( - LinkProperties::fk_typed("replica_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::CatalogItemId), + LinkProperties::fk_typed( + "replica_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::CatalogItemId, + ), r#"{"kind":"foreign_key","source_column":"replica_id","target_column":"id","cardinality":"many_to_one","source_id_type":"CatalogItemId"}"#, ); // fk_mapped — source_id_type + requires_mapping both present check( - LinkProperties::fk_mapped("object_id", "id", Cardinality::ManyToOne, mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), + LinkProperties::fk_mapped( + "object_id", + "id", + Cardinality::ManyToOne, + mz_repr::SemanticType::GlobalId, + "mz_internal.mz_object_global_ids", + ), r#"{"kind":"foreign_key","source_column":"object_id","target_column":"id","cardinality":"many_to_one","source_id_type":"GlobalId","requires_mapping":"mz_internal.mz_object_global_ids"}"#, ); // union_disc — discriminator fields present, note absent @@ -17637,7 +18031,11 @@ mod tests { ); // Union — note only, discriminator absent check( - LinkProperties::Union { discriminator_column: None, discriminator_value: None, note: Some("example note") }, + LinkProperties::Union { + discriminator_column: None, + discriminator_value: None, + note: Some("example note"), + }, r#"{"kind":"union","note":"example note"}"#, ); // measures — basic @@ -17647,17 +18045,34 @@ mod tests { ); // measures_mapped — source_id_type + requires_mapping present check( - LinkProperties::measures_mapped("object_id", "id", "wallclock_lag", mz_repr::SemanticType::GlobalId, "mz_internal.mz_object_global_ids"), + LinkProperties::measures_mapped( + "object_id", + "id", + "wallclock_lag", + mz_repr::SemanticType::GlobalId, + "mz_internal.mz_object_global_ids", + ), r#"{"kind":"measures","source_column":"object_id","target_column":"id","metric":"wallclock_lag","source_id_type":"GlobalId","requires_mapping":"mz_internal.mz_object_global_ids"}"#, ); // DependsOn check( - LinkProperties::DependsOn { source_column: "object_id", target_column: "id", source_id_type: Some(mz_repr::SemanticType::CatalogItemId) }, + LinkProperties::DependsOn { + source_column: "object_id", + target_column: "id", + source_id_type: Some(mz_repr::SemanticType::CatalogItemId), + }, r#"{"kind":"depends_on","source_column":"object_id","target_column":"id","source_id_type":"CatalogItemId"}"#, ); // MapsTo — via + from_type + to_type check( - LinkProperties::MapsTo { source_column: None, target_column: None, via: Some("mz_internal.mz_object_global_ids"), from_type: Some(mz_repr::SemanticType::CatalogItemId), to_type: Some(mz_repr::SemanticType::GlobalId), note: None }, + LinkProperties::MapsTo { + source_column: None, + target_column: None, + via: Some("mz_internal.mz_object_global_ids"), + from_type: Some(mz_repr::SemanticType::CatalogItemId), + to_type: Some(mz_repr::SemanticType::GlobalId), + note: None, + }, r#"{"kind":"maps_to","via":"mz_internal.mz_object_global_ids","from_type":"CatalogItemId","to_type":"GlobalId"}"#, ); } diff --git a/src/catalog/src/builtin/ontology.rs b/src/catalog/src/builtin/ontology.rs index ad2afba5e68db..402bfd5c8757a 100644 --- a/src/catalog/src/builtin/ontology.rs +++ b/src/catalog/src/builtin/ontology.rs @@ -336,7 +336,8 @@ fn link_types_view(infos: &[Info]) -> BuiltinView { Lit::Str(i.entity_name.clone()), Lit::Str(l.target.to_string()), Lit::Json( - serde_json::to_string(&l.properties).expect("LinkProperties is serializable"), + serde_json::to_string(&l.properties) + .expect("LinkProperties is serializable"), ), Lit::Null, ] diff --git a/src/repr/src/relation.rs b/src/repr/src/relation.rs index 82fc510525a11..9281d8e284c77 100644 --- a/src/repr/src/relation.rs +++ b/src/repr/src/relation.rs @@ -28,7 +28,7 @@ use serde::{Deserialize, Serialize}; use crate::relation_and_scalar::proto_relation_type::ProtoKey; pub use crate::relation_and_scalar::{ ProtoColumnMetadata, ProtoColumnName, ProtoColumnType, ProtoRelationDesc, ProtoRelationType, - ProtoRelationVersion, + ProtoRelationVersion, ProtoSemanticType, }; use crate::{Datum, ReprScalarType, Row, SqlScalarType, arb_datum_for_column}; @@ -837,7 +837,8 @@ impl RustType for RelationVersion { PartialOrd, Ord, Hash, - serde::Serialize + serde::Serialize, + serde::Deserialize )] pub enum SemanticType { CatalogItemId, @@ -890,6 +891,61 @@ impl fmt::Display for SemanticType { } } +impl RustType for SemanticType { + fn into_proto(&self) -> ProtoSemanticType { + match self { + SemanticType::CatalogItemId => ProtoSemanticType::CatalogItemId, + SemanticType::GlobalId => ProtoSemanticType::GlobalId, + SemanticType::ClusterId => ProtoSemanticType::ClusterId, + SemanticType::ReplicaId => ProtoSemanticType::ReplicaId, + SemanticType::SchemaId => ProtoSemanticType::SchemaId, + SemanticType::DatabaseId => ProtoSemanticType::DatabaseId, + SemanticType::RoleId => ProtoSemanticType::RoleId, + SemanticType::NetworkPolicyId => ProtoSemanticType::NetworkPolicyId, + SemanticType::ShardId => ProtoSemanticType::ShardId, + SemanticType::OID => ProtoSemanticType::Oid, + SemanticType::ObjectType => ProtoSemanticType::ObjectType, + SemanticType::ConnectionType => ProtoSemanticType::ConnectionType, + SemanticType::SourceType => ProtoSemanticType::SourceType, + SemanticType::MzTimestamp => ProtoSemanticType::MzTimestamp, + SemanticType::WallclockTimestamp => ProtoSemanticType::WallclockTimestamp, + SemanticType::ByteCount => ProtoSemanticType::ByteCount, + SemanticType::RecordCount => ProtoSemanticType::RecordCount, + SemanticType::CreditRate => ProtoSemanticType::CreditRate, + SemanticType::SqlDefinition => ProtoSemanticType::SqlDefinition, + SemanticType::RedactedSqlDefinition => ProtoSemanticType::RedactedSqlDefinition, + } + } + + fn from_proto(proto: ProtoSemanticType) -> Result { + match proto { + ProtoSemanticType::Unspecified => Err(TryFromProtoError::unknown_enum_variant( + "ProtoSemanticType::Unspecified", + )), + ProtoSemanticType::CatalogItemId => Ok(SemanticType::CatalogItemId), + ProtoSemanticType::GlobalId => Ok(SemanticType::GlobalId), + ProtoSemanticType::ClusterId => Ok(SemanticType::ClusterId), + ProtoSemanticType::ReplicaId => Ok(SemanticType::ReplicaId), + ProtoSemanticType::SchemaId => Ok(SemanticType::SchemaId), + ProtoSemanticType::DatabaseId => Ok(SemanticType::DatabaseId), + ProtoSemanticType::RoleId => Ok(SemanticType::RoleId), + ProtoSemanticType::NetworkPolicyId => Ok(SemanticType::NetworkPolicyId), + ProtoSemanticType::ShardId => Ok(SemanticType::ShardId), + ProtoSemanticType::Oid => Ok(SemanticType::OID), + ProtoSemanticType::ObjectType => Ok(SemanticType::ObjectType), + ProtoSemanticType::ConnectionType => Ok(SemanticType::ConnectionType), + ProtoSemanticType::SourceType => Ok(SemanticType::SourceType), + ProtoSemanticType::MzTimestamp => Ok(SemanticType::MzTimestamp), + ProtoSemanticType::WallclockTimestamp => Ok(SemanticType::WallclockTimestamp), + ProtoSemanticType::ByteCount => Ok(SemanticType::ByteCount), + ProtoSemanticType::RecordCount => Ok(SemanticType::RecordCount), + ProtoSemanticType::CreditRate => Ok(SemanticType::CreditRate), + ProtoSemanticType::SqlDefinition => Ok(SemanticType::SqlDefinition), + ProtoSemanticType::RedactedSqlDefinition => Ok(SemanticType::RedactedSqlDefinition), + } + } +} + /// Metadata (other than type) for a column in a [`RelationDesc`]. #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash, MzReflect)] struct ColumnMetadata { @@ -976,7 +1032,7 @@ pub struct RelationDesc { metadata: BTreeMap, /// Optional semantic type annotations for columns. /// Keyed by column index. Only populated for builtin catalog objects. - #[serde(skip)] + #[serde(default)] semantic_types: BTreeMap, } @@ -1008,10 +1064,17 @@ impl RustType for RelationDesc { metadata }; + let semantic_types = self + .semantic_types + .iter() + .map(|(col_idx, st)| (u64::cast_from(col_idx.0), i32::from(st.into_proto()))) + .collect(); + ProtoRelationDesc { typ: Some(self.typ.into_proto()), names, metadata, + semantic_types, } } @@ -1047,10 +1110,21 @@ impl RustType for RelationDesc { }) .collect::>()?; + let semantic_types = proto + .semantic_types + .into_iter() + .map(|(col_idx, st_i32)| { + let proto_st = ProtoSemanticType::try_from(st_i32) + .map_err(|_| TryFromProtoError::unknown_enum_variant("ProtoSemanticType"))?; + let st = SemanticType::from_proto(proto_st)?; + Ok::<_, TryFromProtoError>((ColumnIndex(usize::cast_from(col_idx)), st)) + }) + .collect::>()?; + Ok(RelationDesc { typ: proto.typ.into_rust_if_some("ProtoRelationDesc::typ")?, metadata, - semantic_types: BTreeMap::default(), + semantic_types, }) } } @@ -1283,6 +1357,15 @@ impl RelationDesc { self.semantic_types.get(&ColumnIndex(i)).copied() } + /// Returns a copy of this [`RelationDesc`] with the given semantic type annotations applied. + pub fn with_semantic_types( + mut self, + semantic_types: BTreeMap, + ) -> Self { + self.semantic_types = semantic_types; + self + } + /// Gets the name of the column at `idx`. /// /// # Panics @@ -1641,7 +1724,7 @@ impl RelationDescBuilder { } /// Appends a column with the specified name and type, and annotates it with - /// a semantic type. Use this instead of chaining [`with_column`] + + /// a semantic type. Use this instead of chaining [`RelationDescBuilder::with_column`] + /// `with_semantic_type` — it is explicit about which column is annotated. pub fn with_column_semantic_type>( mut self, @@ -1863,10 +1946,19 @@ impl VersionedRelationDesc { let relation_type = SqlRelationType { column_types, keys }; + // Preserve semantic type annotations for columns that survived the version filter. + let semantic_types = self + .inner + .semantic_types + .iter() + .filter(|(col_idx, _)| column_metas.contains_key(col_idx)) + .map(|(col_idx, st)| (*col_idx, *st)) + .collect(); + RelationDesc { typ: relation_type, metadata: column_metas, - semantic_types: BTreeMap::default(), + semantic_types, } } @@ -2259,7 +2351,8 @@ mod tests { "added": 0, "dropped": null } - } + }, + "semantic_types": {} } "###); @@ -2297,7 +2390,8 @@ mod tests { "added": 0, "dropped": null } - } + }, + "semantic_types": {} } "###); } @@ -2319,6 +2413,7 @@ mod tests { ColumnName("b".into()).into_proto(), ], metadata: vec![], + semantic_types: Default::default(), }; let desc: RelationDesc = proto.into_rust().unwrap(); @@ -2350,7 +2445,8 @@ mod tests { "added": 0, "dropped": null } - } + }, + "semantic_types": {} } "###); } @@ -2382,7 +2478,8 @@ mod tests { "column_types": [], "keys": [] }, - "metadata": {} + "metadata": {}, + "semantic_types": {} } "###); @@ -2406,7 +2503,8 @@ mod tests { "added": 2, "dropped": null } - } + }, + "semantic_types": {} } "###); } diff --git a/src/repr/src/relation_and_scalar.proto b/src/repr/src/relation_and_scalar.proto index 8c3e13aa07c6e..751c35c4f0d12 100644 --- a/src/repr/src/relation_and_scalar.proto +++ b/src/repr/src/relation_and_scalar.proto @@ -47,10 +47,35 @@ message ProtoColumnMetadata { ProtoRelationVersion dropped = 2; } +enum ProtoSemanticType { + PROTO_SEMANTIC_TYPE_UNSPECIFIED = 0; + PROTO_SEMANTIC_TYPE_CATALOG_ITEM_ID = 1; + PROTO_SEMANTIC_TYPE_GLOBAL_ID = 2; + PROTO_SEMANTIC_TYPE_CLUSTER_ID = 3; + PROTO_SEMANTIC_TYPE_REPLICA_ID = 4; + PROTO_SEMANTIC_TYPE_SCHEMA_ID = 5; + PROTO_SEMANTIC_TYPE_DATABASE_ID = 6; + PROTO_SEMANTIC_TYPE_ROLE_ID = 7; + PROTO_SEMANTIC_TYPE_NETWORK_POLICY_ID = 8; + PROTO_SEMANTIC_TYPE_SHARD_ID = 9; + PROTO_SEMANTIC_TYPE_OID = 10; + PROTO_SEMANTIC_TYPE_OBJECT_TYPE = 11; + PROTO_SEMANTIC_TYPE_CONNECTION_TYPE = 12; + PROTO_SEMANTIC_TYPE_SOURCE_TYPE = 13; + PROTO_SEMANTIC_TYPE_MZ_TIMESTAMP = 14; + PROTO_SEMANTIC_TYPE_WALLCLOCK_TIMESTAMP = 15; + PROTO_SEMANTIC_TYPE_BYTE_COUNT = 16; + PROTO_SEMANTIC_TYPE_RECORD_COUNT = 17; + PROTO_SEMANTIC_TYPE_CREDIT_RATE = 18; + PROTO_SEMANTIC_TYPE_SQL_DEFINITION = 19; + PROTO_SEMANTIC_TYPE_REDACTED_SQL_DEFINITION = 20; +} + message ProtoRelationDesc { ProtoRelationType typ = 1; repeated ProtoColumnName names = 2; repeated ProtoColumnMetadata metadata = 3; + map semantic_types = 4; } message ProtoScalarType { diff --git a/test/sqllogictest/autogenerated/mz_internal.slt b/test/sqllogictest/autogenerated/mz_internal.slt index 77af2f126ff6f..f0d440add2708 100644 --- a/test/sqllogictest/autogenerated/mz_internal.slt +++ b/test/sqllogictest/autogenerated/mz_internal.slt @@ -225,7 +225,7 @@ comment text The␠comment␠itself. query TTT SELECT name, type, comment FROM objects WHERE schema = 'mz_internal' AND object = 'mz_compute_dependencies' ORDER BY position ---- -object_id text The␠ID␠of␠a␠compute␠object.␠Corresponds␠to␠`mz_catalog.mz_indexes.id`,␠`mz_catalog.mz_materialized_views.id`,␠or␠`mz_internal.mz_subscriptions`. +object_id text The␠ID␠of␠a␠compute␠object.␠Corresponds␠to␠`mz_catalog.mz_indexes.id`,␠`mz_catalog.mz_materialized_views.id`,␠or␠`mz_internal.mz_subscriptions.id`. dependency_id text The␠ID␠of␠a␠compute␠dependency.␠Corresponds␠to␠`mz_catalog.mz_indexes.id`,␠`mz_catalog.mz_materialized_views.id`,␠`mz_catalog.mz_sources.id`,␠or␠`mz_catalog.mz_tables.id`. query TTT diff --git a/test/sqllogictest/autogenerated/mz_introspection.slt b/test/sqllogictest/autogenerated/mz_introspection.slt index c30ccfa704691..a914ba4344620 100644 --- a/test/sqllogictest/autogenerated/mz_introspection.slt +++ b/test/sqllogictest/autogenerated/mz_introspection.slt @@ -68,7 +68,7 @@ count numeric The␠count␠of␠errors␠present␠in␠this␠dataflow␠exp query TTT SELECT name, type, comment FROM objects WHERE schema = 'mz_introspection' AND object = 'mz_compute_exports' ORDER BY position ---- -export_id text The␠ID␠of␠the␠index,␠materialized␠view,␠or␠subscription␠exported␠by␠the␠dataflow.␠Corresponds␠to␠`mz_catalog.mz_indexes.id`,␠`mz_catalog.mz_materialized_views.id`,␠or␠`mz_internal.mz_subscriptions`. +export_id text The␠ID␠of␠the␠index,␠materialized␠view,␠or␠subscription␠exported␠by␠the␠dataflow.␠Corresponds␠to␠`mz_catalog.mz_indexes.id`,␠`mz_catalog.mz_materialized_views.id`,␠or␠`mz_internal.mz_subscriptions.id`. dataflow_id uint8 The␠ID␠of␠the␠dataflow.␠Corresponds␠to␠`mz_dataflows.id`. query TTT From 905e3a1156b02111e60db35fe4af4cf35c239dc4 Mon Sep 17 00:00:00 2001 From: mtabebe Date: Thu, 30 Apr 2026 20:10:29 -0400 Subject: [PATCH 12/14] persist: fall back to schema evolution when register_schema returns None During a rolling upgrade from a version without SemanticType annotations to one with them, the RelationDesc (and therefore the serialized schema) differs even though the underlying Arrow data types are identical. `register_schema` returns None because PartialEq now includes semantic_types, causing the old assert to fire and crash environmentd. Fall back to `compare_and_evolve_schema` when `register_schema` returns None. Since semantic_types don't affect Arrow DataType, the backward- compatibility check passes and the new schema is registered as a valid evolution of the existing one. The retry loop handles `ExpectedMismatch` by converging on the actual current SchemaId. This fixes the 0dt smoke test failure where mz_2 crashed repeatedly during the 30-second ReadyToPromote window. Co-Authored-By: Claude Sonnet 4.6 --- src/persist-client/src/write.rs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/persist-client/src/write.rs b/src/persist-client/src/write.rs index 7485ee750cd22..5e0aeb78526ba 100644 --- a/src/persist-client/src/write.rs +++ b/src/persist-client/src/write.rs @@ -51,7 +51,7 @@ use crate::internal::machine::{ use crate::internal::metrics::{BatchWriteMetrics, Metrics, ShardMetrics}; use crate::internal::state::{BatchPart, HandleDebugState, HollowBatch, RunOrder, RunPart}; use crate::read::ReadHandle; -use crate::schema::PartMigration; +use crate::schema::{CaESchema, PartMigration}; use crate::{GarbageCollector, IsolatedRuntime, PersistConfig, ShardId, parse_id}; pub(crate) const COMBINE_INLINE_WRITES: Config = Config::new( @@ -245,10 +245,40 @@ where let (schema_id, maintenance) = self.machine.register_schema(key, val).await; maintenance.start_performing(&self.machine, &self.gc); + if let Some(id) = schema_id { + self.write_schemas.id = Some(id); + return Some(id); + } + + // Schema registration failed because the existing schema doesn't match. + // This can happen during a rolling upgrade when metadata-only fields + // (e.g. SemanticType annotations in RelationDesc) were added to the + // schema without changing the underlying Arrow data types. Fall back to + // schema evolution, which succeeds when the Arrow types are compatible. + let schema_id = self.try_evolve_schema().await; self.write_schemas.id = schema_id; schema_id } + async fn try_evolve_schema(&self) -> Option { + let Schemas { key, val, .. } = &self.write_schemas; + let mut expected = SchemaId(0); + loop { + let (result, maintenance) = self + .machine + .compare_and_evolve_schema(expected, key, val) + .await; + maintenance.start_performing(&self.machine, &self.gc); + match result { + CaESchema::Ok(id) => return Some(id), + CaESchema::Incompatible => return None, + CaESchema::ExpectedMismatch { schema_id, .. } => { + expected = schema_id; + } + } + } + } + /// A cached version of the shard-global `upper` frontier. /// /// This is the most recent upper discovered by this handle. It is From 0c8b2c421ef05191f50908ff861e348f877d3699 Mon Sep 17 00:00:00 2001 From: mtabebe Date: Thu, 30 Apr 2026 21:25:38 -0400 Subject: [PATCH 13/14] [ontology] move column semantic types from RelationDesc to Ontology --- src/adapter/src/catalog/apply.rs | 30 +- src/catalog/src/builtin.rs | 1809 ++++++++++-------------- src/catalog/src/builtin/ontology.rs | 16 +- src/persist-client/src/write.rs | 32 +- src/repr/src/.relation.rs.pending-snap | 19 + src/repr/src/relation.rs | 191 +-- src/repr/src/relation_and_scalar.proto | 25 - src/storage-client/src/healthcheck.rs | 56 +- 8 files changed, 788 insertions(+), 1390 deletions(-) create mode 100644 src/repr/src/.relation.rs.pending-snap diff --git a/src/adapter/src/catalog/apply.rs b/src/adapter/src/catalog/apply.rs index af52bcfaeb339..184eb14a8dcf7 100644 --- a/src/adapter/src/catalog/apply.rs +++ b/src/adapter/src/catalog/apply.rs @@ -46,9 +46,7 @@ use mz_ore::{instrument, soft_assert_eq_or_log, soft_assert_no_log, soft_assert_ use mz_pgrepr::oid::INVALID_OID; use mz_repr::adt::mz_acl_item::{MzAclItem, PrivilegeMap}; use mz_repr::role_id::RoleId; -use mz_repr::{ - CatalogItemId, ColumnIndex, Diff, GlobalId, RelationVersion, Timestamp, VersionedRelationDesc, -}; +use mz_repr::{CatalogItemId, Diff, GlobalId, RelationVersion, Timestamp, VersionedRelationDesc}; use mz_sql::catalog::CatalogError as SqlCatalogError; use mz_sql::catalog::{CatalogItem as SqlCatalogItem, CatalogItemType, CatalogSchema, CatalogType}; use mz_sql::names::{ @@ -983,15 +981,6 @@ impl CatalogState { for key in &mv.desc.typ().keys { desc = desc.with_key(key.clone()); } - // Copy semantic type annotations from the static builtin definition. - let semantic_types = (0..desc.arity()) - .filter_map(|i| { - mv.desc - .get_semantic_type(i) - .map(|st| (ColumnIndex::from_raw(i), st)) - }) - .collect(); - desc = desc.with_semantic_types(semantic_types); catalog_mv.desc = VersionedRelationDesc::new(desc); self.insert_item( @@ -1773,7 +1762,7 @@ impl CatalogState { } }; match res { - Ok((mut item, uncached_expr)) => { + Ok((item, uncached_expr)) => { if let Some((uncached_expr, optimizer_features)) = uncached_expr { local_expression_cache.insert_uncached_expression( global_id, @@ -1800,21 +1789,6 @@ impl CatalogState { )]; acl_items.extend_from_slice(&view.access); - // Copy semantic type annotations from the static builtin definition. - if let CatalogItem::View(catalog_view) = &mut item { - let semantic_types = (0..catalog_view.desc.arity()) - .filter_map(|i| { - view.desc - .get_semantic_type(i) - .map(|st| (ColumnIndex::from_raw(i), st)) - }) - .collect(); - catalog_view.desc = catalog_view - .desc - .clone() - .with_semantic_types(semantic_types); - } - state.insert_item( id, view.oid, diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index d55bf8e836941..51110437f228b 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -165,8 +165,19 @@ pub struct BuiltinLog { /// Ontology metadata for a builtin catalog object. /// /// When present on a builtin, it marks it as an ontology entity with an explicit -/// `entity_name` and `description`. Column-level semantic types are annotated -/// via `RelationDescBuilder::with_column_semantic_type()`. +/// `entity_name`, `description`, and optional per-column semantic type annotations. +/// +/// ## Why `column_semantic_types` lives here and not in `RelationDesc` +/// +/// Semantic types are pure catalog-level metadata: they annotate what an ID +/// column *means* (e.g. "this is a ClusterId") without affecting the Arrow +/// data type used for encoding. Keeping them in `RelationDesc` would cause +/// persist schema mismatches during zero-downtime upgrades: the old binary +/// registers a schema without semantic types, the new binary tries to register +/// a schema with them, and `register_schema` returns `None` because the schemas +/// are not `PartialEq`. Since the only consumers of semantic types are the +/// ontology views (which already have access to `Ontology`), storing them here +/// is both correct and avoids the schema-evolution problem entirely. #[derive(Clone, Hash, Debug, PartialEq, Eq)] pub struct Ontology { /// The ontology entity name (e.g., "database", "table", "mv"). Names a @@ -178,6 +189,9 @@ pub struct Ontology { /// Relationships originating from this entity (foreign keys, unions, /// mappings, dependencies, metrics). pub links: &'static [OntologyLink], + /// Per-column semantic type annotations: `(column_name, SemanticType)`. + /// Only columns that carry a meaningful semantic type need to appear here. + pub column_semantic_types: &'static [(&'static str, SemanticType)], } /// Cardinality of an ontology link. @@ -2359,11 +2373,7 @@ pub static MZ_ICEBERG_SINKS: LazyLock = LazyLock::new(|| BuiltinTa schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_ICEBERG_SINKS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("namespace", SqlScalarType::String.nullable(false)) .with_column("table", SqlScalarType::String.nullable(false)) .finish(), @@ -2387,6 +2397,7 @@ pub static MZ_ICEBERG_SINKS: LazyLock = LazyLock::new(|| BuiltinTa properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); @@ -2395,11 +2406,7 @@ pub static MZ_KAFKA_SINKS: LazyLock = LazyLock::new(|| BuiltinTabl schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_KAFKA_SINKS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("topic", SqlScalarType::String.nullable(false)) .with_key(vec![0]) .finish(), @@ -2422,6 +2429,7 @@ pub static MZ_KAFKA_SINKS: LazyLock = LazyLock::new(|| BuiltinTabl properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); pub static MZ_KAFKA_CONNECTIONS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2429,11 +2437,7 @@ pub static MZ_KAFKA_CONNECTIONS: LazyLock = LazyLock::new(|| Built schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_KAFKA_CONNECTIONS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column( "brokers", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), @@ -2463,6 +2467,7 @@ pub static MZ_KAFKA_CONNECTIONS: LazyLock = LazyLock::new(|| Built properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); pub static MZ_KAFKA_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2470,11 +2475,7 @@ pub static MZ_KAFKA_SOURCES: LazyLock = LazyLock::new(|| BuiltinTa schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_KAFKA_SOURCES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("group_id_prefix", SqlScalarType::String.nullable(false)) .with_column("topic", SqlScalarType::String.nullable(false)) .finish(), @@ -2504,6 +2505,7 @@ pub static MZ_KAFKA_SOURCES: LazyLock = LazyLock::new(|| BuiltinTa properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2511,11 +2513,7 @@ pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| Builti schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_POSTGRES_SOURCES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("replication_slot", SqlScalarType::String.nullable(false)) .with_column("timeline_id", SqlScalarType::UInt64.nullable(true)) .finish(), @@ -2545,6 +2543,7 @@ pub static MZ_POSTGRES_SOURCES: LazyLock = LazyLock::new(|| Builti properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2552,11 +2551,7 @@ pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_POSTGRES_SOURCE_TABLES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("schema_name", SqlScalarType::String.nullable(false)) .with_column("table_name", SqlScalarType::String.nullable(false)) .finish(), @@ -2586,6 +2581,7 @@ pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock = LazyLock::new(|| properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2593,11 +2589,7 @@ pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_MYSQL_SOURCE_TABLES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("schema_name", SqlScalarType::String.nullable(false)) .with_column("table_name", SqlScalarType::String.nullable(false)) .finish(), @@ -2627,6 +2619,7 @@ pub static MZ_MYSQL_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2634,11 +2627,7 @@ pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(| schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_SQL_SERVER_SOURCE_TABLES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("schema_name", SqlScalarType::String.nullable(false)) .with_column("table_name", SqlScalarType::String.nullable(false)) .finish(), @@ -2668,6 +2657,7 @@ pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock = LazyLock::new(| properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2675,11 +2665,7 @@ pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_KAFKA_SOURCE_TABLES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("topic", SqlScalarType::String.nullable(false)) .with_column("envelope_type", SqlScalarType::String.nullable(true)) .with_column("key_format", SqlScalarType::String.nullable(true)) @@ -2716,6 +2702,7 @@ pub static MZ_KAFKA_SOURCE_TABLES: LazyLock = LazyLock::new(|| Bui properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -2723,15 +2710,10 @@ pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| Bui schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_OBJECT_DEPENDENCIES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( + .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_column( "referenced_object_id", SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, ) .finish(), column_comments: BTreeMap::from_iter([ @@ -2773,6 +2755,12 @@ pub static MZ_OBJECT_DEPENDENCIES: LazyLock = LazyLock::new(|| Bui }, ] }, + column_semantic_types: &const { + [ + ("object_id", SemanticType::CatalogItemId), + ("referenced_object_id", SemanticType::CatalogItemId), + ] + }, }), }); pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| BuiltinSource { @@ -2781,16 +2769,8 @@ pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| B oid: oid::SOURCE_MZ_COMPUTE_DEPENDENCIES_OID, data_source: IntrospectionType::ComputeDependencies.into(), desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) - .with_column_semantic_type( - "dependency_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) + .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_column("dependency_id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -2833,6 +2813,12 @@ pub static MZ_COMPUTE_DEPENDENCIES: LazyLock = LazyLock::new(|| B }, ] }, + column_semantic_types: &const { + [ + ("object_id", SemanticType::GlobalId), + ("dependency_id", SemanticType::GlobalId), + ] + }, }), }); @@ -2842,18 +2828,10 @@ pub static MZ_DATABASES: LazyLock = schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_DATABASES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::DatabaseId, - ) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "owner_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) + .with_column("owner_id", SqlScalarType::String.nullable(false)) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -2900,6 +2878,13 @@ WHERE data->>'kind' = 'Database'", properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }] }, + column_semantic_types: &const { + [ + ("id", SemanticType::DatabaseId), + ("oid", SemanticType::OID), + ("owner_id", SemanticType::RoleId), + ] + }, }), }); @@ -2909,23 +2894,11 @@ pub static MZ_SCHEMAS: LazyLock = schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_SCHEMAS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::SchemaId, - ) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) - .with_column_semantic_type( - "database_id", - SqlScalarType::String.nullable(true), - SemanticType::DatabaseId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("database_id", SqlScalarType::String.nullable(true)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "owner_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) + .with_column("owner_id", SqlScalarType::String.nullable(false)) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -2990,6 +2963,14 @@ WHERE data->>'kind' = 'Schema'", }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::SchemaId), + ("oid", SemanticType::OID), + ("database_id", SemanticType::DatabaseId), + ("owner_id", SemanticType::RoleId), + ] + }, }), }); @@ -2998,21 +2979,13 @@ pub static MZ_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_COLUMNS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) // not a key + .with_column("id", SqlScalarType::String.nullable(false)) // not a key .with_column("name", SqlScalarType::String.nullable(false)) .with_column("position", SqlScalarType::UInt64.nullable(false)) .with_column("nullable", SqlScalarType::Bool.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) .with_column("default", SqlScalarType::String.nullable(true)) - .with_column_semantic_type( - "type_oid", - SqlScalarType::Oid.nullable(false), - SemanticType::OID, - ) + .with_column("type_oid", SqlScalarType::Oid.nullable(false)) .with_column("type_mod", SqlScalarType::Int32.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -3054,6 +3027,12 @@ pub static MZ_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { }, }] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("type_oid", SemanticType::OID), + ] + }, }), }); pub static MZ_INDEXES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3061,38 +3040,14 @@ pub static MZ_INDEXES: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_INDEXES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "on_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( - "cluster_id", - SqlScalarType::String.nullable(false), - SemanticType::ClusterId, - ) - .with_column_semantic_type( - "owner_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) - .with_column_semantic_type( - "create_sql", - SqlScalarType::String.nullable(false), - SemanticType::SqlDefinition, - ) - .with_column_semantic_type( - "redacted_create_sql", - SqlScalarType::String.nullable(false), - SemanticType::RedactedSqlDefinition, - ) + .with_column("on_id", SqlScalarType::String.nullable(false)) + .with_column("cluster_id", SqlScalarType::String.nullable(false)) + .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_column("create_sql", SqlScalarType::String.nullable(false)) + .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3142,6 +3097,17 @@ pub static MZ_INDEXES: LazyLock = LazyLock::new(|| BuiltinTable { }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("oid", SemanticType::OID), + ("on_id", SemanticType::CatalogItemId), + ("cluster_id", SemanticType::ClusterId), + ("owner_id", SemanticType::RoleId), + ("create_sql", SemanticType::SqlDefinition), + ("redacted_create_sql", SemanticType::RedactedSqlDefinition), + ] + }, }), }); pub static MZ_INDEX_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3149,11 +3115,7 @@ pub static MZ_INDEX_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTa schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_INDEX_COLUMNS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "index_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("index_id", SqlScalarType::String.nullable(false)) .with_column("index_position", SqlScalarType::UInt64.nullable(false)) .with_column("on_position", SqlScalarType::UInt64.nullable(true)) .with_column("on_expression", SqlScalarType::String.nullable(true)) @@ -3193,6 +3155,7 @@ pub static MZ_INDEX_COLUMNS: LazyLock = LazyLock::new(|| BuiltinTa properties: LinkProperties::fk("index_id", "id", Cardinality::ManyToOne), }] }, + column_semantic_types: &[("index_id", SemanticType::CatalogItemId)], }), }); pub static MZ_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3200,42 +3163,18 @@ pub static MZ_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_TABLES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) - .with_column_semantic_type( - "schema_id", - SqlScalarType::String.nullable(false), - SemanticType::SchemaId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "owner_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) + .with_column("owner_id", SqlScalarType::String.nullable(false)) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) - .with_column_semantic_type( - "create_sql", - SqlScalarType::String.nullable(true), - SemanticType::SqlDefinition, - ) - .with_column_semantic_type( - "redacted_create_sql", - SqlScalarType::String.nullable(true), - SemanticType::RedactedSqlDefinition, - ) - .with_column_semantic_type( - "source_id", - SqlScalarType::String.nullable(true), - SemanticType::CatalogItemId, - ) + .with_column("create_sql", SqlScalarType::String.nullable(true)) + .with_column("redacted_create_sql", SqlScalarType::String.nullable(true)) + .with_column("source_id", SqlScalarType::String.nullable(true)) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3290,6 +3229,17 @@ pub static MZ_TABLES: LazyLock = LazyLock::new(|| BuiltinTable { }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("oid", SemanticType::OID), + ("schema_id", SemanticType::SchemaId), + ("owner_id", SemanticType::RoleId), + ("create_sql", SemanticType::SqlDefinition), + ("redacted_create_sql", SemanticType::RedactedSqlDefinition), + ("source_id", SemanticType::CatalogItemId), + ] + }, }), }); @@ -3299,18 +3249,18 @@ pub static MZ_CONNECTIONS: LazyLock = LazyLock::new(|| schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_CONNECTIONS_OID, desc: RelationDesc::builder() - .with_column_semantic_type("id", SqlScalarType::String.nullable(false), SemanticType::CatalogItemId) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) - .with_column_semantic_type("schema_id", SqlScalarType::String.nullable(false), SemanticType::SchemaId) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type("type", SqlScalarType::String.nullable(false), SemanticType::ConnectionType) - .with_column_semantic_type("owner_id", SqlScalarType::String.nullable(false), SemanticType::RoleId) + .with_column("type", SqlScalarType::String.nullable(false)) + .with_column("owner_id", SqlScalarType::String.nullable(false)) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) - .with_column_semantic_type("create_sql", SqlScalarType::String.nullable(false), SemanticType::SqlDefinition) - .with_column_semantic_type("redacted_create_sql", SqlScalarType::String.nullable(false), SemanticType::RedactedSqlDefinition) + .with_column("create_sql", SqlScalarType::String.nullable(false)) + .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3384,6 +3334,7 @@ WHERE properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }, ] }, + column_semantic_types: &const {[("id", SemanticType::CatalogItemId), ("oid", SemanticType::OID), ("schema_id", SemanticType::SchemaId), ("type", SemanticType::ConnectionType), ("owner_id", SemanticType::RoleId), ("create_sql", SemanticType::SqlDefinition), ("redacted_create_sql", SemanticType::RedactedSqlDefinition)]}, }), } }); @@ -3393,11 +3344,7 @@ pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock = LazyLock::new(|| schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_SSH_TUNNEL_CONNECTIONS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("public_key_1", SqlScalarType::String.nullable(false)) .with_column("public_key_2", SqlScalarType::String.nullable(false)) .finish(), @@ -3424,6 +3371,7 @@ pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock = LazyLock::new(|| properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); pub static MZ_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -3431,56 +3379,24 @@ pub static MZ_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_SOURCES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) - .with_column_semantic_type( - "schema_id", - SqlScalarType::String.nullable(false), - SemanticType::SchemaId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "type", - SqlScalarType::String.nullable(false), - SemanticType::SourceType, - ) - .with_column_semantic_type( - "connection_id", - SqlScalarType::String.nullable(true), - SemanticType::CatalogItemId, - ) + .with_column("type", SqlScalarType::String.nullable(false)) + .with_column("connection_id", SqlScalarType::String.nullable(true)) .with_column("size", SqlScalarType::String.nullable(true)) .with_column("envelope_type", SqlScalarType::String.nullable(true)) .with_column("key_format", SqlScalarType::String.nullable(true)) .with_column("value_format", SqlScalarType::String.nullable(true)) - .with_column_semantic_type( - "cluster_id", - SqlScalarType::String.nullable(true), - SemanticType::ClusterId, - ) - .with_column_semantic_type( - "owner_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) + .with_column("cluster_id", SqlScalarType::String.nullable(true)) + .with_column("owner_id", SqlScalarType::String.nullable(false)) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) - .with_column_semantic_type( - "create_sql", - SqlScalarType::String.nullable(true), - SemanticType::SqlDefinition, - ) - .with_column_semantic_type( - "redacted_create_sql", - SqlScalarType::String.nullable(true), - SemanticType::RedactedSqlDefinition, - ) + .with_column("create_sql", SqlScalarType::String.nullable(true)) + .with_column("redacted_create_sql", SqlScalarType::String.nullable(true)) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3565,6 +3481,19 @@ pub static MZ_SOURCES: LazyLock = LazyLock::new(|| BuiltinTable { }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("oid", SemanticType::OID), + ("schema_id", SemanticType::SchemaId), + ("type", SemanticType::SourceType), + ("connection_id", SemanticType::CatalogItemId), + ("cluster_id", SemanticType::ClusterId), + ("owner_id", SemanticType::RoleId), + ("create_sql", SemanticType::SqlDefinition), + ("redacted_create_sql", SemanticType::RedactedSqlDefinition), + ] + }, }), }); pub static MZ_SINKS: LazyLock = LazyLock::new(|| { @@ -3573,24 +3502,12 @@ pub static MZ_SINKS: LazyLock = LazyLock::new(|| { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_SINKS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) - .with_column_semantic_type( - "schema_id", - SqlScalarType::String.nullable(false), - SemanticType::SchemaId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "connection_id", - SqlScalarType::String.nullable(true), - SemanticType::CatalogItemId, - ) + .with_column("connection_id", SqlScalarType::String.nullable(true)) .with_column("size", SqlScalarType::String.nullable(true)) .with_column("envelope_type", SqlScalarType::String.nullable(true)) // This `format` column is deprecated and replaced by the `key_format` and `value_format` columns @@ -3598,26 +3515,10 @@ pub static MZ_SINKS: LazyLock = LazyLock::new(|| { .with_column("format", SqlScalarType::String.nullable(true)) .with_column("key_format", SqlScalarType::String.nullable(true)) .with_column("value_format", SqlScalarType::String.nullable(true)) - .with_column_semantic_type( - "cluster_id", - SqlScalarType::String.nullable(false), - SemanticType::ClusterId, - ) - .with_column_semantic_type( - "owner_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) - .with_column_semantic_type( - "create_sql", - SqlScalarType::String.nullable(false), - SemanticType::SqlDefinition, - ) - .with_column_semantic_type( - "redacted_create_sql", - SqlScalarType::String.nullable(false), - SemanticType::RedactedSqlDefinition, - ) + .with_column("cluster_id", SqlScalarType::String.nullable(false)) + .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_column("create_sql", SqlScalarType::String.nullable(false)) + .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3698,6 +3599,18 @@ pub static MZ_SINKS: LazyLock = LazyLock::new(|| { }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("oid", SemanticType::OID), + ("schema_id", SemanticType::SchemaId), + ("connection_id", SemanticType::CatalogItemId), + ("cluster_id", SemanticType::ClusterId), + ("owner_id", SemanticType::RoleId), + ("create_sql", SemanticType::SqlDefinition), + ("redacted_create_sql", SemanticType::RedactedSqlDefinition), + ] + }, }), } }); @@ -3706,42 +3619,18 @@ pub static MZ_VIEWS: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_VIEWS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) - .with_column_semantic_type( - "schema_id", - SqlScalarType::String.nullable(false), - SemanticType::SchemaId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "definition", - SqlScalarType::String.nullable(false), - SemanticType::SqlDefinition, - ) - .with_column_semantic_type( - "owner_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) + .with_column("definition", SqlScalarType::String.nullable(false)) + .with_column("owner_id", SqlScalarType::String.nullable(false)) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) - .with_column_semantic_type( - "create_sql", - SqlScalarType::String.nullable(false), - SemanticType::SqlDefinition, - ) - .with_column_semantic_type( - "redacted_create_sql", - SqlScalarType::String.nullable(false), - SemanticType::RedactedSqlDefinition, - ) + .with_column("create_sql", SqlScalarType::String.nullable(false)) + .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3784,6 +3673,17 @@ pub static MZ_VIEWS: LazyLock = LazyLock::new(|| BuiltinTable { }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("oid", SemanticType::OID), + ("schema_id", SemanticType::SchemaId), + ("definition", SemanticType::SqlDefinition), + ("owner_id", SemanticType::RoleId), + ("create_sql", SemanticType::SqlDefinition), + ("redacted_create_sql", SemanticType::RedactedSqlDefinition), + ] + }, }), }); @@ -3793,19 +3693,19 @@ pub static MZ_MATERIALIZED_VIEWS: LazyLock = LazyLock:: schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_MATERIALIZED_VIEWS_OID, desc: RelationDesc::builder() - .with_column_semantic_type("id", SqlScalarType::String.nullable(false), SemanticType::CatalogItemId) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) - .with_column_semantic_type("schema_id", SqlScalarType::String.nullable(false), SemanticType::SchemaId) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type("cluster_id", SqlScalarType::String.nullable(false), SemanticType::ClusterId) - .with_column_semantic_type("definition", SqlScalarType::String.nullable(false), SemanticType::SqlDefinition) - .with_column_semantic_type("owner_id", SqlScalarType::String.nullable(false), SemanticType::RoleId) + .with_column("cluster_id", SqlScalarType::String.nullable(false)) + .with_column("definition", SqlScalarType::String.nullable(false)) + .with_column("owner_id", SqlScalarType::String.nullable(false)) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) - .with_column_semantic_type("create_sql", SqlScalarType::String.nullable(false), SemanticType::SqlDefinition) - .with_column_semantic_type("redacted_create_sql", SqlScalarType::String.nullable(false), SemanticType::RedactedSqlDefinition) + .with_column("create_sql", SqlScalarType::String.nullable(false)) + .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -3918,6 +3818,7 @@ SELECT * FROM builtin_mvs").into_boxed_str()), OntologyLink { name: "owned_by", target: "role", properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne) }, OntologyLink { name: "runs_on_cluster", target: "cluster", properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne) }, ] }, + column_semantic_types: &const {[("id", SemanticType::CatalogItemId), ("oid", SemanticType::OID), ("schema_id", SemanticType::SchemaId), ("cluster_id", SemanticType::ClusterId), ("definition", SemanticType::SqlDefinition), ("owner_id", SemanticType::RoleId), ("create_sql", SemanticType::SqlDefinition), ("redacted_create_sql", SemanticType::RedactedSqlDefinition)]}, }), } }); @@ -3975,38 +3876,18 @@ pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_TYPES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) - .with_column_semantic_type( - "schema_id", - SqlScalarType::String.nullable(false), - SemanticType::SchemaId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("category", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "owner_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) + .with_column("owner_id", SqlScalarType::String.nullable(false)) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) - .with_column_semantic_type( - "create_sql", - SqlScalarType::String.nullable(true), - SemanticType::SqlDefinition, - ) - .with_column_semantic_type( - "redacted_create_sql", - SqlScalarType::String.nullable(true), - SemanticType::RedactedSqlDefinition, - ) + .with_column("create_sql", SqlScalarType::String.nullable(true)) + .with_column("redacted_create_sql", SqlScalarType::String.nullable(true)) .with_key(vec![0]) .with_key(vec![1]) .finish(), @@ -4049,6 +3930,16 @@ pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("oid", SemanticType::OID), + ("schema_id", SemanticType::SchemaId), + ("owner_id", SemanticType::RoleId), + ("create_sql", SemanticType::SqlDefinition), + ("redacted_create_sql", SemanticType::RedactedSqlDefinition), + ] + }, }), }); @@ -4058,22 +3949,14 @@ pub static MZ_NETWORK_POLICIES: LazyLock = LazyLock::ne schema: MZ_INTERNAL_SCHEMA, oid: oid::MV_MZ_NETWORK_POLICIES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::NetworkPolicyId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "owner_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) + .with_column("owner_id", SqlScalarType::String.nullable(false)) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), ) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column("oid", SqlScalarType::Oid.nullable(false)) .with_key(vec![0]) .with_key(vec![4]) .finish(), @@ -4119,6 +4002,13 @@ WHERE data->>'kind' = 'NetworkPolicy'", properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }] }, + column_semantic_types: &const { + [ + ("id", SemanticType::NetworkPolicyId), + ("owner_id", SemanticType::RoleId), + ("oid", SemanticType::OID), + ] + }, }), } }); @@ -4185,6 +4075,7 @@ WHERE data->>'kind' = 'NetworkPolicy'", properties: LinkProperties::fk("policy_id", "id", Cardinality::ManyToOne), }] }, + column_semantic_types: &[], }), } }); @@ -4196,21 +4087,9 @@ pub static MZ_TYPE_PG_METADATA: LazyLock = LazyLock::new(|| Builti schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_TYPE_PG_METADATA_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( - "typinput", - SqlScalarType::Oid.nullable(false), - SemanticType::OID, - ) - .with_column_semantic_type( - "typreceive", - SqlScalarType::Oid.nullable(false), - SemanticType::OID, - ) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("typinput", SqlScalarType::Oid.nullable(false)) + .with_column("typreceive", SqlScalarType::Oid.nullable(false)) .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, @@ -4222,16 +4101,8 @@ pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| BuiltinTabl schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_ARRAY_TYPES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( - "element_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("element_id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ ("id", "The ID of the array type."), @@ -4256,6 +4127,12 @@ pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| BuiltinTabl }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("element_id", SemanticType::CatalogItemId), + ] + }, }), }); pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4263,11 +4140,7 @@ pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinTable schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_BASE_TYPES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]), is_retained_metrics_object: false, @@ -4276,6 +4149,7 @@ pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinTable entity_name: "base_type", description: "A primitive/base data type", links: &const { [] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4283,16 +4157,8 @@ pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_LIST_TYPES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( - "element_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("element_id", SqlScalarType::String.nullable(false)) .with_column( "element_modifiers", SqlScalarType::List { @@ -4329,6 +4195,12 @@ pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("element_id", SemanticType::CatalogItemId), + ] + }, }), }); pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4336,21 +4208,9 @@ pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_MAP_TYPES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( - "key_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( - "value_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("key_id", SqlScalarType::String.nullable(false)) + .with_column("value_id", SqlScalarType::String.nullable(false)) .with_column( "key_modifiers", SqlScalarType::List { @@ -4405,6 +4265,13 @@ pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("key_id", SemanticType::CatalogItemId), + ("value_id", SemanticType::CatalogItemId), + ] + }, }), }); pub static MZ_ROLES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4412,12 +4279,8 @@ pub static MZ_ROLES: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_ROLES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("inherit", SqlScalarType::Bool.nullable(false)) .with_column("rolcanlogin", SqlScalarType::Bool.nullable(true)) @@ -4442,6 +4305,7 @@ pub static MZ_ROLES: LazyLock = LazyLock::new(|| BuiltinTable { entity_name: "role", description: "A user or role for authentication and access control", links: &const { [] }, + column_semantic_types: &const { [("id", SemanticType::RoleId), ("oid", SemanticType::OID)] }, }), }); @@ -4451,21 +4315,9 @@ pub static MZ_ROLE_MEMBERS: LazyLock = LazyLock::new(|| schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_ROLE_MEMBERS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "role_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) - .with_column_semantic_type( - "member", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) - .with_column_semantic_type( - "grantor", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) + .with_column("role_id", SqlScalarType::String.nullable(false)) + .with_column("member", SqlScalarType::String.nullable(false)) + .with_column("grantor", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -4520,6 +4372,13 @@ WHERE data->>'kind' = 'Role'", }, ] }, + column_semantic_types: &const { + [ + ("role_id", SemanticType::RoleId), + ("member", SemanticType::RoleId), + ("grantor", SemanticType::RoleId), + ] + }, }), } }); @@ -4529,11 +4388,7 @@ pub static MZ_ROLE_PARAMETERS: LazyLock = LazyLock::new(|| Builtin schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_ROLE_PARAMETERS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "role_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) + .with_column("role_id", SqlScalarType::String.nullable(false)) .with_column("parameter_name", SqlScalarType::String.nullable(false)) .with_column("parameter_value", SqlScalarType::String.nullable(false)) .finish(), @@ -4563,6 +4418,7 @@ pub static MZ_ROLE_PARAMETERS: LazyLock = LazyLock::new(|| Builtin properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne), }] }, + column_semantic_types: &[("role_id", SemanticType::RoleId)], }), }); pub static MZ_ROLE_AUTH: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4570,16 +4426,8 @@ pub static MZ_ROLE_AUTH: LazyLock = LazyLock::new(|| BuiltinTable schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_ROLE_AUTH_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "role_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) - .with_column_semantic_type( - "role_oid", - SqlScalarType::Oid.nullable(false), - SemanticType::OID, - ) + .with_column("role_id", SqlScalarType::String.nullable(false)) + .with_column("role_oid", SqlScalarType::Oid.nullable(false)) .with_column("password_hash", SqlScalarType::String.nullable(true)) .with_column( "updated_at", @@ -4610,11 +4458,7 @@ pub static MZ_PSEUDO_TYPES: LazyLock = LazyLock::new(|| BuiltinTab schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_PSEUDO_TYPES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]), is_retained_metrics_object: false, @@ -4623,6 +4467,7 @@ pub static MZ_PSEUDO_TYPES: LazyLock = LazyLock::new(|| BuiltinTab entity_name: "pseudo_type", description: "A pseudo-type used in function signatures", links: &const { [] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { @@ -4631,38 +4476,21 @@ pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_FUNCTIONS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) // not a key! - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) - .with_column_semantic_type( - "schema_id", - SqlScalarType::String.nullable(false), - SemanticType::SchemaId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) // not a key! + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) .with_column( "argument_type_ids", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), ) - .with_column_semantic_type( + .with_column( "variadic_argument_type_id", SqlScalarType::String.nullable(true), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( - "return_type_id", - SqlScalarType::String.nullable(true), - SemanticType::CatalogItemId, ) + .with_column("return_type_id", SqlScalarType::String.nullable(true)) .with_column("returns_set", SqlScalarType::Bool.nullable(false)) - .with_column_semantic_type( - "owner_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) + .with_column("owner_id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ ("id", "Materialize's unique ID for the function."), @@ -4730,6 +4558,16 @@ pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("oid", SemanticType::OID), + ("schema_id", SemanticType::SchemaId), + ("variadic_argument_type_id", SemanticType::CatalogItemId), + ("return_type_id", SemanticType::CatalogItemId), + ("owner_id", SemanticType::RoleId), + ] + }, }), } }); @@ -4738,17 +4576,13 @@ pub static MZ_OPERATORS: LazyLock = LazyLock::new(|| BuiltinTable schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_OPERATORS_OID, desc: RelationDesc::builder() - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column("oid", SqlScalarType::Oid.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) .with_column( "argument_type_ids", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), ) - .with_column_semantic_type( - "return_type_id", - SqlScalarType::String.nullable(true), - SemanticType::CatalogItemId, - ) + .with_column("return_type_id", SqlScalarType::String.nullable(true)) .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, @@ -4767,6 +4601,12 @@ pub static MZ_OPERATORS: LazyLock = LazyLock::new(|| BuiltinTable ), }] }, + column_semantic_types: &const { + [ + ("oid", SemanticType::OID), + ("return_type_id", SemanticType::CatalogItemId), + ] + }, }), }); pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinTable { @@ -4774,7 +4614,7 @@ pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinTable schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_AGGREGATES_OID, desc: RelationDesc::builder() - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) + .with_column("oid", SqlScalarType::Oid.nullable(false)) .with_column("agg_kind", SqlScalarType::String.nullable(false)) .with_column("agg_num_direct_args", SqlScalarType::Int16.nullable(false)) .finish(), @@ -4785,6 +4625,7 @@ pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinTable entity_name: "aggregate", description: "Aggregate function metadata", links: &const { [] }, + column_semantic_types: &[("oid", SemanticType::OID)], }), }); @@ -4793,17 +4634,9 @@ pub static MZ_CLUSTERS: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_CLUSTERS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::ClusterId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "owner_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) + .with_column("owner_id", SqlScalarType::String.nullable(false)) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -4886,6 +4719,12 @@ pub static MZ_CLUSTERS: LazyLock = LazyLock::new(|| BuiltinTable { }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::ClusterId), + ("owner_id", SemanticType::RoleId), + ] + }, }), }); @@ -4895,11 +4734,7 @@ pub static MZ_CLUSTER_WORKLOAD_CLASSES: LazyLock = schema: MZ_INTERNAL_SCHEMA, oid: oid::MV_MZ_CLUSTER_WORKLOAD_CLASSES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::ClusterId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("workload_class", SqlScalarType::String.nullable(true)) .with_key(vec![0]) .finish(), @@ -4935,11 +4770,7 @@ pub static MZ_CLUSTER_SCHEDULES: LazyLock = LazyLock::new(|| Built schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_CLUSTER_SCHEDULES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "cluster_id", - SqlScalarType::String.nullable(false), - SemanticType::ClusterId, - ) + .with_column("cluster_id", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) .with_column( "refresh_hydration_time_estimate", @@ -4969,6 +4800,7 @@ pub static MZ_CLUSTER_SCHEDULES: LazyLock = LazyLock::new(|| Built properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne), }] }, + column_semantic_types: &[("cluster_id", SemanticType::ClusterId)], }), }); @@ -4978,11 +4810,11 @@ pub static MZ_SECRETS: LazyLock = LazyLock::new(|| { schema: MZ_CATALOG_SCHEMA, oid: oid::MV_MZ_SECRETS_OID, desc: RelationDesc::builder() - .with_column_semantic_type("id", SqlScalarType::String.nullable(false), SemanticType::CatalogItemId) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) - .with_column_semantic_type("schema_id", SqlScalarType::String.nullable(false), SemanticType::SchemaId) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type("owner_id", SqlScalarType::String.nullable(false), SemanticType::RoleId) + .with_column("owner_id", SqlScalarType::String.nullable(false)) .with_column( "privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), @@ -5040,6 +4872,7 @@ WHERE properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), }, ] }, + column_semantic_types: &const {[("id", SemanticType::CatalogItemId), ("oid", SemanticType::OID), ("schema_id", SemanticType::SchemaId), ("owner_id", SemanticType::RoleId)]}, }), } }); @@ -5049,26 +4882,14 @@ pub static MZ_CLUSTER_REPLICAS: LazyLock = LazyLock::new(|| Builti schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_CLUSTER_REPLICAS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::ReplicaId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "cluster_id", - SqlScalarType::String.nullable(false), - SemanticType::ClusterId, - ) + .with_column("cluster_id", SqlScalarType::String.nullable(false)) .with_column("size", SqlScalarType::String.nullable(true)) // `NULL` for un-orchestrated clusters and for replicas where the user // hasn't specified them. .with_column("availability_zone", SqlScalarType::String.nullable(true)) - .with_column_semantic_type( - "owner_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) + .with_column("owner_id", SqlScalarType::String.nullable(false)) .with_column("disk", SqlScalarType::Bool.nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ @@ -5116,6 +4937,13 @@ pub static MZ_CLUSTER_REPLICAS: LazyLock = LazyLock::new(|| Builti }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::ReplicaId), + ("cluster_id", SemanticType::ClusterId), + ("owner_id", SemanticType::RoleId), + ] + }, }), }); @@ -5153,11 +4981,7 @@ pub static MZ_PENDING_CLUSTER_REPLICAS: LazyLock = schema: MZ_INTERNAL_SCHEMA, oid: oid::MV_MZ_PENDING_CLUSTER_REPLICAS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::ReplicaId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([( @@ -5219,6 +5043,7 @@ pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY: LazyLock = LazyLock ), }] }, + column_semantic_types: &[("replica_id", SemanticType::ReplicaId)], }), } }); @@ -5228,18 +5053,13 @@ pub static MZ_CLUSTER_REPLICA_STATUSES: LazyLock = LazyLock::new(|| schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_CLUSTER_REPLICA_STATUSES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(false), - SemanticType::ReplicaId, - ) + .with_column("replica_id", SqlScalarType::String.nullable(false)) .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("reason", SqlScalarType::String.nullable(true)) - .with_column_semantic_type( + .with_column( "updated_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), - SemanticType::WallclockTimestamp, ) .with_key(vec![0, 1]) .finish(), @@ -5292,6 +5112,12 @@ ORDER BY replica_id, process_id, occurred_at DESC", ), }] }, + column_semantic_types: &const { + [ + ("replica_id", SemanticType::ReplicaId), + ("updated_at", SemanticType::WallclockTimestamp), + ] + }, }), }); @@ -5304,20 +5130,11 @@ pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock = LazyLock::new(|| B .with_column("processes", SqlScalarType::UInt64.nullable(false)) .with_column("workers", SqlScalarType::UInt64.nullable(false)) .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(false)) - .with_column_semantic_type( - "memory_bytes", - SqlScalarType::UInt64.nullable(false), - SemanticType::ByteCount, - ) - .with_column_semantic_type( - "disk_bytes", - SqlScalarType::UInt64.nullable(true), - SemanticType::ByteCount, - ) - .with_column_semantic_type( + .with_column("memory_bytes", SqlScalarType::UInt64.nullable(false)) + .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true)) + .with_column( "credits_per_hour", SqlScalarType::Numeric { max_scale: None }.nullable(false), - SemanticType::CreditRate, ) .finish(), column_comments: BTreeMap::from_iter([ @@ -5347,6 +5164,13 @@ pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock = LazyLock::new(|| B entity_name: "replica_size", description: "Available cluster replica sizes with CPU, memory, and credit cost", links: &const { [] }, + column_semantic_types: &const { + [ + ("memory_bytes", SemanticType::ByteCount), + ("disk_bytes", SemanticType::ByteCount), + ("credits_per_hour", SemanticType::CreditRate), + ] + }, }), }); @@ -5357,17 +5181,12 @@ pub static MZ_AUDIT_EVENTS: LazyLock = LazyLock::new(|| BuiltinTab desc: RelationDesc::builder() .with_column("id", SqlScalarType::UInt64.nullable(false)) .with_column("event_type", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "object_type", - SqlScalarType::String.nullable(false), - SemanticType::ObjectType, - ) + .with_column("object_type", SqlScalarType::String.nullable(false)) .with_column("details", SqlScalarType::Jsonb.nullable(false)) .with_column("user", SqlScalarType::String.nullable(true)) - .with_column_semantic_type( + .with_column( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), - SemanticType::WallclockTimestamp, ) .with_key(vec![0]) .finish(), @@ -5403,6 +5222,12 @@ pub static MZ_AUDIT_EVENTS: LazyLock = LazyLock::new(|| BuiltinTab entity_name: "audit_event", description: "An audit log entry recording a DDL operation", links: &const { [] }, + column_semantic_types: &const { + [ + ("object_type", SemanticType::ObjectType), + ("occurred_at", SemanticType::WallclockTimestamp), + ] + }, }), }); @@ -5467,6 +5292,13 @@ pub static MZ_SOURCE_STATUS_HISTORY: LazyLock = LazyLock::new(|| }, ] }, + column_semantic_types: &const { + [ + ("occurred_at", SemanticType::WallclockTimestamp), + ("source_id", SemanticType::GlobalId), + ("replica_id", SemanticType::ReplicaId), + ] + }, }), }); @@ -5502,11 +5334,7 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUSES: LazyLock = LazyL schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_AWS_PRIVATELINK_CONNECTION_STATUSES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) .with_column( "last_status_change_at", @@ -5566,6 +5394,7 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUSES: LazyLock = LazyL properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), } }); @@ -5653,6 +5482,7 @@ pub static MZ_SQL_TEXT: LazyLock = LazyLock::new(|| BuiltinSource entity_name: "sql_text", description: "Raw SQL text of executed statements", links: &const { [] }, + column_semantic_types: &[], }), }); @@ -5686,11 +5516,7 @@ pub static MZ_RECENT_SQL_TEXT: LazyLock = LazyLock::new(|| { // could have a `prepared day` anywhere from 3 to 4 days back. desc: RelationDesc::builder() .with_column("sql_hash", SqlScalarType::Bytes.nullable(false)) - .with_column_semantic_type( - "sql", - SqlScalarType::String.nullable(false), - SemanticType::SqlDefinition, - ) + .with_column("sql", SqlScalarType::String.nullable(false)) .with_column("redacted_sql", SqlScalarType::String.nullable(false)) .with_key(vec![0, 1, 2]) .finish(), @@ -5701,6 +5527,7 @@ pub static MZ_RECENT_SQL_TEXT: LazyLock = LazyLock::new(|| { entity_name: "recent_sql_text", description: "Recent SQL text (indexed, last ~3-4 days)", links: &const { [] }, + column_semantic_types: &[("sql", SemanticType::SqlDefinition)], }), } }); @@ -5768,6 +5595,7 @@ pub static MZ_SESSION_HISTORY: LazyLock = LazyLock::new(|| Builti properties: LinkProperties::fk_nullable("session_id", "id", Cardinality::ManyToOne), }] }, + column_semantic_types: &[("connected_at", SemanticType::WallclockTimestamp)], }), }); @@ -5881,11 +5709,7 @@ pub static MZ_RECENT_ACTIVITY_LOG: LazyLock = LazyLock::new(|| Buil desc: RelationDesc::builder() .with_column("execution_id", SqlScalarType::Uuid.nullable(false)) .with_column("sample_rate", SqlScalarType::Float64.nullable(false)) - .with_column_semantic_type( - "cluster_id", - SqlScalarType::String.nullable(true), - SemanticType::ClusterId, - ) + .with_column("cluster_id", SqlScalarType::String.nullable(true)) .with_column("application_name", SqlScalarType::String.nullable(false)) .with_column("cluster_name", SqlScalarType::String.nullable(true)) .with_column("database_name", SqlScalarType::String.nullable(false)) @@ -5901,30 +5725,20 @@ pub static MZ_RECENT_ACTIVITY_LOG: LazyLock = LazyLock::new(|| Buil "transaction_isolation", SqlScalarType::String.nullable(false), ) - .with_column_semantic_type( - "execution_timestamp", - SqlScalarType::UInt64.nullable(true), - SemanticType::MzTimestamp, - ) - .with_column_semantic_type( - "transient_index_id", - SqlScalarType::String.nullable(true), - SemanticType::GlobalId, - ) + .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true)) + .with_column("transient_index_id", SqlScalarType::String.nullable(true)) .with_column( "params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), ) .with_column("mz_version", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( + .with_column( "began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), - SemanticType::WallclockTimestamp, ) - .with_column_semantic_type( + .with_column( "finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true), - SemanticType::WallclockTimestamp, ) .with_column("finished_status", SqlScalarType::String.nullable(true)) .with_column("error_message", SqlScalarType::String.nullable(true)) @@ -5939,28 +5753,22 @@ pub static MZ_RECENT_ACTIVITY_LOG: LazyLock = LazyLock::new(|| Buil SqlScalarType::String.nullable(false), ) .with_column("session_id", SqlScalarType::Uuid.nullable(false)) - .with_column_semantic_type( + .with_column( "prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), - SemanticType::WallclockTimestamp, ) .with_column("statement_type", SqlScalarType::String.nullable(true)) .with_column("throttled_count", SqlScalarType::UInt64.nullable(false)) - .with_column_semantic_type( + .with_column( "connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), - SemanticType::WallclockTimestamp, ) .with_column( "initial_application_name", SqlScalarType::String.nullable(false), ) .with_column("authenticated_user", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "sql", - SqlScalarType::String.nullable(false), - SemanticType::SqlDefinition, - ) + .with_column("sql", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -6133,6 +5941,18 @@ WHERE mralt.sql_hash = mrst.sql_hash", }, ] }, + column_semantic_types: &const { + [ + ("cluster_id", SemanticType::ClusterId), + ("execution_timestamp", SemanticType::MzTimestamp), + ("transient_index_id", SemanticType::GlobalId), + ("began_at", SemanticType::WallclockTimestamp), + ("finished_at", SemanticType::WallclockTimestamp), + ("prepared_at", SemanticType::WallclockTimestamp), + ("connected_at", SemanticType::WallclockTimestamp), + ("sql", SemanticType::SqlDefinition), + ] + }, }), }); @@ -6238,6 +6058,7 @@ pub static MZ_STATEMENT_LIFECYCLE_HISTORY: LazyLock = LazyLock::n ), }] }, + column_semantic_types: &[], }), } }); @@ -6247,21 +6068,12 @@ pub static MZ_SOURCE_STATUSES: LazyLock = LazyLock::new(|| BuiltinV schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_SOURCE_STATUSES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "type", - SqlScalarType::String.nullable(false), - SemanticType::SourceType, - ) - .with_column_semantic_type( + .with_column("type", SqlScalarType::String.nullable(false)) + .with_column( "last_status_change_at", SqlScalarType::TimestampTz { precision: None }.nullable(true), - SemanticType::WallclockTimestamp, ) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) @@ -6440,6 +6252,13 @@ WHERE id NOT LIKE 's%';", properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("type", SemanticType::SourceType), + ("last_status_change_at", SemanticType::WallclockTimestamp), + ] + }, }), }); @@ -6504,6 +6323,13 @@ pub static MZ_SINK_STATUS_HISTORY: LazyLock = LazyLock::new(|| Bu }, ] }, + column_semantic_types: &const { + [ + ("occurred_at", SemanticType::WallclockTimestamp), + ("sink_id", SemanticType::GlobalId), + ("replica_id", SemanticType::ReplicaId), + ] + }, }), }); @@ -6512,17 +6338,12 @@ pub static MZ_SINK_STATUSES: LazyLock = LazyLock::new(|| BuiltinVie schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_SINK_STATUSES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( + .with_column( "last_status_change_at", SqlScalarType::TimestampTz { precision: None }.nullable(true), - SemanticType::WallclockTimestamp, ) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) @@ -6630,6 +6451,12 @@ WHERE ), }] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("last_status_change_at", SemanticType::WallclockTimestamp), + ] + }, }), }); @@ -6646,20 +6473,11 @@ pub static MZ_STORAGE_USAGE_BY_SHARD: LazyLock = LazyLock::new(|| oid: oid::TABLE_MZ_STORAGE_USAGE_BY_SHARD_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::UInt64.nullable(false)) - .with_column_semantic_type( - "shard_id", - SqlScalarType::String.nullable(true), - SemanticType::ShardId, - ) - .with_column_semantic_type( - "size_bytes", - SqlScalarType::UInt64.nullable(false), - SemanticType::ByteCount, - ) - .with_column_semantic_type( + .with_column("shard_id", SqlScalarType::String.nullable(true)) + .with_column("size_bytes", SqlScalarType::UInt64.nullable(false)) + .with_column( "collection_timestamp", SqlScalarType::TimestampTz { precision: None }.nullable(false), - SemanticType::WallclockTimestamp, ) .finish(), column_comments: BTreeMap::new(), @@ -6669,6 +6487,13 @@ pub static MZ_STORAGE_USAGE_BY_SHARD: LazyLock = LazyLock::new(|| entity_name: "storage_usage_by_shard", description: "Storage usage broken down by shard", links: &const { [] }, + column_semantic_types: &const { + [ + ("shard_id", SemanticType::ShardId), + ("size_bytes", SemanticType::ByteCount), + ("collection_timestamp", SemanticType::WallclockTimestamp), + ] + }, }), }); @@ -6695,6 +6520,7 @@ pub static MZ_EGRESS_IPS: LazyLock = LazyLock::new(|| BuiltinTable entity_name: "egress_ip", description: "IP addresses used for outbound connections from Materialize", links: &const { [] }, + column_semantic_types: &[], }), }); @@ -6704,11 +6530,7 @@ pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock = schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_AWS_PRIVATELINK_CONNECTIONS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("principal", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -6730,6 +6552,7 @@ pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock = properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); @@ -6821,6 +6644,7 @@ pub static MZ_AWS_CONNECTIONS: LazyLock = LazyLock::new(|| Builtin properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[], }), }); @@ -6860,33 +6684,13 @@ pub static MZ_CLUSTER_REPLICA_METRICS: LazyLock = LazyLock::new(|| schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_CLUSTER_REPLICA_METRICS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(false), - SemanticType::ReplicaId, - ) + .with_column("replica_id", SqlScalarType::String.nullable(false)) .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(true)) - .with_column_semantic_type( - "memory_bytes", - SqlScalarType::UInt64.nullable(true), - SemanticType::ByteCount, - ) - .with_column_semantic_type( - "disk_bytes", - SqlScalarType::UInt64.nullable(true), - SemanticType::ByteCount, - ) - .with_column_semantic_type( - "heap_bytes", - SqlScalarType::UInt64.nullable(true), - SemanticType::ByteCount, - ) - .with_column_semantic_type( - "heap_limit", - SqlScalarType::UInt64.nullable(true), - SemanticType::ByteCount, - ) + .with_column("memory_bytes", SqlScalarType::UInt64.nullable(true)) + .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true)) + .with_column("heap_bytes", SqlScalarType::UInt64.nullable(true)) + .with_column("heap_limit", SqlScalarType::UInt64.nullable(true)) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -6933,6 +6737,15 @@ ORDER BY replica_id, process_id, occurred_at DESC", ), }] }, + column_semantic_types: &const { + [ + ("replica_id", SemanticType::ReplicaId), + ("memory_bytes", SemanticType::ByteCount), + ("disk_bytes", SemanticType::ByteCount), + ("heap_bytes", SemanticType::ByteCount), + ("heap_limit", SemanticType::ByteCount), + ] + }, }), }); @@ -6943,21 +6756,9 @@ pub static MZ_CLUSTER_REPLICA_FRONTIERS: LazyLock = oid: oid::SOURCE_MZ_CLUSTER_REPLICA_FRONTIERS_OID, data_source: IntrospectionType::ReplicaFrontiers.into(), desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(false), - SemanticType::ReplicaId, - ) - .with_column_semantic_type( - "write_frontier", - SqlScalarType::MzTimestamp.nullable(true), - SemanticType::MzTimestamp, - ) + .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_column("replica_id", SqlScalarType::String.nullable(false)) + .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -6990,21 +6791,9 @@ pub static MZ_FRONTIERS: LazyLock = LazyLock::new(|| BuiltinSourc oid: oid::SOURCE_MZ_FRONTIERS_OID, data_source: IntrospectionType::Frontiers.into(), desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) - .with_column_semantic_type( - "read_frontier", - SqlScalarType::MzTimestamp.nullable(true), - SemanticType::MzTimestamp, - ) - .with_column_semantic_type( - "write_frontier", - SqlScalarType::MzTimestamp.nullable(true), - SemanticType::MzTimestamp, - ) + .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_column("read_frontier", SqlScalarType::MzTimestamp.nullable(true)) + .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -7038,6 +6827,13 @@ pub static MZ_FRONTIERS: LazyLock = LazyLock::new(|| BuiltinSourc ), }] }, + column_semantic_types: &const { + [ + ("object_id", SemanticType::GlobalId), + ("read_frontier", SemanticType::MzTimestamp), + ("write_frontier", SemanticType::MzTimestamp), + ] + }, }), }); @@ -7047,16 +6843,8 @@ pub static MZ_GLOBAL_FRONTIERS: LazyLock = LazyLock::new(|| Builtin schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_GLOBAL_FRONTIERS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) - .with_column_semantic_type( - "time", - SqlScalarType::MzTimestamp.nullable(false), - SemanticType::MzTimestamp, - ) + .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) .finish(), column_comments: BTreeMap::new(), sql: " @@ -7120,6 +6908,13 @@ pub static MZ_WALLCLOCK_LAG_HISTORY: LazyLock = LazyLock::new(|| }, ] }, + column_semantic_types: &const { + [ + ("object_id", SemanticType::GlobalId), + ("replica_id", SemanticType::ReplicaId), + ("occurred_at", SemanticType::WallclockTimestamp), + ] + }, }), }); @@ -7128,16 +6923,11 @@ pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTORY: LazyLock = LazyLock::ne schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_HISTORY_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) + .with_column("object_id", SqlScalarType::String.nullable(false)) .with_column("lag", SqlScalarType::Interval.nullable(true)) - .with_column_semantic_type( + .with_column( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), - SemanticType::WallclockTimestamp, ) .with_key(vec![0, 2]) .finish(), @@ -7181,6 +6971,12 @@ OPTIONS (AGGREGATE INPUT GROUP SIZE = 1)", properties: LinkProperties::fk("object_id", "global_id", Cardinality::ManyToOne), }] }, + column_semantic_types: &const { + [ + ("object_id", SemanticType::GlobalId), + ("occurred_at", SemanticType::WallclockTimestamp), + ] + }, }), }); @@ -7190,11 +6986,7 @@ pub static MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY: LazyLock = LazyL schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) + .with_column("object_id", SqlScalarType::String.nullable(false)) .with_column("lag", SqlScalarType::Interval.nullable(true)) .with_column( "occurred_at", @@ -7230,11 +7022,7 @@ pub static MZ_WALLCLOCK_GLOBAL_LAG: LazyLock = LazyLock::new(|| Bui schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) + .with_column("object_id", SqlScalarType::String.nullable(false)) .with_column("lag", SqlScalarType::Interval.nullable(true)) .with_key(vec![0]) .finish(), @@ -7270,6 +7058,7 @@ ORDER BY object_id, occurred_at DESC", ), }] }, + column_semantic_types: &[("object_id", SemanticType::GlobalId)], }), }); @@ -7359,17 +7148,9 @@ pub static MZ_SUBSCRIPTIONS: LazyLock = LazyLock::new(|| BuiltinTa schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_SUBSCRIPTIONS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("session_id", SqlScalarType::Uuid.nullable(false)) - .with_column_semantic_type( - "cluster_id", - SqlScalarType::String.nullable(false), - SemanticType::ClusterId, - ) + .with_column("cluster_id", SqlScalarType::String.nullable(false)) .with_column( "created_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), @@ -7430,6 +7211,12 @@ pub static MZ_SUBSCRIPTIONS: LazyLock = LazyLock::new(|| BuiltinTa }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("cluster_id", SemanticType::ClusterId), + ] + }, }), }); @@ -7440,11 +7227,7 @@ pub static MZ_SESSIONS: LazyLock = LazyLock::new(|| BuiltinTable { desc: RelationDesc::builder() .with_column("id", SqlScalarType::Uuid.nullable(false)) .with_column("connection_id", SqlScalarType::UInt32.nullable(false)) - .with_column_semantic_type( - "role_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) + .with_column("role_id", SqlScalarType::String.nullable(false)) .with_column("client_ip", SqlScalarType::String.nullable(true)) .with_column( "connected_at", @@ -7482,6 +7265,7 @@ pub static MZ_SESSIONS: LazyLock = LazyLock::new(|| BuiltinTable { properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne), }] }, + column_semantic_types: &[("role_id", SemanticType::RoleId)], }), }); @@ -7490,31 +7274,11 @@ pub static MZ_DEFAULT_PRIVILEGES: LazyLock = LazyLock::new(|| Buil schema: MZ_CATALOG_SCHEMA, oid: oid::TABLE_MZ_DEFAULT_PRIVILEGES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "role_id", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) - .with_column_semantic_type( - "database_id", - SqlScalarType::String.nullable(true), - SemanticType::DatabaseId, - ) - .with_column_semantic_type( - "schema_id", - SqlScalarType::String.nullable(true), - SemanticType::SchemaId, - ) - .with_column_semantic_type( - "object_type", - SqlScalarType::String.nullable(false), - SemanticType::ObjectType, - ) - .with_column_semantic_type( - "grantee", - SqlScalarType::String.nullable(false), - SemanticType::RoleId, - ) + .with_column("role_id", SqlScalarType::String.nullable(false)) + .with_column("database_id", SqlScalarType::String.nullable(true)) + .with_column("schema_id", SqlScalarType::String.nullable(true)) + .with_column("object_type", SqlScalarType::String.nullable(false)) + .with_column("grantee", SqlScalarType::String.nullable(false)) .with_column("privileges", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -7577,6 +7341,15 @@ pub static MZ_DEFAULT_PRIVILEGES: LazyLock = LazyLock::new(|| Buil }, ] }, + column_semantic_types: &const { + [ + ("role_id", SemanticType::RoleId), + ("database_id", SemanticType::DatabaseId), + ("schema_id", SemanticType::SchemaId), + ("object_type", SemanticType::ObjectType), + ("grantee", SemanticType::RoleId), + ] + }, }), }); @@ -7597,6 +7370,7 @@ pub static MZ_SYSTEM_PRIVILEGES: LazyLock = LazyLock::new(|| Built entity_name: "system_privilege", description: "A system-level privilege grant", links: &const { [] }, + column_semantic_types: &[], }), }); @@ -7605,16 +7379,8 @@ pub static MZ_COMMENTS: LazyLock = LazyLock::new(|| BuiltinTable { schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_COMMENTS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( - "object_type", - SqlScalarType::String.nullable(false), - SemanticType::ObjectType, - ) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("object_type", SqlScalarType::String.nullable(false)) .with_column("object_sub_id", SqlScalarType::Int32.nullable(true)) .with_column("comment", SqlScalarType::String.nullable(false)) .finish(), @@ -7650,6 +7416,12 @@ pub static MZ_COMMENTS: LazyLock = LazyLock::new(|| BuiltinTable { ), }] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("object_type", SemanticType::ObjectType), + ] + }, }), }); @@ -7658,11 +7430,7 @@ pub static MZ_SOURCE_REFERENCES: LazyLock = LazyLock::new(|| Built schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_SOURCE_REFERENCES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "source_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("source_id", SqlScalarType::String.nullable(false)) .with_column("namespace", SqlScalarType::String.nullable(true)) .with_column("name", SqlScalarType::String.nullable(false)) .with_column( @@ -7687,6 +7455,7 @@ pub static MZ_SOURCE_REFERENCES: LazyLock = LazyLock::new(|| Built properties: LinkProperties::fk("source_id", "id", Cardinality::ManyToOne), }] }, + column_semantic_types: &[("source_id", SemanticType::CatalogItemId)], }), }); @@ -7695,11 +7464,7 @@ pub static MZ_WEBHOOKS_SOURCES: LazyLock = LazyLock::new(|| Builti schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_WEBHOOK_SOURCES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) .with_column("url", SqlScalarType::String.nullable(false)) .finish(), @@ -7726,6 +7491,7 @@ pub static MZ_WEBHOOKS_SOURCES: LazyLock = LazyLock::new(|| Builti properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); @@ -7735,11 +7501,7 @@ pub static MZ_HISTORY_RETENTION_STRATEGIES: LazyLock = LazyLock::n schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_HISTORY_RETENTION_STRATEGIES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("strategy", SqlScalarType::String.nullable(false)) .with_column("value", SqlScalarType::Jsonb.nullable(false)) .finish(), @@ -7760,6 +7522,7 @@ pub static MZ_HISTORY_RETENTION_STRATEGIES: LazyLock = LazyLock::n entity_name: "history_retention", description: "History retention strategy for an object", links: &const { [] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), } }); @@ -7769,11 +7532,7 @@ pub static MZ_LICENSE_KEYS: LazyLock = LazyLock::new(|| BuiltinTab schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_LICENSE_KEYS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("organization", SqlScalarType::String.nullable(false)) .with_column("environment_id", SqlScalarType::String.nullable(false)) .with_column( @@ -7810,6 +7569,7 @@ pub static MZ_LICENSE_KEYS: LazyLock = LazyLock::new(|| BuiltinTab entity_name: "license_key", description: "License key metadata", links: &const { [] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); @@ -7818,11 +7578,7 @@ pub static MZ_REPLACEMENTS: LazyLock = LazyLock::new(|| BuiltinTab schema: MZ_INTERNAL_SCHEMA, oid: oid::TABLE_MZ_REPLACEMENTS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("target_id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -7854,6 +7610,7 @@ pub static MZ_REPLACEMENTS: LazyLock = LazyLock::new(|| BuiltinTab }, ] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); @@ -7888,16 +7645,8 @@ pub static MZ_STORAGE_SHARDS: LazyLock = LazyLock::new(|| Builtin oid: oid::SOURCE_MZ_STORAGE_SHARDS_OID, data_source: IntrospectionType::ShardMapping.into(), desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) - .with_column_semantic_type( - "shard_id", - SqlScalarType::String.nullable(false), - SemanticType::ShardId, - ) + .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_column("shard_id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::new(), is_retained_metrics_object: false, @@ -7918,6 +7667,12 @@ pub static MZ_STORAGE_SHARDS: LazyLock = LazyLock::new(|| Builtin ), }] }, + column_semantic_types: &const { + [ + ("object_id", SemanticType::GlobalId), + ("shard_id", SemanticType::ShardId), + ] + }, }), }); @@ -7926,20 +7681,11 @@ pub static MZ_STORAGE_USAGE: LazyLock = LazyLock::new(|| BuiltinVie schema: MZ_CATALOG_SCHEMA, oid: oid::VIEW_MZ_STORAGE_USAGE_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( - "size_bytes", - SqlScalarType::UInt64.nullable(false), - SemanticType::ByteCount, - ) - .with_column_semantic_type( + .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_column("size_bytes", SqlScalarType::UInt64.nullable(false)) + .with_column( "collection_timestamp", SqlScalarType::TimestampTz { precision: None }.nullable(false), - SemanticType::WallclockTimestamp, ) .with_key(vec![0, 2]) .finish(), @@ -7977,6 +7723,13 @@ GROUP BY object_id, collection_timestamp", properties: LinkProperties::fk("object_id", "id", Cardinality::ManyToOne), }] }, + column_semantic_types: &const { + [ + ("object_id", SemanticType::CatalogItemId), + ("size_bytes", SemanticType::ByteCount), + ("collection_timestamp", SemanticType::WallclockTimestamp), + ] + }, }), }); @@ -7986,8 +7739,8 @@ pub static MZ_RECENT_STORAGE_USAGE: LazyLock = LazyLock::new(|| { schema: MZ_CATALOG_SCHEMA, oid: oid::VIEW_MZ_RECENT_STORAGE_USAGE_OID, desc: RelationDesc::builder() - .with_column_semantic_type("object_id", SqlScalarType::String.nullable(false), SemanticType::CatalogItemId) - .with_column_semantic_type("size_bytes", SqlScalarType::UInt64.nullable(true), SemanticType::ByteCount) + .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_column("size_bytes", SqlScalarType::UInt64.nullable(true)) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -8028,6 +7781,7 @@ GROUP BY object_id", links: &const { [ OntologyLink { name: "recent_storage_of", target: "object", properties: LinkProperties::fk("object_id", "id", Cardinality::OneToOne) }, ] }, + column_semantic_types: &const {[("object_id", SemanticType::CatalogItemId), ("size_bytes", SemanticType::ByteCount)]}, }), } }); @@ -8046,13 +7800,13 @@ pub static MZ_RELATIONS: LazyLock = LazyLock::new(|| { schema: MZ_CATALOG_SCHEMA, oid: oid::VIEW_MZ_RELATIONS_OID, desc: RelationDesc::builder() - .with_column_semantic_type("id", SqlScalarType::String.nullable(false), SemanticType::CatalogItemId) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) - .with_column_semantic_type("schema_id", SqlScalarType::String.nullable(false), SemanticType::SchemaId) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type("type", SqlScalarType::String.nullable(false), SemanticType::ObjectType) - .with_column_semantic_type("owner_id", SqlScalarType::String.nullable(false), SemanticType::RoleId) - .with_column_semantic_type("cluster_id", SqlScalarType::String.nullable(true), SemanticType::ClusterId) + .with_column("type", SqlScalarType::String.nullable(false)) + .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_column("cluster_id", SqlScalarType::String.nullable(true)) .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -8080,6 +7834,7 @@ UNION ALL SELECT id, oid, schema_id, name, 'materialized-view', owner_id, cluste OntologyLink { name: "union_includes", target: "view", properties: LinkProperties::union_disc("type", "view") }, OntologyLink { name: "union_includes", target: "mv", properties: LinkProperties::union_disc("type", "materialized-view") }, ] }, + column_semantic_types: &const {[("id", SemanticType::CatalogItemId), ("oid", SemanticType::OID), ("schema_id", SemanticType::SchemaId), ("type", SemanticType::ObjectType), ("owner_id", SemanticType::RoleId), ("cluster_id", SemanticType::ClusterId)]}, }), } }); @@ -8147,13 +7902,13 @@ pub static MZ_OBJECTS: LazyLock = LazyLock::new(|| { schema: MZ_CATALOG_SCHEMA, oid: oid::VIEW_MZ_OBJECTS_OID, desc: RelationDesc::builder() - .with_column_semantic_type("id", SqlScalarType::String.nullable(false), SemanticType::CatalogItemId) - .with_column_semantic_type("oid", SqlScalarType::Oid.nullable(false), SemanticType::OID) - .with_column_semantic_type("schema_id", SqlScalarType::String.nullable(false), SemanticType::SchemaId) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type("type", SqlScalarType::String.nullable(false), SemanticType::ObjectType) - .with_column_semantic_type("owner_id", SqlScalarType::String.nullable(false), SemanticType::RoleId) - .with_column_semantic_type("cluster_id", SqlScalarType::String.nullable(true), SemanticType::ClusterId) + .with_column("type", SqlScalarType::String.nullable(false)) + .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_column("cluster_id", SqlScalarType::String.nullable(true)) .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ @@ -8204,6 +7959,7 @@ UNION ALL note: Some("A CatalogItemId (SQL layer) maps to one or more GlobalIds (runtime layer)."), } }, ] }, + column_semantic_types: &const {[("id", SemanticType::CatalogItemId), ("oid", SemanticType::OID), ("schema_id", SemanticType::SchemaId), ("type", SemanticType::ObjectType), ("owner_id", SemanticType::RoleId), ("cluster_id", SemanticType::ClusterId)]}, }), } }); @@ -8213,34 +7969,14 @@ pub static MZ_OBJECT_FULLY_QUALIFIED_NAMES: LazyLock = LazyLock::ne schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_OBJECT_FULLY_QUALIFIED_NAMES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "object_type", - SqlScalarType::String.nullable(false), - SemanticType::ObjectType, - ) - .with_column_semantic_type( - "schema_id", - SqlScalarType::String.nullable(false), - SemanticType::SchemaId, - ) + .with_column("object_type", SqlScalarType::String.nullable(false)) + .with_column("schema_id", SqlScalarType::String.nullable(false)) .with_column("schema_name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "database_id", - SqlScalarType::String.nullable(true), - SemanticType::DatabaseId, - ) + .with_column("database_id", SqlScalarType::String.nullable(true)) .with_column("database_name", SqlScalarType::String.nullable(true)) - .with_column_semantic_type( - "cluster_id", - SqlScalarType::String.nullable(true), - SemanticType::ClusterId, - ) + .with_column("cluster_id", SqlScalarType::String.nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ ("id", "Materialize's unique ID for the object."), @@ -8311,6 +8047,15 @@ pub static MZ_OBJECT_FULLY_QUALIFIED_NAMES: LazyLock = LazyLock::ne }, ] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("object_type", SemanticType::ObjectType), + ("schema_id", SemanticType::SchemaId), + ("database_id", SemanticType::DatabaseId), + ("cluster_id", SemanticType::ClusterId), + ] + }, }), }); @@ -8319,11 +8064,7 @@ pub static MZ_OBJECT_GLOBAL_IDS: LazyLock = LazyLock::new(|| Built schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_OBJECT_GLOBAL_IDS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(false)) .with_column("global_id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ @@ -8352,6 +8093,7 @@ pub static MZ_OBJECT_GLOBAL_IDS: LazyLock = LazyLock::new(|| Built }, }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); @@ -8361,17 +8103,9 @@ pub static MZ_OBJECT_LIFETIMES: LazyLock = LazyLock::new(|| Builtin schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_OBJECT_LIFETIMES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(true), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(true)) .with_column("previous_id", SqlScalarType::String.nullable(true)) - .with_column_semantic_type( - "object_type", - SqlScalarType::String.nullable(false), - SemanticType::ObjectType, - ) + .with_column("object_type", SqlScalarType::String.nullable(false)) .with_column("event_type", SqlScalarType::String.nullable(false)) .with_column( "occurred_at", @@ -8422,6 +8156,12 @@ pub static MZ_OBJECT_LIFETIMES: LazyLock = LazyLock::new(|| Builtin ), }] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("object_type", SemanticType::ObjectType), + ] + }, }), }); @@ -8430,11 +8170,7 @@ pub static MZ_OBJECT_HISTORY: LazyLock = LazyLock::new(|| BuiltinVi schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_OBJECT_HISTORY_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(true), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(true)) .with_column("cluster_id", SqlScalarType::String.nullable(true)) .with_column("object_type", SqlScalarType::String.nullable(false)) .with_column( @@ -8522,6 +8258,7 @@ pub static MZ_OBJECT_HISTORY: LazyLock = LazyLock::new(|| BuiltinVi properties: LinkProperties::fk("id", "id", Cardinality::ManyToOne), }] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); @@ -8571,6 +8308,7 @@ WHERE worker_id = 0::uint8", entity_name: "dataflow", description: "Dataflow instances", links: &const { [] }, + column_semantic_types: &[], }), }); @@ -8615,6 +8353,7 @@ WHERE worker_id = 0::uint8", properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[], }), }); @@ -8669,6 +8408,7 @@ WHERE worker_id = 0::uint8", }, }] }, + column_semantic_types: &[], }), }); @@ -8694,6 +8434,7 @@ WHERE worker_id = 0::uint8", entity_name: "dataflow_operator", description: "Operators within dataflows", links: &const { [] }, + column_semantic_types: &[], }), }); @@ -8703,11 +8444,7 @@ pub static MZ_DATAFLOW_GLOBAL_IDS: LazyLock = LazyLock::new(|| Buil oid: oid::VIEW_MZ_DATAFLOW_GLOBAL_IDS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::UInt64.nullable(false)) - .with_column_semantic_type( - "global_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) + .with_column("global_id", SqlScalarType::String.nullable(false)) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -8728,11 +8465,7 @@ pub static MZ_MAPPABLE_OBJECTS: LazyLock = LazyLock::new(|| Builtin oid: oid::VIEW_MZ_MAPPABLE_OBJECTS_OID, desc: RelationDesc::builder() .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "global_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) + .with_column("global_id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -8753,6 +8486,7 @@ FROM mz_catalog.mz_objects mo entity_name: "mappable_object", description: "Objects that can be mapped to dataflow operators", links: &const { [] }, + column_semantic_types: &[("global_id", SemanticType::GlobalId)], }), }); @@ -8761,11 +8495,7 @@ pub static MZ_LIR_MAPPING: LazyLock = LazyLock::new(|| BuiltinView schema: MZ_INTROSPECTION_SCHEMA, oid: oid::VIEW_MZ_LIR_MAPPING_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "global_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) + .with_column("global_id", SqlScalarType::String.nullable(false)) .with_column("lir_id", SqlScalarType::UInt64.nullable(false)) .with_column("operator", SqlScalarType::String.nullable(false)) .with_column("parent_lir_id", SqlScalarType::UInt64.nullable(true)) @@ -8804,6 +8534,7 @@ WHERE worker_id = 0::uint8", entity_name: "lir_mapping", description: "LIR (low-level IR) to dataflow operator mapping", links: &const { [] }, + column_semantic_types: &[("global_id", SemanticType::GlobalId)], }), }); @@ -8879,6 +8610,7 @@ WHERE worker_id = 0::uint8", properties: LinkProperties::fk("dataflow_id", "id", Cardinality::ManyToOne), }] }, + column_semantic_types: &[], }), }); @@ -8888,15 +8620,10 @@ pub static MZ_OBJECT_TRANSITIVE_DEPENDENCIES: LazyLock = LazyLock:: schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_OBJECT_TRANSITIVE_DEPENDENCIES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( + .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_column( "referenced_object_id", SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, ) .with_key(vec![0, 1]) .finish(), @@ -8946,6 +8673,12 @@ SELECT object_id, referenced_object_id FROM reach;", }, ] }, + column_semantic_types: &const { + [ + ("object_id", SemanticType::CatalogItemId), + ("referenced_object_id", SemanticType::CatalogItemId), + ] + }, }), } }); @@ -8955,11 +8688,7 @@ pub static MZ_COMPUTE_EXPORTS: LazyLock = LazyLock::new(|| BuiltinV schema: MZ_INTROSPECTION_SCHEMA, oid: oid::VIEW_MZ_COMPUTE_EXPORTS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "export_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) + .with_column("export_id", SqlScalarType::String.nullable(false)) .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false)) .with_key(vec![0]) .finish(), @@ -9010,6 +8739,7 @@ WHERE worker_id = 0::uint8", }, ] }, + column_semantic_types: &[("export_id", SemanticType::GlobalId)], }), }); @@ -9018,16 +8748,8 @@ pub static MZ_COMPUTE_FRONTIERS: LazyLock = LazyLock::new(|| Builti schema: MZ_INTROSPECTION_SCHEMA, oid: oid::VIEW_MZ_COMPUTE_FRONTIERS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "export_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) - .with_column_semantic_type( - "time", - SqlScalarType::MzTimestamp.nullable(false), - SemanticType::MzTimestamp, - ) + .with_column("export_id", SqlScalarType::String.nullable(false)) + .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -9061,6 +8783,12 @@ GROUP BY export_id", ), }] }, + column_semantic_types: &const { + [ + ("export_id", SemanticType::GlobalId), + ("time", SemanticType::MzTimestamp), + ] + }, }), }); @@ -9195,21 +8923,9 @@ pub static MZ_COMPUTE_IMPORT_FRONTIERS: LazyLock = LazyLock::new(|| schema: MZ_INTROSPECTION_SCHEMA, oid: oid::VIEW_MZ_COMPUTE_IMPORT_FRONTIERS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "export_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) - .with_column_semantic_type( - "import_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) - .with_column_semantic_type( - "time", - SqlScalarType::MzTimestamp.nullable(false), - SemanticType::MzTimestamp, - ) + .with_column("export_id", SqlScalarType::String.nullable(false)) + .with_column("import_id", SqlScalarType::String.nullable(false)) + .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -9247,6 +8963,13 @@ GROUP BY export_id, import_id", ), }] }, + column_semantic_types: &const { + [ + ("export_id", SemanticType::GlobalId), + ("import_id", SemanticType::GlobalId), + ("time", SemanticType::MzTimestamp), + ] + }, }), }); @@ -9439,6 +9162,7 @@ GROUP BY properties: LinkProperties::fk("id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[], }), }); @@ -10720,6 +10444,7 @@ GROUP BY type, duration_ns", entity_name: "peek_duration", description: "Histogram of SELECT query durations", links: &const { [] }, + column_semantic_types: &[], }), }); @@ -10787,6 +10512,7 @@ GROUP BY id", properties: LinkProperties::measures("id", "id", "cpu_time_ns"), }] }, + column_semantic_types: &[], }), }); @@ -10920,6 +10646,7 @@ GROUP BY slept_for_ns, requested_ns", entity_name: "scheduling_parks", description: "Histogram of operator park durations", links: &const { [] }, + column_semantic_types: &[], }), }); @@ -10972,11 +10699,7 @@ pub static MZ_COMPUTE_ERROR_COUNTS: LazyLock = LazyLock::new(|| Bui schema: MZ_INTROSPECTION_SCHEMA, oid: oid::VIEW_MZ_COMPUTE_ERROR_COUNTS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "export_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) + .with_column("export_id", SqlScalarType::String.nullable(false)) .with_column( "count", SqlScalarType::Numeric { @@ -11014,6 +10737,7 @@ HAVING pg_catalog.sum(count) != 0", properties: LinkProperties::fk("export_id", "export_id", Cardinality::OneToOne), }] }, + column_semantic_types: &[("export_id", SemanticType::GlobalId)], }), }); @@ -11026,16 +10750,8 @@ pub static MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED: LazyLock = schema: MZ_INTERNAL_SCHEMA, oid: oid::SOURCE_MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(false), - SemanticType::ReplicaId, - ) - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("replica_id", SqlScalarType::String.nullable(false)) + .with_column("object_id", SqlScalarType::String.nullable(false)) .with_column( "count", SqlScalarType::Numeric { max_scale: None }.nullable(false), @@ -11053,16 +10769,8 @@ pub static MZ_COMPUTE_HYDRATION_TIMES: LazyLock = LazyLock::new(| schema: MZ_INTERNAL_SCHEMA, oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_TIMES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(false), - SemanticType::ReplicaId, - ) - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("replica_id", SqlScalarType::String.nullable(false)) + .with_column("object_id", SqlScalarType::String.nullable(false)) .with_column("time_ns", SqlScalarType::UInt64.nullable(true)) .finish(), data_source: IntrospectionType::ComputeHydrationTimes.into(), @@ -11073,6 +10781,12 @@ pub static MZ_COMPUTE_HYDRATION_TIMES: LazyLock = LazyLock::new(| entity_name: "compute_hydration_time", description: "Time to hydrate compute objects", links: &const { [] }, + column_semantic_types: &const { + [ + ("replica_id", SemanticType::ReplicaId), + ("object_id", SemanticType::CatalogItemId), + ] + }, }), }); @@ -11091,16 +10805,8 @@ pub static MZ_COMPUTE_HYDRATION_STATUSES: LazyLock = LazyLock::new( schema: MZ_INTERNAL_SCHEMA, oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_STATUSES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(false), - SemanticType::ReplicaId, - ) + .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_column("replica_id", SqlScalarType::String.nullable(false)) .with_column("hydrated", SqlScalarType::Bool.nullable(false)) .with_column("hydration_time", SqlScalarType::Interval.nullable(true)) .finish(), @@ -11151,6 +10857,12 @@ SELECT * FROM complete_mvs", entity_name: "compute_hydration_status_view", description: "Computed hydration status per compute object", links: &const { [] }, + column_semantic_types: &const { + [ + ("object_id", SemanticType::GlobalId), + ("replica_id", SemanticType::ReplicaId), + ] + }, }), }); @@ -11160,16 +10872,8 @@ pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES: LazyLock = Laz schema: MZ_INTERNAL_SCHEMA, oid: oid::SOURCE_MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(false), - SemanticType::ReplicaId, - ) - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("replica_id", SqlScalarType::String.nullable(false)) + .with_column("object_id", SqlScalarType::String.nullable(false)) .with_column( "physical_plan_node_id", SqlScalarType::UInt64.nullable(false), @@ -11196,6 +10900,12 @@ pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES: LazyLock = Laz entity_name: "compute_hydration_status", description: "Hydration status per compute operator", links: &const { [] }, + column_semantic_types: &const { + [ + ("replica_id", SemanticType::ReplicaId), + ("object_id", SemanticType::CatalogItemId), + ] + }, }), } }); @@ -11342,6 +11052,7 @@ GROUP BY channel_id", properties: LinkProperties::fk("channel_id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[], }), }); @@ -11351,17 +11062,9 @@ pub static MZ_ACTIVE_PEEKS: LazyLock = LazyLock::new(|| BuiltinView oid: oid::VIEW_MZ_ACTIVE_PEEKS_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::Uuid.nullable(false)) - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) + .with_column("object_id", SqlScalarType::String.nullable(false)) .with_column("type", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "time", - SqlScalarType::MzTimestamp.nullable(false), - SemanticType::MzTimestamp, - ) + .with_column("time", SqlScalarType::MzTimestamp.nullable(false)) .with_key(vec![0]) .finish(), column_comments: BTreeMap::from_iter([ @@ -11385,6 +11088,12 @@ WHERE worker_id = 0::uint8", entity_name: "active_peek", description: "Currently executing SELECT queries", links: &const { [] }, + column_semantic_types: &const { + [ + ("object_id", SemanticType::GlobalId), + ("time", SemanticType::MzTimestamp), + ] + }, }), }); @@ -11682,6 +11391,7 @@ GROUP BY operator_id", }, }] }, + column_semantic_types: &[], }), }); @@ -11742,6 +11452,7 @@ WHERE worker_id = 0::uint8", properties: LinkProperties::fk("operator_id", "id", Cardinality::OneToOne), }] }, + column_semantic_types: &[], }), }); @@ -11750,11 +11461,7 @@ pub static MZ_CLUSTER_REPLICA_UTILIZATION: LazyLock = LazyLock::new schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_CLUSTER_REPLICA_UTILIZATION_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(false), - SemanticType::ReplicaId, - ) + .with_column("replica_id", SqlScalarType::String.nullable(false)) .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("cpu_percent", SqlScalarType::Float64.nullable(true)) .with_column("memory_percent", SqlScalarType::Float64.nullable(true)) @@ -11809,6 +11516,7 @@ FROM ), }] }, + column_semantic_types: &[("replica_id", SemanticType::ReplicaId)], }), }); @@ -12173,6 +11881,7 @@ pub static MZ_EXPECTED_GROUP_SIZE_ADVICE: LazyLock = LazyLock::new( entity_name: "group_size_advice", description: "Advice on expected group sizes for reduce operators", links: &const { [] }, + column_semantic_types: &[], }), }); @@ -15129,6 +14838,7 @@ pub static MZ_CLUSTER_REPLICA_HISTORY: LazyLock = LazyLock::new(|| entity_name: "replica_history", description: "Historical record of replica creation/drops", links: &const { [] }, + column_semantic_types: &[], }), }); @@ -15141,11 +14851,7 @@ pub static MZ_CLUSTER_REPLICA_NAME_HISTORY: LazyLock = LazyLock::ne "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(true), ) - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(true), - SemanticType::CatalogItemId, - ) + .with_column("id", SqlScalarType::String.nullable(true)) .with_column("previous_name", SqlScalarType::String.nullable(true)) .with_column("new_name", SqlScalarType::String.nullable(true)) .finish(), @@ -15204,6 +14910,7 @@ FROM system_replicas"#, entity_name: "replica_name_history", description: "Historical replica names", links: &const { [] }, + column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); @@ -15212,16 +14919,8 @@ pub static MZ_HYDRATION_STATUSES: LazyLock = LazyLock::new(|| Built schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_HYDRATION_STATUSES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(true), - SemanticType::ReplicaId, - ) + .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_column("replica_id", SqlScalarType::String.nullable(true)) .with_column("hydrated", SqlScalarType::Bool.nullable(true)) .finish(), column_comments: BTreeMap::from_iter([ @@ -15320,6 +15019,12 @@ SELECT * FROM sinks"#, }, ] }, + column_semantic_types: &const { + [ + ("object_id", SemanticType::CatalogItemId), + ("replica_id", SemanticType::ReplicaId), + ] + }, }), }); @@ -15337,16 +15042,8 @@ pub static MZ_MATERIALIZATION_DEPENDENCIES: LazyLock = LazyLock::ne schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_MATERIALIZATION_DEPENDENCIES_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( - "dependency_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_column("dependency_id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([ ( @@ -15388,6 +15085,12 @@ JOIN mz_catalog.mz_relations r ON (r.id = d.referenced_object_id)", }, ] }, + column_semantic_types: &const { + [ + ("object_id", SemanticType::CatalogItemId), + ("dependency_id", SemanticType::CatalogItemId), + ] + }, }), }); @@ -15396,22 +15099,16 @@ pub static MZ_MATERIALIZATION_LAG: LazyLock = LazyLock::new(|| Buil schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_MATERIALIZATION_LAG_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) + .with_column("object_id", SqlScalarType::String.nullable(false)) .with_column("local_lag", SqlScalarType::Interval.nullable(true)) .with_column("global_lag", SqlScalarType::Interval.nullable(true)) - .with_column_semantic_type( + .with_column( "slowest_local_input_id", SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, ) - .with_column_semantic_type( + .with_column( "slowest_global_input_id", SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, ) .finish(), column_comments: BTreeMap::from_iter([ @@ -15548,6 +15245,13 @@ JOIN root_times r USING (id)", }, ] }, + column_semantic_types: &const { + [ + ("object_id", SemanticType::CatalogItemId), + ("slowest_local_input_id", SemanticType::CatalogItemId), + ("slowest_global_input_id", SemanticType::CatalogItemId), + ] + }, }), }); @@ -15971,6 +15675,7 @@ FROM mz_cluster_deployment_lineage"#, }, ] }, + column_semantic_types: &[], }), }); @@ -16437,59 +16142,25 @@ pub static MZ_SOURCE_STATISTICS: LazyLock = LazyLock::new(|| { oid: oid::VIEW_MZ_SOURCE_STATISTICS_OID, // We need to add a redundant where clause for a new dataflow to be created. desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(true), - SemanticType::ReplicaId, - ) - .with_column_semantic_type( - "messages_received", - SqlScalarType::UInt64.nullable(false), - SemanticType::RecordCount, - ) - .with_column_semantic_type( - "bytes_received", - SqlScalarType::UInt64.nullable(false), - SemanticType::ByteCount, - ) - .with_column_semantic_type( - "updates_staged", - SqlScalarType::UInt64.nullable(false), - SemanticType::RecordCount, - ) - .with_column_semantic_type( - "updates_committed", - SqlScalarType::UInt64.nullable(false), - SemanticType::RecordCount, - ) - .with_column_semantic_type( - "records_indexed", - SqlScalarType::UInt64.nullable(false), - SemanticType::RecordCount, - ) - .with_column_semantic_type( - "bytes_indexed", - SqlScalarType::UInt64.nullable(false), - SemanticType::ByteCount, - ) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("replica_id", SqlScalarType::String.nullable(true)) + .with_column("messages_received", SqlScalarType::UInt64.nullable(false)) + .with_column("bytes_received", SqlScalarType::UInt64.nullable(false)) + .with_column("updates_staged", SqlScalarType::UInt64.nullable(false)) + .with_column("updates_committed", SqlScalarType::UInt64.nullable(false)) + .with_column("records_indexed", SqlScalarType::UInt64.nullable(false)) + .with_column("bytes_indexed", SqlScalarType::UInt64.nullable(false)) .with_column( "rehydration_latency", SqlScalarType::Interval.nullable(true), ) - .with_column_semantic_type( + .with_column( "snapshot_records_known", SqlScalarType::UInt64.nullable(true), - SemanticType::RecordCount, ) - .with_column_semantic_type( + .with_column( "snapshot_records_staged", SqlScalarType::UInt64.nullable(true), - SemanticType::RecordCount, ) .with_column("snapshot_committed", SqlScalarType::Bool.nullable(false)) .with_column("offset_known", SqlScalarType::UInt64.nullable(true)) @@ -16566,6 +16237,20 @@ pub static MZ_SOURCE_STATISTICS: LazyLock = LazyLock::new(|| { properties: LinkProperties::measures("id", "id", "ingestion_statistics"), }] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("replica_id", SemanticType::ReplicaId), + ("messages_received", SemanticType::RecordCount), + ("bytes_received", SemanticType::ByteCount), + ("updates_staged", SemanticType::RecordCount), + ("updates_committed", SemanticType::RecordCount), + ("records_indexed", SemanticType::RecordCount), + ("bytes_indexed", SemanticType::ByteCount), + ("snapshot_records_known", SemanticType::RecordCount), + ("snapshot_records_staged", SemanticType::RecordCount), + ] + }, }), } }); @@ -16584,36 +16269,12 @@ pub static MZ_SINK_STATISTICS: LazyLock = LazyLock::new(|| BuiltinV schema: MZ_INTERNAL_SCHEMA, oid: oid::VIEW_MZ_SINK_STATISTICS_OID, desc: RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(true), - SemanticType::ReplicaId, - ) - .with_column_semantic_type( - "messages_staged", - SqlScalarType::UInt64.nullable(false), - SemanticType::RecordCount, - ) - .with_column_semantic_type( - "messages_committed", - SqlScalarType::UInt64.nullable(false), - SemanticType::RecordCount, - ) - .with_column_semantic_type( - "bytes_staged", - SqlScalarType::UInt64.nullable(false), - SemanticType::ByteCount, - ) - .with_column_semantic_type( - "bytes_committed", - SqlScalarType::UInt64.nullable(false), - SemanticType::ByteCount, - ) + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("replica_id", SqlScalarType::String.nullable(true)) + .with_column("messages_staged", SqlScalarType::UInt64.nullable(false)) + .with_column("messages_committed", SqlScalarType::UInt64.nullable(false)) + .with_column("bytes_staged", SqlScalarType::UInt64.nullable(false)) + .with_column("bytes_committed", SqlScalarType::UInt64.nullable(false)) .with_key(vec![0, 1]) .finish(), column_comments: BTreeMap::from_iter([ @@ -16663,6 +16324,16 @@ GROUP BY id, replica_id", properties: LinkProperties::measures("id", "id", "export_statistics"), }] }, + column_semantic_types: &const { + [ + ("id", SemanticType::CatalogItemId), + ("replica_id", SemanticType::ReplicaId), + ("messages_staged", SemanticType::RecordCount), + ("messages_committed", SemanticType::RecordCount), + ("bytes_staged", SemanticType::ByteCount), + ("bytes_committed", SemanticType::ByteCount), + ] + }, }), }); @@ -17890,28 +17561,28 @@ mod tests { // Column indices that are part of the declared key set. let pk_indices: BTreeSet = desc.typ().keys.iter().flatten().copied().collect(); - for (idx, col) in desc.iter_names().enumerate() { - let Some(sem) = desc.get_semantic_type(idx) else { - continue; - }; - if !reference_sem_types.contains(&sem) { + for (col_name, sem) in ont.column_semantic_types { + if !reference_sem_types.contains(sem) { continue; } + let Some(idx) = desc.iter_names().position(|n| n.as_str() == *col_name) else { + continue; + }; // Exempt the entity's own primary identifier: column 0 named // "id" is by convention the entity's own PK (not a FK), even // when no explicit with_key() is declared on the relation. - if idx == 0 && col.as_str() == "id" { + if idx == 0 && *col_name == "id" { continue; } if pk_indices.contains(&idx) { continue; } - if linked_cols.contains(col.as_str()) { + if linked_cols.contains(*col_name) { continue; } uncovered_fk_cols.push(format!( "entity {:?} (builtin {}) column {:?} has semantic type {:?} but no OntologyLink covers it (add a link with source_column: {:?})", - ont.entity_name, name, col.as_str(), sem, col.as_str() + ont.entity_name, name, col_name, sem, col_name )); } } diff --git a/src/catalog/src/builtin/ontology.rs b/src/catalog/src/builtin/ontology.rs index 402bfd5c8757a..08c6a332e75f5 100644 --- a/src/catalog/src/builtin/ontology.rs +++ b/src/catalog/src/builtin/ontology.rs @@ -269,7 +269,7 @@ fn semantic_types_view() -> BuiltinView { /// (column additions/removals are picked up automatically). /// /// 2. **Annotation enrichment** — A second VALUES list (`ann`) carries the -/// semantic-type annotations from `RelationDesc` (e.g. "CatalogItemId"). +/// semantic-type annotations from `Ontology::column_semantic_types`. /// Column descriptions come from `mz_comments`. Both are LEFT JOINed so /// columns without annotations or comments still appear (with NULLs). fn properties_view(infos: &[Info]) -> BuiltinView { @@ -281,14 +281,12 @@ fn properties_view(infos: &[Info]) -> BuiltinView { Lit::Str(i.table_name.to_string()), Lit::Str(i.entity_name.clone()), ]); - for (idx, col) in i.desc.iter_names().enumerate() { - if let Some(sem) = i.desc.get_semantic_type(idx) { - ann.push(vec![ - Lit::Str(i.entity_name.clone()), - Lit::Str(col.as_str().to_string()), - Lit::Str(sem.to_string()), - ]); - } + for (col_name, sem) in i.ontology.column_semantic_types { + ann.push(vec![ + Lit::Str(i.entity_name.clone()), + Lit::Str(col_name.to_string()), + Lit::Str(sem.to_string()), + ]); } } let sql = format!( diff --git a/src/persist-client/src/write.rs b/src/persist-client/src/write.rs index 5e0aeb78526ba..7485ee750cd22 100644 --- a/src/persist-client/src/write.rs +++ b/src/persist-client/src/write.rs @@ -51,7 +51,7 @@ use crate::internal::machine::{ use crate::internal::metrics::{BatchWriteMetrics, Metrics, ShardMetrics}; use crate::internal::state::{BatchPart, HandleDebugState, HollowBatch, RunOrder, RunPart}; use crate::read::ReadHandle; -use crate::schema::{CaESchema, PartMigration}; +use crate::schema::PartMigration; use crate::{GarbageCollector, IsolatedRuntime, PersistConfig, ShardId, parse_id}; pub(crate) const COMBINE_INLINE_WRITES: Config = Config::new( @@ -245,40 +245,10 @@ where let (schema_id, maintenance) = self.machine.register_schema(key, val).await; maintenance.start_performing(&self.machine, &self.gc); - if let Some(id) = schema_id { - self.write_schemas.id = Some(id); - return Some(id); - } - - // Schema registration failed because the existing schema doesn't match. - // This can happen during a rolling upgrade when metadata-only fields - // (e.g. SemanticType annotations in RelationDesc) were added to the - // schema without changing the underlying Arrow data types. Fall back to - // schema evolution, which succeeds when the Arrow types are compatible. - let schema_id = self.try_evolve_schema().await; self.write_schemas.id = schema_id; schema_id } - async fn try_evolve_schema(&self) -> Option { - let Schemas { key, val, .. } = &self.write_schemas; - let mut expected = SchemaId(0); - loop { - let (result, maintenance) = self - .machine - .compare_and_evolve_schema(expected, key, val) - .await; - maintenance.start_performing(&self.machine, &self.gc); - match result { - CaESchema::Ok(id) => return Some(id), - CaESchema::Incompatible => return None, - CaESchema::ExpectedMismatch { schema_id, .. } => { - expected = schema_id; - } - } - } - } - /// A cached version of the shard-global `upper` frontier. /// /// This is the most recent upper discovered by this handle. It is diff --git a/src/repr/src/.relation.rs.pending-snap b/src/repr/src/.relation.rs.pending-snap new file mode 100644 index 0000000000000..16b00b3986f9d --- /dev/null +++ b/src/repr/src/.relation.rs.pending-snap @@ -0,0 +1,19 @@ +{"run_id":"1777593030-947227000","line":2491,"new":{"module_name":"mz_repr__relation__tests","snapshot_name":"impl-2","metadata":{"source":"src/repr/src/relation.rs","assertion_line":2491,"expression":"v1"},"snapshot":"{\n \"typ\": {\n \"column_types\": [],\n \"keys\": []\n },\n \"metadata\": {}\n}"},"old":{"module_name":"mz_repr__relation__tests","metadata":{},"snapshot":"{\n \"typ\": {\n \"column_types\": [],\n \"keys\": []\n },\n \"metadata\": {},\n \"semantic_types\": {}\n}"}} +{"run_id":"1777593030-947227000","line":2348,"new":{"module_name":"mz_repr__relation__tests","snapshot_name":"impl-4","metadata":{"source":"src/repr/src/relation.rs","assertion_line":2348,"expression":"v1"},"snapshot":"{\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n }\n ],\n \"keys\": [\n [\n 0\n ]\n ]\n },\n \"metadata\": {\n \"1\": {\n \"name\": \"z\",\n \"typ_idx\": 0,\n \"added\": 0,\n \"dropped\": null\n }\n }\n}"},"old":{"module_name":"mz_repr__relation__tests","metadata":{},"snapshot":"{\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n }\n ],\n \"keys\": [\n [\n 0\n ]\n ]\n },\n \"metadata\": {\n \"1\": {\n \"name\": \"z\",\n \"typ_idx\": 0,\n \"added\": 0,\n \"dropped\": null\n }\n },\n \"semantic_types\": {}\n}"}} +{"run_id":"1777593030-947227000","line":2436,"new":{"module_name":"mz_repr__relation__tests","snapshot_name":"impl","metadata":{"source":"src/repr/src/relation.rs","assertion_line":2436,"expression":"desc"},"snapshot":"{\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"Bool\",\n \"nullable\": true\n }\n ],\n \"keys\": []\n },\n \"metadata\": {\n \"0\": {\n \"name\": \"a\",\n \"typ_idx\": 0,\n \"added\": 0,\n \"dropped\": null\n },\n \"1\": {\n \"name\": \"b\",\n \"typ_idx\": 1,\n \"added\": 0,\n \"dropped\": null\n }\n }\n}"},"old":{"module_name":"mz_repr__relation__tests","metadata":{},"snapshot":"{\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"Bool\",\n \"nullable\": true\n }\n ],\n \"keys\": []\n },\n \"metadata\": {\n \"0\": {\n \"name\": \"a\",\n \"typ_idx\": 0,\n \"added\": 0,\n \"dropped\": null\n },\n \"1\": {\n \"name\": \"b\",\n \"typ_idx\": 1,\n \"added\": 0,\n \"dropped\": null\n }\n },\n \"semantic_types\": {}\n}"}} +{"run_id":"1777599038-784586000","line":2325,"new":null,"old":null} +{"run_id":"1777599038-784586000","line":2379,"new":null,"old":null} +{"run_id":"1777599038-784586000","line":2142,"new":null,"old":null} +{"run_id":"1777599038-784586000","line":2240,"new":null,"old":null} +{"run_id":"1777599038-784586000","line":2173,"new":null,"old":null} +{"run_id":"1777599038-784586000","line":2391,"new":null,"old":null} +{"run_id":"1777599038-784586000","line":2268,"new":null,"old":null} +{"run_id":"1777599038-784586000","line":2197,"new":null,"old":null} +{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2325,"new":null,"old":null} +{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2142,"new":null,"old":null} +{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2173,"new":null,"old":null} +{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2197,"new":null,"old":null} +{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2379,"new":null,"old":null} +{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2391,"new":null,"old":null} +{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2240,"new":null,"old":null} +{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2268,"new":null,"old":null} diff --git a/src/repr/src/relation.rs b/src/repr/src/relation.rs index 9281d8e284c77..03104ff4c8438 100644 --- a/src/repr/src/relation.rs +++ b/src/repr/src/relation.rs @@ -28,7 +28,7 @@ use serde::{Deserialize, Serialize}; use crate::relation_and_scalar::proto_relation_type::ProtoKey; pub use crate::relation_and_scalar::{ ProtoColumnMetadata, ProtoColumnName, ProtoColumnType, ProtoRelationDesc, ProtoRelationType, - ProtoRelationVersion, ProtoSemanticType, + ProtoRelationVersion, }; use crate::{Datum, ReprScalarType, Row, SqlScalarType, arb_datum_for_column}; @@ -837,8 +837,7 @@ impl RustType for RelationVersion { PartialOrd, Ord, Hash, - serde::Serialize, - serde::Deserialize + serde::Serialize )] pub enum SemanticType { CatalogItemId, @@ -891,61 +890,6 @@ impl fmt::Display for SemanticType { } } -impl RustType for SemanticType { - fn into_proto(&self) -> ProtoSemanticType { - match self { - SemanticType::CatalogItemId => ProtoSemanticType::CatalogItemId, - SemanticType::GlobalId => ProtoSemanticType::GlobalId, - SemanticType::ClusterId => ProtoSemanticType::ClusterId, - SemanticType::ReplicaId => ProtoSemanticType::ReplicaId, - SemanticType::SchemaId => ProtoSemanticType::SchemaId, - SemanticType::DatabaseId => ProtoSemanticType::DatabaseId, - SemanticType::RoleId => ProtoSemanticType::RoleId, - SemanticType::NetworkPolicyId => ProtoSemanticType::NetworkPolicyId, - SemanticType::ShardId => ProtoSemanticType::ShardId, - SemanticType::OID => ProtoSemanticType::Oid, - SemanticType::ObjectType => ProtoSemanticType::ObjectType, - SemanticType::ConnectionType => ProtoSemanticType::ConnectionType, - SemanticType::SourceType => ProtoSemanticType::SourceType, - SemanticType::MzTimestamp => ProtoSemanticType::MzTimestamp, - SemanticType::WallclockTimestamp => ProtoSemanticType::WallclockTimestamp, - SemanticType::ByteCount => ProtoSemanticType::ByteCount, - SemanticType::RecordCount => ProtoSemanticType::RecordCount, - SemanticType::CreditRate => ProtoSemanticType::CreditRate, - SemanticType::SqlDefinition => ProtoSemanticType::SqlDefinition, - SemanticType::RedactedSqlDefinition => ProtoSemanticType::RedactedSqlDefinition, - } - } - - fn from_proto(proto: ProtoSemanticType) -> Result { - match proto { - ProtoSemanticType::Unspecified => Err(TryFromProtoError::unknown_enum_variant( - "ProtoSemanticType::Unspecified", - )), - ProtoSemanticType::CatalogItemId => Ok(SemanticType::CatalogItemId), - ProtoSemanticType::GlobalId => Ok(SemanticType::GlobalId), - ProtoSemanticType::ClusterId => Ok(SemanticType::ClusterId), - ProtoSemanticType::ReplicaId => Ok(SemanticType::ReplicaId), - ProtoSemanticType::SchemaId => Ok(SemanticType::SchemaId), - ProtoSemanticType::DatabaseId => Ok(SemanticType::DatabaseId), - ProtoSemanticType::RoleId => Ok(SemanticType::RoleId), - ProtoSemanticType::NetworkPolicyId => Ok(SemanticType::NetworkPolicyId), - ProtoSemanticType::ShardId => Ok(SemanticType::ShardId), - ProtoSemanticType::Oid => Ok(SemanticType::OID), - ProtoSemanticType::ObjectType => Ok(SemanticType::ObjectType), - ProtoSemanticType::ConnectionType => Ok(SemanticType::ConnectionType), - ProtoSemanticType::SourceType => Ok(SemanticType::SourceType), - ProtoSemanticType::MzTimestamp => Ok(SemanticType::MzTimestamp), - ProtoSemanticType::WallclockTimestamp => Ok(SemanticType::WallclockTimestamp), - ProtoSemanticType::ByteCount => Ok(SemanticType::ByteCount), - ProtoSemanticType::RecordCount => Ok(SemanticType::RecordCount), - ProtoSemanticType::CreditRate => Ok(SemanticType::CreditRate), - ProtoSemanticType::SqlDefinition => Ok(SemanticType::SqlDefinition), - ProtoSemanticType::RedactedSqlDefinition => Ok(SemanticType::RedactedSqlDefinition), - } - } -} - /// Metadata (other than type) for a column in a [`RelationDesc`]. #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash, MzReflect)] struct ColumnMetadata { @@ -1030,10 +974,6 @@ struct ColumnMetadata { pub struct RelationDesc { typ: SqlRelationType, metadata: BTreeMap, - /// Optional semantic type annotations for columns. - /// Keyed by column index. Only populated for builtin catalog objects. - #[serde(default)] - semantic_types: BTreeMap, } impl RustType for RelationDesc { @@ -1064,17 +1004,10 @@ impl RustType for RelationDesc { metadata }; - let semantic_types = self - .semantic_types - .iter() - .map(|(col_idx, st)| (u64::cast_from(col_idx.0), i32::from(st.into_proto()))) - .collect(); - ProtoRelationDesc { typ: Some(self.typ.into_proto()), names, metadata, - semantic_types, } } @@ -1110,21 +1043,9 @@ impl RustType for RelationDesc { }) .collect::>()?; - let semantic_types = proto - .semantic_types - .into_iter() - .map(|(col_idx, st_i32)| { - let proto_st = ProtoSemanticType::try_from(st_i32) - .map_err(|_| TryFromProtoError::unknown_enum_variant("ProtoSemanticType"))?; - let st = SemanticType::from_proto(proto_st)?; - Ok::<_, TryFromProtoError>((ColumnIndex(usize::cast_from(col_idx)), st)) - }) - .collect::>()?; - Ok(RelationDesc { typ: proto.typ.into_rust_if_some("ProtoRelationDesc::typ")?, metadata, - semantic_types, }) } } @@ -1141,7 +1062,6 @@ impl RelationDesc { RelationDesc { typ: SqlRelationType::empty(), metadata: BTreeMap::default(), - semantic_types: BTreeMap::default(), } } @@ -1188,7 +1108,6 @@ impl RelationDesc { RelationDesc { typ, metadata, - semantic_types: BTreeMap::default(), } } @@ -1352,20 +1271,6 @@ impl RelationDesc { self.get_name_idx(&ColumnIndex(i)) } - /// Gets the semantic type annotation for column `i`, if any. - pub fn get_semantic_type(&self, i: usize) -> Option { - self.semantic_types.get(&ColumnIndex(i)).copied() - } - - /// Returns a copy of this [`RelationDesc`] with the given semantic type annotations applied. - pub fn with_semantic_types( - mut self, - semantic_types: BTreeMap, - ) -> Self { - self.semantic_types = semantic_types; - self - } - /// Gets the name of the column at `idx`. /// /// # Panics @@ -1686,8 +1591,6 @@ pub struct RelationDescBuilder { columns: Vec<(ColumnName, SqlColumnType)>, /// Sets of indices that are "keys" for the collection. keys: Vec>, - /// Semantic type annotations for columns. - semantic_types: BTreeMap, } impl RelationDescBuilder { @@ -1723,21 +1626,6 @@ impl RelationDescBuilder { self } - /// Appends a column with the specified name and type, and annotates it with - /// a semantic type. Use this instead of chaining [`RelationDescBuilder::with_column`] + - /// `with_semantic_type` — it is explicit about which column is annotated. - pub fn with_column_semantic_type>( - mut self, - name: N, - ty: SqlColumnType, - semantic_type: SemanticType, - ) -> RelationDescBuilder { - let idx = self.columns.len(); - self.columns.push((name.into(), ty)); - self.semantic_types.insert(ColumnIndex(idx), semantic_type); - self - } - /// Removes all previously inserted keys. pub fn without_keys(mut self) -> RelationDescBuilder { self.keys.clear(); @@ -1762,7 +1650,6 @@ impl RelationDescBuilder { pub fn finish(self) -> RelationDesc { let mut desc = RelationDesc::from_names_and_types(self.columns); desc.typ = desc.typ.with_keys(self.keys); - desc.semantic_types = self.semantic_types; desc } } @@ -1946,19 +1833,9 @@ impl VersionedRelationDesc { let relation_type = SqlRelationType { column_types, keys }; - // Preserve semantic type annotations for columns that survived the version filter. - let semantic_types = self - .inner - .semantic_types - .iter() - .filter(|(col_idx, _)| column_metas.contains_key(col_idx)) - .map(|(col_idx, st)| (*col_idx, *st)) - .collect(); - RelationDesc { typ: relation_type, metadata: column_metas, - semantic_types, } } @@ -2351,8 +2228,7 @@ mod tests { "added": 0, "dropped": null } - }, - "semantic_types": {} + } } "###); @@ -2390,8 +2266,7 @@ mod tests { "added": 0, "dropped": null } - }, - "semantic_types": {} + } } "###); } @@ -2413,7 +2288,6 @@ mod tests { ColumnName("b".into()).into_proto(), ], metadata: vec![], - semantic_types: Default::default(), }; let desc: RelationDesc = proto.into_rust().unwrap(); @@ -2445,8 +2319,7 @@ mod tests { "added": 0, "dropped": null } - }, - "semantic_types": {} + } } "###); } @@ -2478,8 +2351,7 @@ mod tests { "column_types": [], "keys": [] }, - "metadata": {}, - "semantic_types": {} + "metadata": {} } "###); @@ -2503,8 +2375,7 @@ mod tests { "added": 2, "dropped": null } - }, - "semantic_types": {} + } } "###); } @@ -2557,52 +2428,4 @@ mod tests { testcase(desc); }); } - - #[mz_ore::test] - fn test_semantic_type_annotations() { - let desc = RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .with_column("name", SqlScalarType::String.nullable(false)) - .with_column_semantic_type( - "cluster_id", - SqlScalarType::String.nullable(true), - SemanticType::ClusterId, - ) - .finish(); - - assert_eq!(desc.get_semantic_type(0), Some(SemanticType::CatalogItemId)); - assert_eq!(desc.get_semantic_type(2), Some(SemanticType::ClusterId)); - assert_eq!(desc.get_semantic_type(1), None); - assert_eq!(desc.get_semantic_type(99), None); - } - - #[mz_ore::test] - fn test_semantic_types_included_in_eq_and_hash() { - let desc_with = RelationDesc::builder() - .with_column_semantic_type( - "id", - SqlScalarType::String.nullable(false), - SemanticType::CatalogItemId, - ) - .finish(); - - let desc_without = RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .finish(); - - // semantic_types is now included in Eq and Hash. - assert_ne!(desc_with, desc_without); - - use std::hash::{Hash, Hasher}; - let hash = |d: &RelationDesc| { - let mut h = std::collections::hash_map::DefaultHasher::new(); - d.hash(&mut h); - h.finish() - }; - assert_ne!(hash(&desc_with), hash(&desc_without)); - } } diff --git a/src/repr/src/relation_and_scalar.proto b/src/repr/src/relation_and_scalar.proto index 751c35c4f0d12..8c3e13aa07c6e 100644 --- a/src/repr/src/relation_and_scalar.proto +++ b/src/repr/src/relation_and_scalar.proto @@ -47,35 +47,10 @@ message ProtoColumnMetadata { ProtoRelationVersion dropped = 2; } -enum ProtoSemanticType { - PROTO_SEMANTIC_TYPE_UNSPECIFIED = 0; - PROTO_SEMANTIC_TYPE_CATALOG_ITEM_ID = 1; - PROTO_SEMANTIC_TYPE_GLOBAL_ID = 2; - PROTO_SEMANTIC_TYPE_CLUSTER_ID = 3; - PROTO_SEMANTIC_TYPE_REPLICA_ID = 4; - PROTO_SEMANTIC_TYPE_SCHEMA_ID = 5; - PROTO_SEMANTIC_TYPE_DATABASE_ID = 6; - PROTO_SEMANTIC_TYPE_ROLE_ID = 7; - PROTO_SEMANTIC_TYPE_NETWORK_POLICY_ID = 8; - PROTO_SEMANTIC_TYPE_SHARD_ID = 9; - PROTO_SEMANTIC_TYPE_OID = 10; - PROTO_SEMANTIC_TYPE_OBJECT_TYPE = 11; - PROTO_SEMANTIC_TYPE_CONNECTION_TYPE = 12; - PROTO_SEMANTIC_TYPE_SOURCE_TYPE = 13; - PROTO_SEMANTIC_TYPE_MZ_TIMESTAMP = 14; - PROTO_SEMANTIC_TYPE_WALLCLOCK_TIMESTAMP = 15; - PROTO_SEMANTIC_TYPE_BYTE_COUNT = 16; - PROTO_SEMANTIC_TYPE_RECORD_COUNT = 17; - PROTO_SEMANTIC_TYPE_CREDIT_RATE = 18; - PROTO_SEMANTIC_TYPE_SQL_DEFINITION = 19; - PROTO_SEMANTIC_TYPE_REDACTED_SQL_DEFINITION = 20; -} - message ProtoRelationDesc { ProtoRelationType typ = 1; repeated ProtoColumnName names = 2; repeated ProtoColumnMetadata metadata = 3; - map semantic_types = 4; } message ProtoScalarType { diff --git a/src/storage-client/src/healthcheck.rs b/src/storage-client/src/healthcheck.rs index e2fdb6ebd8fad..1c164a2f24dd3 100644 --- a/src/storage-client/src/healthcheck.rs +++ b/src/storage-client/src/healthcheck.rs @@ -7,7 +7,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -use mz_repr::{RelationDesc, SemanticType, SqlScalarType}; +use mz_repr::{RelationDesc, SqlScalarType}; use std::sync::LazyLock; pub static MZ_PREPARED_STATEMENT_HISTORY_DESC: LazyLock = LazyLock::new(|| { @@ -40,10 +40,9 @@ pub static MZ_SQL_TEXT_DESC: LazyLock = LazyLock::new(|| { pub static MZ_SESSION_HISTORY_DESC: LazyLock = LazyLock::new(|| { RelationDesc::builder() .with_column("session_id", SqlScalarType::Uuid.nullable(false)) - .with_column_semantic_type( + .with_column( "connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), - SemanticType::WallclockTimestamp, ) .with_column( "initial_application_name", @@ -108,47 +107,29 @@ pub static MZ_STATEMENT_EXECUTION_HISTORY_DESC: LazyLock = LazyLoc pub static MZ_SOURCE_STATUS_HISTORY_DESC: LazyLock = LazyLock::new(|| { RelationDesc::builder() - .with_column_semantic_type( + .with_column( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), - SemanticType::WallclockTimestamp, - ) - .with_column_semantic_type( - "source_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, ) + .with_column("source_id", SqlScalarType::String.nullable(false)) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) .with_column("details", SqlScalarType::Jsonb.nullable(true)) - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(true), - SemanticType::ReplicaId, - ) + .with_column("replica_id", SqlScalarType::String.nullable(true)) .finish() }); pub static MZ_SINK_STATUS_HISTORY_DESC: LazyLock = LazyLock::new(|| { RelationDesc::builder() - .with_column_semantic_type( + .with_column( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), - SemanticType::WallclockTimestamp, - ) - .with_column_semantic_type( - "sink_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, ) + .with_column("sink_id", SqlScalarType::String.nullable(false)) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("error", SqlScalarType::String.nullable(true)) .with_column("details", SqlScalarType::Jsonb.nullable(true)) - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(true), - SemanticType::ReplicaId, - ) + .with_column("replica_id", SqlScalarType::String.nullable(true)) .finish() }); @@ -166,11 +147,7 @@ pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_DESC: LazyLock = LazyLock::new(|| { RelationDesc::builder() - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(false), - SemanticType::ReplicaId, - ) + .with_column("replica_id", SqlScalarType::String.nullable(false)) .with_column("process_id", SqlScalarType::UInt64.nullable(false)) .with_column("status", SqlScalarType::String.nullable(false)) .with_column("reason", SqlScalarType::String.nullable(true)) @@ -202,21 +179,12 @@ pub static REPLICA_METRICS_HISTORY_DESC: LazyLock = LazyLock::new( pub static WALLCLOCK_LAG_HISTORY_DESC: LazyLock = LazyLock::new(|| { RelationDesc::builder() - .with_column_semantic_type( - "object_id", - SqlScalarType::String.nullable(false), - SemanticType::GlobalId, - ) - .with_column_semantic_type( - "replica_id", - SqlScalarType::String.nullable(true), - SemanticType::ReplicaId, - ) + .with_column("object_id", SqlScalarType::String.nullable(false)) + .with_column("replica_id", SqlScalarType::String.nullable(true)) .with_column("lag", SqlScalarType::Interval.nullable(true)) - .with_column_semantic_type( + .with_column( "occurred_at", SqlScalarType::TimestampTz { precision: None }.nullable(false), - SemanticType::WallclockTimestamp, ) .finish() }); From f248ff58e28988c2cfd9fb8b4f3871977a3ca372 Mon Sep 17 00:00:00 2001 From: mtabebe Date: Fri, 1 May 2026 10:36:05 -0400 Subject: [PATCH 14/14] fix rustfmt: collapse RelationDesc struct literal to single line --- src/repr/src/.relation.rs.pending-snap | 19 ------------------- src/repr/src/relation.rs | 5 +---- 2 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 src/repr/src/.relation.rs.pending-snap diff --git a/src/repr/src/.relation.rs.pending-snap b/src/repr/src/.relation.rs.pending-snap deleted file mode 100644 index 16b00b3986f9d..0000000000000 --- a/src/repr/src/.relation.rs.pending-snap +++ /dev/null @@ -1,19 +0,0 @@ -{"run_id":"1777593030-947227000","line":2491,"new":{"module_name":"mz_repr__relation__tests","snapshot_name":"impl-2","metadata":{"source":"src/repr/src/relation.rs","assertion_line":2491,"expression":"v1"},"snapshot":"{\n \"typ\": {\n \"column_types\": [],\n \"keys\": []\n },\n \"metadata\": {}\n}"},"old":{"module_name":"mz_repr__relation__tests","metadata":{},"snapshot":"{\n \"typ\": {\n \"column_types\": [],\n \"keys\": []\n },\n \"metadata\": {},\n \"semantic_types\": {}\n}"}} -{"run_id":"1777593030-947227000","line":2348,"new":{"module_name":"mz_repr__relation__tests","snapshot_name":"impl-4","metadata":{"source":"src/repr/src/relation.rs","assertion_line":2348,"expression":"v1"},"snapshot":"{\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n }\n ],\n \"keys\": [\n [\n 0\n ]\n ]\n },\n \"metadata\": {\n \"1\": {\n \"name\": \"z\",\n \"typ_idx\": 0,\n \"added\": 0,\n \"dropped\": null\n }\n }\n}"},"old":{"module_name":"mz_repr__relation__tests","metadata":{},"snapshot":"{\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n }\n ],\n \"keys\": [\n [\n 0\n ]\n ]\n },\n \"metadata\": {\n \"1\": {\n \"name\": \"z\",\n \"typ_idx\": 0,\n \"added\": 0,\n \"dropped\": null\n }\n },\n \"semantic_types\": {}\n}"}} -{"run_id":"1777593030-947227000","line":2436,"new":{"module_name":"mz_repr__relation__tests","snapshot_name":"impl","metadata":{"source":"src/repr/src/relation.rs","assertion_line":2436,"expression":"desc"},"snapshot":"{\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"Bool\",\n \"nullable\": true\n }\n ],\n \"keys\": []\n },\n \"metadata\": {\n \"0\": {\n \"name\": \"a\",\n \"typ_idx\": 0,\n \"added\": 0,\n \"dropped\": null\n },\n \"1\": {\n \"name\": \"b\",\n \"typ_idx\": 1,\n \"added\": 0,\n \"dropped\": null\n }\n }\n}"},"old":{"module_name":"mz_repr__relation__tests","metadata":{},"snapshot":"{\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"Bool\",\n \"nullable\": true\n }\n ],\n \"keys\": []\n },\n \"metadata\": {\n \"0\": {\n \"name\": \"a\",\n \"typ_idx\": 0,\n \"added\": 0,\n \"dropped\": null\n },\n \"1\": {\n \"name\": \"b\",\n \"typ_idx\": 1,\n \"added\": 0,\n \"dropped\": null\n }\n },\n \"semantic_types\": {}\n}"}} -{"run_id":"1777599038-784586000","line":2325,"new":null,"old":null} -{"run_id":"1777599038-784586000","line":2379,"new":null,"old":null} -{"run_id":"1777599038-784586000","line":2142,"new":null,"old":null} -{"run_id":"1777599038-784586000","line":2240,"new":null,"old":null} -{"run_id":"1777599038-784586000","line":2173,"new":null,"old":null} -{"run_id":"1777599038-784586000","line":2391,"new":null,"old":null} -{"run_id":"1777599038-784586000","line":2268,"new":null,"old":null} -{"run_id":"1777599038-784586000","line":2197,"new":null,"old":null} -{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2325,"new":null,"old":null} -{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2142,"new":null,"old":null} -{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2173,"new":null,"old":null} -{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2197,"new":null,"old":null} -{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2379,"new":null,"old":null} -{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2391,"new":null,"old":null} -{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2240,"new":null,"old":null} -{"run_id":"c98df17c-6965-488d-8760-a2e833881391","line":2268,"new":null,"old":null} diff --git a/src/repr/src/relation.rs b/src/repr/src/relation.rs index 03104ff4c8438..5c6e784ff8889 100644 --- a/src/repr/src/relation.rs +++ b/src/repr/src/relation.rs @@ -1105,10 +1105,7 @@ impl RelationDesc { // TODO(parkmycar): Add better validation here. assert_eq!(typ.column_types.len(), metadata.len()); - RelationDesc { - typ, - metadata, - } + RelationDesc { typ, metadata } } pub fn from_names_and_types(iter: I) -> Self