1use std::collections::BTreeMap;
13use std::sync::LazyLock;
14
15use mz_pgrepr::oid;
16use mz_repr::namespaces::MZ_CATALOG_SCHEMA;
17use mz_repr::{RelationDesc, SemanticType, SqlScalarType};
18use mz_sql::catalog::{
19 CatalogType, CatalogTypeDetails, CatalogTypePgMetadata, NameReference, ObjectType,
20};
21use mz_sql::rbac;
22use mz_sql::session::user::MZ_SYSTEM_ROLE_ID;
23use mz_storage_client::controller::IntrospectionType;
24
25use super::{
26 BuiltinIndex, BuiltinMaterializedView, BuiltinSource, BuiltinTable, BuiltinType, BuiltinView,
27 Cardinality, LinkProperties, Ontology, OntologyLink, PUBLIC_SELECT,
28};
29
30pub const TYPE_LIST: BuiltinType<NameReference> = BuiltinType {
31 name: "list",
32 schema: MZ_CATALOG_SCHEMA,
33 oid: mz_pgrepr::oid::TYPE_LIST_OID,
34 details: CatalogTypeDetails {
35 typ: CatalogType::Pseudo,
36 array_id: None,
37 pg_metadata: None,
38 },
39};
40
41pub const TYPE_MAP: BuiltinType<NameReference> = BuiltinType {
42 name: "map",
43 schema: MZ_CATALOG_SCHEMA,
44 oid: mz_pgrepr::oid::TYPE_MAP_OID,
45 details: CatalogTypeDetails {
46 typ: CatalogType::Pseudo,
47 array_id: None,
48 pg_metadata: None,
49 },
50};
51
52pub const TYPE_ANYCOMPATIBLELIST: BuiltinType<NameReference> = BuiltinType {
53 name: "anycompatiblelist",
54 schema: MZ_CATALOG_SCHEMA,
55 oid: mz_pgrepr::oid::TYPE_ANYCOMPATIBLELIST_OID,
56 details: CatalogTypeDetails {
57 typ: CatalogType::Pseudo,
58 array_id: None,
59 pg_metadata: None,
60 },
61};
62
63pub const TYPE_ANYCOMPATIBLEMAP: BuiltinType<NameReference> = BuiltinType {
64 name: "anycompatiblemap",
65 schema: MZ_CATALOG_SCHEMA,
66 oid: mz_pgrepr::oid::TYPE_ANYCOMPATIBLEMAP_OID,
67 details: CatalogTypeDetails {
68 typ: CatalogType::Pseudo,
69 array_id: None,
70 pg_metadata: None,
71 },
72};
73
74pub const TYPE_UINT2: BuiltinType<NameReference> = BuiltinType {
75 name: "uint2",
76 schema: MZ_CATALOG_SCHEMA,
77 oid: mz_pgrepr::oid::TYPE_UINT2_OID,
78 details: CatalogTypeDetails {
79 typ: CatalogType::UInt16,
80 array_id: None,
81 pg_metadata: None,
82 },
83};
84
85pub const TYPE_UINT2_ARRAY: BuiltinType<NameReference> = BuiltinType {
86 name: "_uint2",
87 schema: MZ_CATALOG_SCHEMA,
88 oid: mz_pgrepr::oid::TYPE_UINT2_ARRAY_OID,
89 details: CatalogTypeDetails {
90 typ: CatalogType::Array {
91 element_reference: TYPE_UINT2.name,
92 },
93 array_id: None,
94 pg_metadata: None,
95 },
96};
97
98pub const TYPE_UINT4: BuiltinType<NameReference> = BuiltinType {
99 name: "uint4",
100 schema: MZ_CATALOG_SCHEMA,
101 oid: mz_pgrepr::oid::TYPE_UINT4_OID,
102 details: CatalogTypeDetails {
103 typ: CatalogType::UInt32,
104 array_id: None,
105 pg_metadata: None,
106 },
107};
108
109pub const TYPE_UINT4_ARRAY: BuiltinType<NameReference> = BuiltinType {
110 name: "_uint4",
111 schema: MZ_CATALOG_SCHEMA,
112 oid: mz_pgrepr::oid::TYPE_UINT4_ARRAY_OID,
113 details: CatalogTypeDetails {
114 typ: CatalogType::Array {
115 element_reference: TYPE_UINT4.name,
116 },
117 array_id: None,
118 pg_metadata: None,
119 },
120};
121
122pub const TYPE_UINT8: BuiltinType<NameReference> = BuiltinType {
123 name: "uint8",
124 schema: MZ_CATALOG_SCHEMA,
125 oid: mz_pgrepr::oid::TYPE_UINT8_OID,
126 details: CatalogTypeDetails {
127 typ: CatalogType::UInt64,
128 array_id: None,
129 pg_metadata: None,
130 },
131};
132
133pub const TYPE_UINT8_ARRAY: BuiltinType<NameReference> = BuiltinType {
134 name: "_uint8",
135 schema: MZ_CATALOG_SCHEMA,
136 oid: mz_pgrepr::oid::TYPE_UINT8_ARRAY_OID,
137 details: CatalogTypeDetails {
138 typ: CatalogType::Array {
139 element_reference: TYPE_UINT8.name,
140 },
141 array_id: None,
142 pg_metadata: None,
143 },
144};
145
146pub const TYPE_MZ_TIMESTAMP: BuiltinType<NameReference> = BuiltinType {
147 name: "mz_timestamp",
148 schema: MZ_CATALOG_SCHEMA,
149 oid: mz_pgrepr::oid::TYPE_MZ_TIMESTAMP_OID,
150 details: CatalogTypeDetails {
151 typ: CatalogType::MzTimestamp,
152 array_id: None,
153 pg_metadata: None,
154 },
155};
156
157pub const TYPE_MZ_TIMESTAMP_ARRAY: BuiltinType<NameReference> = BuiltinType {
158 name: "_mz_timestamp",
159 schema: MZ_CATALOG_SCHEMA,
160 oid: mz_pgrepr::oid::TYPE_MZ_TIMESTAMP_ARRAY_OID,
161 details: CatalogTypeDetails {
162 typ: CatalogType::Array {
163 element_reference: TYPE_MZ_TIMESTAMP.name,
164 },
165 array_id: None,
166 pg_metadata: None,
167 },
168};
169
170pub const TYPE_MZ_ACL_ITEM: BuiltinType<NameReference> = BuiltinType {
171 name: "mz_aclitem",
172 schema: MZ_CATALOG_SCHEMA,
173 oid: mz_pgrepr::oid::TYPE_MZ_ACL_ITEM_OID,
174 details: CatalogTypeDetails {
175 typ: CatalogType::MzAclItem,
176 array_id: None,
177 pg_metadata: None,
178 },
179};
180
181pub const TYPE_MZ_ACL_ITEM_ARRAY: BuiltinType<NameReference> = BuiltinType {
182 name: "_mz_aclitem",
183 schema: MZ_CATALOG_SCHEMA,
184 oid: mz_pgrepr::oid::TYPE_MZ_ACL_ITEM_ARRAY_OID,
185 details: CatalogTypeDetails {
186 typ: CatalogType::Array {
187 element_reference: TYPE_MZ_ACL_ITEM.name,
188 },
189 array_id: None,
190 pg_metadata: Some(CatalogTypePgMetadata {
191 typinput_oid: 750,
192 typreceive_oid: 2400,
193 }),
194 },
195};
196
197pub static MZ_ICEBERG_SINKS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
198 name: "mz_iceberg_sinks",
199 schema: MZ_CATALOG_SCHEMA,
200 oid: oid::TABLE_MZ_ICEBERG_SINKS_OID,
201 desc: RelationDesc::builder()
202 .with_column("id", SqlScalarType::String.nullable(false))
203 .with_column("namespace", SqlScalarType::String.nullable(false))
204 .with_column("table", SqlScalarType::String.nullable(false))
205 .finish(),
206 column_comments: BTreeMap::from_iter([
207 ("id", "The ID of the sink."),
208 (
209 "namespace",
210 "The namespace of the Iceberg table into which the sink is writing.",
211 ),
212 ("table", "The Iceberg table into which the sink is writing."),
213 ]),
214 is_retained_metrics_object: false,
215 access: vec![PUBLIC_SELECT],
216 ontology: Some(Ontology {
217 entity_name: "iceberg_sink",
218 description: "Iceberg-specific sink configuration (namespace, table)",
219 links: &const {
220 [OntologyLink {
221 name: "details_of",
222 target: "sink",
223 properties: LinkProperties::fk("id", "id", Cardinality::OneToOne),
224 }]
225 },
226 column_semantic_types: &[("id", SemanticType::CatalogItemId)],
227 }),
228});
229
230pub static MZ_KAFKA_SINKS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
231 name: "mz_kafka_sinks",
232 schema: MZ_CATALOG_SCHEMA,
233 oid: oid::TABLE_MZ_KAFKA_SINKS_OID,
234 desc: RelationDesc::builder()
235 .with_column("id", SqlScalarType::String.nullable(false))
236 .with_column("topic", SqlScalarType::String.nullable(false))
237 .with_key(vec![0])
238 .finish(),
239 column_comments: BTreeMap::from_iter([
240 ("id", "The ID of the sink."),
241 (
242 "topic",
243 "The name of the Kafka topic into which the sink is writing.",
244 ),
245 ]),
246 is_retained_metrics_object: false,
247 access: vec![PUBLIC_SELECT],
248 ontology: Some(Ontology {
249 entity_name: "kafka_sink",
250 description: "Kafka-specific sink configuration (topic)",
251 links: &const {
252 [OntologyLink {
253 name: "details_of",
254 target: "sink",
255 properties: LinkProperties::fk("id", "id", Cardinality::OneToOne),
256 }]
257 },
258 column_semantic_types: &[("id", SemanticType::CatalogItemId)],
259 }),
260});
261pub static MZ_KAFKA_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
262 name: "mz_kafka_connections",
263 schema: MZ_CATALOG_SCHEMA,
264 oid: oid::TABLE_MZ_KAFKA_CONNECTIONS_OID,
265 desc: RelationDesc::builder()
266 .with_column("id", SqlScalarType::String.nullable(false))
267 .with_column(
268 "brokers",
269 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
270 )
271 .with_column("sink_progress_topic", SqlScalarType::String.nullable(false))
272 .finish(),
273 column_comments: BTreeMap::from_iter([
274 ("id", "The ID of the connection."),
275 (
276 "brokers",
277 "The addresses of the Kafka brokers to connect to.",
278 ),
279 (
280 "sink_progress_topic",
281 "The name of the Kafka topic where any sinks associated with this connection will track their progress information and other metadata. The contents of this topic are unspecified.",
282 ),
283 ]),
284 is_retained_metrics_object: false,
285 access: vec![PUBLIC_SELECT],
286 ontology: Some(Ontology {
287 entity_name: "kafka_connection",
288 description: "Kafka-specific connection configuration (brokers, progress topic)",
289 links: &const {
290 [OntologyLink {
291 name: "details_of",
292 target: "connection",
293 properties: LinkProperties::fk("id", "id", Cardinality::OneToOne),
294 }]
295 },
296 column_semantic_types: &[("id", SemanticType::CatalogItemId)],
297 }),
298});
299pub static MZ_KAFKA_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
300 name: "mz_kafka_sources",
301 schema: MZ_CATALOG_SCHEMA,
302 oid: oid::TABLE_MZ_KAFKA_SOURCES_OID,
303 desc: RelationDesc::builder()
304 .with_column("id", SqlScalarType::String.nullable(false))
305 .with_column("group_id_prefix", SqlScalarType::String.nullable(false))
306 .with_column("topic", SqlScalarType::String.nullable(false))
307 .finish(),
308 column_comments: BTreeMap::from_iter([
309 (
310 "id",
311 "The ID of the Kafka source. Corresponds to `mz_catalog.mz_sources.id`.",
312 ),
313 (
314 "group_id_prefix",
315 "The value of the `GROUP ID PREFIX` connection option.",
316 ),
317 (
318 "topic",
319 "The name of the Kafka topic the source is reading from.",
320 ),
321 ]),
322 is_retained_metrics_object: false,
323 access: vec![PUBLIC_SELECT],
324 ontology: Some(Ontology {
325 entity_name: "kafka_source",
326 description: "Kafka-specific source configuration (topic, group ID)",
327 links: &const {
328 [OntologyLink {
329 name: "details_of",
330 target: "source",
331 properties: LinkProperties::fk("id", "id", Cardinality::OneToOne),
332 }]
333 },
334 column_semantic_types: &[("id", SemanticType::CatalogItemId)],
335 }),
336});
337
338pub static MZ_DATABASES: LazyLock<BuiltinMaterializedView> =
339 LazyLock::new(|| BuiltinMaterializedView {
340 name: "mz_databases",
341 schema: MZ_CATALOG_SCHEMA,
342 oid: oid::MV_MZ_DATABASES_OID,
343 desc: RelationDesc::builder()
344 .with_column("id", SqlScalarType::String.nullable(false))
345 .with_column("oid", SqlScalarType::Oid.nullable(false))
346 .with_column("name", SqlScalarType::String.nullable(false))
347 .with_column("owner_id", SqlScalarType::String.nullable(false))
348 .with_column(
349 "privileges",
350 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
351 )
352 .with_key(vec![0])
353 .with_key(vec![1])
354 .finish(),
355 column_comments: BTreeMap::from_iter([
356 ("id", "Materialize's unique ID for the database."),
357 ("oid", "A PostgreSQL-compatible OID for the database."),
358 ("name", "The name of the database."),
359 (
360 "owner_id",
361 "The role ID of the owner of the database. Corresponds to `mz_roles.id`.",
362 ),
363 ("privileges", "The privileges belonging to the database."),
364 ]),
365 sql: "
366IN CLUSTER mz_catalog_server
367WITH (
368 ASSERT NOT NULL id,
369 ASSERT NOT NULL oid,
370 ASSERT NOT NULL name,
371 ASSERT NOT NULL owner_id,
372 ASSERT NOT NULL privileges
373) AS
374SELECT
375 mz_internal.parse_catalog_id(data->'key'->'id') AS id,
376 (data->'value'->>'oid')::oid AS oid,
377 data->'value'->>'name' AS name,
378 mz_internal.parse_catalog_id(data->'value'->'owner_id') AS owner_id,
379 mz_internal.parse_catalog_privileges(data->'value'->'privileges') AS privileges
380FROM mz_internal.mz_catalog_raw
381WHERE data->>'kind' = 'Database'",
382 is_retained_metrics_object: false,
383 access: vec![PUBLIC_SELECT],
384 ontology: Some(Ontology {
385 entity_name: "database",
386 description: "A top-level namespace that contains schemas",
387 links: &const {
388 [OntologyLink {
389 name: "owned_by",
390 target: "role",
391 properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne),
392 }]
393 },
394 column_semantic_types: &const {
395 [
396 ("id", SemanticType::DatabaseId),
397 ("oid", SemanticType::OID),
398 ("owner_id", SemanticType::RoleId),
399 ]
400 },
401 }),
402 });
403
404pub static MZ_SCHEMAS: LazyLock<BuiltinMaterializedView> =
405 LazyLock::new(|| BuiltinMaterializedView {
406 name: "mz_schemas",
407 schema: MZ_CATALOG_SCHEMA,
408 oid: oid::MV_MZ_SCHEMAS_OID,
409 desc: RelationDesc::builder()
410 .with_column("id", SqlScalarType::String.nullable(false))
411 .with_column("oid", SqlScalarType::Oid.nullable(false))
412 .with_column("database_id", SqlScalarType::String.nullable(true))
413 .with_column("name", SqlScalarType::String.nullable(false))
414 .with_column("owner_id", SqlScalarType::String.nullable(false))
415 .with_column(
416 "privileges",
417 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
418 )
419 .with_key(vec![0])
420 .with_key(vec![1])
421 .finish(),
422 column_comments: BTreeMap::from_iter([
423 ("id", "Materialize's unique ID for the schema."),
424 ("oid", "A PostgreSQL-compatible oid for the schema."),
425 (
426 "database_id",
427 "The ID of the database containing the schema. Corresponds to `mz_databases.id`.",
428 ),
429 ("name", "The name of the schema."),
430 (
431 "owner_id",
432 "The role ID of the owner of the schema. Corresponds to `mz_roles.id`.",
433 ),
434 ("privileges", "The privileges belonging to the schema."),
435 ]),
436 sql: "
437IN CLUSTER mz_catalog_server
438WITH (
439 ASSERT NOT NULL id,
440 ASSERT NOT NULL oid,
441 ASSERT NOT NULL name,
442 ASSERT NOT NULL owner_id,
443 ASSERT NOT NULL privileges
444) AS
445SELECT
446 mz_internal.parse_catalog_id(data->'key'->'id') AS id,
447 (data->'value'->>'oid')::oid AS oid,
448 CASE WHEN data->'value'->'database_id' != 'null'
449 THEN mz_internal.parse_catalog_id(data->'value'->'database_id')
450 END AS database_id,
451 data->'value'->>'name' AS name,
452 mz_internal.parse_catalog_id(data->'value'->'owner_id') AS owner_id,
453 mz_internal.parse_catalog_privileges(data->'value'->'privileges') AS privileges
454FROM mz_internal.mz_catalog_raw
455WHERE data->>'kind' = 'Schema'",
456 is_retained_metrics_object: false,
457 access: vec![PUBLIC_SELECT],
458 ontology: Some(Ontology {
459 entity_name: "schema",
460 description: "A namespace within a database that contains objects",
461 links: &const {
462 [
463 OntologyLink {
464 name: "in_database",
465 target: "database",
466 properties: LinkProperties::fk_nullable(
467 "database_id",
468 "id",
469 Cardinality::ManyToOne,
470 ),
471 },
472 OntologyLink {
473 name: "owned_by",
474 target: "role",
475 properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne),
476 },
477 ]
478 },
479 column_semantic_types: &const {
480 [
481 ("id", SemanticType::SchemaId),
482 ("oid", SemanticType::OID),
483 ("database_id", SemanticType::DatabaseId),
484 ("owner_id", SemanticType::RoleId),
485 ]
486 },
487 }),
488 });
489
490pub static MZ_COLUMNS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
491 name: "mz_columns",
492 schema: MZ_CATALOG_SCHEMA,
493 oid: oid::TABLE_MZ_COLUMNS_OID,
494 desc: RelationDesc::builder()
495 .with_column("id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false))
497 .with_column("position", SqlScalarType::UInt64.nullable(false))
498 .with_column("nullable", SqlScalarType::Bool.nullable(false))
499 .with_column("type", SqlScalarType::String.nullable(false))
500 .with_column("default", SqlScalarType::String.nullable(true))
501 .with_column("type_oid", SqlScalarType::Oid.nullable(false))
502 .with_column("type_mod", SqlScalarType::Int32.nullable(false))
503 .finish(),
504 column_comments: BTreeMap::from_iter([
505 (
506 "id",
507 "The unique ID of the table, source, or view containing the column.",
508 ),
509 ("name", "The name of the column."),
510 (
511 "position",
512 "The 1-indexed position of the column in its containing table, source, or view.",
513 ),
514 ("nullable", "Can the column contain a `NULL` value?"),
515 ("type", "The data type of the column."),
516 ("default", "The default expression of the column."),
517 (
518 "type_oid",
519 "The OID of the type of the column (references `mz_types`).",
520 ),
521 ("type_mod", "The packed type identifier of the column."),
522 ]),
523 is_retained_metrics_object: false,
524 access: vec![PUBLIC_SELECT],
525 ontology: Some(Ontology {
526 entity_name: "column",
527 description: "A column of a relation, with its name, position, type, and nullability",
528 links: &const {
529 [OntologyLink {
530 name: "belongs_to_relation",
531 target: "object",
532 properties: LinkProperties::ForeignKey {
533 source_column: "id",
534 target_column: "id",
535 cardinality: Cardinality::ManyToOne,
536 source_id_type: None,
537 requires_mapping: None,
538 nullable: false,
539 note: Some("id in mz_columns is the relation ID, not a unique column ID"),
540 extra_key_columns: None,
541 },
542 }]
543 },
544 column_semantic_types: &const {
545 [
546 ("id", SemanticType::CatalogItemId),
547 ("type_oid", SemanticType::OID),
548 ]
549 },
550 }),
551});
552pub static MZ_INDEXES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
553 name: "mz_indexes",
554 schema: MZ_CATALOG_SCHEMA,
555 oid: oid::TABLE_MZ_INDEXES_OID,
556 desc: RelationDesc::builder()
557 .with_column("id", SqlScalarType::String.nullable(false))
558 .with_column("oid", SqlScalarType::Oid.nullable(false))
559 .with_column("name", SqlScalarType::String.nullable(false))
560 .with_column("on_id", SqlScalarType::String.nullable(false))
561 .with_column("cluster_id", SqlScalarType::String.nullable(false))
562 .with_column("owner_id", SqlScalarType::String.nullable(false))
563 .with_column("create_sql", SqlScalarType::String.nullable(false))
564 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
565 .with_key(vec![0])
566 .with_key(vec![1])
567 .finish(),
568 column_comments: BTreeMap::from_iter([
569 ("id", "Materialize's unique ID for the index."),
570 ("oid", "A PostgreSQL-compatible OID for the index."),
571 ("name", "The name of the index."),
572 (
573 "on_id",
574 "The ID of the relation on which the index is built.",
575 ),
576 (
577 "cluster_id",
578 "The ID of the cluster in which the index is built.",
579 ),
580 (
581 "owner_id",
582 "The role ID of the owner of the index. Corresponds to `mz_roles.id`.",
583 ),
584 ("create_sql", "The `CREATE` SQL statement for the index."),
585 (
586 "redacted_create_sql",
587 "The redacted `CREATE` SQL statement for the index.",
588 ),
589 ]),
590 is_retained_metrics_object: false,
591 access: vec![PUBLIC_SELECT],
592 ontology: Some(Ontology {
593 entity_name: "index",
594 description: "An in-memory index on a relation for fast lookups",
595 links: &const {
596 [
597 OntologyLink {
598 name: "owned_by",
599 target: "role",
600 properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne),
601 },
602 OntologyLink {
603 name: "runs_on_cluster",
604 target: "cluster",
605 properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne),
606 },
607 OntologyLink {
608 name: "indexes_relation",
609 target: "relation",
610 properties: LinkProperties::fk("on_id", "id", Cardinality::ManyToOne),
611 },
612 ]
613 },
614 column_semantic_types: &const {
615 [
616 ("id", SemanticType::CatalogItemId),
617 ("oid", SemanticType::OID),
618 ("on_id", SemanticType::CatalogItemId),
619 ("cluster_id", SemanticType::ClusterId),
620 ("owner_id", SemanticType::RoleId),
621 ("create_sql", SemanticType::SqlDefinition),
622 ("redacted_create_sql", SemanticType::RedactedSqlDefinition),
623 ]
624 },
625 }),
626});
627pub static MZ_INDEX_COLUMNS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
628 name: "mz_index_columns",
629 schema: MZ_CATALOG_SCHEMA,
630 oid: oid::TABLE_MZ_INDEX_COLUMNS_OID,
631 desc: RelationDesc::builder()
632 .with_column("index_id", SqlScalarType::String.nullable(false))
633 .with_column("index_position", SqlScalarType::UInt64.nullable(false))
634 .with_column("on_position", SqlScalarType::UInt64.nullable(true))
635 .with_column("on_expression", SqlScalarType::String.nullable(true))
636 .with_column("nullable", SqlScalarType::Bool.nullable(false))
637 .finish(),
638 column_comments: BTreeMap::from_iter([
639 (
640 "index_id",
641 "The ID of the index which contains this column. Corresponds to `mz_indexes.id`.",
642 ),
643 (
644 "index_position",
645 "The 1-indexed position of this column within the index. (The order of columns in an index does not necessarily match the order of columns in the relation on which the index is built.)",
646 ),
647 (
648 "on_position",
649 "If not `NULL`, specifies the 1-indexed position of a column in the relation on which this index is built that determines the value of this index column.",
650 ),
651 (
652 "on_expression",
653 "If not `NULL`, specifies a SQL expression that is evaluated to compute the value of this index column. The expression may contain references to any of the columns of the relation.",
654 ),
655 (
656 "nullable",
657 "Can this column of the index evaluate to `NULL`?",
658 ),
659 ]),
660 is_retained_metrics_object: false,
661 access: vec![PUBLIC_SELECT],
662 ontology: Some(Ontology {
663 entity_name: "index_column",
664 description: "A column or expression in an index, with its position",
665 links: &const {
666 [OntologyLink {
667 name: "belongs_to_index",
668 target: "index",
669 properties: LinkProperties::fk("index_id", "id", Cardinality::ManyToOne),
670 }]
671 },
672 column_semantic_types: &[("index_id", SemanticType::CatalogItemId)],
673 }),
674});
675pub static MZ_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
676 name: "mz_tables",
677 schema: MZ_CATALOG_SCHEMA,
678 oid: oid::TABLE_MZ_TABLES_OID,
679 desc: RelationDesc::builder()
680 .with_column("id", SqlScalarType::String.nullable(false))
681 .with_column("oid", SqlScalarType::Oid.nullable(false))
682 .with_column("schema_id", SqlScalarType::String.nullable(false))
683 .with_column("name", SqlScalarType::String.nullable(false))
684 .with_column("owner_id", SqlScalarType::String.nullable(false))
685 .with_column(
686 "privileges",
687 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
688 )
689 .with_column("create_sql", SqlScalarType::String.nullable(true))
690 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
691 .with_column("source_id", SqlScalarType::String.nullable(true))
692 .with_key(vec![0])
693 .with_key(vec![1])
694 .finish(),
695 column_comments: BTreeMap::from_iter([
696 ("id", "Materialize's unique ID for the table."),
697 ("oid", "A PostgreSQL-compatible OID for the table."),
698 (
699 "schema_id",
700 "The ID of the schema to which the table belongs. Corresponds to `mz_schemas.id`.",
701 ),
702 ("name", "The name of the table."),
703 (
704 "owner_id",
705 "The role ID of the owner of the table. Corresponds to `mz_roles.id`.",
706 ),
707 ("privileges", "The privileges belonging to the table."),
708 ("create_sql", "The `CREATE` SQL statement for the table."),
709 (
710 "redacted_create_sql",
711 "The redacted `CREATE` SQL statement for the table.",
712 ),
713 (
714 "source_id",
715 "The ID of the source associated with the table, if any. Corresponds to `mz_sources.id`.",
716 ),
717 ]),
718 is_retained_metrics_object: true,
719 access: vec![PUBLIC_SELECT],
720 ontology: Some(Ontology {
721 entity_name: "table",
722 description: "A user-writable table that can be inserted into and updated",
723 links: &const {
724 [
725 OntologyLink {
726 name: "in_schema",
727 target: "schema",
728 properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne),
729 },
730 OntologyLink {
731 name: "owned_by",
732 target: "role",
733 properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne),
734 },
735 OntologyLink {
736 name: "created_by_source",
737 target: "source",
738 properties: LinkProperties::fk_nullable(
739 "source_id",
740 "id",
741 Cardinality::ManyToOne,
742 ),
743 },
744 ]
745 },
746 column_semantic_types: &const {
747 [
748 ("id", SemanticType::CatalogItemId),
749 ("oid", SemanticType::OID),
750 ("schema_id", SemanticType::SchemaId),
751 ("owner_id", SemanticType::RoleId),
752 ("create_sql", SemanticType::SqlDefinition),
753 ("redacted_create_sql", SemanticType::RedactedSqlDefinition),
754 ("source_id", SemanticType::CatalogItemId),
755 ]
756 },
757 }),
758});
759
760pub static MZ_CONNECTIONS: LazyLock<BuiltinMaterializedView> = LazyLock::new(|| {
761 BuiltinMaterializedView {
762 name: "mz_connections",
763 schema: MZ_CATALOG_SCHEMA,
764 oid: oid::MV_MZ_CONNECTIONS_OID,
765 desc: RelationDesc::builder()
766 .with_column("id", SqlScalarType::String.nullable(false))
767 .with_column("oid", SqlScalarType::Oid.nullable(false))
768 .with_column("schema_id", SqlScalarType::String.nullable(false))
769 .with_column("name", SqlScalarType::String.nullable(false))
770 .with_column("type", SqlScalarType::String.nullable(false))
771 .with_column("owner_id", SqlScalarType::String.nullable(false))
772 .with_column(
773 "privileges",
774 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
775 )
776 .with_column("create_sql", SqlScalarType::String.nullable(false))
777 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
778 .with_key(vec![0])
779 .with_key(vec![1])
780 .finish(),
781 column_comments: BTreeMap::from_iter([
782 ("id", "The unique ID of the connection."),
783 ("oid", "A PostgreSQL-compatible OID for the connection."),
784 (
785 "schema_id",
786 "The ID of the schema to which the connection belongs. Corresponds to `mz_schemas.id`.",
787 ),
788 ("name", "The name of the connection."),
789 (
790 "type",
791 "The type of the connection: `confluent-schema-registry`, `kafka`, `postgres`, or `ssh-tunnel`.",
792 ),
793 (
794 "owner_id",
795 "The role ID of the owner of the connection. Corresponds to `mz_roles.id`.",
796 ),
797 ("privileges", "The privileges belonging to the connection."),
798 (
799 "create_sql",
800 "The `CREATE` SQL statement for the connection.",
801 ),
802 (
803 "redacted_create_sql",
804 "The redacted `CREATE` SQL statement for the connection.",
805 ),
806 ]),
807 sql: "
808IN CLUSTER mz_catalog_server
809WITH (
810 ASSERT NOT NULL id,
811 ASSERT NOT NULL oid,
812 ASSERT NOT NULL schema_id,
813 ASSERT NOT NULL name,
814 ASSERT NOT NULL type,
815 ASSERT NOT NULL owner_id,
816 ASSERT NOT NULL privileges,
817 ASSERT NOT NULL create_sql,
818 ASSERT NOT NULL redacted_create_sql
819) AS
820SELECT
821 mz_internal.parse_catalog_id(data->'key'->'gid') AS id,
822 (data->'value'->>'oid')::oid AS oid,
823 mz_internal.parse_catalog_id(data->'value'->'schema_id') AS schema_id,
824 data->'value'->>'name' AS name,
825 mz_internal.parse_catalog_create_sql(data->'value'->'definition'->'V1'->>'create_sql')->>'connection_type' AS type,
826 mz_internal.parse_catalog_id(data->'value'->'owner_id') AS owner_id,
827 mz_internal.parse_catalog_privileges(data->'value'->'privileges') AS privileges,
828 data->'value'->'definition'->'V1'->>'create_sql' AS create_sql,
829 mz_internal.redact_sql(data->'value'->'definition'->'V1'->>'create_sql') AS redacted_create_sql
830FROM mz_internal.mz_catalog_raw
831WHERE
832 data->>'kind' = 'Item' AND
833 mz_internal.parse_catalog_create_sql(data->'value'->'definition'->'V1'->>'create_sql')->>'type' = 'connection'",
834 is_retained_metrics_object: false,
835 access: vec![PUBLIC_SELECT],
836 ontology: Some(Ontology {
837 entity_name: "connection",
838 description: "A reusable connection configuration to an external system",
839 links: &const { [
840 OntologyLink {
841 name: "in_schema",
842 target: "schema",
843 properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne),
844 },
845 OntologyLink {
846 name: "owned_by",
847 target: "role",
848 properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne),
849 },
850 ] },
851 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)]},
852 }),
853 }
854});
855
856pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
857 name: "mz_ssh_tunnel_connections",
858 schema: MZ_CATALOG_SCHEMA,
859 oid: oid::TABLE_MZ_SSH_TUNNEL_CONNECTIONS_OID,
860 desc: RelationDesc::builder()
861 .with_column("id", SqlScalarType::String.nullable(false))
862 .with_column("public_key_1", SqlScalarType::String.nullable(false))
863 .with_column("public_key_2", SqlScalarType::String.nullable(false))
864 .finish(),
865 column_comments: BTreeMap::from_iter([
866 ("id", "The ID of the connection."),
867 (
868 "public_key_1",
869 "The first public key associated with the SSH tunnel.",
870 ),
871 (
872 "public_key_2",
873 "The second public key associated with the SSH tunnel.",
874 ),
875 ]),
876 is_retained_metrics_object: false,
877 access: vec![PUBLIC_SELECT],
878 ontology: Some(Ontology {
879 entity_name: "ssh_tunnel_connection",
880 description: "SSH tunnel connection with public keys",
881 links: &const {
882 [OntologyLink {
883 name: "details_of",
884 target: "connection",
885 properties: LinkProperties::fk("id", "id", Cardinality::OneToOne),
886 }]
887 },
888 column_semantic_types: &[("id", SemanticType::CatalogItemId)],
889 }),
890});
891pub static MZ_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
892 name: "mz_sources",
893 schema: MZ_CATALOG_SCHEMA,
894 oid: oid::TABLE_MZ_SOURCES_OID,
895 desc: RelationDesc::builder()
896 .with_column("id", SqlScalarType::String.nullable(false))
897 .with_column("oid", SqlScalarType::Oid.nullable(false))
898 .with_column("schema_id", SqlScalarType::String.nullable(false))
899 .with_column("name", SqlScalarType::String.nullable(false))
900 .with_column("type", SqlScalarType::String.nullable(false))
901 .with_column("connection_id", SqlScalarType::String.nullable(true))
902 .with_column("size", SqlScalarType::String.nullable(true))
903 .with_column("envelope_type", SqlScalarType::String.nullable(true))
904 .with_column("key_format", SqlScalarType::String.nullable(true))
905 .with_column("value_format", SqlScalarType::String.nullable(true))
906 .with_column("cluster_id", SqlScalarType::String.nullable(true))
907 .with_column("owner_id", SqlScalarType::String.nullable(false))
908 .with_column(
909 "privileges",
910 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
911 )
912 .with_column("create_sql", SqlScalarType::String.nullable(true))
913 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
914 .with_key(vec![0])
915 .with_key(vec![1])
916 .finish(),
917 column_comments: BTreeMap::from_iter([
918 ("id", "Materialize's unique ID for the source."),
919 ("oid", "A PostgreSQL-compatible OID for the source."),
920 (
921 "schema_id",
922 "The ID of the schema to which the source belongs. Corresponds to `mz_schemas.id`.",
923 ),
924 ("name", "The name of the source."),
925 (
926 "type",
927 "The type of the source: `kafka`, `mysql`, `postgres`, `load-generator`, `progress`, or `subsource`.",
928 ),
929 (
930 "connection_id",
931 "The ID of the connection associated with the source, if any. Corresponds to `mz_connections.id`.",
932 ),
933 ("size", "*Deprecated* The size of the source."),
934 (
935 "envelope_type",
936 "For Kafka sources, the envelope type: `none`, `upsert`, or `debezium`. `NULL` for other source types.",
937 ),
938 (
939 "key_format",
940 "For Kafka sources, the format of the Kafka message key: `avro`, `csv`, `regex`, `bytes`, `json`, `text`, or `NULL`.",
941 ),
942 (
943 "value_format",
944 "For Kafka sources, the format of the Kafka message value: `avro`, `csv`, `regex`, `bytes`, `json`, `text`. `NULL` for other source types.",
945 ),
946 (
947 "cluster_id",
948 "The ID of the cluster maintaining the source. Corresponds to `mz_clusters.id`.",
949 ),
950 (
951 "owner_id",
952 "The role ID of the owner of the source. Corresponds to `mz_roles.id`.",
953 ),
954 ("privileges", "The privileges granted on the source."),
955 ("create_sql", "The `CREATE` SQL statement for the source."),
956 (
957 "redacted_create_sql",
958 "The redacted `CREATE` SQL statement for the source.",
959 ),
960 ]),
961 is_retained_metrics_object: true,
962 access: vec![PUBLIC_SELECT],
963 ontology: Some(Ontology {
964 entity_name: "source",
965 description: "An external data source ingested into Materialize (e.g., Kafka, Postgres)",
966 links: &const {
967 [
968 OntologyLink {
969 name: "in_schema",
970 target: "schema",
971 properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne),
972 },
973 OntologyLink {
974 name: "owned_by",
975 target: "role",
976 properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne),
977 },
978 OntologyLink {
979 name: "runs_on_cluster",
980 target: "cluster",
981 properties: LinkProperties::fk_nullable(
982 "cluster_id",
983 "id",
984 Cardinality::ManyToOne,
985 ),
986 },
987 OntologyLink {
988 name: "uses_connection",
989 target: "connection",
990 properties: LinkProperties::fk_nullable(
991 "connection_id",
992 "id",
993 Cardinality::ManyToOne,
994 ),
995 },
996 ]
997 },
998 column_semantic_types: &const {
999 [
1000 ("id", SemanticType::CatalogItemId),
1001 ("oid", SemanticType::OID),
1002 ("schema_id", SemanticType::SchemaId),
1003 ("type", SemanticType::SourceType),
1004 ("connection_id", SemanticType::CatalogItemId),
1005 ("cluster_id", SemanticType::ClusterId),
1006 ("owner_id", SemanticType::RoleId),
1007 ("create_sql", SemanticType::SqlDefinition),
1008 ("redacted_create_sql", SemanticType::RedactedSqlDefinition),
1009 ]
1010 },
1011 }),
1012});
1013pub static MZ_SINKS: LazyLock<BuiltinTable> = LazyLock::new(|| {
1014 BuiltinTable {
1015 name: "mz_sinks",
1016 schema: MZ_CATALOG_SCHEMA,
1017 oid: oid::TABLE_MZ_SINKS_OID,
1018 desc: RelationDesc::builder()
1019 .with_column("id", SqlScalarType::String.nullable(false))
1020 .with_column("oid", SqlScalarType::Oid.nullable(false))
1021 .with_column("schema_id", SqlScalarType::String.nullable(false))
1022 .with_column("name", SqlScalarType::String.nullable(false))
1023 .with_column("type", SqlScalarType::String.nullable(false))
1024 .with_column("connection_id", SqlScalarType::String.nullable(true))
1025 .with_column("size", SqlScalarType::String.nullable(true))
1026 .with_column("envelope_type", SqlScalarType::String.nullable(true))
1027 .with_column("format", SqlScalarType::String.nullable(true))
1030 .with_column("key_format", SqlScalarType::String.nullable(true))
1031 .with_column("value_format", SqlScalarType::String.nullable(true))
1032 .with_column("cluster_id", SqlScalarType::String.nullable(false))
1033 .with_column("owner_id", SqlScalarType::String.nullable(false))
1034 .with_column("create_sql", SqlScalarType::String.nullable(false))
1035 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
1036 .with_key(vec![0])
1037 .with_key(vec![1])
1038 .finish(),
1039 column_comments: BTreeMap::from_iter([
1040 ("id", "Materialize's unique ID for the sink."),
1041 ("oid", "A PostgreSQL-compatible OID for the sink."),
1042 (
1043 "schema_id",
1044 "The ID of the schema to which the sink belongs. Corresponds to `mz_schemas.id`.",
1045 ),
1046 ("name", "The name of the sink."),
1047 ("type", "The type of the sink: `kafka`."),
1048 (
1049 "connection_id",
1050 "The ID of the connection associated with the sink, if any. Corresponds to `mz_connections.id`.",
1051 ),
1052 ("size", "The size of the sink."),
1053 (
1054 "envelope_type",
1055 "The envelope of the sink: `upsert`, or `debezium`.",
1056 ),
1057 (
1058 "format",
1059 "*Deprecated* The format of the Kafka messages produced by the sink: `avro`, `json`, `text`, or `bytes`.",
1060 ),
1061 (
1062 "key_format",
1063 "The format of the Kafka message key for messages produced by the sink: `avro`, `json`, `bytes`, `text`, or `NULL`.",
1064 ),
1065 (
1066 "value_format",
1067 "The format of the Kafka message value for messages produced by the sink: `avro`, `json`, `text`, or `bytes`.",
1068 ),
1069 (
1070 "cluster_id",
1071 "The ID of the cluster maintaining the sink. Corresponds to `mz_clusters.id`.",
1072 ),
1073 (
1074 "owner_id",
1075 "The role ID of the owner of the sink. Corresponds to `mz_roles.id`.",
1076 ),
1077 ("create_sql", "The `CREATE` SQL statement for the sink."),
1078 (
1079 "redacted_create_sql",
1080 "The redacted `CREATE` SQL statement for the sink.",
1081 ),
1082 ]),
1083 is_retained_metrics_object: true,
1084 access: vec![PUBLIC_SELECT],
1085 ontology: Some(Ontology {
1086 entity_name: "sink",
1087 description: "An export of data from Materialize to an external system",
1088 links: &const {
1089 [
1090 OntologyLink {
1091 name: "in_schema",
1092 target: "schema",
1093 properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne),
1094 },
1095 OntologyLink {
1096 name: "owned_by",
1097 target: "role",
1098 properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne),
1099 },
1100 OntologyLink {
1101 name: "runs_on_cluster",
1102 target: "cluster",
1103 properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne),
1104 },
1105 OntologyLink {
1106 name: "uses_connection",
1107 target: "connection",
1108 properties: LinkProperties::fk_nullable(
1109 "connection_id",
1110 "id",
1111 Cardinality::ManyToOne,
1112 ),
1113 },
1114 ]
1115 },
1116 column_semantic_types: &const {
1117 [
1118 ("id", SemanticType::CatalogItemId),
1119 ("oid", SemanticType::OID),
1120 ("schema_id", SemanticType::SchemaId),
1121 ("connection_id", SemanticType::CatalogItemId),
1122 ("cluster_id", SemanticType::ClusterId),
1123 ("owner_id", SemanticType::RoleId),
1124 ("create_sql", SemanticType::SqlDefinition),
1125 ("redacted_create_sql", SemanticType::RedactedSqlDefinition),
1126 ]
1127 },
1128 }),
1129 }
1130});
1131pub static MZ_VIEWS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
1132 name: "mz_views",
1133 schema: MZ_CATALOG_SCHEMA,
1134 oid: oid::TABLE_MZ_VIEWS_OID,
1135 desc: RelationDesc::builder()
1136 .with_column("id", SqlScalarType::String.nullable(false))
1137 .with_column("oid", SqlScalarType::Oid.nullable(false))
1138 .with_column("schema_id", SqlScalarType::String.nullable(false))
1139 .with_column("name", SqlScalarType::String.nullable(false))
1140 .with_column("definition", SqlScalarType::String.nullable(false))
1141 .with_column("owner_id", SqlScalarType::String.nullable(false))
1142 .with_column(
1143 "privileges",
1144 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
1145 )
1146 .with_column("create_sql", SqlScalarType::String.nullable(false))
1147 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
1148 .with_key(vec![0])
1149 .with_key(vec![1])
1150 .finish(),
1151 column_comments: BTreeMap::from_iter([
1152 ("id", "Materialize's unique ID for the view."),
1153 ("oid", "A PostgreSQL-compatible OID for the view."),
1154 (
1155 "schema_id",
1156 "The ID of the schema to which the view belongs. Corresponds to `mz_schemas.id`.",
1157 ),
1158 ("name", "The name of the view."),
1159 ("definition", "The view definition (a `SELECT` query)."),
1160 (
1161 "owner_id",
1162 "The role ID of the owner of the view. Corresponds to `mz_roles.id`.",
1163 ),
1164 ("privileges", "The privileges belonging to the view."),
1165 ("create_sql", "The `CREATE` SQL statement for the view."),
1166 (
1167 "redacted_create_sql",
1168 "The redacted `CREATE` SQL statement for the view.",
1169 ),
1170 ]),
1171 is_retained_metrics_object: false,
1172 access: vec![PUBLIC_SELECT],
1173 ontology: Some(Ontology {
1174 entity_name: "view",
1175 description: "A non-materialized view defined by a SQL query",
1176 links: &const {
1177 [
1178 OntologyLink {
1179 name: "in_schema",
1180 target: "schema",
1181 properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne),
1182 },
1183 OntologyLink {
1184 name: "owned_by",
1185 target: "role",
1186 properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne),
1187 },
1188 ]
1189 },
1190 column_semantic_types: &const {
1191 [
1192 ("id", SemanticType::CatalogItemId),
1193 ("oid", SemanticType::OID),
1194 ("schema_id", SemanticType::SchemaId),
1195 ("definition", SemanticType::SqlDefinition),
1196 ("owner_id", SemanticType::RoleId),
1197 ("create_sql", SemanticType::SqlDefinition),
1198 ("redacted_create_sql", SemanticType::RedactedSqlDefinition),
1199 ]
1200 },
1201 }),
1202});
1203
1204pub static MZ_MATERIALIZED_VIEWS: LazyLock<BuiltinMaterializedView> = LazyLock::new(|| {
1205 BuiltinMaterializedView {
1206 name: "mz_materialized_views",
1207 schema: MZ_CATALOG_SCHEMA,
1208 oid: oid::MV_MZ_MATERIALIZED_VIEWS_OID,
1209 desc: RelationDesc::builder()
1210 .with_column("id", SqlScalarType::String.nullable(false))
1211 .with_column("oid", SqlScalarType::Oid.nullable(false))
1212 .with_column("schema_id", SqlScalarType::String.nullable(false))
1213 .with_column("name", SqlScalarType::String.nullable(false))
1214 .with_column("cluster_id", SqlScalarType::String.nullable(false))
1215 .with_column("definition", SqlScalarType::String.nullable(false))
1216 .with_column("owner_id", SqlScalarType::String.nullable(false))
1217 .with_column(
1218 "privileges",
1219 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
1220 )
1221 .with_column("create_sql", SqlScalarType::String.nullable(false))
1222 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
1223 .with_key(vec![0])
1224 .with_key(vec![1])
1225 .finish(),
1226 column_comments: BTreeMap::from_iter([
1227 ("id", "Materialize's unique ID for the materialized view."),
1228 (
1229 "oid",
1230 "A PostgreSQL-compatible OID for the materialized view.",
1231 ),
1232 (
1233 "schema_id",
1234 "The ID of the schema to which the materialized view belongs. Corresponds to `mz_schemas.id`.",
1235 ),
1236 ("name", "The name of the materialized view."),
1237 (
1238 "cluster_id",
1239 "The ID of the cluster maintaining the materialized view. Corresponds to `mz_clusters.id`.",
1240 ),
1241 (
1242 "definition",
1243 "The materialized view definition (a `SELECT` query).",
1244 ),
1245 (
1246 "owner_id",
1247 "The role ID of the owner of the materialized view. Corresponds to `mz_roles.id`.",
1248 ),
1249 (
1250 "privileges",
1251 "The privileges belonging to the materialized view.",
1252 ),
1253 (
1254 "create_sql",
1255 "The `CREATE` SQL statement for the materialized view.",
1256 ),
1257 (
1258 "redacted_create_sql",
1259 "The redacted `CREATE` SQL statement for the materialized view.",
1260 ),
1261 ]),
1262 sql: Box::leak(format!("
1263IN CLUSTER mz_catalog_server
1264WITH (
1265 ASSERT NOT NULL id,
1266 ASSERT NOT NULL oid,
1267 ASSERT NOT NULL schema_id,
1268 ASSERT NOT NULL name,
1269 ASSERT NOT NULL cluster_id,
1270 ASSERT NOT NULL definition,
1271 ASSERT NOT NULL owner_id,
1272 ASSERT NOT NULL privileges,
1273 ASSERT NOT NULL create_sql,
1274 ASSERT NOT NULL redacted_create_sql
1275) AS
1276WITH
1277 user_mvs AS (
1278 SELECT
1279 mz_internal.parse_catalog_id(data->'key'->'gid') AS id,
1280 (data->'value'->>'oid')::oid AS oid,
1281 mz_internal.parse_catalog_id(data->'value'->'schema_id') AS schema_id,
1282 data->'value'->>'name' AS name,
1283 mz_internal.parse_catalog_create_sql(data->'value'->'definition'->'V1'->>'create_sql')->>'cluster_id' AS cluster_id,
1284 mz_internal.parse_catalog_create_sql(data->'value'->'definition'->'V1'->>'create_sql')->>'definition' AS definition,
1285 mz_internal.parse_catalog_id(data->'value'->'owner_id') AS owner_id,
1286 mz_internal.parse_catalog_privileges(data->'value'->'privileges') AS privileges,
1287 data->'value'->'definition'->'V1'->>'create_sql' AS create_sql,
1288 mz_internal.redact_sql(data->'value'->'definition'->'V1'->>'create_sql') AS redacted_create_sql
1289 FROM mz_internal.mz_catalog_raw
1290 WHERE
1291 data->>'kind' = 'Item' AND
1292 mz_internal.parse_catalog_create_sql(data->'value'->'definition'->'V1'->>'create_sql')->>'type' = 'materialized-view'
1293 ),
1294 builtin_mappings AS (
1295 SELECT
1296 data->'key'->>'schema_name' AS schema_name,
1297 data->'key'->>'object_name' AS name,
1298 's' || (data->'value'->>'catalog_id') AS id
1299 FROM mz_internal.mz_catalog_raw
1300 WHERE
1301 data->>'kind' = 'GidMapping' AND
1302 data->'key'->>'object_type' = '5'
1303 ),
1304 builtin_mvs AS (
1305 SELECT
1306 m.id,
1307 mv.oid,
1308 s.id AS schema_id,
1309 mv.name,
1310 c.id AS cluster_id,
1311 mv.definition,
1312 '{MZ_SYSTEM_ROLE_ID}' AS owner_id,
1313 mv.privileges,
1314 mv.create_sql,
1315 mz_internal.redact_sql(mv.create_sql) AS redacted_create_sql
1316 FROM mz_internal.mz_builtin_materialized_views mv
1317 JOIN builtin_mappings m USING (schema_name, name)
1318 JOIN mz_schemas s ON s.name = mv.schema_name
1319 JOIN mz_clusters c ON c.name = mv.cluster_name
1320 WHERE s.database_id IS NULL
1321 )
1322SELECT * FROM user_mvs
1323UNION ALL
1324SELECT * FROM builtin_mvs").into_boxed_str()),
1325 is_retained_metrics_object: false,
1326 access: vec![PUBLIC_SELECT],
1327 ontology: Some(Ontology {
1328 entity_name: "mv",
1329 description: "A materialized view maintained incrementally on a cluster",
1330 links: &const { [
1331 OntologyLink { name: "in_schema", target: "schema", properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne) },
1332 OntologyLink { name: "owned_by", target: "role", properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne) },
1333 OntologyLink { name: "runs_on_cluster", target: "cluster", properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne) },
1334 ] },
1335 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)]},
1336 }),
1337 }
1338});
1339pub static MZ_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
1340 name: "mz_types",
1341 schema: MZ_CATALOG_SCHEMA,
1342 oid: oid::TABLE_MZ_TYPES_OID,
1343 desc: RelationDesc::builder()
1344 .with_column("id", SqlScalarType::String.nullable(false))
1345 .with_column("oid", SqlScalarType::Oid.nullable(false))
1346 .with_column("schema_id", SqlScalarType::String.nullable(false))
1347 .with_column("name", SqlScalarType::String.nullable(false))
1348 .with_column("category", SqlScalarType::String.nullable(false))
1349 .with_column("owner_id", SqlScalarType::String.nullable(false))
1350 .with_column(
1351 "privileges",
1352 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
1353 )
1354 .with_column("create_sql", SqlScalarType::String.nullable(true))
1355 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
1356 .with_key(vec![0])
1357 .with_key(vec![1])
1358 .finish(),
1359 column_comments: BTreeMap::from_iter([
1360 ("id", "Materialize's unique ID for the type."),
1361 ("oid", "A PostgreSQL-compatible OID for the type."),
1362 (
1363 "schema_id",
1364 "The ID of the schema to which the type belongs. Corresponds to `mz_schemas.id`.",
1365 ),
1366 ("name", "The name of the type."),
1367 ("category", "The category of the type."),
1368 (
1369 "owner_id",
1370 "The role ID of the owner of the type. Corresponds to `mz_roles.id`.",
1371 ),
1372 ("privileges", "The privileges belonging to the type."),
1373 ("create_sql", "The `CREATE` SQL statement for the type."),
1374 (
1375 "redacted_create_sql",
1376 "The redacted `CREATE` SQL statement for the type.",
1377 ),
1378 ]),
1379 is_retained_metrics_object: false,
1380 access: vec![PUBLIC_SELECT],
1381 ontology: Some(Ontology {
1382 entity_name: "type",
1383 description: "A named data type (base, array, list, map, or pseudo)",
1384 links: &const {
1385 [
1386 OntologyLink {
1387 name: "in_schema",
1388 target: "schema",
1389 properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne),
1390 },
1391 OntologyLink {
1392 name: "owned_by",
1393 target: "role",
1394 properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne),
1395 },
1396 ]
1397 },
1398 column_semantic_types: &const {
1399 [
1400 ("id", SemanticType::CatalogItemId),
1401 ("oid", SemanticType::OID),
1402 ("schema_id", SemanticType::SchemaId),
1403 ("owner_id", SemanticType::RoleId),
1404 ("create_sql", SemanticType::SqlDefinition),
1405 ("redacted_create_sql", SemanticType::RedactedSqlDefinition),
1406 ]
1407 },
1408 }),
1409});
1410pub static MZ_ARRAY_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
1411 name: "mz_array_types",
1412 schema: MZ_CATALOG_SCHEMA,
1413 oid: oid::TABLE_MZ_ARRAY_TYPES_OID,
1414 desc: RelationDesc::builder()
1415 .with_column("id", SqlScalarType::String.nullable(false))
1416 .with_column("element_id", SqlScalarType::String.nullable(false))
1417 .finish(),
1418 column_comments: BTreeMap::from_iter([
1419 ("id", "The ID of the array type."),
1420 ("element_id", "The ID of the array's element type."),
1421 ]),
1422 is_retained_metrics_object: false,
1423 access: vec![PUBLIC_SELECT],
1424 ontology: Some(Ontology {
1425 entity_name: "array_type",
1426 description: "An array type with its element type",
1427 links: &const {
1428 [
1429 OntologyLink {
1430 name: "detail_of",
1431 target: "type",
1432 properties: LinkProperties::fk("id", "id", Cardinality::OneToOne),
1433 },
1434 OntologyLink {
1435 name: "has_element_type",
1436 target: "type",
1437 properties: LinkProperties::fk("element_id", "id", Cardinality::ManyToOne),
1438 },
1439 ]
1440 },
1441 column_semantic_types: &const {
1442 [
1443 ("id", SemanticType::CatalogItemId),
1444 ("element_id", SemanticType::CatalogItemId),
1445 ]
1446 },
1447 }),
1448});
1449pub static MZ_BASE_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
1450 name: "mz_base_types",
1451 schema: MZ_CATALOG_SCHEMA,
1452 oid: oid::TABLE_MZ_BASE_TYPES_OID,
1453 desc: RelationDesc::builder()
1454 .with_column("id", SqlScalarType::String.nullable(false))
1455 .finish(),
1456 column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]),
1457 is_retained_metrics_object: false,
1458 access: vec![PUBLIC_SELECT],
1459 ontology: Some(Ontology {
1460 entity_name: "base_type",
1461 description: "A primitive/base data type",
1462 links: &const { [] },
1463 column_semantic_types: &[("id", SemanticType::CatalogItemId)],
1464 }),
1465});
1466pub static MZ_LIST_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
1467 name: "mz_list_types",
1468 schema: MZ_CATALOG_SCHEMA,
1469 oid: oid::TABLE_MZ_LIST_TYPES_OID,
1470 desc: RelationDesc::builder()
1471 .with_column("id", SqlScalarType::String.nullable(false))
1472 .with_column("element_id", SqlScalarType::String.nullable(false))
1473 .with_column(
1474 "element_modifiers",
1475 SqlScalarType::List {
1476 element_type: Box::new(SqlScalarType::Int64),
1477 custom_id: None,
1478 }
1479 .nullable(true),
1480 )
1481 .finish(),
1482 column_comments: BTreeMap::from_iter([
1483 ("id", "The ID of the list type."),
1484 ("element_id", "The IID of the list's element type."),
1485 (
1486 "element_modifiers",
1487 "The element type modifiers, or `NULL` if none.",
1488 ),
1489 ]),
1490 is_retained_metrics_object: false,
1491 access: vec![PUBLIC_SELECT],
1492 ontology: Some(Ontology {
1493 entity_name: "list_type",
1494 description: "A list type with its element type",
1495 links: &const {
1496 [
1497 OntologyLink {
1498 name: "detail_of",
1499 target: "type",
1500 properties: LinkProperties::fk("id", "id", Cardinality::OneToOne),
1501 },
1502 OntologyLink {
1503 name: "has_element_type",
1504 target: "type",
1505 properties: LinkProperties::fk("element_id", "id", Cardinality::ManyToOne),
1506 },
1507 ]
1508 },
1509 column_semantic_types: &const {
1510 [
1511 ("id", SemanticType::CatalogItemId),
1512 ("element_id", SemanticType::CatalogItemId),
1513 ]
1514 },
1515 }),
1516});
1517pub static MZ_MAP_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
1518 name: "mz_map_types",
1519 schema: MZ_CATALOG_SCHEMA,
1520 oid: oid::TABLE_MZ_MAP_TYPES_OID,
1521 desc: RelationDesc::builder()
1522 .with_column("id", SqlScalarType::String.nullable(false))
1523 .with_column("key_id", SqlScalarType::String.nullable(false))
1524 .with_column("value_id", SqlScalarType::String.nullable(false))
1525 .with_column(
1526 "key_modifiers",
1527 SqlScalarType::List {
1528 element_type: Box::new(SqlScalarType::Int64),
1529 custom_id: None,
1530 }
1531 .nullable(true),
1532 )
1533 .with_column(
1534 "value_modifiers",
1535 SqlScalarType::List {
1536 element_type: Box::new(SqlScalarType::Int64),
1537 custom_id: None,
1538 }
1539 .nullable(true),
1540 )
1541 .finish(),
1542 column_comments: BTreeMap::from_iter([
1543 ("id", "The ID of the map type."),
1544 ("key_id", "The ID of the map's key type."),
1545 ("value_id", "The ID of the map's value type."),
1546 (
1547 "key_modifiers",
1548 "The key type modifiers, or `NULL` if none.",
1549 ),
1550 (
1551 "value_modifiers",
1552 "The value type modifiers, or `NULL` if none.",
1553 ),
1554 ]),
1555 is_retained_metrics_object: false,
1556 access: vec![PUBLIC_SELECT],
1557 ontology: Some(Ontology {
1558 entity_name: "map_type",
1559 description: "A map type with its key and value types",
1560 links: &const {
1561 [
1562 OntologyLink {
1563 name: "detail_of",
1564 target: "type",
1565 properties: LinkProperties::fk("id", "id", Cardinality::OneToOne),
1566 },
1567 OntologyLink {
1568 name: "has_key_type",
1569 target: "type",
1570 properties: LinkProperties::fk("key_id", "id", Cardinality::ManyToOne),
1571 },
1572 OntologyLink {
1573 name: "has_value_type",
1574 target: "type",
1575 properties: LinkProperties::fk("value_id", "id", Cardinality::ManyToOne),
1576 },
1577 ]
1578 },
1579 column_semantic_types: &const {
1580 [
1581 ("id", SemanticType::CatalogItemId),
1582 ("key_id", SemanticType::CatalogItemId),
1583 ("value_id", SemanticType::CatalogItemId),
1584 ]
1585 },
1586 }),
1587});
1588pub static MZ_ROLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
1589 name: "mz_roles",
1590 schema: MZ_CATALOG_SCHEMA,
1591 oid: oid::TABLE_MZ_ROLES_OID,
1592 desc: RelationDesc::builder()
1593 .with_column("id", SqlScalarType::String.nullable(false))
1594 .with_column("oid", SqlScalarType::Oid.nullable(false))
1595 .with_column("name", SqlScalarType::String.nullable(false))
1596 .with_column("inherit", SqlScalarType::Bool.nullable(false))
1597 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(true))
1598 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
1599 .with_key(vec![0])
1600 .with_key(vec![1])
1601 .finish(),
1602 column_comments: BTreeMap::from_iter([
1603 ("id", "Materialize's unique ID for the role."),
1604 ("oid", "A PostgreSQL-compatible OID for the role."),
1605 ("name", "The name of the role."),
1606 (
1607 "inherit",
1608 "Indicates whether the role has inheritance of privileges.",
1609 ),
1610 ("rolcanlogin", "Indicates whether the role can log in."),
1611 ("rolsuper", "Indicates whether the role is a superuser."),
1612 ]),
1613 is_retained_metrics_object: false,
1614 access: vec![PUBLIC_SELECT],
1615 ontology: Some(Ontology {
1616 entity_name: "role",
1617 description: "A user or role for authentication and access control",
1618 links: &const { [] },
1619 column_semantic_types: &const { [("id", SemanticType::RoleId), ("oid", SemanticType::OID)] },
1620 }),
1621});
1622
1623pub static MZ_ROLE_MEMBERS: LazyLock<BuiltinMaterializedView> = LazyLock::new(|| {
1624 BuiltinMaterializedView {
1625 name: "mz_role_members",
1626 schema: MZ_CATALOG_SCHEMA,
1627 oid: oid::MV_MZ_ROLE_MEMBERS_OID,
1628 desc: RelationDesc::builder()
1629 .with_column("role_id", SqlScalarType::String.nullable(false))
1630 .with_column("member", SqlScalarType::String.nullable(false))
1631 .with_column("grantor", SqlScalarType::String.nullable(false))
1632 .finish(),
1633 column_comments: BTreeMap::from_iter([
1634 (
1635 "role_id",
1636 "The ID of the role the `member` is a member of. Corresponds to `mz_roles.id`.",
1637 ),
1638 (
1639 "member",
1640 "The ID of the role that is a member of `role_id`. Corresponds to `mz_roles.id`.",
1641 ),
1642 (
1643 "grantor",
1644 "The ID of the role that granted membership of `member` to `role_id`. Corresponds to `mz_roles.id`.",
1645 ),
1646 ]),
1647 sql: "
1648IN CLUSTER mz_catalog_server
1649WITH (
1650 ASSERT NOT NULL role_id,
1651 ASSERT NOT NULL member,
1652 ASSERT NOT NULL grantor
1653) AS
1654SELECT
1655 mz_internal.parse_catalog_id(entry->'key') AS role_id,
1656 mz_internal.parse_catalog_id(data->'key'->'id') AS member,
1657 mz_internal.parse_catalog_id(entry->'value') AS grantor
1658FROM
1659 mz_internal.mz_catalog_raw,
1660 jsonb_array_elements(data->'value'->'membership'->'map') AS entry
1661WHERE data->>'kind' = 'Role'",
1662 is_retained_metrics_object: false,
1663 access: vec![PUBLIC_SELECT],
1664 ontology: Some(Ontology {
1665 entity_name: "role_membership",
1666 description: "A membership grant: one role is a member of another role",
1667 links: &const {
1668 [
1669 OntologyLink {
1670 name: "group_role",
1671 target: "role",
1672 properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne),
1673 },
1674 OntologyLink {
1675 name: "member_role",
1676 target: "role",
1677 properties: LinkProperties::fk("member", "id", Cardinality::ManyToOne),
1678 },
1679 OntologyLink {
1680 name: "granted_by",
1681 target: "role",
1682 properties: LinkProperties::fk("grantor", "id", Cardinality::ManyToOne),
1683 },
1684 ]
1685 },
1686 column_semantic_types: &const {
1687 [
1688 ("role_id", SemanticType::RoleId),
1689 ("member", SemanticType::RoleId),
1690 ("grantor", SemanticType::RoleId),
1691 ]
1692 },
1693 }),
1694 }
1695});
1696
1697pub static MZ_ROLE_PARAMETERS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
1698 name: "mz_role_parameters",
1699 schema: MZ_CATALOG_SCHEMA,
1700 oid: oid::TABLE_MZ_ROLE_PARAMETERS_OID,
1701 desc: RelationDesc::builder()
1702 .with_column("role_id", SqlScalarType::String.nullable(false))
1703 .with_column("parameter_name", SqlScalarType::String.nullable(false))
1704 .with_column("parameter_value", SqlScalarType::String.nullable(false))
1705 .finish(),
1706 column_comments: BTreeMap::from_iter([
1707 (
1708 "role_id",
1709 "The ID of the role whose configuration parameter default is set. Corresponds to `mz_roles.id`.",
1710 ),
1711 (
1712 "parameter_name",
1713 "The configuration parameter name. One of the supported configuration parameters.",
1714 ),
1715 (
1716 "parameter_value",
1717 "The default value of the parameter for the given role. Can be either a single value, or a comma-separated list of values for configuration parameters that accept a list.",
1718 ),
1719 ]),
1720 is_retained_metrics_object: false,
1721 access: vec![PUBLIC_SELECT],
1722 ontology: Some(Ontology {
1723 entity_name: "role_parameter",
1724 description: "A session parameter default set for a role",
1725 links: &const {
1726 [OntologyLink {
1727 name: "default_parameter_setting_of",
1728 target: "role",
1729 properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne),
1730 }]
1731 },
1732 column_semantic_types: &[("role_id", SemanticType::RoleId)],
1733 }),
1734});
1735pub static MZ_ROLE_AUTH: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
1736 name: "mz_role_auth",
1737 schema: MZ_CATALOG_SCHEMA,
1738 oid: oid::TABLE_MZ_ROLE_AUTH_OID,
1739 desc: RelationDesc::builder()
1740 .with_column("role_id", SqlScalarType::String.nullable(false))
1741 .with_column("role_oid", SqlScalarType::Oid.nullable(false))
1742 .with_column("password_hash", SqlScalarType::String.nullable(true))
1743 .with_column(
1744 "updated_at",
1745 SqlScalarType::TimestampTz { precision: None }.nullable(false),
1746 )
1747 .finish(),
1748 column_comments: BTreeMap::from_iter([
1749 (
1750 "role_id",
1751 "The ID of the role. Corresponds to `mz_roles.id`.",
1752 ),
1753 ("role_oid", "A PostgreSQL-compatible OID for the role."),
1754 (
1755 "password_hash",
1756 "The hashed password for the role, if any. Uses the `SCRAM-SHA-256` algorithm.",
1757 ),
1758 (
1759 "updated_at",
1760 "The time at which the password was last updated.",
1761 ),
1762 ]),
1763 is_retained_metrics_object: false,
1764 access: vec![rbac::owner_privilege(ObjectType::Table, MZ_SYSTEM_ROLE_ID)],
1765 ontology: None,
1766});
1767pub static MZ_PSEUDO_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
1768 name: "mz_pseudo_types",
1769 schema: MZ_CATALOG_SCHEMA,
1770 oid: oid::TABLE_MZ_PSEUDO_TYPES_OID,
1771 desc: RelationDesc::builder()
1772 .with_column("id", SqlScalarType::String.nullable(false))
1773 .finish(),
1774 column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]),
1775 is_retained_metrics_object: false,
1776 access: vec![PUBLIC_SELECT],
1777 ontology: Some(Ontology {
1778 entity_name: "pseudo_type",
1779 description: "A pseudo-type used in function signatures",
1780 links: &const { [] },
1781 column_semantic_types: &[("id", SemanticType::CatalogItemId)],
1782 }),
1783});
1784pub static MZ_FUNCTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| {
1785 BuiltinTable {
1786 name: "mz_functions",
1787 schema: MZ_CATALOG_SCHEMA,
1788 oid: oid::TABLE_MZ_FUNCTIONS_OID,
1789 desc: RelationDesc::builder()
1790 .with_column("id", SqlScalarType::String.nullable(false)) .with_column("oid", SqlScalarType::Oid.nullable(false))
1792 .with_column("schema_id", SqlScalarType::String.nullable(false))
1793 .with_column("name", SqlScalarType::String.nullable(false))
1794 .with_column(
1795 "argument_type_ids",
1796 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
1797 )
1798 .with_column(
1799 "variadic_argument_type_id",
1800 SqlScalarType::String.nullable(true),
1801 )
1802 .with_column("return_type_id", SqlScalarType::String.nullable(true))
1803 .with_column("returns_set", SqlScalarType::Bool.nullable(false))
1804 .with_column("owner_id", SqlScalarType::String.nullable(false))
1805 .finish(),
1806 column_comments: BTreeMap::from_iter([
1807 ("id", "Materialize's unique ID for the function."),
1808 ("oid", "A PostgreSQL-compatible OID for the function."),
1809 (
1810 "schema_id",
1811 "The ID of the schema to which the function belongs. Corresponds to `mz_schemas.id`.",
1812 ),
1813 ("name", "The name of the function."),
1814 (
1815 "argument_type_ids",
1816 "The ID of each argument's type. Each entry refers to `mz_types.id`.",
1817 ),
1818 (
1819 "variadic_argument_type_id",
1820 "The ID of the variadic argument's type, or `NULL` if the function does not have a variadic argument. Refers to `mz_types.id`.",
1821 ),
1822 (
1823 "return_type_id",
1824 "The returned value's type, or `NULL` if the function does not return a value. Refers to `mz_types.id`. Note that for table functions with > 1 column, this type corresponds to [`record`].",
1825 ),
1826 (
1827 "returns_set",
1828 "Whether the function returns a set, i.e. the function is a table function.",
1829 ),
1830 (
1831 "owner_id",
1832 "The role ID of the owner of the function. Corresponds to `mz_roles.id`.",
1833 ),
1834 ]),
1835 is_retained_metrics_object: false,
1836 access: vec![PUBLIC_SELECT],
1837 ontology: Some(Ontology {
1838 entity_name: "function",
1839 description: "A built-in or user-defined function",
1840 links: &const {
1841 [
1842 OntologyLink {
1843 name: "in_schema",
1844 target: "schema",
1845 properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne),
1846 },
1847 OntologyLink {
1848 name: "owned_by",
1849 target: "role",
1850 properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne),
1851 },
1852 OntologyLink {
1853 name: "returns_type",
1854 target: "type",
1855 properties: LinkProperties::fk_nullable(
1856 "return_type_id",
1857 "id",
1858 Cardinality::ManyToOne,
1859 ),
1860 },
1861 OntologyLink {
1862 name: "has_variadic_arg_type",
1863 target: "type",
1864 properties: LinkProperties::fk_nullable(
1865 "variadic_argument_type_id",
1866 "id",
1867 Cardinality::ManyToOne,
1868 ),
1869 },
1870 ]
1871 },
1872 column_semantic_types: &const {
1873 [
1874 ("id", SemanticType::CatalogItemId),
1875 ("oid", SemanticType::OID),
1876 ("schema_id", SemanticType::SchemaId),
1877 ("variadic_argument_type_id", SemanticType::CatalogItemId),
1878 ("return_type_id", SemanticType::CatalogItemId),
1879 ("owner_id", SemanticType::RoleId),
1880 ]
1881 },
1882 }),
1883 }
1884});
1885pub static MZ_OPERATORS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
1886 name: "mz_operators",
1887 schema: MZ_CATALOG_SCHEMA,
1888 oid: oid::TABLE_MZ_OPERATORS_OID,
1889 desc: RelationDesc::builder()
1890 .with_column("oid", SqlScalarType::Oid.nullable(false))
1891 .with_column("name", SqlScalarType::String.nullable(false))
1892 .with_column(
1893 "argument_type_ids",
1894 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
1895 )
1896 .with_column("return_type_id", SqlScalarType::String.nullable(true))
1897 .finish(),
1898 column_comments: BTreeMap::new(),
1899 is_retained_metrics_object: false,
1900 access: vec![PUBLIC_SELECT],
1901 ontology: Some(Ontology {
1902 entity_name: "operator",
1903 description: "A built-in SQL operator",
1904 links: &const {
1905 [OntologyLink {
1906 name: "returns_type",
1907 target: "type",
1908 properties: LinkProperties::fk_nullable(
1909 "return_type_id",
1910 "id",
1911 Cardinality::ManyToOne,
1912 ),
1913 }]
1914 },
1915 column_semantic_types: &const {
1916 [
1917 ("oid", SemanticType::OID),
1918 ("return_type_id", SemanticType::CatalogItemId),
1919 ]
1920 },
1921 }),
1922});
1923
1924pub static MZ_CLUSTERS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
1925 name: "mz_clusters",
1926 schema: MZ_CATALOG_SCHEMA,
1927 oid: oid::TABLE_MZ_CLUSTERS_OID,
1928 desc: RelationDesc::builder()
1929 .with_column("id", SqlScalarType::String.nullable(false))
1930 .with_column("name", SqlScalarType::String.nullable(false))
1931 .with_column("owner_id", SqlScalarType::String.nullable(false))
1932 .with_column(
1933 "privileges",
1934 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
1935 )
1936 .with_column("managed", SqlScalarType::Bool.nullable(false))
1937 .with_column("size", SqlScalarType::String.nullable(true))
1938 .with_column("replication_factor", SqlScalarType::UInt32.nullable(true))
1939 .with_column("disk", SqlScalarType::Bool.nullable(true))
1940 .with_column(
1941 "availability_zones",
1942 SqlScalarType::List {
1943 element_type: Box::new(SqlScalarType::String),
1944 custom_id: None,
1945 }
1946 .nullable(true),
1947 )
1948 .with_column(
1949 "introspection_debugging",
1950 SqlScalarType::Bool.nullable(true),
1951 )
1952 .with_column(
1953 "introspection_interval",
1954 SqlScalarType::Interval.nullable(true),
1955 )
1956 .with_key(vec![0])
1957 .finish(),
1958 column_comments: BTreeMap::from_iter([
1959 ("id", "Materialize's unique ID for the cluster."),
1960 ("name", "The name of the cluster."),
1961 (
1962 "owner_id",
1963 "The role ID of the owner of the cluster. Corresponds to `mz_roles.id`.",
1964 ),
1965 ("privileges", "The privileges belonging to the cluster."),
1966 (
1967 "managed",
1968 "Whether the cluster is a managed cluster with automatically managed replicas.",
1969 ),
1970 (
1971 "size",
1972 "If the cluster is managed, the desired size of the cluster's replicas. `NULL` for unmanaged clusters.",
1973 ),
1974 (
1975 "replication_factor",
1976 "If the cluster is managed, the desired number of replicas of the cluster. `NULL` for unmanaged clusters.",
1977 ),
1978 (
1979 "disk",
1980 "**Unstable** If the cluster is managed, `true` if the replicas have the `DISK` option . `NULL` for unmanaged clusters.",
1981 ),
1982 (
1983 "availability_zones",
1984 "**Unstable** If the cluster is managed, the list of availability zones specified in `AVAILABILITY ZONES`. `NULL` for unmanaged clusters.",
1985 ),
1986 (
1987 "introspection_debugging",
1988 "Whether introspection of the gathering of the introspection data is enabled.",
1989 ),
1990 (
1991 "introspection_interval",
1992 "The interval at which to collect introspection data.",
1993 ),
1994 ]),
1995 is_retained_metrics_object: false,
1996 access: vec![PUBLIC_SELECT],
1997 ontology: Some(Ontology {
1998 entity_name: "cluster",
1999 description: "A compute cluster that runs dataflows for sources, sinks, MVs, and indexes",
2000 links: &const {
2001 [
2002 OntologyLink {
2003 name: "owned_by",
2004 target: "role",
2005 properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne),
2006 },
2007 OntologyLink {
2008 name: "has_size",
2009 target: "replica_size",
2010 properties: LinkProperties::fk_nullable("size", "size", Cardinality::ManyToOne),
2011 },
2012 ]
2013 },
2014 column_semantic_types: &const {
2015 [
2016 ("id", SemanticType::ClusterId),
2017 ("owner_id", SemanticType::RoleId),
2018 ]
2019 },
2020 }),
2021});
2022
2023pub static MZ_SECRETS: LazyLock<BuiltinMaterializedView> = LazyLock::new(|| {
2024 BuiltinMaterializedView {
2025 name: "mz_secrets",
2026 schema: MZ_CATALOG_SCHEMA,
2027 oid: oid::MV_MZ_SECRETS_OID,
2028 desc: RelationDesc::builder()
2029 .with_column("id", SqlScalarType::String.nullable(false))
2030 .with_column("oid", SqlScalarType::Oid.nullable(false))
2031 .with_column("schema_id", SqlScalarType::String.nullable(false))
2032 .with_column("name", SqlScalarType::String.nullable(false))
2033 .with_column("owner_id", SqlScalarType::String.nullable(false))
2034 .with_column(
2035 "privileges",
2036 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2037 )
2038 .finish(),
2039 column_comments: BTreeMap::from_iter([
2040 ("id", "The unique ID of the secret."),
2041 ("oid", "A PostgreSQL-compatible oid for the secret."),
2042 (
2043 "schema_id",
2044 "The ID of the schema to which the secret belongs. Corresponds to `mz_schemas.id`.",
2045 ),
2046 ("name", "The name of the secret."),
2047 (
2048 "owner_id",
2049 "The role ID of the owner of the secret. Corresponds to `mz_roles.id`.",
2050 ),
2051 ("privileges", "The privileges belonging to the secret."),
2052 ]),
2053 sql: "
2054IN CLUSTER mz_catalog_server
2055WITH (
2056 ASSERT NOT NULL id,
2057 ASSERT NOT NULL oid,
2058 ASSERT NOT NULL schema_id,
2059 ASSERT NOT NULL name,
2060 ASSERT NOT NULL owner_id,
2061 ASSERT NOT NULL privileges
2062) AS
2063SELECT
2064 mz_internal.parse_catalog_id(data->'key'->'gid') AS id,
2065 (data->'value'->>'oid')::oid AS oid,
2066 mz_internal.parse_catalog_id(data->'value'->'schema_id') AS schema_id,
2067 data->'value'->>'name' AS name,
2068 mz_internal.parse_catalog_id(data->'value'->'owner_id') AS owner_id,
2069 mz_internal.parse_catalog_privileges(data->'value'->'privileges') AS privileges
2070FROM mz_internal.mz_catalog_raw
2071WHERE
2072 data->>'kind' = 'Item' AND
2073 mz_internal.parse_catalog_create_sql(data->'value'->'definition'->'V1'->>'create_sql')->>'type' = 'secret'",
2074 is_retained_metrics_object: false,
2075 access: vec![PUBLIC_SELECT],
2076 ontology: Some(Ontology {
2077 entity_name: "secret",
2078 description: "A user-defined secret containing sensitive configuration (e.g., credentials)",
2079 links: &const { [
2080 OntologyLink {
2081 name: "in_schema",
2082 target: "schema",
2083 properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne),
2084 },
2085 OntologyLink {
2086 name: "owned_by",
2087 target: "role",
2088 properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne),
2089 },
2090 ] },
2091 column_semantic_types: &const {[("id", SemanticType::CatalogItemId), ("oid", SemanticType::OID), ("schema_id", SemanticType::SchemaId), ("owner_id", SemanticType::RoleId)]},
2092 }),
2093 }
2094});
2095
2096pub static MZ_CLUSTER_REPLICAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2097 name: "mz_cluster_replicas",
2098 schema: MZ_CATALOG_SCHEMA,
2099 oid: oid::TABLE_MZ_CLUSTER_REPLICAS_OID,
2100 desc: RelationDesc::builder()
2101 .with_column("id", SqlScalarType::String.nullable(false))
2102 .with_column("name", SqlScalarType::String.nullable(false))
2103 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2104 .with_column("size", SqlScalarType::String.nullable(true))
2105 .with_column("availability_zone", SqlScalarType::String.nullable(true))
2108 .with_column("owner_id", SqlScalarType::String.nullable(false))
2109 .with_column("disk", SqlScalarType::Bool.nullable(true))
2110 .finish(),
2111 column_comments: BTreeMap::from_iter([
2112 ("id", "Materialize's unique ID for the cluster replica."),
2113 ("name", "The name of the cluster replica."),
2114 (
2115 "cluster_id",
2116 "The ID of the cluster to which the replica belongs. Corresponds to `mz_clusters.id`.",
2117 ),
2118 (
2119 "size",
2120 "The cluster replica's size, selected during creation.",
2121 ),
2122 (
2123 "availability_zone",
2124 "The availability zone in which the cluster is running.",
2125 ),
2126 (
2127 "owner_id",
2128 "The role ID of the owner of the cluster replica. Corresponds to `mz_roles.id`.",
2129 ),
2130 ("disk", "If the replica has a local disk."),
2131 ]),
2132 is_retained_metrics_object: true,
2133 access: vec![PUBLIC_SELECT],
2134 ontology: Some(Ontology {
2135 entity_name: "replica",
2136 description: "A physical replica of a cluster providing fault tolerance",
2137 links: &const {
2138 [
2139 OntologyLink {
2140 name: "owned_by",
2141 target: "role",
2142 properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne),
2143 },
2144 OntologyLink {
2145 name: "belongs_to_cluster",
2146 target: "cluster",
2147 properties: LinkProperties::fk("cluster_id", "id", Cardinality::ManyToOne),
2148 },
2149 OntologyLink {
2150 name: "has_size",
2151 target: "replica_size",
2152 properties: LinkProperties::fk_nullable("size", "size", Cardinality::ManyToOne),
2153 },
2154 ]
2155 },
2156 column_semantic_types: &const {
2157 [
2158 ("id", SemanticType::ReplicaId),
2159 ("cluster_id", SemanticType::ClusterId),
2160 ("owner_id", SemanticType::RoleId),
2161 ]
2162 },
2163 }),
2164});
2165
2166pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2167 name: "mz_cluster_replica_sizes",
2168 schema: MZ_CATALOG_SCHEMA,
2169 oid: oid::TABLE_MZ_CLUSTER_REPLICA_SIZES_OID,
2170 desc: RelationDesc::builder()
2171 .with_column("size", SqlScalarType::String.nullable(false))
2172 .with_column("processes", SqlScalarType::UInt64.nullable(false))
2173 .with_column("workers", SqlScalarType::UInt64.nullable(false))
2174 .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(false))
2175 .with_column("memory_bytes", SqlScalarType::UInt64.nullable(false))
2176 .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true))
2177 .with_column(
2178 "credits_per_hour",
2179 SqlScalarType::Numeric { max_scale: None }.nullable(false),
2180 )
2181 .finish(),
2182 column_comments: BTreeMap::from_iter([
2183 ("size", "The human-readable replica size."),
2184 ("processes", "The number of processes in the replica."),
2185 (
2186 "workers",
2187 "The number of Timely Dataflow workers per process.",
2188 ),
2189 (
2190 "cpu_nano_cores",
2191 "The CPU allocation per process, in billionths of a vCPU core.",
2192 ),
2193 (
2194 "memory_bytes",
2195 "The RAM allocation per process, in billionths of a vCPU core.",
2196 ),
2197 ("disk_bytes", "The disk allocation per process."),
2198 (
2199 "credits_per_hour",
2200 "The number of compute credits consumed per hour.",
2201 ),
2202 ]),
2203 is_retained_metrics_object: true,
2204 access: vec![PUBLIC_SELECT],
2205 ontology: Some(Ontology {
2206 entity_name: "replica_size",
2207 description: "Available cluster replica sizes with CPU, memory, and credit cost",
2208 links: &const { [] },
2209 column_semantic_types: &const {
2210 [
2211 ("memory_bytes", SemanticType::ByteCount),
2212 ("disk_bytes", SemanticType::ByteCount),
2213 ("credits_per_hour", SemanticType::CreditRate),
2214 ]
2215 },
2216 }),
2217});
2218
2219pub static MZ_AUDIT_EVENTS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2220 name: "mz_audit_events",
2221 schema: MZ_CATALOG_SCHEMA,
2222 oid: oid::TABLE_MZ_AUDIT_EVENTS_OID,
2223 desc: RelationDesc::builder()
2224 .with_column("id", SqlScalarType::UInt64.nullable(false))
2225 .with_column("event_type", SqlScalarType::String.nullable(false))
2226 .with_column("object_type", SqlScalarType::String.nullable(false))
2227 .with_column("details", SqlScalarType::Jsonb.nullable(false))
2228 .with_column("user", SqlScalarType::String.nullable(true))
2229 .with_column(
2230 "occurred_at",
2231 SqlScalarType::TimestampTz { precision: None }.nullable(false),
2232 )
2233 .with_key(vec![0])
2234 .finish(),
2235 column_comments: BTreeMap::from_iter([
2236 (
2237 "id",
2238 "Materialize's unique, monotonically increasing ID for the event.",
2239 ),
2240 (
2241 "event_type",
2242 "The type of the event: `create`, `drop`, or `alter`.",
2243 ),
2244 (
2245 "object_type",
2246 "The type of the affected object: `cluster`, `cluster-replica`, `connection`, `database`, `function`, `index`, `materialized-view`, `role`, `schema`, `secret`, `sink`, `source`, `table`, `type`, or `view`.",
2247 ),
2248 (
2249 "details",
2250 "Additional details about the event. The shape of the details varies based on `event_type` and `object_type`.",
2251 ),
2252 (
2253 "user",
2254 "The user who triggered the event, or `NULL` if triggered by the system.",
2255 ),
2256 (
2257 "occurred_at",
2258 "The time at which the event occurred. Guaranteed to be in order of event creation. Events created in the same transaction will have identical values.",
2259 ),
2260 ]),
2261 is_retained_metrics_object: false,
2262 access: vec![PUBLIC_SELECT],
2263 ontology: Some(Ontology {
2264 entity_name: "audit_event",
2265 description: "An audit log entry recording a DDL operation",
2266 links: &const { [] },
2267 column_semantic_types: &const {
2268 [
2269 ("object_type", SemanticType::ObjectType),
2270 ("occurred_at", SemanticType::WallclockTimestamp),
2271 ]
2272 },
2273 }),
2274});
2275
2276pub static MZ_EGRESS_IPS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2277 name: "mz_egress_ips",
2278 schema: MZ_CATALOG_SCHEMA,
2279 oid: oid::TABLE_MZ_EGRESS_IPS_OID,
2280 desc: RelationDesc::builder()
2281 .with_column("egress_ip", SqlScalarType::String.nullable(false))
2282 .with_column("prefix_length", SqlScalarType::Int32.nullable(false))
2283 .with_column("cidr", SqlScalarType::String.nullable(false))
2284 .finish(),
2285 column_comments: BTreeMap::from_iter([
2286 ("egress_ip", "The start of the range of IP addresses."),
2287 (
2288 "prefix_length",
2289 "The number of leading bits in the CIDR netmask.",
2290 ),
2291 ("cidr", "The CIDR representation."),
2292 ]),
2293 is_retained_metrics_object: false,
2294 access: vec![PUBLIC_SELECT],
2295 ontology: Some(Ontology {
2296 entity_name: "egress_ip",
2297 description: "IP addresses used for outbound connections from Materialize",
2298 links: &const { [] },
2299 column_semantic_types: &[],
2300 }),
2301});
2302
2303pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock<BuiltinTable> =
2304 LazyLock::new(|| BuiltinTable {
2305 name: "mz_aws_privatelink_connections",
2306 schema: MZ_CATALOG_SCHEMA,
2307 oid: oid::TABLE_MZ_AWS_PRIVATELINK_CONNECTIONS_OID,
2308 desc: RelationDesc::builder()
2309 .with_column("id", SqlScalarType::String.nullable(false))
2310 .with_column("principal", SqlScalarType::String.nullable(false))
2311 .finish(),
2312 column_comments: BTreeMap::from_iter([
2313 ("id", "The ID of the connection."),
2314 (
2315 "principal",
2316 "The AWS Principal that Materialize will use to connect to the VPC endpoint.",
2317 ),
2318 ]),
2319 is_retained_metrics_object: false,
2320 access: vec![PUBLIC_SELECT],
2321 ontology: Some(Ontology {
2322 entity_name: "aws_privatelink_connection",
2323 description: "AWS PrivateLink connection configuration",
2324 links: &const {
2325 [OntologyLink {
2326 name: "details_of",
2327 target: "connection",
2328 properties: LinkProperties::fk("id", "id", Cardinality::OneToOne),
2329 }]
2330 },
2331 column_semantic_types: &[("id", SemanticType::CatalogItemId)],
2332 }),
2333 });
2334
2335pub static MZ_CLUSTER_REPLICA_FRONTIERS: LazyLock<BuiltinSource> =
2336 LazyLock::new(|| BuiltinSource {
2337 name: "mz_cluster_replica_frontiers",
2338 schema: MZ_CATALOG_SCHEMA,
2339 oid: oid::SOURCE_MZ_CLUSTER_REPLICA_FRONTIERS_OID,
2340 data_source: IntrospectionType::ReplicaFrontiers.into(),
2341 desc: RelationDesc::builder()
2342 .with_column("object_id", SqlScalarType::String.nullable(false))
2343 .with_column("replica_id", SqlScalarType::String.nullable(false))
2344 .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true))
2345 .finish(),
2346 column_comments: BTreeMap::from_iter([
2347 (
2348 "object_id",
2349 "The ID of the source, sink, index, materialized view, or subscription.",
2350 ),
2351 ("replica_id", "The ID of a cluster replica."),
2352 (
2353 "write_frontier",
2354 "The next timestamp at which the output may change.",
2355 ),
2356 ]),
2357 is_retained_metrics_object: false,
2358 access: vec![PUBLIC_SELECT],
2359 ontology: None,
2360 });
2361
2362pub static MZ_CLUSTER_REPLICA_FRONTIERS_IND: LazyLock<BuiltinIndex> =
2363 LazyLock::new(|| BuiltinIndex {
2364 name: "mz_cluster_replica_frontiers_ind",
2365 schema: MZ_CATALOG_SCHEMA,
2366 oid: oid::INDEX_MZ_CLUSTER_REPLICA_FRONTIERS_IND_OID,
2367 sql: "IN CLUSTER mz_catalog_server ON mz_catalog.mz_cluster_replica_frontiers (object_id)",
2368 is_retained_metrics_object: false,
2369 });
2370
2371pub static MZ_DEFAULT_PRIVILEGES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2372 name: "mz_default_privileges",
2373 schema: MZ_CATALOG_SCHEMA,
2374 oid: oid::TABLE_MZ_DEFAULT_PRIVILEGES_OID,
2375 desc: RelationDesc::builder()
2376 .with_column("role_id", SqlScalarType::String.nullable(false))
2377 .with_column("database_id", SqlScalarType::String.nullable(true))
2378 .with_column("schema_id", SqlScalarType::String.nullable(true))
2379 .with_column("object_type", SqlScalarType::String.nullable(false))
2380 .with_column("grantee", SqlScalarType::String.nullable(false))
2381 .with_column("privileges", SqlScalarType::String.nullable(false))
2382 .finish(),
2383 column_comments: BTreeMap::from_iter([
2384 (
2385 "role_id",
2386 "Privileges described in this row will be granted on objects created by `role_id`. The role ID `p` stands for the `PUBLIC` pseudo-role and applies to all roles.",
2387 ),
2388 (
2389 "database_id",
2390 "Privileges described in this row will be granted only on objects in the database identified by `database_id` if non-null.",
2391 ),
2392 (
2393 "schema_id",
2394 "Privileges described in this row will be granted only on objects in the schema identified by `schema_id` if non-null.",
2395 ),
2396 (
2397 "object_type",
2398 "Privileges described in this row will be granted only on objects of type `object_type`.",
2399 ),
2400 (
2401 "grantee",
2402 "Privileges described in this row will be granted to `grantee`. The role ID `p` stands for the `PUBLIC` pseudo-role and applies to all roles.",
2403 ),
2404 ("privileges", "The set of privileges that will be granted."),
2405 ]),
2406 is_retained_metrics_object: false,
2407 access: vec![PUBLIC_SELECT],
2408 ontology: Some(Ontology {
2409 entity_name: "default_privilege",
2410 description: "A default privilege rule applied to newly created objects",
2411 links: &const {
2412 [
2413 OntologyLink {
2414 name: "default_priv_for_role",
2415 target: "role",
2416 properties: LinkProperties::fk("role_id", "id", Cardinality::ManyToOne),
2417 },
2418 OntologyLink {
2419 name: "default_priv_in_database",
2420 target: "database",
2421 properties: LinkProperties::fk_nullable(
2422 "database_id",
2423 "id",
2424 Cardinality::ManyToOne,
2425 ),
2426 },
2427 OntologyLink {
2428 name: "default_priv_in_schema",
2429 target: "schema",
2430 properties: LinkProperties::fk_nullable(
2431 "schema_id",
2432 "id",
2433 Cardinality::ManyToOne,
2434 ),
2435 },
2436 OntologyLink {
2437 name: "default_priv_granted_to",
2438 target: "role",
2439 properties: LinkProperties::fk("grantee", "id", Cardinality::ManyToOne),
2440 },
2441 ]
2442 },
2443 column_semantic_types: &const {
2444 [
2445 ("role_id", SemanticType::RoleId),
2446 ("database_id", SemanticType::DatabaseId),
2447 ("schema_id", SemanticType::SchemaId),
2448 ("object_type", SemanticType::ObjectType),
2449 ("grantee", SemanticType::RoleId),
2450 ]
2451 },
2452 }),
2453});
2454
2455pub static MZ_SYSTEM_PRIVILEGES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2456 name: "mz_system_privileges",
2457 schema: MZ_CATALOG_SCHEMA,
2458 oid: oid::TABLE_MZ_SYSTEM_PRIVILEGES_OID,
2459 desc: RelationDesc::builder()
2460 .with_column("privileges", SqlScalarType::MzAclItem.nullable(false))
2461 .finish(),
2462 column_comments: BTreeMap::from_iter([(
2463 "privileges",
2464 "The privileges belonging to the system.",
2465 )]),
2466 is_retained_metrics_object: false,
2467 access: vec![PUBLIC_SELECT],
2468 ontology: Some(Ontology {
2469 entity_name: "system_privilege",
2470 description: "A system-level privilege grant",
2471 links: &const { [] },
2472 column_semantic_types: &[],
2473 }),
2474});
2475
2476pub static MZ_STORAGE_USAGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2477 name: "mz_storage_usage",
2478 schema: MZ_CATALOG_SCHEMA,
2479 oid: oid::VIEW_MZ_STORAGE_USAGE_OID,
2480 desc: RelationDesc::builder()
2481 .with_column("object_id", SqlScalarType::String.nullable(false))
2482 .with_column("size_bytes", SqlScalarType::UInt64.nullable(false))
2483 .with_column(
2484 "collection_timestamp",
2485 SqlScalarType::TimestampTz { precision: None }.nullable(false),
2486 )
2487 .with_key(vec![0, 2])
2488 .finish(),
2489 column_comments: BTreeMap::from_iter([
2490 (
2491 "object_id",
2492 "The ID of the table, source, or materialized view.",
2493 ),
2494 (
2495 "size_bytes",
2496 "The number of storage bytes used by the object.",
2497 ),
2498 (
2499 "collection_timestamp",
2500 "The time at which storage usage of the object was assessed.",
2501 ),
2502 ]),
2503 sql: "
2504SELECT
2505 object_id,
2506 sum(size_bytes)::uint8 AS size_bytes,
2507 collection_timestamp
2508FROM
2509 mz_internal.mz_storage_shards
2510 JOIN mz_internal.mz_storage_usage_by_shard USING (shard_id)
2511GROUP BY object_id, collection_timestamp",
2512 access: vec![PUBLIC_SELECT],
2513 ontology: Some(Ontology {
2514 entity_name: "storage_usage",
2515 description: "Historical storage usage per object over time",
2516 links: &const {
2517 [OntologyLink {
2518 name: "storage_usage_of",
2519 target: "object",
2520 properties: LinkProperties::fk("object_id", "id", Cardinality::ManyToOne),
2521 }]
2522 },
2523 column_semantic_types: &const {
2524 [
2525 ("object_id", SemanticType::CatalogItemId),
2526 ("size_bytes", SemanticType::ByteCount),
2527 ("collection_timestamp", SemanticType::WallclockTimestamp),
2528 ]
2529 },
2530 }),
2531});
2532
2533pub static MZ_RECENT_STORAGE_USAGE: LazyLock<BuiltinView> = LazyLock::new(|| {
2534 BuiltinView {
2535 name: "mz_recent_storage_usage",
2536 schema: MZ_CATALOG_SCHEMA,
2537 oid: oid::VIEW_MZ_RECENT_STORAGE_USAGE_OID,
2538 desc: RelationDesc::builder()
2539 .with_column("object_id", SqlScalarType::String.nullable(false))
2540 .with_column("size_bytes", SqlScalarType::UInt64.nullable(true))
2541 .with_key(vec![0])
2542 .finish(),
2543 column_comments: BTreeMap::from_iter([
2544 ("object_id", "The ID of the table, source, or materialized view."),
2545 ("size_bytes", "The number of storage bytes used by the object in the most recent assessment."),
2546 ]),
2547 sql: "
2548WITH
2549
2550recent_storage_usage_by_shard AS (
2551 SELECT shard_id, size_bytes, collection_timestamp
2552 FROM mz_internal.mz_storage_usage_by_shard
2553 -- Restricting to the last 6 hours makes it feasible to index the view.
2554 WHERE collection_timestamp + '6 hours' >= mz_now()
2555),
2556
2557most_recent_collection_timestamp_by_shard AS (
2558 SELECT shard_id, max(collection_timestamp) AS collection_timestamp
2559 FROM recent_storage_usage_by_shard
2560 GROUP BY shard_id
2561)
2562
2563SELECT
2564 object_id,
2565 sum(size_bytes)::uint8 AS size_bytes
2566FROM
2567 mz_internal.mz_storage_shards
2568 LEFT JOIN most_recent_collection_timestamp_by_shard
2569 ON mz_storage_shards.shard_id = most_recent_collection_timestamp_by_shard.shard_id
2570 LEFT JOIN recent_storage_usage_by_shard
2571 ON mz_storage_shards.shard_id = recent_storage_usage_by_shard.shard_id
2572 AND most_recent_collection_timestamp_by_shard.collection_timestamp = recent_storage_usage_by_shard.collection_timestamp
2573GROUP BY object_id",
2574 access: vec![PUBLIC_SELECT],
2575 ontology: Some(Ontology {
2576 entity_name: "recent_storage",
2577 description: "Most recent storage usage snapshot per object",
2578 links: &const { [
2579 OntologyLink { name: "recent_storage_of", target: "object", properties: LinkProperties::fk("object_id", "id", Cardinality::OneToOne) },
2580 ] },
2581 column_semantic_types: &const {[("object_id", SemanticType::CatalogItemId), ("size_bytes", SemanticType::ByteCount)]},
2582 }),
2583}
2584});
2585
2586pub static MZ_RECENT_STORAGE_USAGE_IND: LazyLock<BuiltinIndex> = LazyLock::new(|| BuiltinIndex {
2587 name: "mz_recent_storage_usage_ind",
2588 schema: MZ_CATALOG_SCHEMA,
2589 oid: oid::INDEX_MZ_RECENT_STORAGE_USAGE_IND_OID,
2590 sql: "IN CLUSTER mz_catalog_server ON mz_catalog.mz_recent_storage_usage (object_id)",
2591 is_retained_metrics_object: false,
2592});
2593
2594pub static MZ_RELATIONS: LazyLock<BuiltinView> = LazyLock::new(|| {
2595 BuiltinView {
2596 name: "mz_relations",
2597 schema: MZ_CATALOG_SCHEMA,
2598 oid: oid::VIEW_MZ_RELATIONS_OID,
2599 desc: RelationDesc::builder()
2600 .with_column("id", SqlScalarType::String.nullable(false))
2601 .with_column("oid", SqlScalarType::Oid.nullable(false))
2602 .with_column("schema_id", SqlScalarType::String.nullable(false))
2603 .with_column("name", SqlScalarType::String.nullable(false))
2604 .with_column("type", SqlScalarType::String.nullable(false))
2605 .with_column("owner_id", SqlScalarType::String.nullable(false))
2606 .with_column("cluster_id", SqlScalarType::String.nullable(true))
2607 .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false))
2608 .finish(),
2609 column_comments: BTreeMap::from_iter([
2610 ("id", "Materialize's unique ID for the relation."),
2611 ("oid", "A PostgreSQL-compatible OID for the relation."),
2612 ("schema_id", "The ID of the schema to which the relation belongs. Corresponds to `mz_schemas.id`."),
2613 ("name", "The name of the relation."),
2614 ("type", "The type of the relation: either `table`, `source`, `view`, or `materialized-view`."),
2615 ("owner_id", "The role ID of the owner of the relation. Corresponds to `mz_roles.id`."),
2616 ("cluster_id", "The ID of the cluster maintaining the source, materialized view, index, or sink. Corresponds to `mz_clusters.id`. `NULL` for other object types."),
2617 ("privileges", "The privileges belonging to the relation."),
2618 ]),
2619 sql: "
2620 SELECT id, oid, schema_id, name, 'table' AS type, owner_id, NULL::text AS cluster_id, privileges FROM mz_catalog.mz_tables
2621UNION ALL SELECT id, oid, schema_id, name, 'source', owner_id, cluster_id, privileges FROM mz_catalog.mz_sources
2622UNION ALL SELECT id, oid, schema_id, name, 'view', owner_id, NULL::text, privileges FROM mz_catalog.mz_views
2623UNION ALL SELECT id, oid, schema_id, name, 'materialized-view', owner_id, cluster_id, privileges FROM mz_catalog.mz_materialized_views",
2624 access: vec![PUBLIC_SELECT],
2625 ontology: Some(Ontology {
2626 entity_name: "relation",
2627 description: "Union of all relation types: tables, sources, views, MVs (convenience view)",
2628 links: &const { [
2629 OntologyLink { name: "union_includes", target: "table", properties: LinkProperties::union_disc("type", "table") },
2630 OntologyLink { name: "union_includes", target: "source", properties: LinkProperties::union_disc("type", "source") },
2631 OntologyLink { name: "union_includes", target: "view", properties: LinkProperties::union_disc("type", "view") },
2632 OntologyLink { name: "union_includes", target: "mv", properties: LinkProperties::union_disc("type", "materialized-view") },
2633 ] },
2634 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)]},
2635 }),
2636 }
2637});
2638
2639pub static MZ_OBJECTS: LazyLock<BuiltinView> = LazyLock::new(|| {
2640 BuiltinView {
2641 name: "mz_objects",
2642 schema: MZ_CATALOG_SCHEMA,
2643 oid: oid::VIEW_MZ_OBJECTS_OID,
2644 desc: RelationDesc::builder()
2645 .with_column("id", SqlScalarType::String.nullable(false))
2646 .with_column("oid", SqlScalarType::Oid.nullable(false))
2647 .with_column("schema_id", SqlScalarType::String.nullable(false))
2648 .with_column("name", SqlScalarType::String.nullable(false))
2649 .with_column("type", SqlScalarType::String.nullable(false))
2650 .with_column("owner_id", SqlScalarType::String.nullable(false))
2651 .with_column("cluster_id", SqlScalarType::String.nullable(true))
2652 .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(true))
2653 .finish(),
2654 column_comments: BTreeMap::from_iter([
2655 ("id", "Materialize's unique ID for the object."),
2656 ("oid", "A PostgreSQL-compatible OID for the object."),
2657 ("schema_id", "The ID of the schema to which the object belongs. Corresponds to `mz_schemas.id`."),
2658 ("name", "The name of the object."),
2659 ("type", "The type of the object: one of `table`, `source`, `view`, `materialized-view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`."),
2660 ("owner_id", "The role ID of the owner of the object. Corresponds to `mz_roles.id`."),
2661 ("cluster_id", "The ID of the cluster maintaining the source, materialized view, index, or sink. Corresponds to `mz_clusters.id`. `NULL` for other object types."),
2662 ("privileges", "The privileges belonging to the object."),
2663 ]),
2664 sql:
2665 "SELECT id, oid, schema_id, name, type, owner_id, cluster_id, privileges FROM mz_catalog.mz_relations
2666UNION ALL
2667 SELECT id, oid, schema_id, name, 'sink', owner_id, cluster_id, NULL::mz_catalog.mz_aclitem[] FROM mz_catalog.mz_sinks
2668UNION ALL
2669 SELECT mz_indexes.id, mz_indexes.oid, mz_relations.schema_id, mz_indexes.name, 'index', mz_indexes.owner_id, mz_indexes.cluster_id, NULL::mz_catalog.mz_aclitem[]
2670 FROM mz_catalog.mz_indexes
2671 JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
2672UNION ALL
2673 SELECT id, oid, schema_id, name, 'connection', owner_id, NULL::text, privileges FROM mz_catalog.mz_connections
2674UNION ALL
2675 SELECT id, oid, schema_id, name, 'type', owner_id, NULL::text, privileges FROM mz_catalog.mz_types
2676UNION ALL
2677 SELECT id, oid, schema_id, name, 'function', owner_id, NULL::text, NULL::mz_catalog.mz_aclitem[] FROM mz_catalog.mz_functions
2678UNION ALL
2679 SELECT id, oid, schema_id, name, 'secret', owner_id, NULL::text, privileges FROM mz_catalog.mz_secrets",
2680 access: vec![PUBLIC_SELECT],
2681 ontology: Some(Ontology {
2682 entity_name: "object",
2683 description: "Union of all object types: relations, indexes, connections, etc. (convenience view)",
2684 links: &const {
2685 [
2686 OntologyLink {
2687 name: "union_includes",
2688 target: "relation",
2689 properties: LinkProperties::Union {
2690 discriminator_column: None,
2691 discriminator_value: None,
2692 note: Some("covers all mz_relations rows (table, source, view, mv)"),
2693 },
2694 },
2695 OntologyLink {
2696 name: "union_includes",
2697 target: "table",
2698 properties: LinkProperties::union_disc("type", "table"),
2699 },
2700 OntologyLink {
2701 name: "union_includes",
2702 target: "source",
2703 properties: LinkProperties::union_disc("type", "source"),
2704 },
2705 OntologyLink {
2706 name: "union_includes",
2707 target: "view",
2708 properties: LinkProperties::union_disc("type", "view"),
2709 },
2710 OntologyLink {
2711 name: "union_includes",
2712 target: "mv",
2713 properties: LinkProperties::union_disc("type", "materialized-view"),
2714 },
2715 OntologyLink {
2716 name: "union_includes",
2717 target: "sink",
2718 properties: LinkProperties::union_disc("type", "sink"),
2719 },
2720 OntologyLink {
2721 name: "union_includes",
2722 target: "index",
2723 properties: LinkProperties::union_disc("type", "index"),
2724 },
2725 OntologyLink {
2726 name: "union_includes",
2727 target: "connection",
2728 properties: LinkProperties::union_disc("type", "connection"),
2729 },
2730 OntologyLink {
2731 name: "union_includes",
2732 target: "type",
2733 properties: LinkProperties::union_disc("type", "type"),
2734 },
2735 OntologyLink {
2736 name: "union_includes",
2737 target: "function",
2738 properties: LinkProperties::union_disc("type", "function"),
2739 },
2740 OntologyLink {
2741 name: "union_includes",
2742 target: "secret",
2743 properties: LinkProperties::union_disc("type", "secret"),
2744 },
2745 OntologyLink {
2746 name: "in_schema",
2747 target: "schema",
2748 properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne),
2749 },
2750 OntologyLink {
2751 name: "owned_by",
2752 target: "role",
2753 properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne),
2754 },
2755 OntologyLink {
2756 name: "on_cluster",
2757 target: "cluster",
2758 properties: LinkProperties::fk_nullable(
2759 "cluster_id",
2760 "id",
2761 Cardinality::ManyToOne,
2762 ),
2763 },
2764 ]
2765 },
2766 column_semantic_types: &const {
2767 [
2768 ("id", SemanticType::CatalogItemId),
2769 ("oid", SemanticType::OID),
2770 ("schema_id", SemanticType::SchemaId),
2771 ("type", SemanticType::ObjectType),
2772 ("owner_id", SemanticType::RoleId),
2773 ("cluster_id", SemanticType::ClusterId),
2774 ]
2775 },
2776 }),
2777 }
2778});
2779
2780pub static MZ_TIMEZONE_ABBREVIATIONS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2781 name: "mz_timezone_abbreviations",
2782 schema: MZ_CATALOG_SCHEMA,
2783 oid: oid::VIEW_MZ_TIMEZONE_ABBREVIATIONS_OID,
2784 desc: RelationDesc::builder()
2785 .with_column("abbreviation", SqlScalarType::String.nullable(false))
2786 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
2787 .with_column("dst", SqlScalarType::Bool.nullable(true))
2788 .with_column("timezone_name", SqlScalarType::String.nullable(true))
2789 .with_key(vec![0])
2790 .finish(),
2791 column_comments: BTreeMap::from_iter([
2792 ("abbreviation", "The timezone abbreviation."),
2793 (
2794 "utc_offset",
2795 "The UTC offset of the timezone or `NULL` if fixed.",
2796 ),
2797 (
2798 "dst",
2799 "Whether the timezone is in daylight savings or `NULL` if fixed.",
2800 ),
2801 (
2802 "timezone_name",
2803 "The full name of the non-fixed timezone or `NULL` if not fixed.",
2804 ),
2805 ]),
2806 sql: format!(
2807 "SELECT * FROM ({}) _ (abbreviation, utc_offset, dst, timezone_name)",
2808 mz_pgtz::abbrev::MZ_CATALOG_TIMEZONE_ABBREVIATIONS_SQL,
2809 )
2810 .leak(),
2811 access: vec![PUBLIC_SELECT],
2812 ontology: None,
2813});
2814
2815pub static MZ_TIMEZONE_NAMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2816 name: "mz_timezone_names",
2817 schema: MZ_CATALOG_SCHEMA,
2818 oid: oid::VIEW_MZ_TIMEZONE_NAMES_OID,
2819 desc: RelationDesc::builder()
2820 .with_column("name", SqlScalarType::String.nullable(false))
2821 .with_key(vec![0])
2822 .finish(),
2823 column_comments: BTreeMap::from_iter([("name", "The timezone name.")]),
2824 sql: format!(
2825 "SELECT * FROM ({}) _ (name)",
2826 mz_pgtz::timezone::MZ_CATALOG_TIMEZONE_NAMES_SQL,
2827 )
2828 .leak(),
2829 access: vec![PUBLIC_SELECT],
2830 ontology: None,
2831});
2832
2833pub const MZ_DATABASES_IND: BuiltinIndex = BuiltinIndex {
2834 name: "mz_databases_ind",
2835 schema: MZ_CATALOG_SCHEMA,
2836 oid: oid::INDEX_MZ_DATABASES_IND_OID,
2837 sql: "IN CLUSTER mz_catalog_server
2838ON mz_catalog.mz_databases (name)",
2839 is_retained_metrics_object: false,
2840};
2841
2842pub const MZ_SCHEMAS_IND: BuiltinIndex = BuiltinIndex {
2843 name: "mz_schemas_ind",
2844 schema: MZ_CATALOG_SCHEMA,
2845 oid: oid::INDEX_MZ_SCHEMAS_IND_OID,
2846 sql: "IN CLUSTER mz_catalog_server
2847ON mz_catalog.mz_schemas (database_id)",
2848 is_retained_metrics_object: false,
2849};
2850
2851pub const MZ_CONNECTIONS_IND: BuiltinIndex = BuiltinIndex {
2852 name: "mz_connections_ind",
2853 schema: MZ_CATALOG_SCHEMA,
2854 oid: oid::INDEX_MZ_CONNECTIONS_IND_OID,
2855 sql: "IN CLUSTER mz_catalog_server
2856ON mz_catalog.mz_connections (schema_id)",
2857 is_retained_metrics_object: false,
2858};
2859
2860pub const MZ_TABLES_IND: BuiltinIndex = BuiltinIndex {
2861 name: "mz_tables_ind",
2862 schema: MZ_CATALOG_SCHEMA,
2863 oid: oid::INDEX_MZ_TABLES_IND_OID,
2864 sql: "IN CLUSTER mz_catalog_server
2865ON mz_catalog.mz_tables (schema_id)",
2866 is_retained_metrics_object: false,
2867};
2868
2869pub const MZ_TYPES_IND: BuiltinIndex = BuiltinIndex {
2870 name: "mz_types_ind",
2871 schema: MZ_CATALOG_SCHEMA,
2872 oid: oid::INDEX_MZ_TYPES_IND_OID,
2873 sql: "IN CLUSTER mz_catalog_server
2874ON mz_catalog.mz_types (schema_id)",
2875 is_retained_metrics_object: false,
2876};
2877
2878pub const MZ_OBJECTS_IND: BuiltinIndex = BuiltinIndex {
2879 name: "mz_objects_ind",
2880 schema: MZ_CATALOG_SCHEMA,
2881 oid: oid::INDEX_MZ_OBJECTS_IND_OID,
2882 sql: "IN CLUSTER mz_catalog_server
2883ON mz_catalog.mz_objects (schema_id)",
2884 is_retained_metrics_object: false,
2885};
2886
2887pub const MZ_COLUMNS_IND: BuiltinIndex = BuiltinIndex {
2888 name: "mz_columns_ind",
2889 schema: MZ_CATALOG_SCHEMA,
2890 oid: oid::INDEX_MZ_COLUMNS_IND_OID,
2891 sql: "IN CLUSTER mz_catalog_server
2892ON mz_catalog.mz_columns (name)",
2893 is_retained_metrics_object: false,
2894};
2895
2896pub const MZ_SECRETS_IND: BuiltinIndex = BuiltinIndex {
2897 name: "mz_secrets_ind",
2898 schema: MZ_CATALOG_SCHEMA,
2899 oid: oid::INDEX_MZ_SECRETS_IND_OID,
2900 sql: "IN CLUSTER mz_catalog_server
2901ON mz_catalog.mz_secrets (name)",
2902 is_retained_metrics_object: false,
2903};
2904
2905pub const MZ_VIEWS_IND: BuiltinIndex = BuiltinIndex {
2906 name: "mz_views_ind",
2907 schema: MZ_CATALOG_SCHEMA,
2908 oid: oid::INDEX_MZ_VIEWS_IND_OID,
2909 sql: "IN CLUSTER mz_catalog_server
2910ON mz_catalog.mz_views (schema_id)",
2911 is_retained_metrics_object: false,
2912};
2913
2914pub const MZ_CLUSTERS_IND: BuiltinIndex = BuiltinIndex {
2915 name: "mz_clusters_ind",
2916 schema: MZ_CATALOG_SCHEMA,
2917 oid: oid::INDEX_MZ_CLUSTERS_IND_OID,
2918 sql: "IN CLUSTER mz_catalog_server
2919ON mz_catalog.mz_clusters (id)",
2920 is_retained_metrics_object: false,
2921};
2922
2923pub const MZ_INDEXES_IND: BuiltinIndex = BuiltinIndex {
2924 name: "mz_indexes_ind",
2925 schema: MZ_CATALOG_SCHEMA,
2926 oid: oid::INDEX_MZ_INDEXES_IND_OID,
2927 sql: "IN CLUSTER mz_catalog_server
2928ON mz_catalog.mz_indexes (id)",
2929 is_retained_metrics_object: false,
2930};
2931
2932pub const MZ_ROLES_IND: BuiltinIndex = BuiltinIndex {
2933 name: "mz_roles_ind",
2934 schema: MZ_CATALOG_SCHEMA,
2935 oid: oid::INDEX_MZ_ROLES_IND_OID,
2936 sql: "IN CLUSTER mz_catalog_server
2937ON mz_catalog.mz_roles (id)",
2938 is_retained_metrics_object: false,
2939};
2940
2941pub const MZ_SOURCES_IND: BuiltinIndex = BuiltinIndex {
2942 name: "mz_sources_ind",
2943 schema: MZ_CATALOG_SCHEMA,
2944 oid: oid::INDEX_MZ_SOURCES_IND_OID,
2945 sql: "IN CLUSTER mz_catalog_server
2946ON mz_catalog.mz_sources (id)",
2947 is_retained_metrics_object: true,
2948};
2949
2950pub const MZ_SINKS_IND: BuiltinIndex = BuiltinIndex {
2951 name: "mz_sinks_ind",
2952 schema: MZ_CATALOG_SCHEMA,
2953 oid: oid::INDEX_MZ_SINKS_IND_OID,
2954 sql: "IN CLUSTER mz_catalog_server
2955ON mz_catalog.mz_sinks (id)",
2956 is_retained_metrics_object: true,
2957};
2958
2959pub const MZ_MATERIALIZED_VIEWS_IND: BuiltinIndex = BuiltinIndex {
2960 name: "mz_materialized_views_ind",
2961 schema: MZ_CATALOG_SCHEMA,
2962 oid: oid::INDEX_MZ_MATERIALIZED_VIEWS_IND_OID,
2963 sql: "IN CLUSTER mz_catalog_server
2964ON mz_catalog.mz_materialized_views (id)",
2965 is_retained_metrics_object: false,
2966};
2967
2968pub const MZ_CLUSTER_REPLICAS_IND: BuiltinIndex = BuiltinIndex {
2969 name: "mz_cluster_replicas_ind",
2970 schema: MZ_CATALOG_SCHEMA,
2971 oid: oid::INDEX_MZ_CLUSTER_REPLICAS_IND_OID,
2972 sql: "IN CLUSTER mz_catalog_server
2973ON mz_catalog.mz_cluster_replicas (id)",
2974 is_retained_metrics_object: true,
2975};
2976
2977pub const MZ_CLUSTER_REPLICA_SIZES_IND: BuiltinIndex = BuiltinIndex {
2978 name: "mz_cluster_replica_sizes_ind",
2979 schema: MZ_CATALOG_SCHEMA,
2980 oid: oid::INDEX_MZ_CLUSTER_REPLICA_SIZES_IND_OID,
2981 sql: "IN CLUSTER mz_catalog_server
2982ON mz_catalog.mz_cluster_replica_sizes (size)",
2983 is_retained_metrics_object: true,
2984};
2985
2986pub const MZ_KAFKA_SOURCES_IND: BuiltinIndex = BuiltinIndex {
2987 name: "mz_kafka_sources_ind",
2988 schema: MZ_CATALOG_SCHEMA,
2989 oid: oid::INDEX_MZ_KAFKA_SOURCES_IND_OID,
2990 sql: "IN CLUSTER mz_catalog_server
2991ON mz_catalog.mz_kafka_sources (id)",
2992 is_retained_metrics_object: true,
2993};