1pub mod notice;
26
27use std::collections::BTreeMap;
28use std::hash::Hash;
29use std::string::ToString;
30use std::sync::LazyLock;
31
32use mz_compute_client::logging::{ComputeLog, DifferentialLog, LogVariant, TimelyLog};
33use mz_ore::collections::HashMap;
34use mz_pgrepr::oid;
35use mz_repr::adt::mz_acl_item::{AclMode, MzAclItem};
36use mz_repr::adt::numeric::NumericMaxScale;
37use mz_repr::namespaces::{
38 INFORMATION_SCHEMA, MZ_CATALOG_SCHEMA, MZ_INTERNAL_SCHEMA, MZ_INTROSPECTION_SCHEMA,
39 MZ_UNSAFE_SCHEMA, PG_CATALOG_SCHEMA,
40};
41use mz_repr::role_id::RoleId;
42use mz_repr::{RelationDesc, SqlRelationType, SqlScalarType};
43use mz_sql::catalog::RoleAttributesRaw;
44use mz_sql::catalog::{
45 CatalogItemType, CatalogType, CatalogTypeDetails, CatalogTypePgMetadata, NameReference,
46 ObjectType, SystemObjectType, TypeReference,
47};
48use mz_sql::rbac;
49use mz_sql::session::user::{
50 ANALYTICS_USER_NAME, MZ_ANALYTICS_ROLE_ID, MZ_MONITOR_REDACTED_ROLE_ID, MZ_MONITOR_ROLE_ID,
51 MZ_SUPPORT_ROLE_ID, MZ_SYSTEM_ROLE_ID, SUPPORT_USER_NAME, SYSTEM_USER_NAME,
52};
53use mz_storage_client::controller::IntrospectionType;
54use mz_storage_client::healthcheck::WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW_DESC;
55use mz_storage_client::healthcheck::{
56 MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_DESC, MZ_PREPARED_STATEMENT_HISTORY_DESC,
57 MZ_SESSION_HISTORY_DESC, MZ_SINK_STATUS_HISTORY_DESC, MZ_SOURCE_STATUS_HISTORY_DESC,
58 MZ_SQL_TEXT_DESC, MZ_STATEMENT_EXECUTION_HISTORY_DESC, REPLICA_METRICS_HISTORY_DESC,
59 REPLICA_STATUS_HISTORY_DESC, WALLCLOCK_LAG_HISTORY_DESC,
60};
61use mz_storage_client::statistics::{MZ_SINK_STATISTICS_RAW_DESC, MZ_SOURCE_STATISTICS_RAW_DESC};
62use serde::Serialize;
63
64use crate::durable::objects::SystemObjectDescription;
65
66pub const BUILTIN_PREFIXES: &[&str] = &["mz_", "pg_", "external_"];
67const BUILTIN_CLUSTER_REPLICA_NAME: &str = "r1";
68
69pub const RUNTIME_ALTERABLE_FINGERPRINT_SENTINEL: &str = "<RUNTIME-ALTERABLE>";
85
86#[derive(Clone, Debug)]
87pub enum Builtin<T: 'static + TypeReference> {
88 Log(&'static BuiltinLog),
89 Table(&'static BuiltinTable),
90 View(&'static BuiltinView),
91 Type(&'static BuiltinType<T>),
92 Func(BuiltinFunc),
93 Source(&'static BuiltinSource),
94 ContinualTask(&'static BuiltinContinualTask),
95 Index(&'static BuiltinIndex),
96 Connection(&'static BuiltinConnection),
97}
98
99impl<T: TypeReference> Builtin<T> {
100 pub fn name(&self) -> &'static str {
101 match self {
102 Builtin::Log(log) => log.name,
103 Builtin::Table(table) => table.name,
104 Builtin::View(view) => view.name,
105 Builtin::Type(typ) => typ.name,
106 Builtin::Func(func) => func.name,
107 Builtin::Source(coll) => coll.name,
108 Builtin::ContinualTask(ct) => ct.name,
109 Builtin::Index(index) => index.name,
110 Builtin::Connection(connection) => connection.name,
111 }
112 }
113
114 pub fn schema(&self) -> &'static str {
115 match self {
116 Builtin::Log(log) => log.schema,
117 Builtin::Table(table) => table.schema,
118 Builtin::View(view) => view.schema,
119 Builtin::Type(typ) => typ.schema,
120 Builtin::Func(func) => func.schema,
121 Builtin::Source(coll) => coll.schema,
122 Builtin::ContinualTask(ct) => ct.schema,
123 Builtin::Index(index) => index.schema,
124 Builtin::Connection(connection) => connection.schema,
125 }
126 }
127
128 pub fn catalog_item_type(&self) -> CatalogItemType {
129 match self {
130 Builtin::Log(_) => CatalogItemType::Source,
131 Builtin::Source(_) => CatalogItemType::Source,
132 Builtin::ContinualTask(_) => CatalogItemType::ContinualTask,
133 Builtin::Table(_) => CatalogItemType::Table,
134 Builtin::View(_) => CatalogItemType::View,
135 Builtin::Type(_) => CatalogItemType::Type,
136 Builtin::Func(_) => CatalogItemType::Func,
137 Builtin::Index(_) => CatalogItemType::Index,
138 Builtin::Connection(_) => CatalogItemType::Connection,
139 }
140 }
141
142 pub fn runtime_alterable(&self) -> bool {
144 match self {
145 Builtin::Connection(c) => c.runtime_alterable,
146 _ => false,
147 }
148 }
149}
150
151#[derive(Clone, Debug, Hash, Serialize)]
152pub struct BuiltinLog {
153 pub variant: LogVariant,
154 pub name: &'static str,
155 pub schema: &'static str,
156 pub oid: u32,
157 pub access: Vec<MzAclItem>,
159}
160
161#[derive(Clone, Hash, Debug, PartialEq, Eq)]
162pub struct BuiltinTable {
163 pub name: &'static str,
164 pub schema: &'static str,
165 pub oid: u32,
166 pub desc: RelationDesc,
167 pub column_comments: BTreeMap<&'static str, &'static str>,
168 pub is_retained_metrics_object: bool,
171 pub access: Vec<MzAclItem>,
173}
174
175#[derive(Clone, Debug, Hash, Serialize)]
176pub struct BuiltinSource {
177 pub name: &'static str,
178 pub schema: &'static str,
179 pub oid: u32,
180 pub desc: RelationDesc,
181 pub column_comments: BTreeMap<&'static str, &'static str>,
182 pub data_source: IntrospectionType,
183 pub is_retained_metrics_object: bool,
186 pub access: Vec<MzAclItem>,
188}
189
190#[derive(Hash, Debug, PartialEq, Eq)]
191pub struct BuiltinContinualTask {
192 pub name: &'static str,
193 pub schema: &'static str,
194 pub oid: u32,
195 pub desc: RelationDesc,
196 pub sql: &'static str,
197 pub access: Vec<MzAclItem>,
199}
200
201#[derive(Hash, Debug)]
202pub struct BuiltinView {
203 pub name: &'static str,
204 pub schema: &'static str,
205 pub oid: u32,
206 pub desc: RelationDesc,
207 pub column_comments: BTreeMap<&'static str, &'static str>,
208 pub sql: &'static str,
209 pub access: Vec<MzAclItem>,
211}
212
213impl BuiltinView {
214 pub fn create_sql(&self) -> String {
215 format!("CREATE VIEW {}.{} AS {}", self.schema, self.name, self.sql)
216 }
217}
218
219#[derive(Debug)]
220pub struct BuiltinType<T: TypeReference> {
221 pub name: &'static str,
222 pub schema: &'static str,
223 pub oid: u32,
224 pub details: CatalogTypeDetails<T>,
225}
226
227#[derive(Clone, Debug)]
228pub struct BuiltinFunc {
229 pub schema: &'static str,
230 pub name: &'static str,
231 pub inner: &'static mz_sql::func::Func,
232}
233
234#[derive(Debug)]
240pub struct BuiltinIndex {
241 pub name: &'static str,
242 pub schema: &'static str,
243 pub oid: u32,
244 pub sql: &'static str,
248 pub is_retained_metrics_object: bool,
249}
250
251impl BuiltinIndex {
252 pub fn create_sql(&self) -> String {
253 format!("CREATE INDEX {}\n{}", self.name, self.sql)
254 }
255}
256
257impl BuiltinContinualTask {
258 pub fn create_sql(&self) -> String {
259 format!(
260 "CREATE CONTINUAL TASK {}.{}\n{}",
261 self.schema, self.name, self.sql
262 )
263 }
264}
265
266#[derive(Hash, Debug)]
267pub struct BuiltinConnection {
268 pub name: &'static str,
269 pub schema: &'static str,
270 pub oid: u32,
271 pub sql: &'static str,
272 pub access: &'static [MzAclItem],
273 pub owner_id: &'static RoleId,
274 pub runtime_alterable: bool,
279}
280
281#[derive(Clone, Debug)]
282pub struct BuiltinRole {
283 pub id: RoleId,
284 pub name: &'static str,
288 pub oid: u32,
289 pub attributes: RoleAttributesRaw,
290}
291
292#[derive(Clone, Debug)]
293pub struct BuiltinCluster {
294 pub name: &'static str,
298 pub privileges: &'static [MzAclItem],
299 pub owner_id: &'static RoleId,
300}
301
302#[derive(Clone, Debug, PartialEq, Eq)]
303pub struct BuiltinClusterReplica {
304 pub name: &'static str,
306 pub cluster_name: &'static str,
308}
309
310pub trait Fingerprint {
312 fn fingerprint(&self) -> String;
313}
314
315impl<T: TypeReference> Fingerprint for &Builtin<T> {
316 fn fingerprint(&self) -> String {
317 match self {
318 Builtin::Log(log) => log.fingerprint(),
319 Builtin::Table(table) => table.fingerprint(),
320 Builtin::View(view) => view.fingerprint(),
321 Builtin::Type(typ) => typ.fingerprint(),
322 Builtin::Func(func) => func.fingerprint(),
323 Builtin::Source(coll) => coll.fingerprint(),
324 Builtin::ContinualTask(ct) => ct.fingerprint(),
325 Builtin::Index(index) => index.fingerprint(),
326 Builtin::Connection(connection) => connection.fingerprint(),
327 }
328 }
329}
330
331impl<T: TypeReference> Fingerprint for &BuiltinType<T> {
333 fn fingerprint(&self) -> String {
334 "".to_string()
335 }
336}
337
338impl Fingerprint for &BuiltinFunc {
339 fn fingerprint(&self) -> String {
340 "".to_string()
341 }
342}
343
344impl Fingerprint for &BuiltinLog {
345 fn fingerprint(&self) -> String {
346 self.variant.desc().fingerprint()
347 }
348}
349
350impl Fingerprint for &BuiltinTable {
351 fn fingerprint(&self) -> String {
352 self.desc.fingerprint()
353 }
354}
355
356impl Fingerprint for &BuiltinView {
357 fn fingerprint(&self) -> String {
358 self.sql.to_string()
359 }
360}
361
362impl Fingerprint for &BuiltinSource {
363 fn fingerprint(&self) -> String {
364 self.desc.fingerprint()
365 }
366}
367
368impl Fingerprint for &BuiltinContinualTask {
369 fn fingerprint(&self) -> String {
370 self.create_sql()
371 }
372}
373
374impl Fingerprint for &BuiltinIndex {
375 fn fingerprint(&self) -> String {
376 self.create_sql()
377 }
378}
379
380impl Fingerprint for &BuiltinConnection {
381 fn fingerprint(&self) -> String {
382 self.sql.to_string()
383 }
384}
385
386impl Fingerprint for RelationDesc {
387 fn fingerprint(&self) -> String {
388 self.typ().fingerprint()
389 }
390}
391
392impl Fingerprint for SqlRelationType {
393 fn fingerprint(&self) -> String {
394 serde_json::to_string(self).expect("serialization cannot fail")
395 }
396}
397
398pub const TYPE_BOOL: BuiltinType<NameReference> = BuiltinType {
418 name: "bool",
419 schema: PG_CATALOG_SCHEMA,
420 oid: oid::TYPE_BOOL_OID,
421 details: CatalogTypeDetails {
422 typ: CatalogType::Bool,
423 array_id: None,
424 pg_metadata: Some(CatalogTypePgMetadata {
425 typinput_oid: 1242,
426 typreceive_oid: 2436,
427 }),
428 },
429};
430
431pub const TYPE_BYTEA: BuiltinType<NameReference> = BuiltinType {
432 name: "bytea",
433 schema: PG_CATALOG_SCHEMA,
434 oid: oid::TYPE_BYTEA_OID,
435 details: CatalogTypeDetails {
436 typ: CatalogType::Bytes,
437 array_id: None,
438 pg_metadata: Some(CatalogTypePgMetadata {
439 typinput_oid: 1244,
440 typreceive_oid: 2412,
441 }),
442 },
443};
444
445pub const TYPE_INT8: BuiltinType<NameReference> = BuiltinType {
446 name: "int8",
447 schema: PG_CATALOG_SCHEMA,
448 oid: oid::TYPE_INT8_OID,
449 details: CatalogTypeDetails {
450 typ: CatalogType::Int64,
451 array_id: None,
452 pg_metadata: Some(CatalogTypePgMetadata {
453 typinput_oid: 460,
454 typreceive_oid: 2408,
455 }),
456 },
457};
458
459pub const TYPE_INT4: BuiltinType<NameReference> = BuiltinType {
460 name: "int4",
461 schema: PG_CATALOG_SCHEMA,
462 oid: oid::TYPE_INT4_OID,
463 details: CatalogTypeDetails {
464 typ: CatalogType::Int32,
465 array_id: None,
466 pg_metadata: Some(CatalogTypePgMetadata {
467 typinput_oid: 42,
468 typreceive_oid: 2406,
469 }),
470 },
471};
472
473pub const TYPE_TEXT: BuiltinType<NameReference> = BuiltinType {
474 name: "text",
475 schema: PG_CATALOG_SCHEMA,
476 oid: oid::TYPE_TEXT_OID,
477 details: CatalogTypeDetails {
478 typ: CatalogType::String,
479 array_id: None,
480 pg_metadata: Some(CatalogTypePgMetadata {
481 typinput_oid: 46,
482 typreceive_oid: 2414,
483 }),
484 },
485};
486
487pub const TYPE_OID: BuiltinType<NameReference> = BuiltinType {
488 name: "oid",
489 schema: PG_CATALOG_SCHEMA,
490 oid: oid::TYPE_OID_OID,
491 details: CatalogTypeDetails {
492 typ: CatalogType::Oid,
493 array_id: None,
494 pg_metadata: Some(CatalogTypePgMetadata {
495 typinput_oid: 1798,
496 typreceive_oid: 2418,
497 }),
498 },
499};
500
501pub const TYPE_FLOAT4: BuiltinType<NameReference> = BuiltinType {
502 name: "float4",
503 schema: PG_CATALOG_SCHEMA,
504 oid: oid::TYPE_FLOAT4_OID,
505 details: CatalogTypeDetails {
506 typ: CatalogType::Float32,
507 array_id: None,
508 pg_metadata: Some(CatalogTypePgMetadata {
509 typinput_oid: 200,
510 typreceive_oid: 2424,
511 }),
512 },
513};
514
515pub const TYPE_FLOAT8: BuiltinType<NameReference> = BuiltinType {
516 name: "float8",
517 schema: PG_CATALOG_SCHEMA,
518 oid: oid::TYPE_FLOAT8_OID,
519 details: CatalogTypeDetails {
520 typ: CatalogType::Float64,
521 array_id: None,
522 pg_metadata: Some(CatalogTypePgMetadata {
523 typinput_oid: 214,
524 typreceive_oid: 2426,
525 }),
526 },
527};
528
529pub const TYPE_BOOL_ARRAY: BuiltinType<NameReference> = BuiltinType {
530 name: "_bool",
531 schema: PG_CATALOG_SCHEMA,
532 oid: oid::TYPE_BOOL_ARRAY_OID,
533 details: CatalogTypeDetails {
534 typ: CatalogType::Array {
535 element_reference: TYPE_BOOL.name,
536 },
537 array_id: None,
538 pg_metadata: Some(CatalogTypePgMetadata {
539 typinput_oid: 750,
540 typreceive_oid: 2400,
541 }),
542 },
543};
544
545pub const TYPE_BYTEA_ARRAY: BuiltinType<NameReference> = BuiltinType {
546 name: "_bytea",
547 schema: PG_CATALOG_SCHEMA,
548 oid: oid::TYPE_BYTEA_ARRAY_OID,
549 details: CatalogTypeDetails {
550 typ: CatalogType::Array {
551 element_reference: TYPE_BYTEA.name,
552 },
553 array_id: None,
554 pg_metadata: Some(CatalogTypePgMetadata {
555 typinput_oid: 750,
556 typreceive_oid: 2400,
557 }),
558 },
559};
560
561pub const TYPE_INT4_ARRAY: BuiltinType<NameReference> = BuiltinType {
562 name: "_int4",
563 schema: PG_CATALOG_SCHEMA,
564 oid: oid::TYPE_INT4_ARRAY_OID,
565 details: CatalogTypeDetails {
566 typ: CatalogType::Array {
567 element_reference: TYPE_INT4.name,
568 },
569 array_id: None,
570 pg_metadata: Some(CatalogTypePgMetadata {
571 typinput_oid: 750,
572 typreceive_oid: 2400,
573 }),
574 },
575};
576
577pub const TYPE_TEXT_ARRAY: BuiltinType<NameReference> = BuiltinType {
578 name: "_text",
579 schema: PG_CATALOG_SCHEMA,
580 oid: oid::TYPE_TEXT_ARRAY_OID,
581 details: CatalogTypeDetails {
582 typ: CatalogType::Array {
583 element_reference: TYPE_TEXT.name,
584 },
585 array_id: None,
586 pg_metadata: Some(CatalogTypePgMetadata {
587 typinput_oid: 750,
588 typreceive_oid: 2400,
589 }),
590 },
591};
592
593pub const TYPE_INT8_ARRAY: BuiltinType<NameReference> = BuiltinType {
594 name: "_int8",
595 schema: PG_CATALOG_SCHEMA,
596 oid: oid::TYPE_INT8_ARRAY_OID,
597 details: CatalogTypeDetails {
598 typ: CatalogType::Array {
599 element_reference: TYPE_INT8.name,
600 },
601 array_id: None,
602 pg_metadata: Some(CatalogTypePgMetadata {
603 typinput_oid: 750,
604 typreceive_oid: 2400,
605 }),
606 },
607};
608
609pub const TYPE_FLOAT4_ARRAY: BuiltinType<NameReference> = BuiltinType {
610 name: "_float4",
611 schema: PG_CATALOG_SCHEMA,
612 oid: oid::TYPE_FLOAT4_ARRAY_OID,
613 details: CatalogTypeDetails {
614 typ: CatalogType::Array {
615 element_reference: TYPE_FLOAT4.name,
616 },
617 array_id: None,
618 pg_metadata: Some(CatalogTypePgMetadata {
619 typinput_oid: 750,
620 typreceive_oid: 2400,
621 }),
622 },
623};
624
625pub const TYPE_FLOAT8_ARRAY: BuiltinType<NameReference> = BuiltinType {
626 name: "_float8",
627 schema: PG_CATALOG_SCHEMA,
628 oid: oid::TYPE_FLOAT8_ARRAY_OID,
629 details: CatalogTypeDetails {
630 typ: CatalogType::Array {
631 element_reference: TYPE_FLOAT8.name,
632 },
633 array_id: None,
634 pg_metadata: Some(CatalogTypePgMetadata {
635 typinput_oid: 750,
636 typreceive_oid: 2400,
637 }),
638 },
639};
640
641pub const TYPE_OID_ARRAY: BuiltinType<NameReference> = BuiltinType {
642 name: "_oid",
643 schema: PG_CATALOG_SCHEMA,
644 oid: oid::TYPE_OID_ARRAY_OID,
645 details: CatalogTypeDetails {
646 typ: CatalogType::Array {
647 element_reference: TYPE_OID.name,
648 },
649 array_id: None,
650 pg_metadata: Some(CatalogTypePgMetadata {
651 typinput_oid: 750,
652 typreceive_oid: 2400,
653 }),
654 },
655};
656
657pub const TYPE_DATE: BuiltinType<NameReference> = BuiltinType {
658 name: "date",
659 schema: PG_CATALOG_SCHEMA,
660 oid: oid::TYPE_DATE_OID,
661 details: CatalogTypeDetails {
662 typ: CatalogType::Date,
663 array_id: None,
664 pg_metadata: Some(CatalogTypePgMetadata {
665 typinput_oid: 1084,
666 typreceive_oid: 2468,
667 }),
668 },
669};
670
671pub const TYPE_TIME: BuiltinType<NameReference> = BuiltinType {
672 name: "time",
673 schema: PG_CATALOG_SCHEMA,
674 oid: oid::TYPE_TIME_OID,
675 details: CatalogTypeDetails {
676 typ: CatalogType::Time,
677 array_id: None,
678 pg_metadata: Some(CatalogTypePgMetadata {
679 typinput_oid: 1143,
680 typreceive_oid: 2470,
681 }),
682 },
683};
684
685pub const TYPE_TIMESTAMP: BuiltinType<NameReference> = BuiltinType {
686 name: "timestamp",
687 schema: PG_CATALOG_SCHEMA,
688 oid: oid::TYPE_TIMESTAMP_OID,
689 details: CatalogTypeDetails {
690 typ: CatalogType::Timestamp,
691 array_id: None,
692 pg_metadata: Some(CatalogTypePgMetadata {
693 typinput_oid: 1312,
694 typreceive_oid: 2474,
695 }),
696 },
697};
698
699pub const TYPE_TIMESTAMP_ARRAY: BuiltinType<NameReference> = BuiltinType {
700 name: "_timestamp",
701 schema: PG_CATALOG_SCHEMA,
702 oid: oid::TYPE_TIMESTAMP_ARRAY_OID,
703 details: CatalogTypeDetails {
704 typ: CatalogType::Array {
705 element_reference: TYPE_TIMESTAMP.name,
706 },
707 array_id: None,
708 pg_metadata: Some(CatalogTypePgMetadata {
709 typinput_oid: 750,
710 typreceive_oid: 2400,
711 }),
712 },
713};
714
715pub const TYPE_DATE_ARRAY: BuiltinType<NameReference> = BuiltinType {
716 name: "_date",
717 schema: PG_CATALOG_SCHEMA,
718 oid: oid::TYPE_DATE_ARRAY_OID,
719 details: CatalogTypeDetails {
720 typ: CatalogType::Array {
721 element_reference: TYPE_DATE.name,
722 },
723 array_id: None,
724 pg_metadata: Some(CatalogTypePgMetadata {
725 typinput_oid: 750,
726 typreceive_oid: 2400,
727 }),
728 },
729};
730
731pub const TYPE_TIME_ARRAY: BuiltinType<NameReference> = BuiltinType {
732 name: "_time",
733 schema: PG_CATALOG_SCHEMA,
734 oid: oid::TYPE_TIME_ARRAY_OID,
735 details: CatalogTypeDetails {
736 typ: CatalogType::Array {
737 element_reference: TYPE_TIME.name,
738 },
739 array_id: None,
740 pg_metadata: Some(CatalogTypePgMetadata {
741 typinput_oid: 750,
742 typreceive_oid: 2400,
743 }),
744 },
745};
746
747pub const TYPE_TIMESTAMPTZ: BuiltinType<NameReference> = BuiltinType {
748 name: "timestamptz",
749 schema: PG_CATALOG_SCHEMA,
750 oid: oid::TYPE_TIMESTAMPTZ_OID,
751 details: CatalogTypeDetails {
752 typ: CatalogType::TimestampTz,
753 array_id: None,
754 pg_metadata: Some(CatalogTypePgMetadata {
755 typinput_oid: 1150,
756 typreceive_oid: 2476,
757 }),
758 },
759};
760
761pub const TYPE_TIMESTAMPTZ_ARRAY: BuiltinType<NameReference> = BuiltinType {
762 name: "_timestamptz",
763 schema: PG_CATALOG_SCHEMA,
764 oid: oid::TYPE_TIMESTAMPTZ_ARRAY_OID,
765 details: CatalogTypeDetails {
766 typ: CatalogType::Array {
767 element_reference: TYPE_TIMESTAMPTZ.name,
768 },
769 array_id: None,
770 pg_metadata: Some(CatalogTypePgMetadata {
771 typinput_oid: 750,
772 typreceive_oid: 2400,
773 }),
774 },
775};
776
777pub const TYPE_INTERVAL: BuiltinType<NameReference> = BuiltinType {
778 name: "interval",
779 schema: PG_CATALOG_SCHEMA,
780 oid: oid::TYPE_INTERVAL_OID,
781 details: CatalogTypeDetails {
782 typ: CatalogType::Interval,
783 array_id: None,
784 pg_metadata: Some(CatalogTypePgMetadata {
785 typinput_oid: 1160,
786 typreceive_oid: 2478,
787 }),
788 },
789};
790
791pub const TYPE_INTERVAL_ARRAY: BuiltinType<NameReference> = BuiltinType {
792 name: "_interval",
793 schema: PG_CATALOG_SCHEMA,
794 oid: oid::TYPE_INTERVAL_ARRAY_OID,
795 details: CatalogTypeDetails {
796 typ: CatalogType::Array {
797 element_reference: TYPE_INTERVAL.name,
798 },
799 array_id: None,
800 pg_metadata: Some(CatalogTypePgMetadata {
801 typinput_oid: 750,
802 typreceive_oid: 2400,
803 }),
804 },
805};
806
807pub const TYPE_NAME: BuiltinType<NameReference> = BuiltinType {
808 name: "name",
809 schema: PG_CATALOG_SCHEMA,
810 oid: oid::TYPE_NAME_OID,
811 details: CatalogTypeDetails {
812 typ: CatalogType::PgLegacyName,
813 array_id: None,
814 pg_metadata: Some(CatalogTypePgMetadata {
815 typinput_oid: 34,
816 typreceive_oid: 2422,
817 }),
818 },
819};
820
821pub const TYPE_NAME_ARRAY: BuiltinType<NameReference> = BuiltinType {
822 name: "_name",
823 schema: PG_CATALOG_SCHEMA,
824 oid: oid::TYPE_NAME_ARRAY_OID,
825 details: CatalogTypeDetails {
826 typ: CatalogType::Array {
827 element_reference: TYPE_NAME.name,
828 },
829 array_id: None,
830 pg_metadata: Some(CatalogTypePgMetadata {
831 typinput_oid: 750,
832 typreceive_oid: 2400,
833 }),
834 },
835};
836
837pub const TYPE_NUMERIC: BuiltinType<NameReference> = BuiltinType {
838 name: "numeric",
839 schema: PG_CATALOG_SCHEMA,
840 oid: oid::TYPE_NUMERIC_OID,
841 details: CatalogTypeDetails {
842 typ: CatalogType::Numeric,
843 array_id: None,
844 pg_metadata: Some(CatalogTypePgMetadata {
845 typinput_oid: 1701,
846 typreceive_oid: 2460,
847 }),
848 },
849};
850
851pub const TYPE_NUMERIC_ARRAY: BuiltinType<NameReference> = BuiltinType {
852 name: "_numeric",
853 schema: PG_CATALOG_SCHEMA,
854 oid: oid::TYPE_NUMERIC_ARRAY_OID,
855 details: CatalogTypeDetails {
856 typ: CatalogType::Array {
857 element_reference: TYPE_NUMERIC.name,
858 },
859 array_id: None,
860 pg_metadata: Some(CatalogTypePgMetadata {
861 typinput_oid: 750,
862 typreceive_oid: 2400,
863 }),
864 },
865};
866
867pub const TYPE_RECORD: BuiltinType<NameReference> = BuiltinType {
868 name: "record",
869 schema: PG_CATALOG_SCHEMA,
870 oid: oid::TYPE_RECORD_OID,
871 details: CatalogTypeDetails {
872 typ: CatalogType::Pseudo,
873 array_id: None,
874 pg_metadata: Some(CatalogTypePgMetadata {
875 typinput_oid: 2290,
876 typreceive_oid: 2402,
877 }),
878 },
879};
880
881pub const TYPE_RECORD_ARRAY: BuiltinType<NameReference> = BuiltinType {
882 name: "_record",
883 schema: PG_CATALOG_SCHEMA,
884 oid: oid::TYPE_RECORD_ARRAY_OID,
885 details: CatalogTypeDetails {
886 typ: CatalogType::Array {
887 element_reference: TYPE_RECORD.name,
888 },
889 array_id: None,
890 pg_metadata: Some(CatalogTypePgMetadata {
891 typinput_oid: 750,
892 typreceive_oid: 2400,
893 }),
894 },
895};
896
897pub const TYPE_UUID: BuiltinType<NameReference> = BuiltinType {
898 name: "uuid",
899 schema: PG_CATALOG_SCHEMA,
900 oid: oid::TYPE_UUID_OID,
901 details: CatalogTypeDetails {
902 typ: CatalogType::Uuid,
903 array_id: None,
904 pg_metadata: Some(CatalogTypePgMetadata {
905 typinput_oid: 2952,
906 typreceive_oid: 2961,
907 }),
908 },
909};
910
911pub const TYPE_UUID_ARRAY: BuiltinType<NameReference> = BuiltinType {
912 name: "_uuid",
913 schema: PG_CATALOG_SCHEMA,
914 oid: oid::TYPE_UUID_ARRAY_OID,
915 details: CatalogTypeDetails {
916 typ: CatalogType::Array {
917 element_reference: TYPE_UUID.name,
918 },
919 array_id: None,
920 pg_metadata: Some(CatalogTypePgMetadata {
921 typinput_oid: 750,
922 typreceive_oid: 2400,
923 }),
924 },
925};
926
927pub const TYPE_JSONB: BuiltinType<NameReference> = BuiltinType {
928 name: "jsonb",
929 schema: PG_CATALOG_SCHEMA,
930 oid: oid::TYPE_JSONB_OID,
931 details: CatalogTypeDetails {
932 typ: CatalogType::Jsonb,
933 array_id: None,
934 pg_metadata: Some(CatalogTypePgMetadata {
935 typinput_oid: 3806,
936 typreceive_oid: 3805,
937 }),
938 },
939};
940
941pub const TYPE_JSONB_ARRAY: BuiltinType<NameReference> = BuiltinType {
942 name: "_jsonb",
943 schema: PG_CATALOG_SCHEMA,
944 oid: oid::TYPE_JSONB_ARRAY_OID,
945 details: CatalogTypeDetails {
946 typ: CatalogType::Array {
947 element_reference: TYPE_JSONB.name,
948 },
949 array_id: None,
950 pg_metadata: Some(CatalogTypePgMetadata {
951 typinput_oid: 750,
952 typreceive_oid: 2400,
953 }),
954 },
955};
956
957pub const TYPE_ANY: BuiltinType<NameReference> = BuiltinType {
958 name: "any",
959 schema: PG_CATALOG_SCHEMA,
960 oid: oid::TYPE_ANY_OID,
961 details: CatalogTypeDetails {
962 typ: CatalogType::Pseudo,
963 array_id: None,
964 pg_metadata: Some(CatalogTypePgMetadata {
965 typinput_oid: 2294,
966 typreceive_oid: 0,
967 }),
968 },
969};
970
971pub const TYPE_ANYARRAY: BuiltinType<NameReference> = BuiltinType {
972 name: "anyarray",
973 schema: PG_CATALOG_SCHEMA,
974 oid: oid::TYPE_ANYARRAY_OID,
975 details: CatalogTypeDetails {
976 typ: CatalogType::Pseudo,
977 array_id: None,
978 pg_metadata: Some(CatalogTypePgMetadata {
979 typinput_oid: 2296,
980 typreceive_oid: 2502,
981 }),
982 },
983};
984
985pub const TYPE_ANYELEMENT: BuiltinType<NameReference> = BuiltinType {
986 name: "anyelement",
987 schema: PG_CATALOG_SCHEMA,
988 oid: oid::TYPE_ANYELEMENT_OID,
989 details: CatalogTypeDetails {
990 typ: CatalogType::Pseudo,
991 array_id: None,
992 pg_metadata: Some(CatalogTypePgMetadata {
993 typinput_oid: 2312,
994 typreceive_oid: 0,
995 }),
996 },
997};
998
999pub const TYPE_ANYNONARRAY: BuiltinType<NameReference> = BuiltinType {
1000 name: "anynonarray",
1001 schema: PG_CATALOG_SCHEMA,
1002 oid: oid::TYPE_ANYNONARRAY_OID,
1003 details: CatalogTypeDetails {
1004 typ: CatalogType::Pseudo,
1005 array_id: None,
1006 pg_metadata: Some(CatalogTypePgMetadata {
1007 typinput_oid: 2777,
1008 typreceive_oid: 0,
1009 }),
1010 },
1011};
1012
1013pub const TYPE_ANYRANGE: BuiltinType<NameReference> = BuiltinType {
1014 name: "anyrange",
1015 schema: PG_CATALOG_SCHEMA,
1016 oid: oid::TYPE_ANYRANGE_OID,
1017 details: CatalogTypeDetails {
1018 typ: CatalogType::Pseudo,
1019 array_id: None,
1020 pg_metadata: Some(CatalogTypePgMetadata {
1021 typinput_oid: 3832,
1022 typreceive_oid: 0,
1023 }),
1024 },
1025};
1026
1027pub const TYPE_CHAR: BuiltinType<NameReference> = BuiltinType {
1028 name: "char",
1029 schema: PG_CATALOG_SCHEMA,
1030 oid: oid::TYPE_CHAR_OID,
1031 details: CatalogTypeDetails {
1032 typ: CatalogType::PgLegacyChar,
1033 array_id: None,
1034 pg_metadata: Some(CatalogTypePgMetadata {
1035 typinput_oid: 1245,
1036 typreceive_oid: 2434,
1037 }),
1038 },
1039};
1040
1041pub const TYPE_VARCHAR: BuiltinType<NameReference> = BuiltinType {
1042 name: "varchar",
1043 schema: PG_CATALOG_SCHEMA,
1044 oid: oid::TYPE_VARCHAR_OID,
1045 details: CatalogTypeDetails {
1046 typ: CatalogType::VarChar,
1047 array_id: None,
1048 pg_metadata: Some(CatalogTypePgMetadata {
1049 typinput_oid: 1046,
1050 typreceive_oid: 2432,
1051 }),
1052 },
1053};
1054
1055pub const TYPE_INT2: BuiltinType<NameReference> = BuiltinType {
1056 name: "int2",
1057 schema: PG_CATALOG_SCHEMA,
1058 oid: oid::TYPE_INT2_OID,
1059 details: CatalogTypeDetails {
1060 typ: CatalogType::Int16,
1061 array_id: None,
1062 pg_metadata: Some(CatalogTypePgMetadata {
1063 typinput_oid: 38,
1064 typreceive_oid: 2404,
1065 }),
1066 },
1067};
1068
1069pub const TYPE_INT2_ARRAY: BuiltinType<NameReference> = BuiltinType {
1070 name: "_int2",
1071 schema: PG_CATALOG_SCHEMA,
1072 oid: oid::TYPE_INT2_ARRAY_OID,
1073 details: CatalogTypeDetails {
1074 typ: CatalogType::Array {
1075 element_reference: TYPE_INT2.name,
1076 },
1077 array_id: None,
1078 pg_metadata: Some(CatalogTypePgMetadata {
1079 typinput_oid: 750,
1080 typreceive_oid: 2400,
1081 }),
1082 },
1083};
1084
1085pub const TYPE_BPCHAR: BuiltinType<NameReference> = BuiltinType {
1086 name: "bpchar",
1087 schema: PG_CATALOG_SCHEMA,
1088 oid: oid::TYPE_BPCHAR_OID,
1089 details: CatalogTypeDetails {
1090 typ: CatalogType::Char,
1091 array_id: None,
1092 pg_metadata: Some(CatalogTypePgMetadata {
1093 typinput_oid: 1044,
1094 typreceive_oid: 2430,
1095 }),
1096 },
1097};
1098
1099pub const TYPE_CHAR_ARRAY: BuiltinType<NameReference> = BuiltinType {
1100 name: "_char",
1101 schema: PG_CATALOG_SCHEMA,
1102 oid: oid::TYPE_CHAR_ARRAY_OID,
1103 details: CatalogTypeDetails {
1104 typ: CatalogType::Array {
1105 element_reference: TYPE_CHAR.name,
1106 },
1107 array_id: None,
1108 pg_metadata: Some(CatalogTypePgMetadata {
1109 typinput_oid: 750,
1110 typreceive_oid: 2400,
1111 }),
1112 },
1113};
1114
1115pub const TYPE_VARCHAR_ARRAY: BuiltinType<NameReference> = BuiltinType {
1116 name: "_varchar",
1117 schema: PG_CATALOG_SCHEMA,
1118 oid: oid::TYPE_VARCHAR_ARRAY_OID,
1119 details: CatalogTypeDetails {
1120 typ: CatalogType::Array {
1121 element_reference: TYPE_VARCHAR.name,
1122 },
1123 array_id: None,
1124 pg_metadata: Some(CatalogTypePgMetadata {
1125 typinput_oid: 750,
1126 typreceive_oid: 2400,
1127 }),
1128 },
1129};
1130
1131pub const TYPE_BPCHAR_ARRAY: BuiltinType<NameReference> = BuiltinType {
1132 name: "_bpchar",
1133 schema: PG_CATALOG_SCHEMA,
1134 oid: oid::TYPE_BPCHAR_ARRAY_OID,
1135 details: CatalogTypeDetails {
1136 typ: CatalogType::Array {
1137 element_reference: TYPE_BPCHAR.name,
1138 },
1139 array_id: None,
1140 pg_metadata: Some(CatalogTypePgMetadata {
1141 typinput_oid: 750,
1142 typreceive_oid: 2400,
1143 }),
1144 },
1145};
1146
1147pub const TYPE_REGPROC: BuiltinType<NameReference> = BuiltinType {
1148 name: "regproc",
1149 schema: PG_CATALOG_SCHEMA,
1150 oid: oid::TYPE_REGPROC_OID,
1151 details: CatalogTypeDetails {
1152 typ: CatalogType::RegProc,
1153 array_id: None,
1154 pg_metadata: Some(CatalogTypePgMetadata {
1155 typinput_oid: 44,
1156 typreceive_oid: 2444,
1157 }),
1158 },
1159};
1160
1161pub const TYPE_REGPROC_ARRAY: BuiltinType<NameReference> = BuiltinType {
1162 name: "_regproc",
1163 schema: PG_CATALOG_SCHEMA,
1164 oid: oid::TYPE_REGPROC_ARRAY_OID,
1165 details: CatalogTypeDetails {
1166 typ: CatalogType::Array {
1167 element_reference: TYPE_REGPROC.name,
1168 },
1169 array_id: None,
1170 pg_metadata: Some(CatalogTypePgMetadata {
1171 typinput_oid: 750,
1172 typreceive_oid: 2400,
1173 }),
1174 },
1175};
1176
1177pub const TYPE_REGTYPE: BuiltinType<NameReference> = BuiltinType {
1178 name: "regtype",
1179 schema: PG_CATALOG_SCHEMA,
1180 oid: oid::TYPE_REGTYPE_OID,
1181 details: CatalogTypeDetails {
1182 typ: CatalogType::RegType,
1183 array_id: None,
1184 pg_metadata: Some(CatalogTypePgMetadata {
1185 typinput_oid: 2220,
1186 typreceive_oid: 2454,
1187 }),
1188 },
1189};
1190
1191pub const TYPE_REGTYPE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1192 name: "_regtype",
1193 schema: PG_CATALOG_SCHEMA,
1194 oid: oid::TYPE_REGTYPE_ARRAY_OID,
1195 details: CatalogTypeDetails {
1196 typ: CatalogType::Array {
1197 element_reference: TYPE_REGTYPE.name,
1198 },
1199 array_id: None,
1200 pg_metadata: Some(CatalogTypePgMetadata {
1201 typinput_oid: 750,
1202 typreceive_oid: 2400,
1203 }),
1204 },
1205};
1206
1207pub const TYPE_REGCLASS: BuiltinType<NameReference> = BuiltinType {
1208 name: "regclass",
1209 schema: PG_CATALOG_SCHEMA,
1210 oid: oid::TYPE_REGCLASS_OID,
1211 details: CatalogTypeDetails {
1212 typ: CatalogType::RegClass,
1213 array_id: None,
1214 pg_metadata: Some(CatalogTypePgMetadata {
1215 typinput_oid: 2218,
1216 typreceive_oid: 2452,
1217 }),
1218 },
1219};
1220
1221pub const TYPE_REGCLASS_ARRAY: BuiltinType<NameReference> = BuiltinType {
1222 name: "_regclass",
1223 schema: PG_CATALOG_SCHEMA,
1224 oid: oid::TYPE_REGCLASS_ARRAY_OID,
1225 details: CatalogTypeDetails {
1226 typ: CatalogType::Array {
1227 element_reference: TYPE_REGCLASS.name,
1228 },
1229 array_id: None,
1230 pg_metadata: Some(CatalogTypePgMetadata {
1231 typinput_oid: 750,
1232 typreceive_oid: 2400,
1233 }),
1234 },
1235};
1236
1237pub const TYPE_INT2_VECTOR: BuiltinType<NameReference> = BuiltinType {
1238 name: "int2vector",
1239 schema: PG_CATALOG_SCHEMA,
1240 oid: oid::TYPE_INT2_VECTOR_OID,
1241 details: CatalogTypeDetails {
1242 typ: CatalogType::Int2Vector,
1243 array_id: None,
1244 pg_metadata: Some(CatalogTypePgMetadata {
1245 typinput_oid: 40,
1246 typreceive_oid: 2410,
1247 }),
1248 },
1249};
1250
1251pub const TYPE_INT2_VECTOR_ARRAY: BuiltinType<NameReference> = BuiltinType {
1252 name: "_int2vector",
1253 schema: PG_CATALOG_SCHEMA,
1254 oid: oid::TYPE_INT2_VECTOR_ARRAY_OID,
1255 details: CatalogTypeDetails {
1256 typ: CatalogType::Array {
1257 element_reference: TYPE_INT2_VECTOR.name,
1258 },
1259 array_id: None,
1260 pg_metadata: Some(CatalogTypePgMetadata {
1261 typinput_oid: 750,
1262 typreceive_oid: 2400,
1263 }),
1264 },
1265};
1266
1267pub const TYPE_ANYCOMPATIBLE: BuiltinType<NameReference> = BuiltinType {
1268 name: "anycompatible",
1269 schema: PG_CATALOG_SCHEMA,
1270 oid: oid::TYPE_ANYCOMPATIBLE_OID,
1271 details: CatalogTypeDetails {
1272 typ: CatalogType::Pseudo,
1273 array_id: None,
1274 pg_metadata: Some(CatalogTypePgMetadata {
1275 typinput_oid: 5086,
1276 typreceive_oid: 0,
1277 }),
1278 },
1279};
1280
1281pub const TYPE_ANYCOMPATIBLEARRAY: BuiltinType<NameReference> = BuiltinType {
1282 name: "anycompatiblearray",
1283 schema: PG_CATALOG_SCHEMA,
1284 oid: oid::TYPE_ANYCOMPATIBLEARRAY_OID,
1285 details: CatalogTypeDetails {
1286 typ: CatalogType::Pseudo,
1287 array_id: None,
1288 pg_metadata: Some(CatalogTypePgMetadata {
1289 typinput_oid: 5088,
1290 typreceive_oid: 5090,
1291 }),
1292 },
1293};
1294
1295pub const TYPE_ANYCOMPATIBLENONARRAY: BuiltinType<NameReference> = BuiltinType {
1296 name: "anycompatiblenonarray",
1297 schema: PG_CATALOG_SCHEMA,
1298 oid: oid::TYPE_ANYCOMPATIBLENONARRAY_OID,
1299 details: CatalogTypeDetails {
1300 typ: CatalogType::Pseudo,
1301 array_id: None,
1302 pg_metadata: Some(CatalogTypePgMetadata {
1303 typinput_oid: 5092,
1304 typreceive_oid: 0,
1305 }),
1306 },
1307};
1308
1309pub const TYPE_ANYCOMPATIBLERANGE: BuiltinType<NameReference> = BuiltinType {
1310 name: "anycompatiblerange",
1311 schema: PG_CATALOG_SCHEMA,
1312 oid: oid::TYPE_ANYCOMPATIBLERANGE_OID,
1313 details: CatalogTypeDetails {
1314 typ: CatalogType::Pseudo,
1315 array_id: None,
1316 pg_metadata: Some(CatalogTypePgMetadata {
1317 typinput_oid: 5094,
1318 typreceive_oid: 0,
1319 }),
1320 },
1321};
1322
1323pub const TYPE_LIST: BuiltinType<NameReference> = BuiltinType {
1324 name: "list",
1325 schema: MZ_CATALOG_SCHEMA,
1326 oid: mz_pgrepr::oid::TYPE_LIST_OID,
1327 details: CatalogTypeDetails {
1328 typ: CatalogType::Pseudo,
1329 array_id: None,
1330 pg_metadata: None,
1331 },
1332};
1333
1334pub const TYPE_MAP: BuiltinType<NameReference> = BuiltinType {
1335 name: "map",
1336 schema: MZ_CATALOG_SCHEMA,
1337 oid: mz_pgrepr::oid::TYPE_MAP_OID,
1338 details: CatalogTypeDetails {
1339 typ: CatalogType::Pseudo,
1340 array_id: None,
1341 pg_metadata: None,
1342 },
1343};
1344
1345pub const TYPE_ANYCOMPATIBLELIST: BuiltinType<NameReference> = BuiltinType {
1346 name: "anycompatiblelist",
1347 schema: MZ_CATALOG_SCHEMA,
1348 oid: mz_pgrepr::oid::TYPE_ANYCOMPATIBLELIST_OID,
1349 details: CatalogTypeDetails {
1350 typ: CatalogType::Pseudo,
1351 array_id: None,
1352 pg_metadata: None,
1353 },
1354};
1355
1356pub const TYPE_ANYCOMPATIBLEMAP: BuiltinType<NameReference> = BuiltinType {
1357 name: "anycompatiblemap",
1358 schema: MZ_CATALOG_SCHEMA,
1359 oid: mz_pgrepr::oid::TYPE_ANYCOMPATIBLEMAP_OID,
1360 details: CatalogTypeDetails {
1361 typ: CatalogType::Pseudo,
1362 array_id: None,
1363 pg_metadata: None,
1364 },
1365};
1366
1367pub const TYPE_UINT2: BuiltinType<NameReference> = BuiltinType {
1368 name: "uint2",
1369 schema: MZ_CATALOG_SCHEMA,
1370 oid: mz_pgrepr::oid::TYPE_UINT2_OID,
1371 details: CatalogTypeDetails {
1372 typ: CatalogType::UInt16,
1373 array_id: None,
1374 pg_metadata: None,
1375 },
1376};
1377
1378pub const TYPE_UINT2_ARRAY: BuiltinType<NameReference> = BuiltinType {
1379 name: "_uint2",
1380 schema: MZ_CATALOG_SCHEMA,
1381 oid: mz_pgrepr::oid::TYPE_UINT2_ARRAY_OID,
1382 details: CatalogTypeDetails {
1383 typ: CatalogType::Array {
1384 element_reference: TYPE_UINT2.name,
1385 },
1386 array_id: None,
1387 pg_metadata: None,
1388 },
1389};
1390
1391pub const TYPE_UINT4: BuiltinType<NameReference> = BuiltinType {
1392 name: "uint4",
1393 schema: MZ_CATALOG_SCHEMA,
1394 oid: mz_pgrepr::oid::TYPE_UINT4_OID,
1395 details: CatalogTypeDetails {
1396 typ: CatalogType::UInt32,
1397 array_id: None,
1398 pg_metadata: None,
1399 },
1400};
1401
1402pub const TYPE_UINT4_ARRAY: BuiltinType<NameReference> = BuiltinType {
1403 name: "_uint4",
1404 schema: MZ_CATALOG_SCHEMA,
1405 oid: mz_pgrepr::oid::TYPE_UINT4_ARRAY_OID,
1406 details: CatalogTypeDetails {
1407 typ: CatalogType::Array {
1408 element_reference: TYPE_UINT4.name,
1409 },
1410 array_id: None,
1411 pg_metadata: None,
1412 },
1413};
1414
1415pub const TYPE_UINT8: BuiltinType<NameReference> = BuiltinType {
1416 name: "uint8",
1417 schema: MZ_CATALOG_SCHEMA,
1418 oid: mz_pgrepr::oid::TYPE_UINT8_OID,
1419 details: CatalogTypeDetails {
1420 typ: CatalogType::UInt64,
1421 array_id: None,
1422 pg_metadata: None,
1423 },
1424};
1425
1426pub const TYPE_UINT8_ARRAY: BuiltinType<NameReference> = BuiltinType {
1427 name: "_uint8",
1428 schema: MZ_CATALOG_SCHEMA,
1429 oid: mz_pgrepr::oid::TYPE_UINT8_ARRAY_OID,
1430 details: CatalogTypeDetails {
1431 typ: CatalogType::Array {
1432 element_reference: TYPE_UINT8.name,
1433 },
1434 array_id: None,
1435 pg_metadata: None,
1436 },
1437};
1438
1439pub const TYPE_MZ_TIMESTAMP: BuiltinType<NameReference> = BuiltinType {
1440 name: "mz_timestamp",
1441 schema: MZ_CATALOG_SCHEMA,
1442 oid: mz_pgrepr::oid::TYPE_MZ_TIMESTAMP_OID,
1443 details: CatalogTypeDetails {
1444 typ: CatalogType::MzTimestamp,
1445 array_id: None,
1446 pg_metadata: None,
1447 },
1448};
1449
1450pub const TYPE_MZ_TIMESTAMP_ARRAY: BuiltinType<NameReference> = BuiltinType {
1451 name: "_mz_timestamp",
1452 schema: MZ_CATALOG_SCHEMA,
1453 oid: mz_pgrepr::oid::TYPE_MZ_TIMESTAMP_ARRAY_OID,
1454 details: CatalogTypeDetails {
1455 typ: CatalogType::Array {
1456 element_reference: TYPE_MZ_TIMESTAMP.name,
1457 },
1458 array_id: None,
1459 pg_metadata: None,
1460 },
1461};
1462
1463pub const TYPE_INT4_RANGE: BuiltinType<NameReference> = BuiltinType {
1464 name: "int4range",
1465 schema: PG_CATALOG_SCHEMA,
1466 oid: mz_pgrepr::oid::TYPE_INT4RANGE_OID,
1467 details: CatalogTypeDetails {
1468 typ: CatalogType::Range {
1469 element_reference: TYPE_INT4.name,
1470 },
1471 array_id: None,
1472 pg_metadata: Some(CatalogTypePgMetadata {
1473 typinput_oid: 3834,
1474 typreceive_oid: 3836,
1475 }),
1476 },
1477};
1478
1479pub const TYPE_INT4_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1480 name: "_int4range",
1481 schema: PG_CATALOG_SCHEMA,
1482 oid: mz_pgrepr::oid::TYPE_INT4RANGE_ARRAY_OID,
1483 details: CatalogTypeDetails {
1484 typ: CatalogType::Array {
1485 element_reference: TYPE_INT4_RANGE.name,
1486 },
1487 array_id: None,
1488 pg_metadata: Some(CatalogTypePgMetadata {
1489 typinput_oid: 750,
1490 typreceive_oid: 2400,
1491 }),
1492 },
1493};
1494
1495pub const TYPE_INT8_RANGE: BuiltinType<NameReference> = BuiltinType {
1496 name: "int8range",
1497 schema: PG_CATALOG_SCHEMA,
1498 oid: mz_pgrepr::oid::TYPE_INT8RANGE_OID,
1499 details: CatalogTypeDetails {
1500 typ: CatalogType::Range {
1501 element_reference: TYPE_INT8.name,
1502 },
1503 array_id: None,
1504 pg_metadata: Some(CatalogTypePgMetadata {
1505 typinput_oid: 3834,
1506 typreceive_oid: 3836,
1507 }),
1508 },
1509};
1510
1511pub const TYPE_INT8_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1512 name: "_int8range",
1513 schema: PG_CATALOG_SCHEMA,
1514 oid: mz_pgrepr::oid::TYPE_INT8RANGE_ARRAY_OID,
1515 details: CatalogTypeDetails {
1516 typ: CatalogType::Array {
1517 element_reference: TYPE_INT8_RANGE.name,
1518 },
1519 array_id: None,
1520 pg_metadata: Some(CatalogTypePgMetadata {
1521 typinput_oid: 750,
1522 typreceive_oid: 2400,
1523 }),
1524 },
1525};
1526
1527pub const TYPE_DATE_RANGE: BuiltinType<NameReference> = BuiltinType {
1528 name: "daterange",
1529 schema: PG_CATALOG_SCHEMA,
1530 oid: mz_pgrepr::oid::TYPE_DATERANGE_OID,
1531 details: CatalogTypeDetails {
1532 typ: CatalogType::Range {
1533 element_reference: TYPE_DATE.name,
1534 },
1535 array_id: None,
1536 pg_metadata: Some(CatalogTypePgMetadata {
1537 typinput_oid: 3834,
1538 typreceive_oid: 3836,
1539 }),
1540 },
1541};
1542
1543pub const TYPE_DATE_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1544 name: "_daterange",
1545 schema: PG_CATALOG_SCHEMA,
1546 oid: mz_pgrepr::oid::TYPE_DATERANGE_ARRAY_OID,
1547 details: CatalogTypeDetails {
1548 typ: CatalogType::Array {
1549 element_reference: TYPE_DATE_RANGE.name,
1550 },
1551 array_id: None,
1552 pg_metadata: Some(CatalogTypePgMetadata {
1553 typinput_oid: 750,
1554 typreceive_oid: 2400,
1555 }),
1556 },
1557};
1558
1559pub const TYPE_NUM_RANGE: BuiltinType<NameReference> = BuiltinType {
1560 name: "numrange",
1561 schema: PG_CATALOG_SCHEMA,
1562 oid: mz_pgrepr::oid::TYPE_NUMRANGE_OID,
1563 details: CatalogTypeDetails {
1564 typ: CatalogType::Range {
1565 element_reference: TYPE_NUMERIC.name,
1566 },
1567 array_id: None,
1568 pg_metadata: Some(CatalogTypePgMetadata {
1569 typinput_oid: 3834,
1570 typreceive_oid: 3836,
1571 }),
1572 },
1573};
1574
1575pub const TYPE_NUM_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1576 name: "_numrange",
1577 schema: PG_CATALOG_SCHEMA,
1578 oid: mz_pgrepr::oid::TYPE_NUMRANGE_ARRAY_OID,
1579 details: CatalogTypeDetails {
1580 typ: CatalogType::Array {
1581 element_reference: TYPE_NUM_RANGE.name,
1582 },
1583 array_id: None,
1584 pg_metadata: Some(CatalogTypePgMetadata {
1585 typinput_oid: 750,
1586 typreceive_oid: 2400,
1587 }),
1588 },
1589};
1590
1591pub const TYPE_TS_RANGE: BuiltinType<NameReference> = BuiltinType {
1592 name: "tsrange",
1593 schema: PG_CATALOG_SCHEMA,
1594 oid: mz_pgrepr::oid::TYPE_TSRANGE_OID,
1595 details: CatalogTypeDetails {
1596 typ: CatalogType::Range {
1597 element_reference: TYPE_TIMESTAMP.name,
1598 },
1599 array_id: None,
1600 pg_metadata: Some(CatalogTypePgMetadata {
1601 typinput_oid: 3834,
1602 typreceive_oid: 3836,
1603 }),
1604 },
1605};
1606
1607pub const TYPE_TS_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1608 name: "_tsrange",
1609 schema: PG_CATALOG_SCHEMA,
1610 oid: mz_pgrepr::oid::TYPE_TSRANGE_ARRAY_OID,
1611 details: CatalogTypeDetails {
1612 typ: CatalogType::Array {
1613 element_reference: TYPE_TS_RANGE.name,
1614 },
1615 array_id: None,
1616 pg_metadata: Some(CatalogTypePgMetadata {
1617 typinput_oid: 750,
1618 typreceive_oid: 2400,
1619 }),
1620 },
1621};
1622
1623pub const TYPE_TSTZ_RANGE: BuiltinType<NameReference> = BuiltinType {
1624 name: "tstzrange",
1625 schema: PG_CATALOG_SCHEMA,
1626 oid: mz_pgrepr::oid::TYPE_TSTZRANGE_OID,
1627 details: CatalogTypeDetails {
1628 typ: CatalogType::Range {
1629 element_reference: TYPE_TIMESTAMPTZ.name,
1630 },
1631 array_id: None,
1632 pg_metadata: Some(CatalogTypePgMetadata {
1633 typinput_oid: 3834,
1634 typreceive_oid: 3836,
1635 }),
1636 },
1637};
1638
1639pub const TYPE_TSTZ_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1640 name: "_tstzrange",
1641 schema: PG_CATALOG_SCHEMA,
1642 oid: mz_pgrepr::oid::TYPE_TSTZRANGE_ARRAY_OID,
1643 details: CatalogTypeDetails {
1644 typ: CatalogType::Array {
1645 element_reference: TYPE_TSTZ_RANGE.name,
1646 },
1647 array_id: None,
1648 pg_metadata: Some(CatalogTypePgMetadata {
1649 typinput_oid: 750,
1650 typreceive_oid: 2400,
1651 }),
1652 },
1653};
1654
1655pub const TYPE_MZ_ACL_ITEM: BuiltinType<NameReference> = BuiltinType {
1656 name: "mz_aclitem",
1657 schema: MZ_CATALOG_SCHEMA,
1658 oid: mz_pgrepr::oid::TYPE_MZ_ACL_ITEM_OID,
1659 details: CatalogTypeDetails {
1660 typ: CatalogType::MzAclItem,
1661 array_id: None,
1662 pg_metadata: None,
1663 },
1664};
1665
1666pub const TYPE_MZ_ACL_ITEM_ARRAY: BuiltinType<NameReference> = BuiltinType {
1667 name: "_mz_aclitem",
1668 schema: MZ_CATALOG_SCHEMA,
1669 oid: mz_pgrepr::oid::TYPE_MZ_ACL_ITEM_ARRAY_OID,
1670 details: CatalogTypeDetails {
1671 typ: CatalogType::Array {
1672 element_reference: TYPE_MZ_ACL_ITEM.name,
1673 },
1674 array_id: None,
1675 pg_metadata: Some(CatalogTypePgMetadata {
1676 typinput_oid: 750,
1677 typreceive_oid: 2400,
1678 }),
1679 },
1680};
1681
1682pub const TYPE_ACL_ITEM: BuiltinType<NameReference> = BuiltinType {
1683 name: "aclitem",
1684 schema: PG_CATALOG_SCHEMA,
1685 oid: 1033,
1686 details: CatalogTypeDetails {
1687 typ: CatalogType::AclItem,
1688 array_id: None,
1689 pg_metadata: Some(CatalogTypePgMetadata {
1690 typinput_oid: 1031,
1691 typreceive_oid: 0,
1692 }),
1693 },
1694};
1695
1696pub const TYPE_ACL_ITEM_ARRAY: BuiltinType<NameReference> = BuiltinType {
1697 name: "_aclitem",
1698 schema: PG_CATALOG_SCHEMA,
1699 oid: 1034,
1700 details: CatalogTypeDetails {
1701 typ: CatalogType::Array {
1702 element_reference: TYPE_ACL_ITEM.name,
1703 },
1704 array_id: None,
1705 pg_metadata: Some(CatalogTypePgMetadata {
1706 typinput_oid: 750,
1707 typreceive_oid: 2400,
1708 }),
1709 },
1710};
1711
1712pub const TYPE_INTERNAL: BuiltinType<NameReference> = BuiltinType {
1713 name: "internal",
1714 schema: PG_CATALOG_SCHEMA,
1715 oid: 2281,
1716 details: CatalogTypeDetails {
1717 typ: CatalogType::Pseudo,
1718 array_id: None,
1719 pg_metadata: Some(CatalogTypePgMetadata {
1720 typinput_oid: 2304,
1721 typreceive_oid: 0,
1722 }),
1723 },
1724};
1725
1726const PUBLIC_SELECT: MzAclItem = MzAclItem {
1727 grantee: RoleId::Public,
1728 grantor: MZ_SYSTEM_ROLE_ID,
1729 acl_mode: AclMode::SELECT,
1730};
1731
1732const SUPPORT_SELECT: MzAclItem = MzAclItem {
1733 grantee: MZ_SUPPORT_ROLE_ID,
1734 grantor: MZ_SYSTEM_ROLE_ID,
1735 acl_mode: AclMode::SELECT,
1736};
1737
1738const ANALYTICS_SELECT: MzAclItem = MzAclItem {
1739 grantee: MZ_ANALYTICS_ROLE_ID,
1740 grantor: MZ_SYSTEM_ROLE_ID,
1741 acl_mode: AclMode::SELECT,
1742};
1743
1744const MONITOR_SELECT: MzAclItem = MzAclItem {
1745 grantee: MZ_MONITOR_ROLE_ID,
1746 grantor: MZ_SYSTEM_ROLE_ID,
1747 acl_mode: AclMode::SELECT,
1748};
1749
1750const MONITOR_REDACTED_SELECT: MzAclItem = MzAclItem {
1751 grantee: MZ_MONITOR_REDACTED_ROLE_ID,
1752 grantor: MZ_SYSTEM_ROLE_ID,
1753 acl_mode: AclMode::SELECT,
1754};
1755
1756pub static MZ_DATAFLOW_OPERATORS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1757 name: "mz_dataflow_operators_per_worker",
1758 schema: MZ_INTROSPECTION_SCHEMA,
1759 oid: oid::LOG_MZ_DATAFLOW_OPERATORS_PER_WORKER_OID,
1760 variant: LogVariant::Timely(TimelyLog::Operates),
1761 access: vec![PUBLIC_SELECT],
1762});
1763
1764pub static MZ_DATAFLOW_ADDRESSES_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1765 name: "mz_dataflow_addresses_per_worker",
1766 schema: MZ_INTROSPECTION_SCHEMA,
1767 oid: oid::LOG_MZ_DATAFLOW_ADDRESSES_PER_WORKER_OID,
1768 variant: LogVariant::Timely(TimelyLog::Addresses),
1769 access: vec![PUBLIC_SELECT],
1770});
1771
1772pub static MZ_DATAFLOW_CHANNELS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1773 name: "mz_dataflow_channels_per_worker",
1774 schema: MZ_INTROSPECTION_SCHEMA,
1775 oid: oid::LOG_MZ_DATAFLOW_CHANNELS_PER_WORKER_OID,
1776 variant: LogVariant::Timely(TimelyLog::Channels),
1777 access: vec![PUBLIC_SELECT],
1778});
1779
1780pub static MZ_SCHEDULING_ELAPSED_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1781 name: "mz_scheduling_elapsed_raw",
1782 schema: MZ_INTROSPECTION_SCHEMA,
1783 oid: oid::LOG_MZ_SCHEDULING_ELAPSED_RAW_OID,
1784 variant: LogVariant::Timely(TimelyLog::Elapsed),
1785 access: vec![PUBLIC_SELECT],
1786});
1787
1788pub static MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_RAW: LazyLock<BuiltinLog> =
1789 LazyLock::new(|| BuiltinLog {
1790 name: "mz_compute_operator_durations_histogram_raw",
1791 schema: MZ_INTROSPECTION_SCHEMA,
1792 oid: oid::LOG_MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_RAW_OID,
1793 variant: LogVariant::Timely(TimelyLog::Histogram),
1794 access: vec![PUBLIC_SELECT],
1795 });
1796
1797pub static MZ_SCHEDULING_PARKS_HISTOGRAM_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1798 name: "mz_scheduling_parks_histogram_raw",
1799 schema: MZ_INTROSPECTION_SCHEMA,
1800 oid: oid::LOG_MZ_SCHEDULING_PARKS_HISTOGRAM_RAW_OID,
1801 variant: LogVariant::Timely(TimelyLog::Parks),
1802 access: vec![PUBLIC_SELECT],
1803});
1804
1805pub static MZ_ARRANGEMENT_RECORDS_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1806 name: "mz_arrangement_records_raw",
1807 schema: MZ_INTROSPECTION_SCHEMA,
1808 oid: oid::LOG_MZ_ARRANGEMENT_RECORDS_RAW_OID,
1809 variant: LogVariant::Differential(DifferentialLog::ArrangementRecords),
1810 access: vec![PUBLIC_SELECT],
1811});
1812
1813pub static MZ_ARRANGEMENT_BATCHES_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1814 name: "mz_arrangement_batches_raw",
1815 schema: MZ_INTROSPECTION_SCHEMA,
1816 oid: oid::LOG_MZ_ARRANGEMENT_BATCHES_RAW_OID,
1817 variant: LogVariant::Differential(DifferentialLog::ArrangementBatches),
1818 access: vec![PUBLIC_SELECT],
1819});
1820
1821pub static MZ_ARRANGEMENT_SHARING_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1822 name: "mz_arrangement_sharing_raw",
1823 schema: MZ_INTROSPECTION_SCHEMA,
1824 oid: oid::LOG_MZ_ARRANGEMENT_SHARING_RAW_OID,
1825 variant: LogVariant::Differential(DifferentialLog::Sharing),
1826 access: vec![PUBLIC_SELECT],
1827});
1828
1829pub static MZ_ARRANGEMENT_BATCHER_RECORDS_RAW: LazyLock<BuiltinLog> =
1830 LazyLock::new(|| BuiltinLog {
1831 name: "mz_arrangement_batcher_records_raw",
1832 schema: MZ_INTROSPECTION_SCHEMA,
1833 oid: oid::LOG_MZ_ARRANGEMENT_BATCHER_RECORDS_RAW_OID,
1834 variant: LogVariant::Differential(DifferentialLog::BatcherRecords),
1835 access: vec![PUBLIC_SELECT],
1836 });
1837
1838pub static MZ_ARRANGEMENT_BATCHER_SIZE_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1839 name: "mz_arrangement_batcher_size_raw",
1840 schema: MZ_INTROSPECTION_SCHEMA,
1841 oid: oid::LOG_MZ_ARRANGEMENT_BATCHER_SIZE_RAW_OID,
1842 variant: LogVariant::Differential(DifferentialLog::BatcherSize),
1843 access: vec![PUBLIC_SELECT],
1844});
1845
1846pub static MZ_ARRANGEMENT_BATCHER_CAPACITY_RAW: LazyLock<BuiltinLog> =
1847 LazyLock::new(|| BuiltinLog {
1848 name: "mz_arrangement_batcher_capacity_raw",
1849 schema: MZ_INTROSPECTION_SCHEMA,
1850 oid: oid::LOG_MZ_ARRANGEMENT_BATCHER_CAPACITY_RAW_OID,
1851 variant: LogVariant::Differential(DifferentialLog::BatcherCapacity),
1852 access: vec![PUBLIC_SELECT],
1853 });
1854
1855pub static MZ_ARRANGEMENT_BATCHER_ALLOCATIONS_RAW: LazyLock<BuiltinLog> =
1856 LazyLock::new(|| BuiltinLog {
1857 name: "mz_arrangement_batcher_allocations_raw",
1858 schema: MZ_INTROSPECTION_SCHEMA,
1859 oid: oid::LOG_MZ_ARRANGEMENT_BATCHER_ALLOCATIONS_RAW_OID,
1860 variant: LogVariant::Differential(DifferentialLog::BatcherAllocations),
1861 access: vec![PUBLIC_SELECT],
1862 });
1863
1864pub static MZ_COMPUTE_EXPORTS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1865 name: "mz_compute_exports_per_worker",
1866 schema: MZ_INTROSPECTION_SCHEMA,
1867 oid: oid::LOG_MZ_COMPUTE_EXPORTS_PER_WORKER_OID,
1868 variant: LogVariant::Compute(ComputeLog::DataflowCurrent),
1869 access: vec![PUBLIC_SELECT],
1870});
1871
1872pub static MZ_COMPUTE_DATAFLOW_GLOBAL_IDS_PER_WORKER: LazyLock<BuiltinLog> =
1873 LazyLock::new(|| BuiltinLog {
1874 name: "mz_compute_dataflow_global_ids_per_worker",
1875 schema: MZ_INTROSPECTION_SCHEMA,
1876 oid: oid::LOG_MZ_COMPUTE_DATAFLOW_GLOBAL_IDS_PER_WORKER_OID,
1877 variant: LogVariant::Compute(ComputeLog::DataflowGlobal),
1878 access: vec![PUBLIC_SELECT],
1879 });
1880
1881pub static MZ_COMPUTE_FRONTIERS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1882 name: "mz_compute_frontiers_per_worker",
1883 schema: MZ_INTROSPECTION_SCHEMA,
1884 oid: oid::LOG_MZ_COMPUTE_FRONTIERS_PER_WORKER_OID,
1885 variant: LogVariant::Compute(ComputeLog::FrontierCurrent),
1886 access: vec![PUBLIC_SELECT],
1887});
1888
1889pub static MZ_COMPUTE_IMPORT_FRONTIERS_PER_WORKER: LazyLock<BuiltinLog> =
1890 LazyLock::new(|| BuiltinLog {
1891 name: "mz_compute_import_frontiers_per_worker",
1892 schema: MZ_INTROSPECTION_SCHEMA,
1893 oid: oid::LOG_MZ_COMPUTE_IMPORT_FRONTIERS_PER_WORKER_OID,
1894 variant: LogVariant::Compute(ComputeLog::ImportFrontierCurrent),
1895 access: vec![PUBLIC_SELECT],
1896 });
1897
1898pub static MZ_COMPUTE_ERROR_COUNTS_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1899 name: "mz_compute_error_counts_raw",
1900 schema: MZ_INTROSPECTION_SCHEMA,
1901 oid: oid::LOG_MZ_COMPUTE_ERROR_COUNTS_RAW_OID,
1902 variant: LogVariant::Compute(ComputeLog::ErrorCount),
1903 access: vec![PUBLIC_SELECT],
1904});
1905
1906pub static MZ_COMPUTE_HYDRATION_TIMES_PER_WORKER: LazyLock<BuiltinLog> =
1907 LazyLock::new(|| BuiltinLog {
1908 name: "mz_compute_hydration_times_per_worker",
1909 schema: MZ_INTROSPECTION_SCHEMA,
1910 oid: oid::LOG_MZ_COMPUTE_HYDRATION_TIMES_PER_WORKER_OID,
1911 variant: LogVariant::Compute(ComputeLog::HydrationTime),
1912 access: vec![PUBLIC_SELECT],
1913 });
1914
1915pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_PER_WORKER: LazyLock<BuiltinLog> =
1916 LazyLock::new(|| BuiltinLog {
1917 name: "mz_compute_operator_hydration_statuses_per_worker",
1918 schema: MZ_INTROSPECTION_SCHEMA,
1919 oid: oid::LOG_MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_PER_WORKER_OID,
1920 variant: LogVariant::Compute(ComputeLog::OperatorHydrationStatus),
1921 access: vec![PUBLIC_SELECT],
1922 });
1923
1924pub static MZ_ACTIVE_PEEKS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1925 name: "mz_active_peeks_per_worker",
1926 schema: MZ_INTROSPECTION_SCHEMA,
1927 oid: oid::LOG_MZ_ACTIVE_PEEKS_PER_WORKER_OID,
1928 variant: LogVariant::Compute(ComputeLog::PeekCurrent),
1929 access: vec![PUBLIC_SELECT],
1930});
1931
1932pub static MZ_COMPUTE_LIR_MAPPING_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1933 name: "mz_compute_lir_mapping_per_worker",
1934 schema: MZ_INTROSPECTION_SCHEMA,
1935 oid: oid::LOG_MZ_COMPUTE_LIR_MAPPING_PER_WORKER_OID,
1936 variant: LogVariant::Compute(ComputeLog::LirMapping),
1937 access: vec![PUBLIC_SELECT],
1938});
1939
1940pub static MZ_PEEK_DURATIONS_HISTOGRAM_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1941 name: "mz_peek_durations_histogram_raw",
1942 schema: MZ_INTROSPECTION_SCHEMA,
1943 oid: oid::LOG_MZ_PEEK_DURATIONS_HISTOGRAM_RAW_OID,
1944 variant: LogVariant::Compute(ComputeLog::PeekDuration),
1945 access: vec![PUBLIC_SELECT],
1946});
1947
1948pub static MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_RAW: LazyLock<BuiltinLog> =
1949 LazyLock::new(|| BuiltinLog {
1950 name: "mz_dataflow_shutdown_durations_histogram_raw",
1951 schema: MZ_INTROSPECTION_SCHEMA,
1952 oid: oid::LOG_MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_RAW_OID,
1953 variant: LogVariant::Compute(ComputeLog::ShutdownDuration),
1954 access: vec![PUBLIC_SELECT],
1955 });
1956
1957pub static MZ_ARRANGEMENT_HEAP_SIZE_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1958 name: "mz_arrangement_heap_size_raw",
1959 schema: MZ_INTROSPECTION_SCHEMA,
1960 oid: oid::LOG_MZ_ARRANGEMENT_HEAP_SIZE_RAW_OID,
1961 variant: LogVariant::Compute(ComputeLog::ArrangementHeapSize),
1962 access: vec![PUBLIC_SELECT],
1963});
1964
1965pub static MZ_ARRANGEMENT_HEAP_CAPACITY_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1966 name: "mz_arrangement_heap_capacity_raw",
1967 schema: MZ_INTROSPECTION_SCHEMA,
1968 oid: oid::LOG_MZ_ARRANGEMENT_HEAP_CAPACITY_RAW_OID,
1969 variant: LogVariant::Compute(ComputeLog::ArrangementHeapCapacity),
1970 access: vec![PUBLIC_SELECT],
1971});
1972
1973pub static MZ_ARRANGEMENT_HEAP_ALLOCATIONS_RAW: LazyLock<BuiltinLog> =
1974 LazyLock::new(|| BuiltinLog {
1975 name: "mz_arrangement_heap_allocations_raw",
1976 schema: MZ_INTROSPECTION_SCHEMA,
1977 oid: oid::LOG_MZ_ARRANGEMENT_HEAP_ALLOCATIONS_RAW_OID,
1978 variant: LogVariant::Compute(ComputeLog::ArrangementHeapAllocations),
1979 access: vec![PUBLIC_SELECT],
1980 });
1981
1982pub static MZ_MESSAGE_BATCH_COUNTS_RECEIVED_RAW: LazyLock<BuiltinLog> =
1983 LazyLock::new(|| BuiltinLog {
1984 name: "mz_message_batch_counts_received_raw",
1985 schema: MZ_INTROSPECTION_SCHEMA,
1986 oid: oid::LOG_MZ_MESSAGE_BATCH_COUNTS_RECEIVED_RAW_OID,
1987 variant: LogVariant::Timely(TimelyLog::BatchesReceived),
1988 access: vec![PUBLIC_SELECT],
1989 });
1990
1991pub static MZ_MESSAGE_BATCH_COUNTS_SENT_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1992 name: "mz_message_batch_counts_sent_raw",
1993 schema: MZ_INTROSPECTION_SCHEMA,
1994 oid: oid::LOG_MZ_MESSAGE_BATCH_COUNTS_SENT_RAW_OID,
1995 variant: LogVariant::Timely(TimelyLog::BatchesSent),
1996 access: vec![PUBLIC_SELECT],
1997});
1998
1999pub static MZ_MESSAGE_COUNTS_RECEIVED_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
2000 name: "mz_message_counts_received_raw",
2001 schema: MZ_INTROSPECTION_SCHEMA,
2002 oid: oid::LOG_MZ_MESSAGE_COUNTS_RECEIVED_RAW_OID,
2003 variant: LogVariant::Timely(TimelyLog::MessagesReceived),
2004 access: vec![PUBLIC_SELECT],
2005});
2006
2007pub static MZ_MESSAGE_COUNTS_SENT_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
2008 name: "mz_message_counts_sent_raw",
2009 schema: MZ_INTROSPECTION_SCHEMA,
2010 oid: oid::LOG_MZ_MESSAGE_COUNTS_SENT_RAW_OID,
2011 variant: LogVariant::Timely(TimelyLog::MessagesSent),
2012 access: vec![PUBLIC_SELECT],
2013});
2014
2015pub static MZ_DATAFLOW_OPERATOR_REACHABILITY_RAW: LazyLock<BuiltinLog> =
2016 LazyLock::new(|| BuiltinLog {
2017 name: "mz_dataflow_operator_reachability_raw",
2018 schema: MZ_INTROSPECTION_SCHEMA,
2019 oid: oid::LOG_MZ_DATAFLOW_OPERATOR_REACHABILITY_RAW_OID,
2020 variant: LogVariant::Timely(TimelyLog::Reachability),
2021 access: vec![PUBLIC_SELECT],
2022 });
2023
2024pub static MZ_ICEBERG_SINKS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2025 name: "mz_iceberg_sinks",
2026 schema: MZ_CATALOG_SCHEMA,
2027 oid: oid::TABLE_MZ_ICEBERG_SINKS_OID,
2028 desc: RelationDesc::builder()
2029 .with_column("id", SqlScalarType::String.nullable(false))
2030 .with_column("namespace", SqlScalarType::String.nullable(false))
2031 .with_column("table", SqlScalarType::String.nullable(false))
2032 .finish(),
2033 column_comments: BTreeMap::from_iter([
2034 ("id", "The ID of the sink."),
2035 ("namespace", "The namespace of the sink."),
2036 ("table", "The table the sink is writing to."),
2037 ]),
2038 is_retained_metrics_object: false,
2039 access: vec![PUBLIC_SELECT],
2040});
2041
2042pub static MZ_KAFKA_SINKS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2043 name: "mz_kafka_sinks",
2044 schema: MZ_CATALOG_SCHEMA,
2045 oid: oid::TABLE_MZ_KAFKA_SINKS_OID,
2046 desc: RelationDesc::builder()
2047 .with_column("id", SqlScalarType::String.nullable(false))
2048 .with_column("topic", SqlScalarType::String.nullable(false))
2049 .with_key(vec![0])
2050 .finish(),
2051 column_comments: BTreeMap::from_iter([
2052 ("id", "The ID of the sink."),
2053 (
2054 "topic",
2055 "The name of the Kafka topic into which the sink is writing.",
2056 ),
2057 ]),
2058 is_retained_metrics_object: false,
2059 access: vec![PUBLIC_SELECT],
2060});
2061pub static MZ_KAFKA_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2062 name: "mz_kafka_connections",
2063 schema: MZ_CATALOG_SCHEMA,
2064 oid: oid::TABLE_MZ_KAFKA_CONNECTIONS_OID,
2065 desc: RelationDesc::builder()
2066 .with_column("id", SqlScalarType::String.nullable(false))
2067 .with_column(
2068 "brokers",
2069 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
2070 )
2071 .with_column("sink_progress_topic", SqlScalarType::String.nullable(false))
2072 .finish(),
2073 column_comments: BTreeMap::from_iter([
2074 ("id", "The ID of the connection."),
2075 (
2076 "brokers",
2077 "The addresses of the Kafka brokers to connect to.",
2078 ),
2079 (
2080 "sink_progress_topic",
2081 "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.",
2082 ),
2083 ]),
2084 is_retained_metrics_object: false,
2085 access: vec![PUBLIC_SELECT],
2086});
2087pub static MZ_KAFKA_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2088 name: "mz_kafka_sources",
2089 schema: MZ_CATALOG_SCHEMA,
2090 oid: oid::TABLE_MZ_KAFKA_SOURCES_OID,
2091 desc: RelationDesc::builder()
2092 .with_column("id", SqlScalarType::String.nullable(false))
2093 .with_column("group_id_prefix", SqlScalarType::String.nullable(false))
2094 .with_column("topic", SqlScalarType::String.nullable(false))
2095 .finish(),
2096 column_comments: BTreeMap::from_iter([
2097 (
2098 "id",
2099 "The ID of the Kafka source. Corresponds to `mz_catalog.mz_sources.id`.",
2100 ),
2101 (
2102 "group_id_prefix",
2103 "The value of the `GROUP ID PREFIX` connection option.",
2104 ),
2105 (
2106 "topic",
2107 "The name of the Kafka topic the source is reading from.",
2108 ),
2109 ]),
2110 is_retained_metrics_object: false,
2111 access: vec![PUBLIC_SELECT],
2112});
2113pub static MZ_POSTGRES_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2114 name: "mz_postgres_sources",
2115 schema: MZ_INTERNAL_SCHEMA,
2116 oid: oid::TABLE_MZ_POSTGRES_SOURCES_OID,
2117 desc: RelationDesc::builder()
2118 .with_column("id", SqlScalarType::String.nullable(false))
2119 .with_column("replication_slot", SqlScalarType::String.nullable(false))
2120 .with_column("timeline_id", SqlScalarType::UInt64.nullable(true))
2121 .finish(),
2122 column_comments: BTreeMap::from_iter([
2123 (
2124 "id",
2125 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
2126 ),
2127 (
2128 "replication_slot",
2129 "The name of the replication slot in the PostgreSQL database that Materialize will create and stream data from.",
2130 ),
2131 (
2132 "timeline_id",
2133 "The PostgreSQL timeline ID determined on source creation.",
2134 ),
2135 ]),
2136 is_retained_metrics_object: false,
2137 access: vec![PUBLIC_SELECT],
2138});
2139pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2140 name: "mz_postgres_source_tables",
2141 schema: MZ_INTERNAL_SCHEMA,
2142 oid: oid::TABLE_MZ_POSTGRES_SOURCE_TABLES_OID,
2143 desc: RelationDesc::builder()
2144 .with_column("id", SqlScalarType::String.nullable(false))
2145 .with_column("schema_name", SqlScalarType::String.nullable(false))
2146 .with_column("table_name", SqlScalarType::String.nullable(false))
2147 .finish(),
2148 column_comments: BTreeMap::from_iter([
2149 (
2150 "id",
2151 "The ID of the subsource or table. Corresponds to `mz_catalog.mz_sources.id` or `mz_catalog.mz_tables.id`.",
2152 ),
2153 (
2154 "schema_name",
2155 "The schema of the upstream table being ingested.",
2156 ),
2157 (
2158 "table_name",
2159 "The name of the upstream table being ingested.",
2160 ),
2161 ]),
2162 is_retained_metrics_object: true,
2163 access: vec![PUBLIC_SELECT],
2164});
2165pub static MZ_MYSQL_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2166 name: "mz_mysql_source_tables",
2167 schema: MZ_INTERNAL_SCHEMA,
2168 oid: oid::TABLE_MZ_MYSQL_SOURCE_TABLES_OID,
2169 desc: RelationDesc::builder()
2170 .with_column("id", SqlScalarType::String.nullable(false))
2171 .with_column("schema_name", SqlScalarType::String.nullable(false))
2172 .with_column("table_name", SqlScalarType::String.nullable(false))
2173 .finish(),
2174 column_comments: BTreeMap::from_iter([
2175 (
2176 "id",
2177 "The ID of the subsource or table. Corresponds to `mz_catalog.mz_sources.id` or `mz_catalog.mz_tables.id`.",
2178 ),
2179 (
2180 "schema_name",
2181 "The schema (or, database) of the upstream table being ingested.",
2182 ),
2183 (
2184 "table_name",
2185 "The name of the upstream table being ingested.",
2186 ),
2187 ]),
2188 is_retained_metrics_object: true,
2189 access: vec![PUBLIC_SELECT],
2190});
2191pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2192 name: "mz_sql_server_source_tables",
2193 schema: MZ_INTERNAL_SCHEMA,
2194 oid: oid::TABLE_MZ_SQL_SERVER_SOURCE_TABLES_OID,
2195 desc: RelationDesc::builder()
2196 .with_column("id", SqlScalarType::String.nullable(false))
2197 .with_column("schema_name", SqlScalarType::String.nullable(false))
2198 .with_column("table_name", SqlScalarType::String.nullable(false))
2199 .finish(),
2200 column_comments: BTreeMap::from_iter([
2201 (
2202 "id",
2203 "The ID of the subsource or table. Corresponds to `mz_catalog.mz_sources.id` or `mz_catalog.mz_tables.id`.",
2204 ),
2205 (
2206 "schema_name",
2207 "The schema (or, database) of the upstream table being ingested.",
2208 ),
2209 (
2210 "table_name",
2211 "The name of the upstream table being ingested.",
2212 ),
2213 ]),
2214 is_retained_metrics_object: true,
2215 access: vec![PUBLIC_SELECT],
2216});
2217pub static MZ_KAFKA_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2218 name: "mz_kafka_source_tables",
2219 schema: MZ_INTERNAL_SCHEMA,
2220 oid: oid::TABLE_MZ_KAFKA_SOURCE_TABLES_OID,
2221 desc: RelationDesc::builder()
2222 .with_column("id", SqlScalarType::String.nullable(false))
2223 .with_column("topic", SqlScalarType::String.nullable(false))
2224 .with_column("envelope_type", SqlScalarType::String.nullable(true))
2225 .with_column("key_format", SqlScalarType::String.nullable(true))
2226 .with_column("value_format", SqlScalarType::String.nullable(true))
2227 .finish(),
2228 column_comments: BTreeMap::from_iter([
2229 (
2230 "id",
2231 "The ID of the table. Corresponds to `mz_catalog.mz_tables.id`.",
2232 ),
2233 ("topic", "The topic being ingested."),
2234 (
2235 "envelope_type",
2236 "The envelope type: `none`, `upsert`, or `debezium`. `NULL` for other source types.",
2237 ),
2238 (
2239 "key_format",
2240 "The format of the Kafka message key: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`, or `NULL`.",
2241 ),
2242 (
2243 "value_format",
2244 "The format of the Kafka message value: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`. `NULL` for other source types.",
2245 ),
2246 ]),
2247 is_retained_metrics_object: true,
2248 access: vec![PUBLIC_SELECT],
2249});
2250pub static MZ_OBJECT_DEPENDENCIES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2251 name: "mz_object_dependencies",
2252 schema: MZ_INTERNAL_SCHEMA,
2253 oid: oid::TABLE_MZ_OBJECT_DEPENDENCIES_OID,
2254 desc: RelationDesc::builder()
2255 .with_column("object_id", SqlScalarType::String.nullable(false))
2256 .with_column(
2257 "referenced_object_id",
2258 SqlScalarType::String.nullable(false),
2259 )
2260 .finish(),
2261 column_comments: BTreeMap::from_iter([
2262 (
2263 "object_id",
2264 "The ID of the dependent object. Corresponds to `mz_objects.id`.",
2265 ),
2266 (
2267 "referenced_object_id",
2268 "The ID of the referenced object. Corresponds to `mz_objects.id`.",
2269 ),
2270 ]),
2271 is_retained_metrics_object: true,
2272 access: vec![PUBLIC_SELECT],
2273});
2274pub static MZ_COMPUTE_DEPENDENCIES: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
2275 name: "mz_compute_dependencies",
2276 schema: MZ_INTERNAL_SCHEMA,
2277 oid: oid::SOURCE_MZ_COMPUTE_DEPENDENCIES_OID,
2278 data_source: IntrospectionType::ComputeDependencies,
2279 desc: RelationDesc::builder()
2280 .with_column("object_id", SqlScalarType::String.nullable(false))
2281 .with_column("dependency_id", SqlScalarType::String.nullable(false))
2282 .finish(),
2283 column_comments: BTreeMap::from_iter([
2284 (
2285 "object_id",
2286 "The ID of a compute object. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, or `mz_internal.mz_subscriptions`.",
2287 ),
2288 (
2289 "dependency_id",
2290 "The ID of a compute dependency. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, `mz_catalog.mz_sources.id`, or `mz_catalog.mz_tables.id`.",
2291 ),
2292 ]),
2293 is_retained_metrics_object: false,
2294 access: vec![PUBLIC_SELECT],
2295});
2296
2297pub static MZ_DATABASES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2298 name: "mz_databases",
2299 schema: MZ_CATALOG_SCHEMA,
2300 oid: oid::TABLE_MZ_DATABASES_OID,
2301 desc: RelationDesc::builder()
2302 .with_column("id", SqlScalarType::String.nullable(false))
2303 .with_column("oid", SqlScalarType::Oid.nullable(false))
2304 .with_column("name", SqlScalarType::String.nullable(false))
2305 .with_column("owner_id", SqlScalarType::String.nullable(false))
2306 .with_column(
2307 "privileges",
2308 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2309 )
2310 .with_key(vec![0])
2311 .with_key(vec![1])
2312 .finish(),
2313 column_comments: BTreeMap::from_iter([
2314 ("id", "Materialize's unique ID for the database."),
2315 (
2316 "oid",
2317 "A [PostgreSQL-compatible OID][`oid`] for the database.",
2318 ),
2319 ("name", "The name of the database."),
2320 (
2321 "owner_id",
2322 "The role ID of the owner of the database. Corresponds to `mz_roles.id`.",
2323 ),
2324 ("privileges", "The privileges belonging to the database."),
2325 ]),
2326 is_retained_metrics_object: false,
2327 access: vec![PUBLIC_SELECT],
2328});
2329pub static MZ_SCHEMAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2330 name: "mz_schemas",
2331 schema: MZ_CATALOG_SCHEMA,
2332 oid: oid::TABLE_MZ_SCHEMAS_OID,
2333 desc: RelationDesc::builder()
2334 .with_column("id", SqlScalarType::String.nullable(false))
2335 .with_column("oid", SqlScalarType::Oid.nullable(false))
2336 .with_column("database_id", SqlScalarType::String.nullable(true))
2337 .with_column("name", SqlScalarType::String.nullable(false))
2338 .with_column("owner_id", SqlScalarType::String.nullable(false))
2339 .with_column(
2340 "privileges",
2341 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2342 )
2343 .with_key(vec![0])
2344 .with_key(vec![1])
2345 .finish(),
2346 column_comments: BTreeMap::from_iter([
2347 ("id", "Materialize's unique ID for the schema."),
2348 (
2349 "oid",
2350 "A [PostgreSQL-compatible oid][`oid`] for the schema.",
2351 ),
2352 (
2353 "database_id",
2354 "The ID of the database containing the schema. Corresponds to `mz_databases.id`.",
2355 ),
2356 ("name", "The name of the schema."),
2357 (
2358 "owner_id",
2359 "The role ID of the owner of the schema. Corresponds to `mz_roles.id`.",
2360 ),
2361 ("privileges", "The privileges belonging to the schema."),
2362 ]),
2363 is_retained_metrics_object: false,
2364 access: vec![PUBLIC_SELECT],
2365});
2366pub static MZ_COLUMNS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2367 name: "mz_columns",
2368 schema: MZ_CATALOG_SCHEMA,
2369 oid: oid::TABLE_MZ_COLUMNS_OID,
2370 desc: RelationDesc::builder()
2371 .with_column("id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false))
2373 .with_column("position", SqlScalarType::UInt64.nullable(false))
2374 .with_column("nullable", SqlScalarType::Bool.nullable(false))
2375 .with_column("type", SqlScalarType::String.nullable(false))
2376 .with_column("default", SqlScalarType::String.nullable(true))
2377 .with_column("type_oid", SqlScalarType::Oid.nullable(false))
2378 .with_column("type_mod", SqlScalarType::Int32.nullable(false))
2379 .finish(),
2380 column_comments: BTreeMap::from_iter([
2381 (
2382 "id",
2383 "The unique ID of the table, source, or view containing the column.",
2384 ),
2385 ("name", "The name of the column."),
2386 (
2387 "position",
2388 "The 1-indexed position of the column in its containing table, source, or view.",
2389 ),
2390 ("nullable", "Can the column contain a `NULL` value?"),
2391 ("type", "The data type of the column."),
2392 ("default", "The default expression of the column."),
2393 (
2394 "type_oid",
2395 "The OID of the type of the column (references `mz_types`).",
2396 ),
2397 ("type_mod", "The packed type identifier of the column."),
2398 ]),
2399 is_retained_metrics_object: false,
2400 access: vec![PUBLIC_SELECT],
2401});
2402pub static MZ_INDEXES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2403 name: "mz_indexes",
2404 schema: MZ_CATALOG_SCHEMA,
2405 oid: oid::TABLE_MZ_INDEXES_OID,
2406 desc: RelationDesc::builder()
2407 .with_column("id", SqlScalarType::String.nullable(false))
2408 .with_column("oid", SqlScalarType::Oid.nullable(false))
2409 .with_column("name", SqlScalarType::String.nullable(false))
2410 .with_column("on_id", SqlScalarType::String.nullable(false))
2411 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2412 .with_column("owner_id", SqlScalarType::String.nullable(false))
2413 .with_column("create_sql", SqlScalarType::String.nullable(false))
2414 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2415 .with_key(vec![0])
2416 .with_key(vec![1])
2417 .finish(),
2418 column_comments: BTreeMap::from_iter([
2419 ("id", "Materialize's unique ID for the index."),
2420 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the index."),
2421 ("name", "The name of the index."),
2422 (
2423 "on_id",
2424 "The ID of the relation on which the index is built.",
2425 ),
2426 (
2427 "cluster_id",
2428 "The ID of the cluster in which the index is built.",
2429 ),
2430 (
2431 "owner_id",
2432 "The role ID of the owner of the index. Corresponds to `mz_roles.id`.",
2433 ),
2434 ("create_sql", "The `CREATE` SQL statement for the index."),
2435 (
2436 "redacted_create_sql",
2437 "The redacted `CREATE` SQL statement for the index.",
2438 ),
2439 ]),
2440 is_retained_metrics_object: false,
2441 access: vec![PUBLIC_SELECT],
2442});
2443pub static MZ_INDEX_COLUMNS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2444 name: "mz_index_columns",
2445 schema: MZ_CATALOG_SCHEMA,
2446 oid: oid::TABLE_MZ_INDEX_COLUMNS_OID,
2447 desc: RelationDesc::builder()
2448 .with_column("index_id", SqlScalarType::String.nullable(false))
2449 .with_column("index_position", SqlScalarType::UInt64.nullable(false))
2450 .with_column("on_position", SqlScalarType::UInt64.nullable(true))
2451 .with_column("on_expression", SqlScalarType::String.nullable(true))
2452 .with_column("nullable", SqlScalarType::Bool.nullable(false))
2453 .finish(),
2454 column_comments: BTreeMap::from_iter([
2455 (
2456 "index_id",
2457 "The ID of the index which contains this column. Corresponds to `mz_indexes.id`.",
2458 ),
2459 (
2460 "index_position",
2461 "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.)",
2462 ),
2463 (
2464 "on_position",
2465 "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.",
2466 ),
2467 (
2468 "on_expression",
2469 "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.",
2470 ),
2471 (
2472 "nullable",
2473 "Can this column of the index evaluate to `NULL`?",
2474 ),
2475 ]),
2476 is_retained_metrics_object: false,
2477 access: vec![PUBLIC_SELECT],
2478});
2479pub static MZ_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2480 name: "mz_tables",
2481 schema: MZ_CATALOG_SCHEMA,
2482 oid: oid::TABLE_MZ_TABLES_OID,
2483 desc: RelationDesc::builder()
2484 .with_column("id", SqlScalarType::String.nullable(false))
2485 .with_column("oid", SqlScalarType::Oid.nullable(false))
2486 .with_column("schema_id", SqlScalarType::String.nullable(false))
2487 .with_column("name", SqlScalarType::String.nullable(false))
2488 .with_column("owner_id", SqlScalarType::String.nullable(false))
2489 .with_column(
2490 "privileges",
2491 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2492 )
2493 .with_column("create_sql", SqlScalarType::String.nullable(true))
2494 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
2495 .with_column("source_id", SqlScalarType::String.nullable(true))
2496 .with_key(vec![0])
2497 .with_key(vec![1])
2498 .finish(),
2499 column_comments: BTreeMap::from_iter([
2500 ("id", "Materialize's unique ID for the table."),
2501 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the table."),
2502 (
2503 "schema_id",
2504 "The ID of the schema to which the table belongs. Corresponds to `mz_schemas.id`.",
2505 ),
2506 ("name", "The name of the table."),
2507 (
2508 "owner_id",
2509 "The role ID of the owner of the table. Corresponds to `mz_roles.id`.",
2510 ),
2511 ("privileges", "The privileges belonging to the table."),
2512 ("create_sql", "The `CREATE` SQL statement for the table."),
2513 (
2514 "redacted_create_sql",
2515 "The redacted `CREATE` SQL statement for the table.",
2516 ),
2517 (
2518 "source_id",
2519 "The ID of the source associated with the table, if any. Corresponds to `mz_sources.id`.",
2520 ),
2521 ]),
2522 is_retained_metrics_object: true,
2523 access: vec![PUBLIC_SELECT],
2524});
2525pub static MZ_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2526 name: "mz_connections",
2527 schema: MZ_CATALOG_SCHEMA,
2528 oid: oid::TABLE_MZ_CONNECTIONS_OID,
2529 desc: RelationDesc::builder()
2530 .with_column("id", SqlScalarType::String.nullable(false))
2531 .with_column("oid", SqlScalarType::Oid.nullable(false))
2532 .with_column("schema_id", SqlScalarType::String.nullable(false))
2533 .with_column("name", SqlScalarType::String.nullable(false))
2534 .with_column("type", SqlScalarType::String.nullable(false))
2535 .with_column("owner_id", SqlScalarType::String.nullable(false))
2536 .with_column(
2537 "privileges",
2538 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2539 )
2540 .with_column("create_sql", SqlScalarType::String.nullable(false))
2541 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2542 .with_key(vec![0])
2543 .with_key(vec![1])
2544 .finish(),
2545 column_comments: BTreeMap::from_iter([
2546 ("id", "The unique ID of the connection."),
2547 (
2548 "oid",
2549 "A [PostgreSQL-compatible OID][`oid`] for the connection.",
2550 ),
2551 (
2552 "schema_id",
2553 "The ID of the schema to which the connection belongs. Corresponds to `mz_schemas.id`.",
2554 ),
2555 ("name", "The name of the connection."),
2556 (
2557 "type",
2558 "The type of the connection: `confluent-schema-registry`, `kafka`, `postgres`, or `ssh-tunnel`.",
2559 ),
2560 (
2561 "owner_id",
2562 "The role ID of the owner of the connection. Corresponds to `mz_roles.id`.",
2563 ),
2564 ("privileges", "The privileges belonging to the connection."),
2565 (
2566 "create_sql",
2567 "The `CREATE` SQL statement for the connection.",
2568 ),
2569 (
2570 "redacted_create_sql",
2571 "The redacted `CREATE` SQL statement for the connection.",
2572 ),
2573 ]),
2574 is_retained_metrics_object: false,
2575 access: vec![PUBLIC_SELECT],
2576});
2577pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2578 name: "mz_ssh_tunnel_connections",
2579 schema: MZ_CATALOG_SCHEMA,
2580 oid: oid::TABLE_MZ_SSH_TUNNEL_CONNECTIONS_OID,
2581 desc: RelationDesc::builder()
2582 .with_column("id", SqlScalarType::String.nullable(false))
2583 .with_column("public_key_1", SqlScalarType::String.nullable(false))
2584 .with_column("public_key_2", SqlScalarType::String.nullable(false))
2585 .finish(),
2586 column_comments: BTreeMap::from_iter([
2587 ("id", "The ID of the connection."),
2588 (
2589 "public_key_1",
2590 "The first public key associated with the SSH tunnel.",
2591 ),
2592 (
2593 "public_key_2",
2594 "The second public key associated with the SSH tunnel.",
2595 ),
2596 ]),
2597 is_retained_metrics_object: false,
2598 access: vec![PUBLIC_SELECT],
2599});
2600pub static MZ_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2601 name: "mz_sources",
2602 schema: MZ_CATALOG_SCHEMA,
2603 oid: oid::TABLE_MZ_SOURCES_OID,
2604 desc: RelationDesc::builder()
2605 .with_column("id", SqlScalarType::String.nullable(false))
2606 .with_column("oid", SqlScalarType::Oid.nullable(false))
2607 .with_column("schema_id", SqlScalarType::String.nullable(false))
2608 .with_column("name", SqlScalarType::String.nullable(false))
2609 .with_column("type", SqlScalarType::String.nullable(false))
2610 .with_column("connection_id", SqlScalarType::String.nullable(true))
2611 .with_column("size", SqlScalarType::String.nullable(true))
2612 .with_column("envelope_type", SqlScalarType::String.nullable(true))
2613 .with_column("key_format", SqlScalarType::String.nullable(true))
2614 .with_column("value_format", SqlScalarType::String.nullable(true))
2615 .with_column("cluster_id", SqlScalarType::String.nullable(true))
2616 .with_column("owner_id", SqlScalarType::String.nullable(false))
2617 .with_column(
2618 "privileges",
2619 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2620 )
2621 .with_column("create_sql", SqlScalarType::String.nullable(true))
2622 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
2623 .with_key(vec![0])
2624 .with_key(vec![1])
2625 .finish(),
2626 column_comments: BTreeMap::from_iter([
2627 ("id", "Materialize's unique ID for the source."),
2628 (
2629 "oid",
2630 "A [PostgreSQL-compatible OID][`oid`] for the source.",
2631 ),
2632 (
2633 "schema_id",
2634 "The ID of the schema to which the source belongs. Corresponds to `mz_schemas.id`.",
2635 ),
2636 ("name", "The name of the source."),
2637 (
2638 "type",
2639 "The type of the source: `kafka`, `mysql`, `postgres`, `load-generator`, `progress`, or `subsource`.",
2640 ),
2641 (
2642 "connection_id",
2643 "The ID of the connection associated with the source, if any. Corresponds to `mz_connections.id`.",
2644 ),
2645 ("size", "Deprecated The size of the source."),
2646 (
2647 "envelope_type",
2648 "For Kafka sources, the envelope type: `none`, `upsert`, or `debezium`. `NULL` for other source types.",
2649 ),
2650 (
2651 "key_format",
2652 "For Kafka sources, the format of the Kafka message key: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`, or `NULL`.",
2653 ),
2654 (
2655 "value_format",
2656 "For Kafka sources, the format of the Kafka message value: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`. `NULL` for other source types.",
2657 ),
2658 (
2659 "cluster_id",
2660 "The ID of the cluster maintaining the source. Corresponds to `mz_clusters.id`.",
2661 ),
2662 (
2663 "owner_id",
2664 "The role ID of the owner of the source. Corresponds to `mz_roles.id`.",
2665 ),
2666 ("privileges", "The privileges granted on the source."),
2667 ("create_sql", "The `CREATE` SQL statement for the source."),
2668 (
2669 "redacted_create_sql",
2670 "The redacted `CREATE` SQL statement for the source.",
2671 ),
2672 ]),
2673 is_retained_metrics_object: true,
2674 access: vec![PUBLIC_SELECT],
2675});
2676pub static MZ_SINKS: LazyLock<BuiltinTable> = LazyLock::new(|| {
2677 BuiltinTable {
2678 name: "mz_sinks",
2679 schema: MZ_CATALOG_SCHEMA,
2680 oid: oid::TABLE_MZ_SINKS_OID,
2681 desc: RelationDesc::builder()
2682 .with_column("id", SqlScalarType::String.nullable(false))
2683 .with_column("oid", SqlScalarType::Oid.nullable(false))
2684 .with_column("schema_id", SqlScalarType::String.nullable(false))
2685 .with_column("name", SqlScalarType::String.nullable(false))
2686 .with_column("type", SqlScalarType::String.nullable(false))
2687 .with_column("connection_id", SqlScalarType::String.nullable(true))
2688 .with_column("size", SqlScalarType::String.nullable(true))
2689 .with_column("envelope_type", SqlScalarType::String.nullable(true))
2690 .with_column("format", SqlScalarType::String.nullable(true))
2693 .with_column("key_format", SqlScalarType::String.nullable(true))
2694 .with_column("value_format", SqlScalarType::String.nullable(true))
2695 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2696 .with_column("owner_id", SqlScalarType::String.nullable(false))
2697 .with_column("create_sql", SqlScalarType::String.nullable(false))
2698 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2699 .with_key(vec![0])
2700 .with_key(vec![1])
2701 .finish(),
2702 column_comments: BTreeMap::from_iter([
2703 ("id", "Materialize's unique ID for the sink."),
2704 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the sink."),
2705 (
2706 "schema_id",
2707 "The ID of the schema to which the sink belongs. Corresponds to `mz_schemas.id`.",
2708 ),
2709 ("name", "The name of the sink."),
2710 ("type", "The type of the sink: `kafka`."),
2711 (
2712 "connection_id",
2713 "The ID of the connection associated with the sink, if any. Corresponds to `mz_connections.id`.",
2714 ),
2715 ("size", "The size of the sink."),
2716 (
2717 "envelope_type",
2718 "The envelope of the sink: `upsert`, or `debezium`.",
2719 ),
2720 (
2721 "format",
2722 "Deprecated The format of the Kafka messages produced by the sink: `avro`, `json`, `text`, or `bytes`.",
2723 ),
2724 (
2725 "key_format",
2726 "The format of the Kafka message key for messages produced by the sink: `avro`, `json`, `bytes`, `text`, or `NULL`.",
2727 ),
2728 (
2729 "value_format",
2730 "The format of the Kafka message value for messages produced by the sink: `avro`, `json`, `text`, or `bytes`.",
2731 ),
2732 (
2733 "cluster_id",
2734 "The ID of the cluster maintaining the sink. Corresponds to `mz_clusters.id`.",
2735 ),
2736 (
2737 "owner_id",
2738 "The role ID of the owner of the sink. Corresponds to `mz_roles.id`.",
2739 ),
2740 ("create_sql", "The `CREATE` SQL statement for the sink."),
2741 (
2742 "redacted_create_sql",
2743 "The redacted `CREATE` SQL statement for the sink.",
2744 ),
2745 ]),
2746 is_retained_metrics_object: true,
2747 access: vec![PUBLIC_SELECT],
2748 }
2749});
2750pub static MZ_VIEWS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2751 name: "mz_views",
2752 schema: MZ_CATALOG_SCHEMA,
2753 oid: oid::TABLE_MZ_VIEWS_OID,
2754 desc: RelationDesc::builder()
2755 .with_column("id", SqlScalarType::String.nullable(false))
2756 .with_column("oid", SqlScalarType::Oid.nullable(false))
2757 .with_column("schema_id", SqlScalarType::String.nullable(false))
2758 .with_column("name", SqlScalarType::String.nullable(false))
2759 .with_column("definition", SqlScalarType::String.nullable(false))
2760 .with_column("owner_id", SqlScalarType::String.nullable(false))
2761 .with_column(
2762 "privileges",
2763 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2764 )
2765 .with_column("create_sql", SqlScalarType::String.nullable(false))
2766 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2767 .with_key(vec![0])
2768 .with_key(vec![1])
2769 .finish(),
2770 column_comments: BTreeMap::from_iter([
2771 ("id", "Materialize's unique ID for the view."),
2772 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the view."),
2773 (
2774 "schema_id",
2775 "The ID of the schema to which the view belongs. Corresponds to `mz_schemas.id`.",
2776 ),
2777 ("name", "The name of the view."),
2778 ("definition", "The view definition (a `SELECT` query)."),
2779 (
2780 "owner_id",
2781 "The role ID of the owner of the view. Corresponds to `mz_roles.id`.",
2782 ),
2783 ("privileges", "The privileges belonging to the view."),
2784 ("create_sql", "The `CREATE` SQL statement for the view."),
2785 (
2786 "redacted_create_sql",
2787 "The redacted `CREATE` SQL statement for the view.",
2788 ),
2789 ]),
2790 is_retained_metrics_object: false,
2791 access: vec![PUBLIC_SELECT],
2792});
2793pub static MZ_MATERIALIZED_VIEWS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2794 name: "mz_materialized_views",
2795 schema: MZ_CATALOG_SCHEMA,
2796 oid: oid::TABLE_MZ_MATERIALIZED_VIEWS_OID,
2797 desc: RelationDesc::builder()
2798 .with_column("id", SqlScalarType::String.nullable(false))
2799 .with_column("oid", SqlScalarType::Oid.nullable(false))
2800 .with_column("schema_id", SqlScalarType::String.nullable(false))
2801 .with_column("name", SqlScalarType::String.nullable(false))
2802 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2803 .with_column("definition", SqlScalarType::String.nullable(false))
2804 .with_column("owner_id", SqlScalarType::String.nullable(false))
2805 .with_column(
2806 "privileges",
2807 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2808 )
2809 .with_column("create_sql", SqlScalarType::String.nullable(false))
2810 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2811 .with_key(vec![0])
2812 .with_key(vec![1])
2813 .finish(),
2814 column_comments: BTreeMap::from_iter([
2815 ("id", "Materialize's unique ID for the materialized view."),
2816 (
2817 "oid",
2818 "A [PostgreSQL-compatible OID][`oid`] for the materialized view.",
2819 ),
2820 (
2821 "schema_id",
2822 "The ID of the schema to which the materialized view belongs. Corresponds to `mz_schemas.id`.",
2823 ),
2824 ("name", "The name of the materialized view."),
2825 (
2826 "cluster_id",
2827 "The ID of the cluster maintaining the materialized view. Corresponds to `mz_clusters.id`.",
2828 ),
2829 (
2830 "definition",
2831 "The materialized view definition (a `SELECT` query).",
2832 ),
2833 (
2834 "owner_id",
2835 "The role ID of the owner of the materialized view. Corresponds to `mz_roles.id`.",
2836 ),
2837 (
2838 "privileges",
2839 "The privileges belonging to the materialized view.",
2840 ),
2841 (
2842 "create_sql",
2843 "The `CREATE` SQL statement for the materialized view.",
2844 ),
2845 (
2846 "redacted_create_sql",
2847 "The redacted `CREATE` SQL statement for the materialized view.",
2848 ),
2849 ]),
2850 is_retained_metrics_object: false,
2851 access: vec![PUBLIC_SELECT],
2852});
2853pub static MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES: LazyLock<BuiltinTable> = LazyLock::new(|| {
2854 BuiltinTable {
2855 name: "mz_materialized_view_refresh_strategies",
2856 schema: MZ_INTERNAL_SCHEMA,
2857 oid: oid::TABLE_MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES_OID,
2858 desc: RelationDesc::builder()
2859 .with_column(
2860 "materialized_view_id",
2861 SqlScalarType::String.nullable(false),
2862 )
2863 .with_column("type", SqlScalarType::String.nullable(false))
2864 .with_column("interval", SqlScalarType::Interval.nullable(true))
2865 .with_column(
2866 "aligned_to",
2867 SqlScalarType::TimestampTz { precision: None }.nullable(true),
2868 )
2869 .with_column(
2870 "at",
2871 SqlScalarType::TimestampTz { precision: None }.nullable(true),
2872 )
2873 .finish(),
2874 column_comments: BTreeMap::from_iter([
2875 (
2876 "materialized_view_id",
2877 "The ID of the materialized view. Corresponds to `mz_catalog.mz_materialized_views.id`",
2878 ),
2879 (
2880 "type",
2881 "`at`, `every`, or `on-commit`. Default: `on-commit`",
2882 ),
2883 (
2884 "interval",
2885 "The refresh interval of a `REFRESH EVERY` option, or `NULL` if the `type` is not `every`.",
2886 ),
2887 (
2888 "aligned_to",
2889 "The `ALIGNED TO` option of a `REFRESH EVERY` option, or `NULL` if the `type` is not `every`.",
2890 ),
2891 (
2892 "at",
2893 "The time of a `REFRESH AT`, or `NULL` if the `type` is not `at`.",
2894 ),
2895 ]),
2896 is_retained_metrics_object: false,
2897 access: vec![PUBLIC_SELECT],
2898 }
2899});
2900pub static MZ_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2901 name: "mz_types",
2902 schema: MZ_CATALOG_SCHEMA,
2903 oid: oid::TABLE_MZ_TYPES_OID,
2904 desc: RelationDesc::builder()
2905 .with_column("id", SqlScalarType::String.nullable(false))
2906 .with_column("oid", SqlScalarType::Oid.nullable(false))
2907 .with_column("schema_id", SqlScalarType::String.nullable(false))
2908 .with_column("name", SqlScalarType::String.nullable(false))
2909 .with_column("category", SqlScalarType::String.nullable(false))
2910 .with_column("owner_id", SqlScalarType::String.nullable(false))
2911 .with_column(
2912 "privileges",
2913 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2914 )
2915 .with_column("create_sql", SqlScalarType::String.nullable(true))
2916 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
2917 .with_key(vec![0])
2918 .with_key(vec![1])
2919 .finish(),
2920 column_comments: BTreeMap::from_iter([
2921 ("id", "Materialize's unique ID for the type."),
2922 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the type."),
2923 (
2924 "schema_id",
2925 "The ID of the schema to which the type belongs. Corresponds to `mz_schemas.id`.",
2926 ),
2927 ("name", "The name of the type."),
2928 ("category", "The category of the type."),
2929 (
2930 "owner_id",
2931 "The role ID of the owner of the type. Corresponds to `mz_roles.id`.",
2932 ),
2933 ("privileges", "The privileges belonging to the type."),
2934 ("create_sql", "The `CREATE` SQL statement for the type."),
2935 (
2936 "redacted_create_sql",
2937 "The redacted `CREATE` SQL statement for the type.",
2938 ),
2939 ]),
2940 is_retained_metrics_object: false,
2941 access: vec![PUBLIC_SELECT],
2942});
2943pub static MZ_CONTINUAL_TASKS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2944 name: "mz_continual_tasks",
2945 schema: MZ_INTERNAL_SCHEMA,
2946 oid: oid::TABLE_MZ_CONTINUAL_TASKS_OID,
2947 desc: RelationDesc::builder()
2948 .with_column("id", SqlScalarType::String.nullable(false))
2949 .with_column("oid", SqlScalarType::Oid.nullable(false))
2950 .with_column("schema_id", SqlScalarType::String.nullable(false))
2951 .with_column("name", SqlScalarType::String.nullable(false))
2952 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2953 .with_column("definition", SqlScalarType::String.nullable(false))
2954 .with_column("owner_id", SqlScalarType::String.nullable(false))
2955 .with_column(
2956 "privileges",
2957 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2958 )
2959 .with_column("create_sql", SqlScalarType::String.nullable(false))
2960 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2961 .with_key(vec![0])
2962 .with_key(vec![1])
2963 .finish(),
2964 column_comments: BTreeMap::new(),
2965 is_retained_metrics_object: false,
2966 access: vec![PUBLIC_SELECT],
2967});
2968pub static MZ_NETWORK_POLICIES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2969 name: "mz_network_policies",
2970 schema: MZ_INTERNAL_SCHEMA,
2971 oid: oid::TABLE_MZ_NETWORK_POLICIES_OID,
2972 desc: RelationDesc::builder()
2973 .with_column("id", SqlScalarType::String.nullable(false))
2974 .with_column("name", SqlScalarType::String.nullable(false))
2975 .with_column("owner_id", SqlScalarType::String.nullable(false))
2976 .with_column(
2977 "privileges",
2978 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2979 )
2980 .with_column("oid", SqlScalarType::Oid.nullable(false))
2981 .finish(),
2982 column_comments: BTreeMap::from_iter([
2983 ("id", "The ID of the network policy."),
2984 ("name", "The name of the network policy."),
2985 (
2986 "owner_id",
2987 "The role ID of the owner of the network policy. Corresponds to `mz_catalog.mz_roles.id`.",
2988 ),
2989 (
2990 "privileges",
2991 "The privileges belonging to the network policy.",
2992 ),
2993 (
2994 "oid",
2995 "A [PostgreSQL-compatible OID][`oid`] for the network policy.",
2996 ),
2997 ]),
2998 is_retained_metrics_object: false,
2999 access: vec![PUBLIC_SELECT],
3000});
3001pub static MZ_NETWORK_POLICY_RULES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3002 name: "mz_network_policy_rules",
3003 schema: MZ_INTERNAL_SCHEMA,
3004 oid: oid::TABLE_MZ_NETWORK_POLICY_RULES_OID,
3005 desc: RelationDesc::builder()
3006 .with_column("name", SqlScalarType::String.nullable(false))
3007 .with_column("policy_id", SqlScalarType::String.nullable(false))
3008 .with_column("action", SqlScalarType::String.nullable(false))
3009 .with_column("address", SqlScalarType::String.nullable(false))
3010 .with_column("direction", SqlScalarType::String.nullable(false))
3011 .finish(),
3012 column_comments: BTreeMap::from_iter([
3013 (
3014 "name",
3015 "The name of the network policy rule. Can be combined with `policy_id` to form a unique identifier.",
3016 ),
3017 (
3018 "policy_id",
3019 "The ID the network policy the rule is part of. Corresponds to `mz_network_policy_rules.id`.",
3020 ),
3021 (
3022 "action",
3023 "The action of the rule. `allow` is the only supported action.",
3024 ),
3025 ("address", "The address the rule will take action on."),
3026 (
3027 "direction",
3028 "The direction of traffic the rule applies to. `ingress` is the only supported direction.",
3029 ),
3030 ]),
3031 is_retained_metrics_object: false,
3032 access: vec![PUBLIC_SELECT],
3033});
3034pub static MZ_TYPE_PG_METADATA: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3037 name: "mz_type_pg_metadata",
3038 schema: MZ_INTERNAL_SCHEMA,
3039 oid: oid::TABLE_MZ_TYPE_PG_METADATA_OID,
3040 desc: RelationDesc::builder()
3041 .with_column("id", SqlScalarType::String.nullable(false))
3042 .with_column("typinput", SqlScalarType::Oid.nullable(false))
3043 .with_column("typreceive", SqlScalarType::Oid.nullable(false))
3044 .finish(),
3045 column_comments: BTreeMap::new(),
3046 is_retained_metrics_object: false,
3047 access: vec![PUBLIC_SELECT],
3048});
3049pub static MZ_ARRAY_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3050 name: "mz_array_types",
3051 schema: MZ_CATALOG_SCHEMA,
3052 oid: oid::TABLE_MZ_ARRAY_TYPES_OID,
3053 desc: RelationDesc::builder()
3054 .with_column("id", SqlScalarType::String.nullable(false))
3055 .with_column("element_id", SqlScalarType::String.nullable(false))
3056 .finish(),
3057 column_comments: BTreeMap::from_iter([
3058 ("id", "The ID of the array type."),
3059 ("element_id", "The ID of the array's element type."),
3060 ]),
3061 is_retained_metrics_object: false,
3062 access: vec![PUBLIC_SELECT],
3063});
3064pub static MZ_BASE_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3065 name: "mz_base_types",
3066 schema: MZ_CATALOG_SCHEMA,
3067 oid: oid::TABLE_MZ_BASE_TYPES_OID,
3068 desc: RelationDesc::builder()
3069 .with_column("id", SqlScalarType::String.nullable(false))
3070 .finish(),
3071 column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]),
3072 is_retained_metrics_object: false,
3073 access: vec![PUBLIC_SELECT],
3074});
3075pub static MZ_LIST_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3076 name: "mz_list_types",
3077 schema: MZ_CATALOG_SCHEMA,
3078 oid: oid::TABLE_MZ_LIST_TYPES_OID,
3079 desc: RelationDesc::builder()
3080 .with_column("id", SqlScalarType::String.nullable(false))
3081 .with_column("element_id", SqlScalarType::String.nullable(false))
3082 .with_column(
3083 "element_modifiers",
3084 SqlScalarType::List {
3085 element_type: Box::new(SqlScalarType::Int64),
3086 custom_id: None,
3087 }
3088 .nullable(true),
3089 )
3090 .finish(),
3091 column_comments: BTreeMap::from_iter([
3092 ("id", "The ID of the list type."),
3093 ("element_id", "The IID of the list's element type."),
3094 (
3095 "element_modifiers",
3096 "The element type modifiers, or `NULL` if none.",
3097 ),
3098 ]),
3099 is_retained_metrics_object: false,
3100 access: vec![PUBLIC_SELECT],
3101});
3102pub static MZ_MAP_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3103 name: "mz_map_types",
3104 schema: MZ_CATALOG_SCHEMA,
3105 oid: oid::TABLE_MZ_MAP_TYPES_OID,
3106 desc: RelationDesc::builder()
3107 .with_column("id", SqlScalarType::String.nullable(false))
3108 .with_column("key_id", SqlScalarType::String.nullable(false))
3109 .with_column("value_id", SqlScalarType::String.nullable(false))
3110 .with_column(
3111 "key_modifiers",
3112 SqlScalarType::List {
3113 element_type: Box::new(SqlScalarType::Int64),
3114 custom_id: None,
3115 }
3116 .nullable(true),
3117 )
3118 .with_column(
3119 "value_modifiers",
3120 SqlScalarType::List {
3121 element_type: Box::new(SqlScalarType::Int64),
3122 custom_id: None,
3123 }
3124 .nullable(true),
3125 )
3126 .finish(),
3127 column_comments: BTreeMap::from_iter([
3128 ("id", "The ID of the map type."),
3129 ("key_id", "The ID of the map's key type."),
3130 ("value_id", "The ID of the map's value type."),
3131 (
3132 "key_modifiers",
3133 "The key type modifiers, or `NULL` if none.",
3134 ),
3135 (
3136 "value_modifiers",
3137 "The value type modifiers, or `NULL` if none.",
3138 ),
3139 ]),
3140 is_retained_metrics_object: false,
3141 access: vec![PUBLIC_SELECT],
3142});
3143pub static MZ_ROLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3144 name: "mz_roles",
3145 schema: MZ_CATALOG_SCHEMA,
3146 oid: oid::TABLE_MZ_ROLES_OID,
3147 desc: RelationDesc::builder()
3148 .with_column("id", SqlScalarType::String.nullable(false))
3149 .with_column("oid", SqlScalarType::Oid.nullable(false))
3150 .with_column("name", SqlScalarType::String.nullable(false))
3151 .with_column("inherit", SqlScalarType::Bool.nullable(false))
3152 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(true))
3153 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
3154 .with_key(vec![0])
3155 .with_key(vec![1])
3156 .finish(),
3157 column_comments: BTreeMap::from_iter([
3158 ("id", "Materialize's unique ID for the role."),
3159 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the role."),
3160 ("name", "The name of the role."),
3161 (
3162 "inherit",
3163 "Indicates whether the role has inheritance of privileges.",
3164 ),
3165 (
3166 "rolcanlogin",
3167 "Indicates whether the role can log in (i.e., is a user).",
3168 ),
3169 ("rolsuper", "Indicates whether the role is a superuser."),
3170 ]),
3171 is_retained_metrics_object: false,
3172 access: vec![PUBLIC_SELECT],
3173});
3174pub static MZ_ROLE_MEMBERS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3175 name: "mz_role_members",
3176 schema: MZ_CATALOG_SCHEMA,
3177 oid: oid::TABLE_MZ_ROLE_MEMBERS_OID,
3178 desc: RelationDesc::builder()
3179 .with_column("role_id", SqlScalarType::String.nullable(false))
3180 .with_column("member", SqlScalarType::String.nullable(false))
3181 .with_column("grantor", SqlScalarType::String.nullable(false))
3182 .finish(),
3183 column_comments: BTreeMap::from_iter([
3184 (
3185 "role_id",
3186 "The ID of the role the `member` is a member of. Corresponds to `mz_roles.id`.",
3187 ),
3188 (
3189 "member",
3190 "The ID of the role that is a member of `role_id`. Corresponds to `mz_roles.id`.",
3191 ),
3192 (
3193 "grantor",
3194 "The ID of the role that granted membership of `member` to `role_id`. Corresponds to `mz_roles.id`.",
3195 ),
3196 ]),
3197 is_retained_metrics_object: false,
3198 access: vec![PUBLIC_SELECT],
3199});
3200pub static MZ_ROLE_PARAMETERS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3201 name: "mz_role_parameters",
3202 schema: MZ_CATALOG_SCHEMA,
3203 oid: oid::TABLE_MZ_ROLE_PARAMETERS_OID,
3204 desc: RelationDesc::builder()
3205 .with_column("role_id", SqlScalarType::String.nullable(false))
3206 .with_column("parameter_name", SqlScalarType::String.nullable(false))
3207 .with_column("parameter_value", SqlScalarType::String.nullable(false))
3208 .finish(),
3209 column_comments: BTreeMap::from_iter([
3210 (
3211 "role_id",
3212 "The ID of the role whose configuration parameter default is set. Corresponds to `mz_roles.id`.",
3213 ),
3214 (
3215 "parameter_name",
3216 "The configuration parameter name. One of the supported configuration parameters.",
3217 ),
3218 (
3219 "parameter_value",
3220 "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.",
3221 ),
3222 ]),
3223 is_retained_metrics_object: false,
3224 access: vec![PUBLIC_SELECT],
3225});
3226pub static MZ_ROLE_AUTH: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3227 name: "mz_role_auth",
3228 schema: MZ_CATALOG_SCHEMA,
3229 oid: oid::TABLE_MZ_ROLE_AUTH_OID,
3230 desc: RelationDesc::builder()
3231 .with_column("role_id", SqlScalarType::String.nullable(false))
3232 .with_column("role_oid", SqlScalarType::Oid.nullable(false))
3233 .with_column("password_hash", SqlScalarType::String.nullable(true))
3234 .with_column(
3235 "updated_at",
3236 SqlScalarType::TimestampTz { precision: None }.nullable(false),
3237 )
3238 .finish(),
3239 column_comments: BTreeMap::from_iter([
3240 (
3241 "role_id",
3242 "The ID of the role. Corresponds to `mz_roles.id`.",
3243 ),
3244 (
3245 "role_oid",
3246 "The OID of the role whose configuration parameter default is set. Corresponds to `mz_roles.oid`.",
3247 ),
3248 ("password_hash", "The hashed password for the role"),
3249 (
3250 "updated_at",
3251 "The timestamp when the password was last updated.",
3252 ),
3253 ]),
3254 is_retained_metrics_object: false,
3255 access: vec![rbac::owner_privilege(ObjectType::Table, MZ_SYSTEM_ROLE_ID)],
3256});
3257pub static MZ_PSEUDO_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3258 name: "mz_pseudo_types",
3259 schema: MZ_CATALOG_SCHEMA,
3260 oid: oid::TABLE_MZ_PSEUDO_TYPES_OID,
3261 desc: RelationDesc::builder()
3262 .with_column("id", SqlScalarType::String.nullable(false))
3263 .finish(),
3264 column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]),
3265 is_retained_metrics_object: false,
3266 access: vec![PUBLIC_SELECT],
3267});
3268pub static MZ_FUNCTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| {
3269 BuiltinTable {
3270 name: "mz_functions",
3271 schema: MZ_CATALOG_SCHEMA,
3272 oid: oid::TABLE_MZ_FUNCTIONS_OID,
3273 desc: RelationDesc::builder()
3274 .with_column("id", SqlScalarType::String.nullable(false)) .with_column("oid", SqlScalarType::Oid.nullable(false))
3276 .with_column("schema_id", SqlScalarType::String.nullable(false))
3277 .with_column("name", SqlScalarType::String.nullable(false))
3278 .with_column(
3279 "argument_type_ids",
3280 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
3281 )
3282 .with_column(
3283 "variadic_argument_type_id",
3284 SqlScalarType::String.nullable(true),
3285 )
3286 .with_column("return_type_id", SqlScalarType::String.nullable(true))
3287 .with_column("returns_set", SqlScalarType::Bool.nullable(false))
3288 .with_column("owner_id", SqlScalarType::String.nullable(false))
3289 .finish(),
3290 column_comments: BTreeMap::from_iter([
3291 ("id", "Materialize's unique ID for the function."),
3292 (
3293 "oid",
3294 "A [PostgreSQL-compatible OID][`oid`] for the function.",
3295 ),
3296 (
3297 "schema_id",
3298 "The ID of the schema to which the function belongs. Corresponds to `mz_schemas.id`.",
3299 ),
3300 ("name", "The name of the function."),
3301 (
3302 "argument_type_ids",
3303 "The ID of each argument's type. Each entry refers to `mz_types.id`.",
3304 ),
3305 (
3306 "variadic_argument_type_id",
3307 "The ID of the variadic argument's type, or `NULL` if the function does not have a variadic argument. Refers to `mz_types.id`.",
3308 ),
3309 (
3310 "return_type_id",
3311 "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`].",
3312 ),
3313 (
3314 "returns_set",
3315 "Whether the function returns a set, i.e. the function is a table function.",
3316 ),
3317 (
3318 "owner_id",
3319 "The role ID of the owner of the function. Corresponds to `mz_roles.id`.",
3320 ),
3321 ]),
3322 is_retained_metrics_object: false,
3323 access: vec![PUBLIC_SELECT],
3324 }
3325});
3326pub static MZ_OPERATORS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3327 name: "mz_operators",
3328 schema: MZ_CATALOG_SCHEMA,
3329 oid: oid::TABLE_MZ_OPERATORS_OID,
3330 desc: RelationDesc::builder()
3331 .with_column("oid", SqlScalarType::Oid.nullable(false))
3332 .with_column("name", SqlScalarType::String.nullable(false))
3333 .with_column(
3334 "argument_type_ids",
3335 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
3336 )
3337 .with_column("return_type_id", SqlScalarType::String.nullable(true))
3338 .finish(),
3339 column_comments: BTreeMap::new(),
3340 is_retained_metrics_object: false,
3341 access: vec![PUBLIC_SELECT],
3342});
3343pub static MZ_AGGREGATES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3344 name: "mz_aggregates",
3345 schema: MZ_INTERNAL_SCHEMA,
3346 oid: oid::TABLE_MZ_AGGREGATES_OID,
3347 desc: RelationDesc::builder()
3348 .with_column("oid", SqlScalarType::Oid.nullable(false))
3349 .with_column("agg_kind", SqlScalarType::String.nullable(false))
3350 .with_column("agg_num_direct_args", SqlScalarType::Int16.nullable(false))
3351 .finish(),
3352 column_comments: BTreeMap::new(),
3353 is_retained_metrics_object: false,
3354 access: vec![PUBLIC_SELECT],
3355});
3356
3357pub static MZ_CLUSTERS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3358 name: "mz_clusters",
3359 schema: MZ_CATALOG_SCHEMA,
3360 oid: oid::TABLE_MZ_CLUSTERS_OID,
3361 desc: RelationDesc::builder()
3362 .with_column("id", SqlScalarType::String.nullable(false))
3363 .with_column("name", SqlScalarType::String.nullable(false))
3364 .with_column("owner_id", SqlScalarType::String.nullable(false))
3365 .with_column(
3366 "privileges",
3367 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
3368 )
3369 .with_column("managed", SqlScalarType::Bool.nullable(false))
3370 .with_column("size", SqlScalarType::String.nullable(true))
3371 .with_column("replication_factor", SqlScalarType::UInt32.nullable(true))
3372 .with_column("disk", SqlScalarType::Bool.nullable(true))
3373 .with_column(
3374 "availability_zones",
3375 SqlScalarType::List {
3376 element_type: Box::new(SqlScalarType::String),
3377 custom_id: None,
3378 }
3379 .nullable(true),
3380 )
3381 .with_column(
3382 "introspection_debugging",
3383 SqlScalarType::Bool.nullable(true),
3384 )
3385 .with_column(
3386 "introspection_interval",
3387 SqlScalarType::Interval.nullable(true),
3388 )
3389 .with_key(vec![0])
3390 .finish(),
3391 column_comments: BTreeMap::from_iter([
3392 ("id", "Materialize's unique ID for the cluster."),
3393 ("name", "The name of the cluster."),
3394 (
3395 "owner_id",
3396 "The role ID of the owner of the cluster. Corresponds to `mz_roles.id`.",
3397 ),
3398 ("privileges", "The privileges belonging to the cluster."),
3399 (
3400 "managed",
3401 "Whether the cluster is a managed cluster with automatically managed replicas.",
3402 ),
3403 (
3404 "size",
3405 "If the cluster is managed, the desired size of the cluster's replicas. `NULL` for unmanaged clusters.",
3406 ),
3407 (
3408 "replication_factor",
3409 "If the cluster is managed, the desired number of replicas of the cluster. `NULL` for unmanaged clusters.",
3410 ),
3411 (
3412 "disk",
3413 "Unstable If the cluster is managed, `true` if the replicas have the `DISK` option . `NULL` for unmanaged clusters.",
3414 ),
3415 (
3416 "availability_zones",
3417 "Unstable If the cluster is managed, the list of availability zones specified in `AVAILABILITY ZONES`. `NULL` for unmanaged clusters.",
3418 ),
3419 (
3420 "introspection_debugging",
3421 "Whether introspection of the gathering of the introspection data is enabled.",
3422 ),
3423 (
3424 "introspection_interval",
3425 "The interval at which to collect introspection data.",
3426 ),
3427 ]),
3428 is_retained_metrics_object: false,
3429 access: vec![PUBLIC_SELECT],
3430});
3431
3432pub static MZ_CLUSTER_WORKLOAD_CLASSES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3433 name: "mz_cluster_workload_classes",
3434 schema: MZ_INTERNAL_SCHEMA,
3435 oid: oid::TABLE_MZ_CLUSTER_WORKLOAD_CLASSES_OID,
3436 desc: RelationDesc::builder()
3437 .with_column("id", SqlScalarType::String.nullable(false))
3438 .with_column("workload_class", SqlScalarType::String.nullable(true))
3439 .with_key(vec![0])
3440 .finish(),
3441 column_comments: BTreeMap::new(),
3442 is_retained_metrics_object: false,
3443 access: vec![PUBLIC_SELECT],
3444});
3445
3446pub const MZ_CLUSTER_WORKLOAD_CLASSES_IND: BuiltinIndex = BuiltinIndex {
3447 name: "mz_cluster_workload_classes_ind",
3448 schema: MZ_INTERNAL_SCHEMA,
3449 oid: oid::INDEX_MZ_CLUSTER_WORKLOAD_CLASSES_IND_OID,
3450 sql: "IN CLUSTER mz_catalog_server
3451ON mz_internal.mz_cluster_workload_classes (id)",
3452 is_retained_metrics_object: false,
3453};
3454
3455pub static MZ_CLUSTER_SCHEDULES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3456 name: "mz_cluster_schedules",
3457 schema: MZ_INTERNAL_SCHEMA,
3458 oid: oid::TABLE_MZ_CLUSTER_SCHEDULES_OID,
3459 desc: RelationDesc::builder()
3460 .with_column("cluster_id", SqlScalarType::String.nullable(false))
3461 .with_column("type", SqlScalarType::String.nullable(false))
3462 .with_column(
3463 "refresh_hydration_time_estimate",
3464 SqlScalarType::Interval.nullable(true),
3465 )
3466 .finish(),
3467 column_comments: BTreeMap::from_iter([
3468 (
3469 "cluster_id",
3470 "The ID of the cluster. Corresponds to `mz_clusters.id`.",
3471 ),
3472 ("type", "`on-refresh`, or `manual`. Default: `manual`"),
3473 (
3474 "refresh_hydration_time_estimate",
3475 "The interval given in the `HYDRATION TIME ESTIMATE` option.",
3476 ),
3477 ]),
3478 is_retained_metrics_object: false,
3479 access: vec![PUBLIC_SELECT],
3480});
3481
3482pub static MZ_SECRETS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3483 name: "mz_secrets",
3484 schema: MZ_CATALOG_SCHEMA,
3485 oid: oid::TABLE_MZ_SECRETS_OID,
3486 desc: RelationDesc::builder()
3487 .with_column("id", SqlScalarType::String.nullable(false))
3488 .with_column("oid", SqlScalarType::Oid.nullable(false))
3489 .with_column("schema_id", SqlScalarType::String.nullable(false))
3490 .with_column("name", SqlScalarType::String.nullable(false))
3491 .with_column("owner_id", SqlScalarType::String.nullable(false))
3492 .with_column(
3493 "privileges",
3494 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
3495 )
3496 .finish(),
3497 column_comments: BTreeMap::from_iter([
3498 ("id", "The unique ID of the secret."),
3499 (
3500 "oid",
3501 "A [PostgreSQL-compatible oid][`oid`] for the secret.",
3502 ),
3503 (
3504 "schema_id",
3505 "The ID of the schema to which the secret belongs. Corresponds to `mz_schemas.id`.",
3506 ),
3507 ("name", "The name of the secret."),
3508 (
3509 "owner_id",
3510 "The role ID of the owner of the secret. Corresponds to `mz_roles.id`.",
3511 ),
3512 ("privileges", "The privileges belonging to the secret."),
3513 ]),
3514 is_retained_metrics_object: false,
3515 access: vec![PUBLIC_SELECT],
3516});
3517
3518pub static MZ_CLUSTER_REPLICAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3519 name: "mz_cluster_replicas",
3520 schema: MZ_CATALOG_SCHEMA,
3521 oid: oid::TABLE_MZ_CLUSTER_REPLICAS_OID,
3522 desc: RelationDesc::builder()
3523 .with_column("id", SqlScalarType::String.nullable(false))
3524 .with_column("name", SqlScalarType::String.nullable(false))
3525 .with_column("cluster_id", SqlScalarType::String.nullable(false))
3526 .with_column("size", SqlScalarType::String.nullable(true))
3527 .with_column("availability_zone", SqlScalarType::String.nullable(true))
3530 .with_column("owner_id", SqlScalarType::String.nullable(false))
3531 .with_column("disk", SqlScalarType::Bool.nullable(true))
3532 .finish(),
3533 column_comments: BTreeMap::from_iter([
3534 ("id", "Materialize's unique ID for the cluster replica."),
3535 ("name", "The name of the cluster replica."),
3536 (
3537 "cluster_id",
3538 "The ID of the cluster to which the replica belongs. Corresponds to `mz_clusters.id`.",
3539 ),
3540 (
3541 "size",
3542 "The cluster replica's size, selected during creation.",
3543 ),
3544 (
3545 "availability_zone",
3546 "The availability zone in which the cluster is running.",
3547 ),
3548 (
3549 "owner_id",
3550 "The role ID of the owner of the cluster replica. Corresponds to `mz_roles.id`.",
3551 ),
3552 ("disk", "If the replica has a local disk."),
3553 ]),
3554 is_retained_metrics_object: true,
3555 access: vec![PUBLIC_SELECT],
3556});
3557
3558pub static MZ_INTERNAL_CLUSTER_REPLICAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3559 name: "mz_internal_cluster_replicas",
3560 schema: MZ_INTERNAL_SCHEMA,
3561 oid: oid::TABLE_MZ_INTERNAL_CLUSTER_REPLICAS_OID,
3562 desc: RelationDesc::builder()
3563 .with_column("id", SqlScalarType::String.nullable(false))
3564 .finish(),
3565 column_comments: BTreeMap::from_iter([(
3566 "id",
3567 "The ID of a cluster replica. Corresponds to `mz_cluster_replicas.id`.",
3568 )]),
3569 is_retained_metrics_object: false,
3570 access: vec![PUBLIC_SELECT],
3571});
3572
3573pub static MZ_PENDING_CLUSTER_REPLICAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3574 name: "mz_pending_cluster_replicas",
3575 schema: MZ_INTERNAL_SCHEMA,
3576 oid: oid::TABLE_MZ_PENDING_CLUSTER_REPLICAS_OID,
3577 desc: RelationDesc::builder()
3578 .with_column("id", SqlScalarType::String.nullable(false))
3579 .finish(),
3580 column_comments: BTreeMap::from_iter([(
3581 "id",
3582 "The ID of a cluster replica. Corresponds to `mz_cluster_replicas.id`.",
3583 )]),
3584 is_retained_metrics_object: false,
3585 access: vec![PUBLIC_SELECT],
3586});
3587
3588pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| {
3589 BuiltinSource {
3590 name: "mz_cluster_replica_status_history",
3591 schema: MZ_INTERNAL_SCHEMA,
3592 oid: oid::SOURCE_MZ_CLUSTER_REPLICA_STATUS_HISTORY_OID,
3593 data_source: IntrospectionType::ReplicaStatusHistory,
3594 desc: REPLICA_STATUS_HISTORY_DESC.clone(),
3595 column_comments: BTreeMap::from_iter([
3596 ("replica_id", "The ID of a cluster replica."),
3597 ("process_id", "The ID of a process within the replica."),
3598 (
3599 "status",
3600 "The status of the cluster replica: `online` or `offline`.",
3601 ),
3602 (
3603 "reason",
3604 "If the cluster replica is in an `offline` state, the reason (if available). For example, `oom-killed`.",
3605 ),
3606 (
3607 "occurred_at",
3608 "Wall-clock timestamp at which the event occurred.",
3609 ),
3610 ]),
3611 is_retained_metrics_object: false,
3612 access: vec![PUBLIC_SELECT],
3613 }
3614});
3615
3616pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY_CT: LazyLock<BuiltinContinualTask> = LazyLock::new(
3617 || {
3618 BuiltinContinualTask {
3619 name: "mz_cluster_replica_status_history_ct",
3620 schema: MZ_INTERNAL_SCHEMA,
3621 oid: oid::CT_MZ_CLUSTER_REPLICA_STATUS_HISTORY_OID,
3622 desc: REPLICA_STATUS_HISTORY_DESC.clone(),
3623 sql: "
3624IN CLUSTER mz_catalog_server
3625ON INPUT mz_internal.mz_cluster_replica_status_history AS (
3626 DELETE FROM mz_internal.mz_cluster_replica_status_history_ct WHERE occurred_at + '30d' < mz_now();
3627 INSERT INTO mz_internal.mz_cluster_replica_status_history_ct SELECT * FROM mz_internal.mz_cluster_replica_status_history;
3628)",
3629 access: vec![PUBLIC_SELECT],
3630 }
3631 },
3632);
3633
3634pub static MZ_CLUSTER_REPLICA_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
3635 name: "mz_cluster_replica_statuses",
3636 schema: MZ_INTERNAL_SCHEMA,
3637 oid: oid::VIEW_MZ_CLUSTER_REPLICA_STATUSES_OID,
3638 desc: RelationDesc::builder()
3639 .with_column("replica_id", SqlScalarType::String.nullable(false))
3640 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
3641 .with_column("status", SqlScalarType::String.nullable(false))
3642 .with_column("reason", SqlScalarType::String.nullable(true))
3643 .with_column(
3644 "updated_at",
3645 SqlScalarType::TimestampTz { precision: None }.nullable(false),
3646 )
3647 .with_key(vec![0, 1])
3648 .finish(),
3649 column_comments: BTreeMap::from_iter([
3650 (
3651 "replica_id",
3652 "Materialize's unique ID for the cluster replica.",
3653 ),
3654 (
3655 "process_id",
3656 "The ID of the process within the cluster replica.",
3657 ),
3658 (
3659 "status",
3660 "The status of the cluster replica: `online` or `offline`.",
3661 ),
3662 (
3663 "reason",
3664 "If the cluster replica is in a `offline` state, the reason (if available). For example, `oom-killed`.",
3665 ),
3666 (
3667 "updated_at",
3668 "The time at which the status was last updated.",
3669 ),
3670 ]),
3671 sql: "
3672SELECT
3673 DISTINCT ON (replica_id, process_id)
3674 replica_id,
3675 process_id,
3676 status,
3677 reason,
3678 occurred_at as updated_at
3679FROM mz_internal.mz_cluster_replica_status_history
3680JOIN mz_cluster_replicas r ON r.id = replica_id
3681ORDER BY replica_id, process_id, occurred_at DESC",
3682 access: vec![PUBLIC_SELECT],
3683});
3684
3685pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3686 name: "mz_cluster_replica_sizes",
3687 schema: MZ_CATALOG_SCHEMA,
3688 oid: oid::TABLE_MZ_CLUSTER_REPLICA_SIZES_OID,
3689 desc: RelationDesc::builder()
3690 .with_column("size", SqlScalarType::String.nullable(false))
3691 .with_column("processes", SqlScalarType::UInt64.nullable(false))
3692 .with_column("workers", SqlScalarType::UInt64.nullable(false))
3693 .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(false))
3694 .with_column("memory_bytes", SqlScalarType::UInt64.nullable(false))
3695 .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true))
3696 .with_column(
3697 "credits_per_hour",
3698 SqlScalarType::Numeric { max_scale: None }.nullable(false),
3699 )
3700 .finish(),
3701 column_comments: BTreeMap::from_iter([
3702 ("size", "The human-readable replica size."),
3703 ("processes", "The number of processes in the replica."),
3704 (
3705 "workers",
3706 "The number of Timely Dataflow workers per process.",
3707 ),
3708 (
3709 "cpu_nano_cores",
3710 "The CPU allocation per process, in billionths of a vCPU core.",
3711 ),
3712 (
3713 "memory_bytes",
3714 "The RAM allocation per process, in billionths of a vCPU core.",
3715 ),
3716 ("disk_bytes", "The disk allocation per process."),
3717 (
3718 "credits_per_hour",
3719 "The number of compute credits consumed per hour.",
3720 ),
3721 ]),
3722 is_retained_metrics_object: true,
3723 access: vec![PUBLIC_SELECT],
3724});
3725
3726pub static MZ_AUDIT_EVENTS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3727 name: "mz_audit_events",
3728 schema: MZ_CATALOG_SCHEMA,
3729 oid: oid::TABLE_MZ_AUDIT_EVENTS_OID,
3730 desc: RelationDesc::builder()
3731 .with_column("id", SqlScalarType::UInt64.nullable(false))
3732 .with_column("event_type", SqlScalarType::String.nullable(false))
3733 .with_column("object_type", SqlScalarType::String.nullable(false))
3734 .with_column("details", SqlScalarType::Jsonb.nullable(false))
3735 .with_column("user", SqlScalarType::String.nullable(true))
3736 .with_column(
3737 "occurred_at",
3738 SqlScalarType::TimestampTz { precision: None }.nullable(false),
3739 )
3740 .with_key(vec![0])
3741 .finish(),
3742 column_comments: BTreeMap::from_iter([
3743 (
3744 "id",
3745 "Materialize's unique, monotonically increasing ID for the event.",
3746 ),
3747 (
3748 "event_type",
3749 "The type of the event: `create`, `drop`, or `alter`.",
3750 ),
3751 (
3752 "object_type",
3753 "The type of the affected object: `cluster`, `cluster-replica`, `connection`, `database`, `function`, `index`, `materialized-view`, `role`, `schema`, `secret`, `sink`, `source`, `table`, `type`, or `view`.",
3754 ),
3755 (
3756 "details",
3757 "Additional details about the event. The shape of the details varies based on `event_type` and `object_type`.",
3758 ),
3759 (
3760 "user",
3761 "The user who triggered the event, or `NULL` if triggered by the system.",
3762 ),
3763 (
3764 "occurred_at",
3765 "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.",
3766 ),
3767 ]),
3768 is_retained_metrics_object: false,
3769 access: vec![PUBLIC_SELECT],
3770});
3771
3772pub static MZ_SOURCE_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
3773 name: "mz_source_status_history",
3774 schema: MZ_INTERNAL_SCHEMA,
3775 oid: oid::SOURCE_MZ_SOURCE_STATUS_HISTORY_OID,
3776 data_source: IntrospectionType::SourceStatusHistory,
3777 desc: MZ_SOURCE_STATUS_HISTORY_DESC.clone(),
3778 column_comments: BTreeMap::from_iter([
3779 (
3780 "occurred_at",
3781 "Wall-clock timestamp of the source status change.",
3782 ),
3783 (
3784 "source_id",
3785 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
3786 ),
3787 (
3788 "status",
3789 "The status of the source: one of `created`, `starting`, `running`, `paused`, `stalled`, `failed`, or `dropped`.",
3790 ),
3791 (
3792 "error",
3793 "If the source is in an error state, the error message.",
3794 ),
3795 (
3796 "details",
3797 "Additional metadata provided by the source. In case of error, may contain a `hint` field with helpful suggestions.",
3798 ),
3799 (
3800 "replica_id",
3801 "The ID of the replica that an instance of a source is running on.",
3802 ),
3803 ]),
3804 is_retained_metrics_object: false,
3805 access: vec![PUBLIC_SELECT],
3806});
3807
3808pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(
3809 || BuiltinSource {
3810 name: "mz_aws_privatelink_connection_status_history",
3811 schema: MZ_INTERNAL_SCHEMA,
3812 oid: oid::SOURCE_MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_OID,
3813 data_source: IntrospectionType::PrivatelinkConnectionStatusHistory,
3814 desc: MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_DESC.clone(),
3815 column_comments: BTreeMap::from_iter([
3816 ("occurred_at", "Wall-clock timestamp of the status change."),
3817 (
3818 "connection_id",
3819 "The unique identifier of the AWS PrivateLink connection. Corresponds to `mz_catalog.mz_connections.id`.",
3820 ),
3821 (
3822 "status",
3823 "The status of the connection: one of `pending-service-discovery`, `creating-endpoint`, `recreating-endpoint`, `updating-endpoint`, `available`, `deleted`, `deleting`, `expired`, `failed`, `pending`, `pending-acceptance`, `rejected`, or `unknown`.",
3824 ),
3825 ]),
3826 is_retained_metrics_object: false,
3827 access: vec![PUBLIC_SELECT],
3828 },
3829);
3830
3831pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUSES: LazyLock<BuiltinView> =
3832 LazyLock::new(|| BuiltinView {
3833 name: "mz_aws_privatelink_connection_statuses",
3834 schema: MZ_INTERNAL_SCHEMA,
3835 oid: oid::VIEW_MZ_AWS_PRIVATELINK_CONNECTION_STATUSES_OID,
3836 desc: RelationDesc::builder()
3837 .with_column("id", SqlScalarType::String.nullable(false))
3838 .with_column("name", SqlScalarType::String.nullable(false))
3839 .with_column(
3840 "last_status_change_at",
3841 SqlScalarType::TimestampTz { precision: None }.nullable(true),
3842 )
3843 .with_column("status", SqlScalarType::String.nullable(true))
3844 .with_key(vec![0])
3845 .finish(),
3846 column_comments: BTreeMap::from_iter([
3847 (
3848 "id",
3849 "The ID of the connection. Corresponds to `mz_catalog.mz_connections.id`.",
3850 ),
3851 ("name", "The name of the connection."),
3852 (
3853 "last_status_change_at",
3854 "Wall-clock timestamp of the connection status change.",
3855 ),
3856 ("status", ""),
3857 ]),
3858 sql: "
3859 WITH statuses_w_last_status AS (
3860 SELECT
3861 connection_id,
3862 occurred_at,
3863 status,
3864 lag(status) OVER (PARTITION BY connection_id ORDER BY occurred_at) AS last_status
3865 FROM mz_internal.mz_aws_privatelink_connection_status_history
3866 ),
3867 latest_events AS (
3868 -- Only take the most recent transition for each ID
3869 SELECT DISTINCT ON(connection_id) connection_id, occurred_at, status
3870 FROM statuses_w_last_status
3871 -- Only keep first status transitions
3872 WHERE status <> last_status OR last_status IS NULL
3873 ORDER BY connection_id, occurred_at DESC
3874 )
3875 SELECT
3876 conns.id,
3877 name,
3878 occurred_at as last_status_change_at,
3879 status
3880 FROM latest_events
3881 JOIN mz_catalog.mz_connections AS conns
3882 ON conns.id = latest_events.connection_id",
3883 access: vec![PUBLIC_SELECT],
3884 });
3885
3886pub static MZ_STATEMENT_EXECUTION_HISTORY: LazyLock<BuiltinSource> =
3887 LazyLock::new(|| BuiltinSource {
3888 name: "mz_statement_execution_history",
3889 schema: MZ_INTERNAL_SCHEMA,
3890 oid: oid::SOURCE_MZ_STATEMENT_EXECUTION_HISTORY_OID,
3891 data_source: IntrospectionType::StatementExecutionHistory,
3892 desc: MZ_STATEMENT_EXECUTION_HISTORY_DESC.clone(),
3893 column_comments: BTreeMap::new(),
3894 is_retained_metrics_object: false,
3895 access: vec![MONITOR_SELECT],
3896 });
3897
3898pub static MZ_STATEMENT_EXECUTION_HISTORY_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| {
3899 BuiltinView {
3900 name: "mz_statement_execution_history_redacted",
3901 schema: MZ_INTERNAL_SCHEMA,
3902 oid: oid::VIEW_MZ_STATEMENT_EXECUTION_HISTORY_REDACTED_OID,
3903 desc: RelationDesc::builder()
3905 .with_column("id", SqlScalarType::Uuid.nullable(false))
3906 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
3907 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
3908 .with_column("cluster_id", SqlScalarType::String.nullable(true))
3909 .with_column("application_name", SqlScalarType::String.nullable(false))
3910 .with_column("cluster_name", SqlScalarType::String.nullable(true))
3911 .with_column("database_name", SqlScalarType::String.nullable(false))
3912 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
3913 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
3914 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
3915 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
3916 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
3917 .with_column("mz_version", SqlScalarType::String.nullable(false))
3918 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
3919 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
3920 .with_column("finished_status", SqlScalarType::String.nullable(true))
3921 .with_column("result_size", SqlScalarType::Int64.nullable(true))
3922 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
3923 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
3924 .finish(),
3925 column_comments: BTreeMap::new(),
3926 sql: "
3927SELECT id, prepared_statement_id, sample_rate, cluster_id, application_name,
3928cluster_name, database_name, search_path, transaction_isolation, execution_timestamp, transaction_id,
3929transient_index_id, mz_version, began_at, finished_at, finished_status,
3930result_size, rows_returned, execution_strategy
3931FROM mz_internal.mz_statement_execution_history",
3932 access: vec![SUPPORT_SELECT, ANALYTICS_SELECT, MONITOR_REDACTED_SELECT, MONITOR_SELECT],
3933}
3934});
3935
3936pub static MZ_PREPARED_STATEMENT_HISTORY: LazyLock<BuiltinSource> =
3937 LazyLock::new(|| BuiltinSource {
3938 name: "mz_prepared_statement_history",
3939 schema: MZ_INTERNAL_SCHEMA,
3940 oid: oid::SOURCE_MZ_PREPARED_STATEMENT_HISTORY_OID,
3941 data_source: IntrospectionType::PreparedStatementHistory,
3942 desc: MZ_PREPARED_STATEMENT_HISTORY_DESC.clone(),
3943 column_comments: BTreeMap::new(),
3944 is_retained_metrics_object: false,
3945 access: vec![
3946 SUPPORT_SELECT,
3947 ANALYTICS_SELECT,
3948 MONITOR_REDACTED_SELECT,
3949 MONITOR_SELECT,
3950 ],
3951 });
3952
3953pub static MZ_SQL_TEXT: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
3954 name: "mz_sql_text",
3955 schema: MZ_INTERNAL_SCHEMA,
3956 oid: oid::SOURCE_MZ_SQL_TEXT_OID,
3957 desc: MZ_SQL_TEXT_DESC.clone(),
3958 data_source: IntrospectionType::SqlText,
3959 column_comments: BTreeMap::new(),
3960 is_retained_metrics_object: false,
3961 access: vec![MONITOR_SELECT],
3962});
3963
3964pub static MZ_SQL_TEXT_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
3965 name: "mz_sql_text_redacted",
3966 schema: MZ_INTERNAL_SCHEMA,
3967 oid: oid::VIEW_MZ_SQL_TEXT_REDACTED_OID,
3968 desc: RelationDesc::builder()
3969 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
3970 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
3971 .finish(),
3972 column_comments: BTreeMap::new(),
3973 sql: "SELECT sql_hash, redacted_sql FROM mz_internal.mz_sql_text",
3974 access: vec![
3975 MONITOR_SELECT,
3976 MONITOR_REDACTED_SELECT,
3977 SUPPORT_SELECT,
3978 ANALYTICS_SELECT,
3979 ],
3980});
3981
3982pub static MZ_RECENT_SQL_TEXT: LazyLock<BuiltinView> = LazyLock::new(|| {
3983 BuiltinView {
3984 name: "mz_recent_sql_text",
3985 schema: MZ_INTERNAL_SCHEMA,
3986 oid: oid::VIEW_MZ_RECENT_SQL_TEXT_OID,
3987 desc: RelationDesc::builder()
3992 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
3993 .with_column("sql", SqlScalarType::String.nullable(false))
3994 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
3995 .with_key(vec![0, 1, 2])
3996 .finish(),
3997 column_comments: BTreeMap::new(),
3998 sql: "SELECT DISTINCT sql_hash, sql, redacted_sql FROM mz_internal.mz_sql_text WHERE prepared_day + INTERVAL '4 days' >= mz_now()",
3999 access: vec![MONITOR_SELECT],
4000 }
4001});
4002
4003pub static MZ_RECENT_SQL_TEXT_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4004 name: "mz_recent_sql_text_redacted",
4005 schema: MZ_INTERNAL_SCHEMA,
4006 oid: oid::VIEW_MZ_RECENT_SQL_TEXT_REDACTED_OID,
4007 desc: RelationDesc::builder()
4008 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4009 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
4010 .finish(),
4011 column_comments: BTreeMap::new(),
4012 sql: "SELECT sql_hash, redacted_sql FROM mz_internal.mz_recent_sql_text",
4013 access: vec![
4014 MONITOR_SELECT,
4015 MONITOR_REDACTED_SELECT,
4016 SUPPORT_SELECT,
4017 ANALYTICS_SELECT,
4018 ],
4019});
4020
4021pub static MZ_RECENT_SQL_TEXT_IND: LazyLock<BuiltinIndex> = LazyLock::new(|| BuiltinIndex {
4022 name: "mz_recent_sql_text_ind",
4023 schema: MZ_INTERNAL_SCHEMA,
4024 oid: oid::INDEX_MZ_RECENT_SQL_TEXT_IND_OID,
4025 sql: "IN CLUSTER mz_catalog_server ON mz_internal.mz_recent_sql_text (sql_hash)",
4026 is_retained_metrics_object: false,
4027});
4028
4029pub static MZ_SESSION_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
4030 name: "mz_session_history",
4031 schema: MZ_INTERNAL_SCHEMA,
4032 oid: oid::SOURCE_MZ_SESSION_HISTORY_OID,
4033 data_source: IntrospectionType::SessionHistory,
4034 desc: MZ_SESSION_HISTORY_DESC.clone(),
4035 column_comments: BTreeMap::new(),
4036 is_retained_metrics_object: false,
4037 access: vec![PUBLIC_SELECT],
4038});
4039
4040pub static MZ_ACTIVITY_LOG_THINNED: LazyLock<BuiltinView> = LazyLock::new(|| {
4041 BuiltinView {
4042 name: "mz_activity_log_thinned",
4043 schema: MZ_INTERNAL_SCHEMA,
4044 oid: oid::VIEW_MZ_ACTIVITY_LOG_THINNED_OID,
4045 desc: RelationDesc::builder()
4046 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4047 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4048 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4049 .with_column("application_name", SqlScalarType::String.nullable(false))
4050 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4051 .with_column("database_name", SqlScalarType::String.nullable(false))
4052 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
4053 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
4054 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4055 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4056 .with_column("params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false))
4057 .with_column("mz_version", SqlScalarType::String.nullable(false))
4058 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4059 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
4060 .with_column("finished_status", SqlScalarType::String.nullable(true))
4061 .with_column("error_message", SqlScalarType::String.nullable(true))
4062 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4063 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4064 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4065 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4066 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4067 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4068 .with_column("prepared_statement_name", SqlScalarType::String.nullable(false))
4069 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4070 .with_column("prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4071 .with_column("statement_type", SqlScalarType::String.nullable(true))
4072 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4073 .with_column("connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4074 .with_column("initial_application_name", SqlScalarType::String.nullable(false))
4075 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4076 .finish(),
4077 column_comments: BTreeMap::new(),
4078 sql: "
4079SELECT mseh.id AS execution_id, sample_rate, cluster_id, application_name, cluster_name, database_name, search_path,
4080transaction_isolation, execution_timestamp, transient_index_id, params, mz_version, began_at, finished_at, finished_status,
4081error_message, result_size, rows_returned, execution_strategy, transaction_id,
4082mpsh.id AS prepared_statement_id, sql_hash, mpsh.name AS prepared_statement_name,
4083mpsh.session_id, prepared_at, statement_type, throttled_count,
4084connected_at, initial_application_name, authenticated_user
4085FROM mz_internal.mz_statement_execution_history mseh,
4086 mz_internal.mz_prepared_statement_history mpsh,
4087 mz_internal.mz_session_history msh
4088WHERE mseh.prepared_statement_id = mpsh.id
4089AND mpsh.session_id = msh.session_id",
4090 access: vec![MONITOR_SELECT],
4091 }
4092});
4093
4094pub static MZ_RECENT_ACTIVITY_LOG_THINNED: LazyLock<BuiltinView> = LazyLock::new(|| {
4095 BuiltinView {
4096 name: "mz_recent_activity_log_thinned",
4097 schema: MZ_INTERNAL_SCHEMA,
4098 oid: oid::VIEW_MZ_RECENT_ACTIVITY_LOG_THINNED_OID,
4099 desc: RelationDesc::builder()
4100 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4101 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4102 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4103 .with_column("application_name", SqlScalarType::String.nullable(false))
4104 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4105 .with_column("database_name", SqlScalarType::String.nullable(false))
4106 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
4107 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
4108 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4109 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4110 .with_column("params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false))
4111 .with_column("mz_version", SqlScalarType::String.nullable(false))
4112 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4113 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
4114 .with_column("finished_status", SqlScalarType::String.nullable(true))
4115 .with_column("error_message", SqlScalarType::String.nullable(true))
4116 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4117 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4118 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4119 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4120 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4121 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4122 .with_column("prepared_statement_name", SqlScalarType::String.nullable(false))
4123 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4124 .with_column("prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4125 .with_column("statement_type", SqlScalarType::String.nullable(true))
4126 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4127 .with_column("connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4128 .with_column("initial_application_name", SqlScalarType::String.nullable(false))
4129 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4130 .finish(),
4131 column_comments: BTreeMap::new(),
4132 sql:
4135 "SELECT * FROM mz_internal.mz_activity_log_thinned WHERE prepared_at + INTERVAL '1 day' > mz_now()
4136AND began_at + INTERVAL '1 day' > mz_now() AND connected_at + INTERVAL '2 days' > mz_now()",
4137 access: vec![MONITOR_SELECT],
4138 }
4139});
4140
4141pub static MZ_RECENT_ACTIVITY_LOG: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4142 name: "mz_recent_activity_log",
4143 schema: MZ_INTERNAL_SCHEMA,
4144 oid: oid::VIEW_MZ_RECENT_ACTIVITY_LOG_OID,
4145 desc: RelationDesc::builder()
4146 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4147 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4148 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4149 .with_column("application_name", SqlScalarType::String.nullable(false))
4150 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4151 .with_column("database_name", SqlScalarType::String.nullable(false))
4152 .with_column(
4153 "search_path",
4154 SqlScalarType::List {
4155 element_type: Box::new(SqlScalarType::String),
4156 custom_id: None,
4157 }
4158 .nullable(false),
4159 )
4160 .with_column(
4161 "transaction_isolation",
4162 SqlScalarType::String.nullable(false),
4163 )
4164 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4165 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4166 .with_column(
4167 "params",
4168 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
4169 )
4170 .with_column("mz_version", SqlScalarType::String.nullable(false))
4171 .with_column(
4172 "began_at",
4173 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4174 )
4175 .with_column(
4176 "finished_at",
4177 SqlScalarType::TimestampTz { precision: None }.nullable(true),
4178 )
4179 .with_column("finished_status", SqlScalarType::String.nullable(true))
4180 .with_column("error_message", SqlScalarType::String.nullable(true))
4181 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4182 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4183 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4184 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4185 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4186 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4187 .with_column(
4188 "prepared_statement_name",
4189 SqlScalarType::String.nullable(false),
4190 )
4191 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4192 .with_column(
4193 "prepared_at",
4194 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4195 )
4196 .with_column("statement_type", SqlScalarType::String.nullable(true))
4197 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4198 .with_column(
4199 "connected_at",
4200 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4201 )
4202 .with_column(
4203 "initial_application_name",
4204 SqlScalarType::String.nullable(false),
4205 )
4206 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4207 .with_column("sql", SqlScalarType::String.nullable(false))
4208 .finish(),
4209 column_comments: BTreeMap::from_iter([
4210 (
4211 "execution_id",
4212 "An ID that is unique for each executed statement.",
4213 ),
4214 (
4215 "sample_rate",
4216 "The actual rate at which the statement was sampled.",
4217 ),
4218 (
4219 "cluster_id",
4220 "The ID of the cluster the statement execution was directed to. Corresponds to mz_clusters.id.",
4221 ),
4222 (
4223 "application_name",
4224 "The value of the `application_name` configuration parameter at execution time.",
4225 ),
4226 (
4227 "cluster_name",
4228 "The name of the cluster with ID `cluster_id` at execution time.",
4229 ),
4230 (
4231 "database_name",
4232 "The value of the `database` configuration parameter at execution time.",
4233 ),
4234 (
4235 "search_path",
4236 "The value of the `search_path` configuration parameter at execution time.",
4237 ),
4238 (
4239 "transaction_isolation",
4240 "The value of the `transaction_isolation` configuration parameter at execution time.",
4241 ),
4242 (
4243 "execution_timestamp",
4244 "The logical timestamp at which execution was scheduled.",
4245 ),
4246 (
4247 "transient_index_id",
4248 "The internal index of the compute dataflow created for the query, if any.",
4249 ),
4250 (
4251 "params",
4252 "The parameters with which the statement was executed.",
4253 ),
4254 (
4255 "mz_version",
4256 "The version of Materialize that was running when the statement was executed.",
4257 ),
4258 (
4259 "began_at",
4260 "The wall-clock time at which the statement began executing.",
4261 ),
4262 (
4263 "finished_at",
4264 "The wall-clock time at which the statement finished executing.",
4265 ),
4266 (
4267 "finished_status",
4268 "The final status of the statement (e.g., `success`, `canceled`, `error`, or `aborted`). `aborted` means that Materialize exited before the statement finished executing.",
4269 ),
4270 (
4271 "error_message",
4272 "The error message, if the statement failed.",
4273 ),
4274 (
4275 "result_size",
4276 "The size in bytes of the result, for statements that return rows.",
4277 ),
4278 (
4279 "rows_returned",
4280 "The number of rows returned, for statements that return rows.",
4281 ),
4282 (
4283 "execution_strategy",
4284 "For `SELECT` queries, the strategy for executing the query. `constant` means computed in the control plane without the involvement of a cluster, `fast-path` means read by a cluster directly from an in-memory index, and `standard` means computed by a temporary dataflow.",
4285 ),
4286 (
4287 "transaction_id",
4288 "The ID of the transaction that the statement was part of. Note that transaction IDs are only unique per session.",
4289 ),
4290 (
4291 "prepared_statement_id",
4292 "An ID that is unique for each prepared statement. For example, if a statement is prepared once and then executed multiple times, all executions will have the same value for this column (but different values for `execution_id`).",
4293 ),
4294 (
4295 "sql_hash",
4296 "An opaque value uniquely identifying the text of the query.",
4297 ),
4298 (
4299 "prepared_statement_name",
4300 "The name given by the client library to the prepared statement.",
4301 ),
4302 (
4303 "session_id",
4304 "An ID that is unique for each session. Corresponds to mz_sessions.id.",
4305 ),
4306 (
4307 "prepared_at",
4308 "The time at which the statement was prepared.",
4309 ),
4310 (
4311 "statement_type",
4312 "The type of the statement, e.g. `select` for a `SELECT` query, or `NULL` if the statement was empty.",
4313 ),
4314 (
4315 "throttled_count",
4316 "The number of statements that were dropped due to throttling before the current one was seen. If you have a very high volume of queries and need to log them without throttling, contact our team.",
4317 ),
4318 (
4319 "connected_at",
4320 "The time at which the session was established.",
4321 ),
4322 (
4323 "initial_application_name",
4324 "The initial value of `application_name` at the beginning of the session.",
4325 ),
4326 (
4327 "authenticated_user",
4328 "The name of the user for which the session was established.",
4329 ),
4330 ("sql", "The SQL text of the statement."),
4331 ]),
4332 sql: "SELECT mralt.*, mrst.sql
4333FROM mz_internal.mz_recent_activity_log_thinned mralt,
4334 mz_internal.mz_recent_sql_text mrst
4335WHERE mralt.sql_hash = mrst.sql_hash",
4336 access: vec![MONITOR_SELECT],
4337});
4338
4339pub static MZ_RECENT_ACTIVITY_LOG_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| {
4340 BuiltinView {
4341 name: "mz_recent_activity_log_redacted",
4342 schema: MZ_INTERNAL_SCHEMA,
4343 oid: oid::VIEW_MZ_RECENT_ACTIVITY_LOG_REDACTED_OID,
4344 desc: RelationDesc::builder()
4346 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4347 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4348 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4349 .with_column("application_name", SqlScalarType::String.nullable(false))
4350 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4351 .with_column("database_name", SqlScalarType::String.nullable(false))
4352 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
4353 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
4354 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4355 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4356 .with_column("params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false))
4357 .with_column("mz_version", SqlScalarType::String.nullable(false))
4358 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4359 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
4360 .with_column("finished_status", SqlScalarType::String.nullable(true))
4361 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4362 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4363 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4364 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4365 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4366 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4367 .with_column("prepared_statement_name", SqlScalarType::String.nullable(false))
4368 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4369 .with_column("prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4370 .with_column("statement_type", SqlScalarType::String.nullable(true))
4371 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4372 .with_column("initial_application_name", SqlScalarType::String.nullable(false))
4373 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4374 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
4375 .finish(),
4376 column_comments: BTreeMap::new(),
4377 sql: "SELECT mralt.execution_id, mralt.sample_rate, mralt.cluster_id, mralt.application_name,
4378 mralt.cluster_name, mralt.database_name, mralt.search_path, mralt.transaction_isolation, mralt.execution_timestamp,
4379 mralt.transient_index_id, mralt.params, mralt.mz_version, mralt.began_at, mralt.finished_at,
4380 mralt.finished_status, mralt.result_size, mralt.rows_returned, mralt.execution_strategy, mralt.transaction_id,
4381 mralt.prepared_statement_id, mralt.sql_hash, mralt.prepared_statement_name, mralt.session_id,
4382 mralt.prepared_at, mralt.statement_type, mralt.throttled_count,
4383 mralt.initial_application_name, mralt.authenticated_user,
4384 mrst.redacted_sql
4385FROM mz_internal.mz_recent_activity_log_thinned mralt,
4386 mz_internal.mz_recent_sql_text mrst
4387WHERE mralt.sql_hash = mrst.sql_hash",
4388 access: vec![MONITOR_SELECT, MONITOR_REDACTED_SELECT, SUPPORT_SELECT, ANALYTICS_SELECT],
4389}
4390});
4391
4392pub static MZ_STATEMENT_LIFECYCLE_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| {
4393 BuiltinSource {
4394 name: "mz_statement_lifecycle_history",
4395 schema: MZ_INTERNAL_SCHEMA,
4396 oid: oid::SOURCE_MZ_STATEMENT_LIFECYCLE_HISTORY_OID,
4397 desc: RelationDesc::builder()
4398 .with_column("statement_id", SqlScalarType::Uuid.nullable(false))
4399 .with_column("event_type", SqlScalarType::String.nullable(false))
4400 .with_column(
4401 "occurred_at",
4402 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4403 )
4404 .finish(),
4405 data_source: IntrospectionType::StatementLifecycleHistory,
4406 column_comments: BTreeMap::from_iter([
4407 (
4408 "statement_id",
4409 "The ID of the execution event. Corresponds to `mz_recent_activity_log.execution_id`",
4410 ),
4411 (
4412 "event_type",
4413 "The type of lifecycle event, e.g. `'execution-began'`, `'storage-dependencies-finished'`, `'compute-dependencies-finished'`, or `'execution-finished'`",
4414 ),
4415 ("occurred_at", "The time at which the event took place."),
4416 ]),
4417 is_retained_metrics_object: false,
4418 access: vec![
4422 SUPPORT_SELECT,
4423 ANALYTICS_SELECT,
4424 MONITOR_REDACTED_SELECT,
4425 MONITOR_SELECT,
4426 ],
4427 }
4428});
4429
4430pub static MZ_SOURCE_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4431 name: "mz_source_statuses",
4432 schema: MZ_INTERNAL_SCHEMA,
4433 oid: oid::VIEW_MZ_SOURCE_STATUSES_OID,
4434 desc: RelationDesc::builder()
4435 .with_column("id", SqlScalarType::String.nullable(false))
4436 .with_column("name", SqlScalarType::String.nullable(false))
4437 .with_column("type", SqlScalarType::String.nullable(false))
4438 .with_column(
4439 "last_status_change_at",
4440 SqlScalarType::TimestampTz { precision: None }.nullable(true),
4441 )
4442 .with_column("status", SqlScalarType::String.nullable(false))
4443 .with_column("error", SqlScalarType::String.nullable(true))
4444 .with_column("details", SqlScalarType::Jsonb.nullable(true))
4445 .finish(),
4446 column_comments: BTreeMap::from_iter([
4447 (
4448 "id",
4449 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
4450 ),
4451 ("name", "The name of the source."),
4452 ("type", "The type of the source."),
4453 (
4454 "last_status_change_at",
4455 "Wall-clock timestamp of the source status change.",
4456 ),
4457 (
4458 "status",
4459 "The status of the source: one of `created`, `starting`, `running`, `paused`, `stalled`, `failed`, or `dropped`.",
4460 ),
4461 (
4462 "error",
4463 "If the source is in an error state, the error message.",
4464 ),
4465 (
4466 "details",
4467 "Additional metadata provided by the source. In case of error, may contain a `hint` field with helpful suggestions.",
4468 ),
4469 ]),
4470 sql: "
4471 WITH
4472 -- The status history contains per-replica events and source-global events.
4473 -- For the latter, replica_id is NULL. We turn these into '<source>', so that
4474 -- we can treat them uniformly below.
4475 uniform_status_history AS
4476 (
4477 SELECT
4478 s.source_id,
4479 COALESCE(s.replica_id, '<source>') as replica_id,
4480 s.occurred_at,
4481 s.status,
4482 s.error,
4483 s.details
4484 FROM mz_internal.mz_source_status_history s
4485 ),
4486 -- For getting the latest events, we first determine the latest per-replica
4487 -- events here and then apply precedence rules below.
4488 latest_per_replica_events AS
4489 (
4490 SELECT DISTINCT ON (source_id, replica_id)
4491 occurred_at, source_id, replica_id, status, error, details
4492 FROM uniform_status_history
4493 ORDER BY source_id, replica_id, occurred_at DESC
4494 ),
4495 -- We have a precedence list that determines the overall status in case
4496 -- there is differing per-replica (including source-global) statuses. If
4497 -- there is no 'dropped' status, and any replica reports 'running', the
4498 -- overall status is 'running' even if there might be some replica that has
4499 -- errors or is paused.
4500 latest_events AS
4501 (
4502 SELECT DISTINCT ON (source_id)
4503 source_id,
4504 occurred_at,
4505 status,
4506 error,
4507 details
4508 FROM latest_per_replica_events
4509 ORDER BY source_id, CASE status
4510 WHEN 'dropped' THEN 1
4511 WHEN 'running' THEN 2
4512 WHEN 'stalled' THEN 3
4513 WHEN 'starting' THEN 4
4514 WHEN 'paused' THEN 5
4515 WHEN 'ceased' THEN 6
4516 ELSE 7 -- For any other status values
4517 END
4518 ),
4519 -- Determine which sources are subsources and which are parent sources
4520 subsources AS
4521 (
4522 SELECT subsources.id AS self, sources.id AS parent
4523 FROM
4524 mz_catalog.mz_sources AS subsources
4525 JOIN
4526 mz_internal.mz_object_dependencies AS deps
4527 ON subsources.id = deps.object_id
4528 JOIN mz_catalog.mz_sources AS sources ON sources.id = deps.referenced_object_id
4529 ),
4530 -- Determine which sources are source tables
4531 tables AS
4532 (
4533 SELECT tables.id AS self, tables.source_id AS parent, tables.name
4534 FROM mz_catalog.mz_tables AS tables
4535 WHERE tables.source_id IS NOT NULL
4536 ),
4537 -- Determine which collection's ID to use for the status
4538 id_of_status_to_use AS
4539 (
4540 SELECT
4541 self_events.source_id,
4542 -- If self not errored, but parent is, use parent; else self
4543 CASE
4544 WHEN
4545 self_events.status <> 'ceased' AND
4546 parent_events.status = 'stalled'
4547 THEN parent_events.source_id
4548 ELSE self_events.source_id
4549 END AS id_to_use
4550 FROM
4551 latest_events AS self_events
4552 LEFT JOIN subsources ON self_events.source_id = subsources.self
4553 LEFT JOIN tables ON self_events.source_id = tables.self
4554 LEFT JOIN
4555 latest_events AS parent_events
4556 ON parent_events.source_id = COALESCE(subsources.parent, tables.parent)
4557 ),
4558 -- Swap out events for the ID of the event we plan to use instead
4559 latest_events_to_use AS
4560 (
4561 SELECT occurred_at, s.source_id, status, error, details
4562 FROM
4563 id_of_status_to_use AS s
4564 JOIN latest_events AS e ON e.source_id = s.id_to_use
4565 ),
4566 combined AS (
4567 SELECT
4568 mz_sources.id,
4569 mz_sources.name,
4570 mz_sources.type,
4571 occurred_at,
4572 status,
4573 error,
4574 details
4575 FROM
4576 mz_catalog.mz_sources
4577 LEFT JOIN latest_events_to_use AS e ON mz_sources.id = e.source_id
4578 UNION ALL
4579 SELECT
4580 tables.self AS id,
4581 tables.name,
4582 'table' AS type,
4583 occurred_at,
4584 status,
4585 error,
4586 details
4587 FROM
4588 tables
4589 LEFT JOIN latest_events_to_use AS e ON tables.self = e.source_id
4590 )
4591SELECT
4592 id,
4593 name,
4594 type,
4595 occurred_at AS last_status_change_at,
4596 -- TODO(parkmycar): Report status of webhook source once database-issues#5986 is closed.
4597 CASE
4598 WHEN
4599 type = 'webhook' OR
4600 type = 'progress'
4601 THEN 'running'
4602 ELSE COALESCE(status, 'created')
4603 END AS status,
4604 error,
4605 details
4606FROM combined
4607WHERE id NOT LIKE 's%';",
4608 access: vec![PUBLIC_SELECT],
4609});
4610
4611pub static MZ_SINK_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
4612 name: "mz_sink_status_history",
4613 schema: MZ_INTERNAL_SCHEMA,
4614 oid: oid::SOURCE_MZ_SINK_STATUS_HISTORY_OID,
4615 data_source: IntrospectionType::SinkStatusHistory,
4616 desc: MZ_SINK_STATUS_HISTORY_DESC.clone(),
4617 column_comments: BTreeMap::from_iter([
4618 (
4619 "occurred_at",
4620 "Wall-clock timestamp of the sink status change.",
4621 ),
4622 (
4623 "sink_id",
4624 "The ID of the sink. Corresponds to `mz_catalog.mz_sinks.id`.",
4625 ),
4626 (
4627 "status",
4628 "The status of the sink: one of `created`, `starting`, `running`, `stalled`, `failed`, or `dropped`.",
4629 ),
4630 (
4631 "error",
4632 "If the sink is in an error state, the error message.",
4633 ),
4634 (
4635 "details",
4636 "Additional metadata provided by the sink. In case of error, may contain a `hint` field with helpful suggestions.",
4637 ),
4638 (
4639 "replica_id",
4640 "The ID of the replica that an instance of a sink is running on.",
4641 ),
4642 ]),
4643 is_retained_metrics_object: false,
4644 access: vec![PUBLIC_SELECT],
4645});
4646
4647pub static MZ_SINK_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4648 name: "mz_sink_statuses",
4649 schema: MZ_INTERNAL_SCHEMA,
4650 oid: oid::VIEW_MZ_SINK_STATUSES_OID,
4651 desc: RelationDesc::builder()
4652 .with_column("id", SqlScalarType::String.nullable(false))
4653 .with_column("name", SqlScalarType::String.nullable(false))
4654 .with_column("type", SqlScalarType::String.nullable(false))
4655 .with_column(
4656 "last_status_change_at",
4657 SqlScalarType::TimestampTz { precision: None }.nullable(true),
4658 )
4659 .with_column("status", SqlScalarType::String.nullable(false))
4660 .with_column("error", SqlScalarType::String.nullable(true))
4661 .with_column("details", SqlScalarType::Jsonb.nullable(true))
4662 .finish(),
4663 column_comments: BTreeMap::from_iter([
4664 (
4665 "id",
4666 "The ID of the sink. Corresponds to `mz_catalog.mz_sinks.id`.",
4667 ),
4668 ("name", "The name of the sink."),
4669 ("type", "The type of the sink."),
4670 (
4671 "last_status_change_at",
4672 "Wall-clock timestamp of the sink status change.",
4673 ),
4674 (
4675 "status",
4676 "The status of the sink: one of `created`, `starting`, `running`, `stalled`, `failed`, or `dropped`.",
4677 ),
4678 (
4679 "error",
4680 "If the sink is in an error state, the error message.",
4681 ),
4682 (
4683 "details",
4684 "Additional metadata provided by the sink. In case of error, may contain a `hint` field with helpful suggestions.",
4685 ),
4686 ]),
4687 sql: "
4688WITH
4689-- The status history contains per-replica events and sink-global events.
4690-- For the latter, replica_id is NULL. We turn these into '<sink>', so that
4691-- we can treat them uniformly below.
4692uniform_status_history AS
4693(
4694 SELECT
4695 s.sink_id,
4696 COALESCE(s.replica_id, '<sink>') as replica_id,
4697 s.occurred_at,
4698 s.status,
4699 s.error,
4700 s.details
4701 FROM mz_internal.mz_sink_status_history s
4702),
4703-- For getting the latest events, we first determine the latest per-replica
4704-- events here and then apply precedence rules below.
4705latest_per_replica_events AS
4706(
4707 SELECT DISTINCT ON (sink_id, replica_id)
4708 occurred_at, sink_id, replica_id, status, error, details
4709 FROM uniform_status_history
4710 ORDER BY sink_id, replica_id, occurred_at DESC
4711),
4712-- We have a precedence list that determines the overall status in case
4713-- there is differing per-replica (including sink-global) statuses. If
4714-- there is no 'dropped' status, and any replica reports 'running', the
4715-- overall status is 'running' even if there might be some replica that has
4716-- errors or is paused.
4717latest_events AS
4718(
4719 SELECT DISTINCT ON (sink_id)
4720 sink_id,
4721 occurred_at,
4722 status,
4723 error,
4724 details
4725 FROM latest_per_replica_events
4726 ORDER BY sink_id, CASE status
4727 WHEN 'dropped' THEN 1
4728 WHEN 'running' THEN 2
4729 WHEN 'stalled' THEN 3
4730 WHEN 'starting' THEN 4
4731 WHEN 'paused' THEN 5
4732 WHEN 'ceased' THEN 6
4733 ELSE 7 -- For any other status values
4734 END
4735)
4736SELECT
4737 mz_sinks.id,
4738 name,
4739 mz_sinks.type,
4740 occurred_at as last_status_change_at,
4741 coalesce(status, 'created') as status,
4742 error,
4743 details
4744FROM mz_catalog.mz_sinks
4745LEFT JOIN latest_events ON mz_sinks.id = latest_events.sink_id
4746WHERE
4747 -- This is a convenient way to filter out system sinks, like the status_history table itself.
4748 mz_sinks.id NOT LIKE 's%'",
4749 access: vec![PUBLIC_SELECT],
4750});
4751
4752pub static MZ_STORAGE_USAGE_BY_SHARD_DESCRIPTION: LazyLock<SystemObjectDescription> =
4753 LazyLock::new(|| SystemObjectDescription {
4754 schema_name: MZ_STORAGE_USAGE_BY_SHARD.schema.to_string(),
4755 object_type: CatalogItemType::Table,
4756 object_name: MZ_STORAGE_USAGE_BY_SHARD.name.to_string(),
4757 });
4758
4759pub static MZ_STORAGE_USAGE_BY_SHARD: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
4760 name: "mz_storage_usage_by_shard",
4761 schema: MZ_INTERNAL_SCHEMA,
4762 oid: oid::TABLE_MZ_STORAGE_USAGE_BY_SHARD_OID,
4763 desc: RelationDesc::builder()
4764 .with_column("id", SqlScalarType::UInt64.nullable(false))
4765 .with_column("shard_id", SqlScalarType::String.nullable(true))
4766 .with_column("size_bytes", SqlScalarType::UInt64.nullable(false))
4767 .with_column(
4768 "collection_timestamp",
4769 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4770 )
4771 .finish(),
4772 column_comments: BTreeMap::new(),
4773 is_retained_metrics_object: false,
4774 access: vec![PUBLIC_SELECT],
4775});
4776
4777pub static MZ_EGRESS_IPS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
4778 name: "mz_egress_ips",
4779 schema: MZ_CATALOG_SCHEMA,
4780 oid: oid::TABLE_MZ_EGRESS_IPS_OID,
4781 desc: RelationDesc::builder()
4782 .with_column("egress_ip", SqlScalarType::String.nullable(false))
4783 .with_column("prefix_length", SqlScalarType::Int32.nullable(false))
4784 .with_column("cidr", SqlScalarType::String.nullable(false))
4785 .finish(),
4786 column_comments: BTreeMap::from_iter([
4787 ("egress_ip", "The start of the range of IP addresses."),
4788 (
4789 "prefix_length",
4790 "The number of leading bits in the CIDR netmask.",
4791 ),
4792 ("cidr", "The CIDR representation."),
4793 ]),
4794 is_retained_metrics_object: false,
4795 access: vec![PUBLIC_SELECT],
4796});
4797
4798pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock<BuiltinTable> =
4799 LazyLock::new(|| BuiltinTable {
4800 name: "mz_aws_privatelink_connections",
4801 schema: MZ_CATALOG_SCHEMA,
4802 oid: oid::TABLE_MZ_AWS_PRIVATELINK_CONNECTIONS_OID,
4803 desc: RelationDesc::builder()
4804 .with_column("id", SqlScalarType::String.nullable(false))
4805 .with_column("principal", SqlScalarType::String.nullable(false))
4806 .finish(),
4807 column_comments: BTreeMap::from_iter([
4808 ("id", "The ID of the connection."),
4809 (
4810 "principal",
4811 "The AWS Principal that Materialize will use to connect to the VPC endpoint.",
4812 ),
4813 ]),
4814 is_retained_metrics_object: false,
4815 access: vec![PUBLIC_SELECT],
4816 });
4817
4818pub static MZ_AWS_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
4819 name: "mz_aws_connections",
4820 schema: MZ_INTERNAL_SCHEMA,
4821 oid: oid::TABLE_MZ_AWS_CONNECTIONS_OID,
4822 desc: RelationDesc::builder()
4823 .with_column("id", SqlScalarType::String.nullable(false))
4824 .with_column("endpoint", SqlScalarType::String.nullable(true))
4825 .with_column("region", SqlScalarType::String.nullable(true))
4826 .with_column("access_key_id", SqlScalarType::String.nullable(true))
4827 .with_column(
4828 "access_key_id_secret_id",
4829 SqlScalarType::String.nullable(true),
4830 )
4831 .with_column(
4832 "secret_access_key_secret_id",
4833 SqlScalarType::String.nullable(true),
4834 )
4835 .with_column("session_token", SqlScalarType::String.nullable(true))
4836 .with_column(
4837 "session_token_secret_id",
4838 SqlScalarType::String.nullable(true),
4839 )
4840 .with_column("assume_role_arn", SqlScalarType::String.nullable(true))
4841 .with_column(
4842 "assume_role_session_name",
4843 SqlScalarType::String.nullable(true),
4844 )
4845 .with_column("principal", SqlScalarType::String.nullable(true))
4846 .with_column("external_id", SqlScalarType::String.nullable(true))
4847 .with_column("example_trust_policy", SqlScalarType::Jsonb.nullable(true))
4848 .finish(),
4849 column_comments: BTreeMap::from_iter([
4850 ("id", "The ID of the connection."),
4851 ("endpoint", "The value of the `ENDPOINT` option, if set."),
4852 ("region", "The value of the `REGION` option, if set."),
4853 (
4854 "access_key_id",
4855 "The value of the `ACCESS KEY ID` option, if provided in line.",
4856 ),
4857 (
4858 "access_key_id_secret_id",
4859 "The ID of the secret referenced by the `ACCESS KEY ID` option, if provided via a secret.",
4860 ),
4861 (
4862 "secret_access_key_secret_id",
4863 "The ID of the secret referenced by the `SECRET ACCESS KEY` option, if set.",
4864 ),
4865 (
4866 "session_token",
4867 "The value of the `SESSION TOKEN` option, if provided in line.",
4868 ),
4869 (
4870 "session_token_secret_id",
4871 "The ID of the secret referenced by the `SESSION TOKEN` option, if provided via a secret.",
4872 ),
4873 (
4874 "assume_role_arn",
4875 "The value of the `ASSUME ROLE ARN` option, if set.",
4876 ),
4877 (
4878 "assume_role_session_name",
4879 "The value of the `ASSUME ROLE SESSION NAME` option, if set.",
4880 ),
4881 (
4882 "principal",
4883 "The ARN of the AWS principal Materialize will use when assuming the provided role, if the connection is configured to use role assumption.",
4884 ),
4885 (
4886 "external_id",
4887 "The external ID Materialize will use when assuming the provided role, if the connection is configured to use role assumption.",
4888 ),
4889 (
4890 "example_trust_policy",
4891 "An example of an IAM role trust policy that allows this connection's principal and external ID to assume the role.",
4892 ),
4893 ]),
4894 is_retained_metrics_object: false,
4895 access: vec![PUBLIC_SELECT],
4896});
4897
4898pub static MZ_CLUSTER_REPLICA_METRICS_HISTORY: LazyLock<BuiltinSource> =
4899 LazyLock::new(|| BuiltinSource {
4900 name: "mz_cluster_replica_metrics_history",
4901 schema: MZ_INTERNAL_SCHEMA,
4902 oid: oid::SOURCE_MZ_CLUSTER_REPLICA_METRICS_HISTORY_OID,
4903 data_source: IntrospectionType::ReplicaMetricsHistory,
4904 desc: REPLICA_METRICS_HISTORY_DESC.clone(),
4905 column_comments: BTreeMap::from_iter([
4906 ("replica_id", "The ID of a cluster replica."),
4907 ("process_id", "The ID of a process within the replica."),
4908 (
4909 "cpu_nano_cores",
4910 "Approximate CPU usage, in billionths of a vCPU core.",
4911 ),
4912 ("memory_bytes", "Approximate memory usage, in bytes."),
4913 ("disk_bytes", "Approximate disk usage, in bytes."),
4914 (
4915 "occurred_at",
4916 "Wall-clock timestamp at which the event occurred.",
4917 ),
4918 (
4919 "heap_bytes",
4920 "Approximate heap (RAM + swap) usage, in bytes.",
4921 ),
4922 ("heap_limit", "Available heap (RAM + swap) space, in bytes."),
4923 ]),
4924 is_retained_metrics_object: false,
4925 access: vec![PUBLIC_SELECT],
4926 });
4927
4928pub static MZ_CLUSTER_REPLICA_METRICS_HISTORY_CT: LazyLock<BuiltinContinualTask> = LazyLock::new(
4929 || {
4930 BuiltinContinualTask {
4931 name: "mz_cluster_replica_metrics_history_ct",
4932 schema: MZ_INTERNAL_SCHEMA,
4933 oid: oid::CT_MZ_CLUSTER_REPLICA_METRICS_HISTORY_OID,
4934 desc: REPLICA_METRICS_HISTORY_DESC.clone(),
4935 sql: "
4936IN CLUSTER mz_catalog_server
4937ON INPUT mz_internal.mz_cluster_replica_metrics_history AS (
4938 DELETE FROM mz_internal.mz_cluster_replica_metrics_history_ct WHERE occurred_at + '30d' < mz_now();
4939 INSERT INTO mz_internal.mz_cluster_replica_metrics_history_ct SELECT * FROM mz_internal.mz_cluster_replica_metrics_history;
4940)",
4941 access: vec![PUBLIC_SELECT],
4942 }
4943 },
4944);
4945
4946pub static MZ_CLUSTER_REPLICA_METRICS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4947 name: "mz_cluster_replica_metrics",
4948 schema: MZ_INTERNAL_SCHEMA,
4949 oid: oid::VIEW_MZ_CLUSTER_REPLICA_METRICS_OID,
4950 desc: RelationDesc::builder()
4951 .with_column("replica_id", SqlScalarType::String.nullable(false))
4952 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
4953 .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(true))
4954 .with_column("memory_bytes", SqlScalarType::UInt64.nullable(true))
4955 .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true))
4956 .with_column("heap_bytes", SqlScalarType::UInt64.nullable(true))
4957 .with_column("heap_limit", SqlScalarType::UInt64.nullable(true))
4958 .with_key(vec![0, 1])
4959 .finish(),
4960 column_comments: BTreeMap::from_iter([
4961 ("replica_id", "The ID of a cluster replica."),
4962 ("process_id", "The ID of a process within the replica."),
4963 (
4964 "cpu_nano_cores",
4965 "Approximate CPU usage, in billionths of a vCPU core.",
4966 ),
4967 ("memory_bytes", "Approximate RAM usage, in bytes."),
4968 ("disk_bytes", "Approximate disk usage, in bytes."),
4969 (
4970 "heap_bytes",
4971 "Approximate heap (RAM + swap) usage, in bytes.",
4972 ),
4973 ("heap_limit", "Available heap (RAM + swap) space, in bytes."),
4974 ]),
4975 sql: "
4976SELECT
4977 DISTINCT ON (replica_id, process_id)
4978 replica_id,
4979 process_id,
4980 cpu_nano_cores,
4981 memory_bytes,
4982 disk_bytes,
4983 heap_bytes,
4984 heap_limit
4985FROM mz_internal.mz_cluster_replica_metrics_history
4986JOIN mz_cluster_replicas r ON r.id = replica_id
4987ORDER BY replica_id, process_id, occurred_at DESC",
4988 access: vec![PUBLIC_SELECT],
4989});
4990
4991pub static MZ_CLUSTER_REPLICA_FRONTIERS: LazyLock<BuiltinSource> =
4992 LazyLock::new(|| BuiltinSource {
4993 name: "mz_cluster_replica_frontiers",
4994 schema: MZ_CATALOG_SCHEMA,
4995 oid: oid::SOURCE_MZ_CLUSTER_REPLICA_FRONTIERS_OID,
4996 data_source: IntrospectionType::ReplicaFrontiers,
4997 desc: RelationDesc::builder()
4998 .with_column("object_id", SqlScalarType::String.nullable(false))
4999 .with_column("replica_id", SqlScalarType::String.nullable(false))
5000 .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true))
5001 .finish(),
5002 column_comments: BTreeMap::from_iter([
5003 (
5004 "object_id",
5005 "The ID of the source, sink, index, materialized view, or subscription.",
5006 ),
5007 ("replica_id", "The ID of a cluster replica."),
5008 (
5009 "write_frontier",
5010 "The next timestamp at which the output may change.",
5011 ),
5012 ]),
5013 is_retained_metrics_object: false,
5014 access: vec![PUBLIC_SELECT],
5015 });
5016
5017pub static MZ_CLUSTER_REPLICA_FRONTIERS_IND: LazyLock<BuiltinIndex> =
5018 LazyLock::new(|| BuiltinIndex {
5019 name: "mz_cluster_replica_frontiers_ind",
5020 schema: MZ_CATALOG_SCHEMA,
5021 oid: oid::INDEX_MZ_CLUSTER_REPLICA_FRONTIERS_IND_OID,
5022 sql: "IN CLUSTER mz_catalog_server ON mz_catalog.mz_cluster_replica_frontiers (object_id)",
5023 is_retained_metrics_object: false,
5024 });
5025
5026pub static MZ_FRONTIERS: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5027 name: "mz_frontiers",
5028 schema: MZ_INTERNAL_SCHEMA,
5029 oid: oid::SOURCE_MZ_FRONTIERS_OID,
5030 data_source: IntrospectionType::Frontiers,
5031 desc: RelationDesc::builder()
5032 .with_column("object_id", SqlScalarType::String.nullable(false))
5033 .with_column("read_frontier", SqlScalarType::MzTimestamp.nullable(true))
5034 .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true))
5035 .finish(),
5036 column_comments: BTreeMap::from_iter([
5037 (
5038 "object_id",
5039 "The ID of the source, sink, table, index, materialized view, or subscription.",
5040 ),
5041 (
5042 "read_frontier",
5043 "The earliest timestamp at which the output is still readable.",
5044 ),
5045 (
5046 "write_frontier",
5047 "The next timestamp at which the output may change.",
5048 ),
5049 ]),
5050 is_retained_metrics_object: false,
5051 access: vec![PUBLIC_SELECT],
5052});
5053
5054pub static MZ_GLOBAL_FRONTIERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5056 name: "mz_global_frontiers",
5057 schema: MZ_INTERNAL_SCHEMA,
5058 oid: oid::VIEW_MZ_GLOBAL_FRONTIERS_OID,
5059 desc: RelationDesc::builder()
5060 .with_column("object_id", SqlScalarType::String.nullable(false))
5061 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
5062 .finish(),
5063 column_comments: BTreeMap::new(),
5064 sql: "
5065SELECT object_id, write_frontier AS time
5066FROM mz_internal.mz_frontiers
5067WHERE write_frontier IS NOT NULL",
5068 access: vec![PUBLIC_SELECT],
5069});
5070
5071pub static MZ_WALLCLOCK_LAG_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5072 name: "mz_wallclock_lag_history",
5073 schema: MZ_INTERNAL_SCHEMA,
5074 oid: oid::SOURCE_MZ_WALLCLOCK_LAG_HISTORY_OID,
5075 desc: WALLCLOCK_LAG_HISTORY_DESC.clone(),
5076 data_source: IntrospectionType::WallclockLagHistory,
5077 column_comments: BTreeMap::from_iter([
5078 (
5079 "object_id",
5080 "The ID of the table, source, materialized view, index, or sink. Corresponds to `mz_objects.id`.",
5081 ),
5082 (
5083 "replica_id",
5084 "The ID of a replica computing the object, or `NULL` for persistent objects. Corresponds to `mz_cluster_replicas.id`.",
5085 ),
5086 (
5087 "lag",
5088 "The amount of time the object's write frontier lags behind wallclock time.",
5089 ),
5090 (
5091 "occurred_at",
5092 "Wall-clock timestamp at which the event occurred.",
5093 ),
5094 ]),
5095 is_retained_metrics_object: false,
5096 access: vec![PUBLIC_SELECT],
5097});
5098
5099pub static MZ_WALLCLOCK_LAG_HISTORY_CT: LazyLock<BuiltinContinualTask> = LazyLock::new(|| {
5100 BuiltinContinualTask {
5101 name: "mz_wallclock_lag_history_ct",
5102 schema: MZ_INTERNAL_SCHEMA,
5103 oid: oid::CT_MZ_WALLCLOCK_LAG_HISTORY_OID,
5104 desc: WALLCLOCK_LAG_HISTORY_DESC.clone(),
5105 sql: "
5106IN CLUSTER mz_catalog_server
5107ON INPUT mz_internal.mz_wallclock_lag_history AS (
5108 DELETE FROM mz_internal.mz_wallclock_lag_history_ct WHERE occurred_at + '30d' < mz_now();
5109 INSERT INTO mz_internal.mz_wallclock_lag_history_ct SELECT * FROM mz_internal.mz_wallclock_lag_history;
5110)",
5111 access: vec![PUBLIC_SELECT],
5112 }
5113});
5114
5115pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5116 name: "mz_wallclock_global_lag_history",
5117 schema: MZ_INTERNAL_SCHEMA,
5118 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_HISTORY_OID,
5119 desc: RelationDesc::builder()
5120 .with_column("object_id", SqlScalarType::String.nullable(false))
5121 .with_column("lag", SqlScalarType::Interval.nullable(true))
5122 .with_column(
5123 "occurred_at",
5124 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5125 )
5126 .with_key(vec![0, 2])
5127 .finish(),
5128 column_comments: BTreeMap::new(),
5129 sql: "
5130WITH times_binned AS (
5131 SELECT
5132 object_id,
5133 lag,
5134 date_trunc('minute', occurred_at) AS occurred_at
5135 FROM mz_internal.mz_wallclock_lag_history
5136)
5137SELECT
5138 object_id,
5139 min(lag) AS lag,
5140 occurred_at
5141FROM times_binned
5142GROUP BY object_id, occurred_at
5143OPTIONS (AGGREGATE INPUT GROUP SIZE = 1)",
5144 access: vec![PUBLIC_SELECT],
5145});
5146
5147pub static MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY: LazyLock<BuiltinView> =
5148 LazyLock::new(|| BuiltinView {
5149 name: "mz_wallclock_global_lag_recent_history",
5150 schema: MZ_INTERNAL_SCHEMA,
5151 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_OID,
5152 desc: RelationDesc::builder()
5153 .with_column("object_id", SqlScalarType::String.nullable(false))
5154 .with_column("lag", SqlScalarType::Interval.nullable(true))
5155 .with_column(
5156 "occurred_at",
5157 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5158 )
5159 .with_key(vec![0, 2])
5160 .finish(),
5161 column_comments: BTreeMap::new(),
5162 sql: "
5163SELECT object_id, lag, occurred_at
5164FROM mz_internal.mz_wallclock_global_lag_history
5165WHERE occurred_at + '1 day' > mz_now()",
5166 access: vec![PUBLIC_SELECT],
5167 });
5168
5169pub static MZ_WALLCLOCK_GLOBAL_LAG: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5170 name: "mz_wallclock_global_lag",
5171 schema: MZ_INTERNAL_SCHEMA,
5172 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_OID,
5173 desc: RelationDesc::builder()
5174 .with_column("object_id", SqlScalarType::String.nullable(false))
5175 .with_column("lag", SqlScalarType::Interval.nullable(true))
5176 .with_key(vec![0])
5177 .finish(),
5178 column_comments: BTreeMap::from_iter([
5179 (
5180 "object_id",
5181 "The ID of the table, source, materialized view, index, or sink. Corresponds to `mz_objects.id`.",
5182 ),
5183 (
5184 "lag",
5185 "The amount of time the object's write frontier lags behind wallclock time.",
5186 ),
5187 ]),
5188 sql: "
5189SELECT DISTINCT ON (object_id) object_id, lag
5190FROM mz_internal.mz_wallclock_global_lag_recent_history
5191WHERE occurred_at + '5 minutes' > mz_now()
5192ORDER BY object_id, occurred_at DESC",
5193 access: vec![PUBLIC_SELECT],
5194});
5195
5196pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW: LazyLock<BuiltinSource> =
5197 LazyLock::new(|| BuiltinSource {
5198 name: "mz_wallclock_global_lag_histogram_raw",
5199 schema: MZ_INTERNAL_SCHEMA,
5200 oid: oid::SOURCE_MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW_OID,
5201 desc: WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW_DESC.clone(),
5202 column_comments: BTreeMap::new(),
5203 data_source: IntrospectionType::WallclockLagHistogram,
5204 is_retained_metrics_object: false,
5205 access: vec![PUBLIC_SELECT],
5206 });
5207
5208pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM: LazyLock<BuiltinView> =
5209 LazyLock::new(|| BuiltinView {
5210 name: "mz_wallclock_global_lag_histogram",
5211 schema: MZ_INTERNAL_SCHEMA,
5212 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_OID,
5213 desc: RelationDesc::builder()
5214 .with_column(
5215 "period_start",
5216 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5217 )
5218 .with_column(
5219 "period_end",
5220 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5221 )
5222 .with_column("object_id", SqlScalarType::String.nullable(false))
5223 .with_column("lag_seconds", SqlScalarType::UInt64.nullable(true))
5224 .with_column("labels", SqlScalarType::Jsonb.nullable(false))
5225 .with_column("count", SqlScalarType::Int64.nullable(false))
5226 .with_key(vec![0, 1, 2, 3, 4])
5227 .finish(),
5228 column_comments: BTreeMap::new(),
5229 sql: "
5230SELECT *, count(*) AS count
5231FROM mz_internal.mz_wallclock_global_lag_histogram_raw
5232GROUP BY period_start, period_end, object_id, lag_seconds, labels",
5233 access: vec![PUBLIC_SELECT],
5234 });
5235
5236pub static MZ_MATERIALIZED_VIEW_REFRESHES: LazyLock<BuiltinSource> = LazyLock::new(|| {
5237 BuiltinSource {
5238 name: "mz_materialized_view_refreshes",
5239 schema: MZ_INTERNAL_SCHEMA,
5240 oid: oid::SOURCE_MZ_MATERIALIZED_VIEW_REFRESHES_OID,
5241 data_source: IntrospectionType::ComputeMaterializedViewRefreshes,
5242 desc: RelationDesc::builder()
5243 .with_column(
5244 "materialized_view_id",
5245 SqlScalarType::String.nullable(false),
5246 )
5247 .with_column(
5248 "last_completed_refresh",
5249 SqlScalarType::MzTimestamp.nullable(true),
5250 )
5251 .with_column("next_refresh", SqlScalarType::MzTimestamp.nullable(true))
5252 .finish(),
5253 column_comments: BTreeMap::from_iter([
5254 (
5255 "materialized_view_id",
5256 "The ID of the materialized view. Corresponds to `mz_catalog.mz_materialized_views.id`",
5257 ),
5258 (
5259 "last_completed_refresh",
5260 "The time of the last successfully completed refresh. `NULL` if the materialized view hasn't completed any refreshes yet.",
5261 ),
5262 (
5263 "next_refresh",
5264 "The time of the next scheduled refresh. `NULL` if the materialized view has no future scheduled refreshes.",
5265 ),
5266 ]),
5267 is_retained_metrics_object: false,
5268 access: vec![PUBLIC_SELECT],
5269 }
5270});
5271
5272pub static MZ_SUBSCRIPTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5273 name: "mz_subscriptions",
5274 schema: MZ_INTERNAL_SCHEMA,
5275 oid: oid::TABLE_MZ_SUBSCRIPTIONS_OID,
5276 desc: RelationDesc::builder()
5277 .with_column("id", SqlScalarType::String.nullable(false))
5278 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
5279 .with_column("cluster_id", SqlScalarType::String.nullable(false))
5280 .with_column(
5281 "created_at",
5282 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5283 )
5284 .with_column(
5285 "referenced_object_ids",
5286 SqlScalarType::List {
5287 element_type: Box::new(SqlScalarType::String),
5288 custom_id: None,
5289 }
5290 .nullable(false),
5291 )
5292 .finish(),
5293 column_comments: BTreeMap::from_iter([
5294 ("id", "The ID of the subscription."),
5295 (
5296 "session_id",
5297 "The ID of the session that runs the subscription. Corresponds to `mz_sessions.id`.",
5298 ),
5299 (
5300 "cluster_id",
5301 "The ID of the cluster on which the subscription is running. Corresponds to `mz_clusters.id`.",
5302 ),
5303 (
5304 "created_at",
5305 "The time at which the subscription was created.",
5306 ),
5307 (
5308 "referenced_object_ids",
5309 "The IDs of objects referenced by the subscription. Corresponds to `mz_objects.id`",
5310 ),
5311 ]),
5312 is_retained_metrics_object: false,
5313 access: vec![PUBLIC_SELECT],
5314});
5315
5316pub static MZ_SESSIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5317 name: "mz_sessions",
5318 schema: MZ_INTERNAL_SCHEMA,
5319 oid: oid::TABLE_MZ_SESSIONS_OID,
5320 desc: RelationDesc::builder()
5321 .with_column("id", SqlScalarType::Uuid.nullable(false))
5322 .with_column("connection_id", SqlScalarType::UInt32.nullable(false))
5323 .with_column("role_id", SqlScalarType::String.nullable(false))
5324 .with_column("client_ip", SqlScalarType::String.nullable(true))
5325 .with_column(
5326 "connected_at",
5327 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5328 )
5329 .finish(),
5330 column_comments: BTreeMap::from_iter([
5331 ("id", "The globally unique ID of the session."),
5332 (
5333 "connection_id",
5334 "The connection ID of the session. Unique only for active sessions and can be recycled. Corresponds to `pg_backend_pid()`.",
5335 ),
5336 (
5337 "role_id",
5338 "The role ID of the role that the session is logged in as. Corresponds to `mz_catalog.mz_roles`.",
5339 ),
5340 (
5341 "client_ip",
5342 "The IP address of the client that initiated the session.",
5343 ),
5344 (
5345 "connected_at",
5346 "The time at which the session connected to the system.",
5347 ),
5348 ]),
5349 is_retained_metrics_object: false,
5350 access: vec![PUBLIC_SELECT],
5351});
5352
5353pub static MZ_DEFAULT_PRIVILEGES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5354 name: "mz_default_privileges",
5355 schema: MZ_CATALOG_SCHEMA,
5356 oid: oid::TABLE_MZ_DEFAULT_PRIVILEGES_OID,
5357 desc: RelationDesc::builder()
5358 .with_column("role_id", SqlScalarType::String.nullable(false))
5359 .with_column("database_id", SqlScalarType::String.nullable(true))
5360 .with_column("schema_id", SqlScalarType::String.nullable(true))
5361 .with_column("object_type", SqlScalarType::String.nullable(false))
5362 .with_column("grantee", SqlScalarType::String.nullable(false))
5363 .with_column("privileges", SqlScalarType::String.nullable(false))
5364 .finish(),
5365 column_comments: BTreeMap::from_iter([
5366 (
5367 "role_id",
5368 "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.",
5369 ),
5370 (
5371 "database_id",
5372 "Privileges described in this row will be granted only on objects in the database identified by `database_id` if non-null.",
5373 ),
5374 (
5375 "schema_id",
5376 "Privileges described in this row will be granted only on objects in the schema identified by `schema_id` if non-null.",
5377 ),
5378 (
5379 "object_type",
5380 "Privileges described in this row will be granted only on objects of type `object_type`.",
5381 ),
5382 (
5383 "grantee",
5384 "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.",
5385 ),
5386 ("privileges", "The set of privileges that will be granted."),
5387 ]),
5388 is_retained_metrics_object: false,
5389 access: vec![PUBLIC_SELECT],
5390});
5391
5392pub static MZ_SYSTEM_PRIVILEGES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5393 name: "mz_system_privileges",
5394 schema: MZ_CATALOG_SCHEMA,
5395 oid: oid::TABLE_MZ_SYSTEM_PRIVILEGES_OID,
5396 desc: RelationDesc::builder()
5397 .with_column("privileges", SqlScalarType::MzAclItem.nullable(false))
5398 .finish(),
5399 column_comments: BTreeMap::from_iter([(
5400 "privileges",
5401 "The privileges belonging to the system.",
5402 )]),
5403 is_retained_metrics_object: false,
5404 access: vec![PUBLIC_SELECT],
5405});
5406
5407pub static MZ_COMMENTS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5408 name: "mz_comments",
5409 schema: MZ_INTERNAL_SCHEMA,
5410 oid: oid::TABLE_MZ_COMMENTS_OID,
5411 desc: RelationDesc::builder()
5412 .with_column("id", SqlScalarType::String.nullable(false))
5413 .with_column("object_type", SqlScalarType::String.nullable(false))
5414 .with_column("object_sub_id", SqlScalarType::Int32.nullable(true))
5415 .with_column("comment", SqlScalarType::String.nullable(false))
5416 .finish(),
5417 column_comments: BTreeMap::from_iter([
5418 (
5419 "id",
5420 "The ID of the object. Corresponds to `mz_objects.id`.",
5421 ),
5422 (
5423 "object_type",
5424 "The type of object the comment is associated with.",
5425 ),
5426 (
5427 "object_sub_id",
5428 "For a comment on a column of a relation, the column number. `NULL` for other object types.",
5429 ),
5430 ("comment", "The comment itself."),
5431 ]),
5432 is_retained_metrics_object: false,
5433 access: vec![PUBLIC_SELECT],
5434});
5435
5436pub static MZ_SOURCE_REFERENCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5437 name: "mz_source_references",
5438 schema: MZ_INTERNAL_SCHEMA,
5439 oid: oid::TABLE_MZ_SOURCE_REFERENCES_OID,
5440 desc: RelationDesc::builder()
5441 .with_column("source_id", SqlScalarType::String.nullable(false))
5442 .with_column("namespace", SqlScalarType::String.nullable(true))
5443 .with_column("name", SqlScalarType::String.nullable(false))
5444 .with_column(
5445 "updated_at",
5446 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5447 )
5448 .with_column(
5449 "columns",
5450 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
5451 )
5452 .finish(),
5453 column_comments: BTreeMap::new(),
5454 is_retained_metrics_object: false,
5455 access: vec![PUBLIC_SELECT],
5456});
5457
5458pub static MZ_WEBHOOKS_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5459 name: "mz_webhook_sources",
5460 schema: MZ_INTERNAL_SCHEMA,
5461 oid: oid::TABLE_MZ_WEBHOOK_SOURCES_OID,
5462 desc: RelationDesc::builder()
5463 .with_column("id", SqlScalarType::String.nullable(false))
5464 .with_column("name", SqlScalarType::String.nullable(false))
5465 .with_column("url", SqlScalarType::String.nullable(false))
5466 .finish(),
5467 column_comments: BTreeMap::from_iter([
5468 (
5469 "id",
5470 "The ID of the webhook source. Corresponds to `mz_sources.id`.",
5471 ),
5472 ("name", "The name of the webhook source."),
5473 (
5474 "url",
5475 "The URL which can be used to send events to the source.",
5476 ),
5477 ]),
5478 is_retained_metrics_object: false,
5479 access: vec![PUBLIC_SELECT],
5480});
5481
5482pub static MZ_HISTORY_RETENTION_STRATEGIES: LazyLock<BuiltinTable> = LazyLock::new(|| {
5483 BuiltinTable {
5484 name: "mz_history_retention_strategies",
5485 schema: MZ_INTERNAL_SCHEMA,
5486 oid: oid::TABLE_MZ_HISTORY_RETENTION_STRATEGIES_OID,
5487 desc: RelationDesc::builder()
5488 .with_column("id", SqlScalarType::String.nullable(false))
5489 .with_column("strategy", SqlScalarType::String.nullable(false))
5490 .with_column("value", SqlScalarType::Jsonb.nullable(false))
5491 .finish(),
5492 column_comments: BTreeMap::from_iter([
5493 ("id", "The ID of the object."),
5494 (
5495 "strategy",
5496 "The strategy. `FOR` is the only strategy, and means the object's compaction window is the duration of the `value` field.",
5497 ),
5498 (
5499 "value",
5500 "The value of the strategy. For `FOR`, is a number of milliseconds.",
5501 ),
5502 ]),
5503 is_retained_metrics_object: false,
5504 access: vec![PUBLIC_SELECT],
5505 }
5506});
5507
5508pub static MZ_LICENSE_KEYS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5509 name: "mz_license_keys",
5510 schema: MZ_INTERNAL_SCHEMA,
5511 oid: oid::TABLE_MZ_LICENSE_KEYS_OID,
5512 desc: RelationDesc::builder()
5513 .with_column("id", SqlScalarType::String.nullable(false))
5514 .with_column("organization", SqlScalarType::String.nullable(false))
5515 .with_column("environment_id", SqlScalarType::String.nullable(false))
5516 .with_column(
5517 "expiration",
5518 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5519 )
5520 .with_column(
5521 "not_before",
5522 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5523 )
5524 .finish(),
5525 column_comments: BTreeMap::from_iter([
5526 ("id", "The identifier of the license key."),
5527 (
5528 "organization",
5529 "The name of the organization that this license key was issued to.",
5530 ),
5531 (
5532 "environment_id",
5533 "The environment ID that this license key was issued for.",
5534 ),
5535 (
5536 "expiration",
5537 "The date and time when this license key expires.",
5538 ),
5539 (
5540 "not_before",
5541 "The start of the validity period for this license key.",
5542 ),
5543 ]),
5544 is_retained_metrics_object: false,
5545 access: vec![PUBLIC_SELECT],
5546});
5547
5548pub static MZ_SOURCE_STATISTICS_RAW: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5551 name: "mz_source_statistics_raw",
5552 schema: MZ_INTERNAL_SCHEMA,
5553 oid: oid::SOURCE_MZ_SOURCE_STATISTICS_RAW_OID,
5554 data_source: IntrospectionType::StorageSourceStatistics,
5555 desc: MZ_SOURCE_STATISTICS_RAW_DESC.clone(),
5556 column_comments: BTreeMap::new(),
5557 is_retained_metrics_object: true,
5558 access: vec![PUBLIC_SELECT],
5559});
5560pub static MZ_SINK_STATISTICS_RAW: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5561 name: "mz_sink_statistics_raw",
5562 schema: MZ_INTERNAL_SCHEMA,
5563 oid: oid::SOURCE_MZ_SINK_STATISTICS_RAW_OID,
5564 data_source: IntrospectionType::StorageSinkStatistics,
5565 desc: MZ_SINK_STATISTICS_RAW_DESC.clone(),
5566 column_comments: BTreeMap::new(),
5567 is_retained_metrics_object: true,
5568 access: vec![PUBLIC_SELECT],
5569});
5570
5571pub static MZ_STORAGE_SHARDS: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5572 name: "mz_storage_shards",
5573 schema: MZ_INTERNAL_SCHEMA,
5574 oid: oid::SOURCE_MZ_STORAGE_SHARDS_OID,
5575 data_source: IntrospectionType::ShardMapping,
5576 desc: RelationDesc::builder()
5577 .with_column("object_id", SqlScalarType::String.nullable(false))
5578 .with_column("shard_id", SqlScalarType::String.nullable(false))
5579 .finish(),
5580 column_comments: BTreeMap::new(),
5581 is_retained_metrics_object: false,
5582 access: vec![PUBLIC_SELECT],
5583});
5584
5585pub static MZ_STORAGE_USAGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5586 name: "mz_storage_usage",
5587 schema: MZ_CATALOG_SCHEMA,
5588 oid: oid::VIEW_MZ_STORAGE_USAGE_OID,
5589 desc: RelationDesc::builder()
5590 .with_column("object_id", SqlScalarType::String.nullable(false))
5591 .with_column("size_bytes", SqlScalarType::UInt64.nullable(false))
5592 .with_column(
5593 "collection_timestamp",
5594 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5595 )
5596 .with_key(vec![0, 2])
5597 .finish(),
5598 column_comments: BTreeMap::from_iter([
5599 (
5600 "object_id",
5601 "The ID of the table, source, or materialized view.",
5602 ),
5603 (
5604 "size_bytes",
5605 "The number of storage bytes used by the object.",
5606 ),
5607 (
5608 "collection_timestamp",
5609 "The time at which storage usage of the object was assessed.",
5610 ),
5611 ]),
5612 sql: "
5613SELECT
5614 object_id,
5615 sum(size_bytes)::uint8 AS size_bytes,
5616 collection_timestamp
5617FROM
5618 mz_internal.mz_storage_shards
5619 JOIN mz_internal.mz_storage_usage_by_shard USING (shard_id)
5620GROUP BY object_id, collection_timestamp",
5621 access: vec![PUBLIC_SELECT],
5622});
5623
5624pub static MZ_RECENT_STORAGE_USAGE: LazyLock<BuiltinView> = LazyLock::new(|| {
5625 BuiltinView {
5626 name: "mz_recent_storage_usage",
5627 schema: MZ_CATALOG_SCHEMA,
5628 oid: oid::VIEW_MZ_RECENT_STORAGE_USAGE_OID,
5629 desc: RelationDesc::builder()
5630 .with_column("object_id", SqlScalarType::String.nullable(false))
5631 .with_column("size_bytes", SqlScalarType::UInt64.nullable(true))
5632 .with_key(vec![0])
5633 .finish(),
5634 column_comments: BTreeMap::from_iter([
5635 ("object_id", "The ID of the table, source, or materialized view."),
5636 ("size_bytes", "The number of storage bytes used by the object in the most recent assessment."),
5637 ]),
5638 sql: "
5639WITH
5640
5641recent_storage_usage_by_shard AS (
5642 SELECT shard_id, size_bytes, collection_timestamp
5643 FROM mz_internal.mz_storage_usage_by_shard
5644 -- Restricting to the last 6 hours makes it feasible to index the view.
5645 WHERE collection_timestamp + '6 hours' >= mz_now()
5646),
5647
5648most_recent_collection_timestamp_by_shard AS (
5649 SELECT shard_id, max(collection_timestamp) AS collection_timestamp
5650 FROM recent_storage_usage_by_shard
5651 GROUP BY shard_id
5652)
5653
5654SELECT
5655 object_id,
5656 sum(size_bytes)::uint8 AS size_bytes
5657FROM
5658 mz_internal.mz_storage_shards
5659 LEFT JOIN most_recent_collection_timestamp_by_shard
5660 ON mz_storage_shards.shard_id = most_recent_collection_timestamp_by_shard.shard_id
5661 LEFT JOIN recent_storage_usage_by_shard
5662 ON mz_storage_shards.shard_id = recent_storage_usage_by_shard.shard_id
5663 AND most_recent_collection_timestamp_by_shard.collection_timestamp = recent_storage_usage_by_shard.collection_timestamp
5664GROUP BY object_id",
5665 access: vec![PUBLIC_SELECT],
5666}
5667});
5668
5669pub static MZ_RECENT_STORAGE_USAGE_IND: LazyLock<BuiltinIndex> = LazyLock::new(|| BuiltinIndex {
5670 name: "mz_recent_storage_usage_ind",
5671 schema: MZ_CATALOG_SCHEMA,
5672 oid: oid::INDEX_MZ_RECENT_STORAGE_USAGE_IND_OID,
5673 sql: "IN CLUSTER mz_catalog_server ON mz_catalog.mz_recent_storage_usage (object_id)",
5674 is_retained_metrics_object: false,
5675});
5676
5677pub static MZ_RELATIONS: LazyLock<BuiltinView> = LazyLock::new(|| {
5678 BuiltinView {
5679 name: "mz_relations",
5680 schema: MZ_CATALOG_SCHEMA,
5681 oid: oid::VIEW_MZ_RELATIONS_OID,
5682 desc: RelationDesc::builder()
5683 .with_column("id", SqlScalarType::String.nullable(false))
5684 .with_column("oid", SqlScalarType::Oid.nullable(false))
5685 .with_column("schema_id", SqlScalarType::String.nullable(false))
5686 .with_column("name", SqlScalarType::String.nullable(false))
5687 .with_column("type", SqlScalarType::String.nullable(false))
5688 .with_column("owner_id", SqlScalarType::String.nullable(false))
5689 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5690 .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false))
5691 .finish(),
5692 column_comments: BTreeMap::from_iter([
5693 ("id", "Materialize's unique ID for the relation."),
5694 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the relation."),
5695 ("schema_id", "The ID of the schema to which the relation belongs. Corresponds to `mz_schemas.id`."),
5696 ("name", "The name of the relation."),
5697 ("type", "The type of the relation: either `table`, `source`, `view`, or `materialized view`."),
5698 ("owner_id", "The role ID of the owner of the relation. Corresponds to `mz_roles.id`."),
5699 ("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."),
5700 ("privileges", "The privileges belonging to the relation."),
5701 ]),
5702 sql: "
5703 SELECT id, oid, schema_id, name, 'table' AS type, owner_id, NULL::text AS cluster_id, privileges FROM mz_catalog.mz_tables
5704UNION ALL SELECT id, oid, schema_id, name, 'source', owner_id, cluster_id, privileges FROM mz_catalog.mz_sources
5705UNION ALL SELECT id, oid, schema_id, name, 'view', owner_id, NULL::text, privileges FROM mz_catalog.mz_views
5706UNION ALL SELECT id, oid, schema_id, name, 'materialized-view', owner_id, cluster_id, privileges FROM mz_catalog.mz_materialized_views
5707UNION ALL SELECT id, oid, schema_id, name, 'continual-task', owner_id, cluster_id, privileges FROM mz_internal.mz_continual_tasks",
5708 access: vec![PUBLIC_SELECT],
5709 }
5710});
5711
5712pub static MZ_OBJECTS_ID_NAMESPACE_TYPES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5713 name: "mz_objects_id_namespace_types",
5714 schema: MZ_INTERNAL_SCHEMA,
5715 oid: oid::VIEW_MZ_OBJECTS_ID_NAMESPACE_TYPES_OID,
5716 desc: RelationDesc::builder()
5717 .with_column("object_type", SqlScalarType::String.nullable(false))
5718 .with_key(vec![0])
5719 .finish(),
5720 column_comments: BTreeMap::new(),
5721 sql: r#"SELECT *
5722 FROM (
5723 VALUES
5724 ('table'),
5725 ('view'),
5726 ('materialized-view'),
5727 ('source'),
5728 ('sink'),
5729 ('index'),
5730 ('connection'),
5731 ('type'),
5732 ('function'),
5733 ('secret')
5734 )
5735 AS _ (object_type)"#,
5736 access: vec![PUBLIC_SELECT],
5737});
5738
5739pub static MZ_OBJECT_OID_ALIAS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5740 name: "mz_object_oid_alias",
5741 schema: MZ_INTERNAL_SCHEMA,
5742 oid: oid::VIEW_MZ_OBJECT_OID_ALIAS_OID,
5743 desc: RelationDesc::builder()
5744 .with_column("object_type", SqlScalarType::String.nullable(false))
5745 .with_column("oid_alias", SqlScalarType::String.nullable(false))
5746 .with_key(vec![0])
5747 .finish(),
5748 column_comments: BTreeMap::new(),
5749 sql: "SELECT object_type, oid_alias
5750 FROM (
5751 VALUES
5752 (
5753 'table'::pg_catalog.text,
5754 'regclass'::pg_catalog.text
5755 ),
5756 ('source', 'regclass'),
5757 ('view', 'regclass'),
5758 ('materialized-view', 'regclass'),
5759 ('index', 'regclass'),
5760 ('type', 'regtype'),
5761 ('function', 'regproc')
5762 )
5763 AS _ (object_type, oid_alias);",
5764 access: vec![PUBLIC_SELECT],
5765});
5766
5767pub static MZ_OBJECTS: LazyLock<BuiltinView> = LazyLock::new(|| {
5768 BuiltinView {
5769 name: "mz_objects",
5770 schema: MZ_CATALOG_SCHEMA,
5771 oid: oid::VIEW_MZ_OBJECTS_OID,
5772 desc: RelationDesc::builder()
5773 .with_column("id", SqlScalarType::String.nullable(false))
5774 .with_column("oid", SqlScalarType::Oid.nullable(false))
5775 .with_column("schema_id", SqlScalarType::String.nullable(false))
5776 .with_column("name", SqlScalarType::String.nullable(false))
5777 .with_column("type", SqlScalarType::String.nullable(false))
5778 .with_column("owner_id", SqlScalarType::String.nullable(false))
5779 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5780 .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(true))
5781 .finish(),
5782 column_comments: BTreeMap::from_iter([
5783 ("id", "Materialize's unique ID for the object."),
5784 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the object."),
5785 ("schema_id", "The ID of the schema to which the object belongs. Corresponds to `mz_schemas.id`."),
5786 ("name", "The name of the object."),
5787 ("type", "The type of the object: one of `table`, `source`, `view`, `materialized-view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`."),
5788 ("owner_id", "The role ID of the owner of the object. Corresponds to `mz_roles.id`."),
5789 ("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."),
5790 ("privileges", "The privileges belonging to the object."),
5791 ]),
5792 sql:
5793 "SELECT id, oid, schema_id, name, type, owner_id, cluster_id, privileges FROM mz_catalog.mz_relations
5794UNION ALL
5795 SELECT id, oid, schema_id, name, 'sink', owner_id, cluster_id, NULL::mz_catalog.mz_aclitem[] FROM mz_catalog.mz_sinks
5796UNION ALL
5797 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[]
5798 FROM mz_catalog.mz_indexes
5799 JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
5800UNION ALL
5801 SELECT id, oid, schema_id, name, 'connection', owner_id, NULL::text, privileges FROM mz_catalog.mz_connections
5802UNION ALL
5803 SELECT id, oid, schema_id, name, 'type', owner_id, NULL::text, privileges FROM mz_catalog.mz_types
5804UNION ALL
5805 SELECT id, oid, schema_id, name, 'function', owner_id, NULL::text, NULL::mz_catalog.mz_aclitem[] FROM mz_catalog.mz_functions
5806UNION ALL
5807 SELECT id, oid, schema_id, name, 'secret', owner_id, NULL::text, privileges FROM mz_catalog.mz_secrets",
5808 access: vec![PUBLIC_SELECT],
5809 }
5810});
5811
5812pub static MZ_OBJECT_FULLY_QUALIFIED_NAMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5813 name: "mz_object_fully_qualified_names",
5814 schema: MZ_INTERNAL_SCHEMA,
5815 oid: oid::VIEW_MZ_OBJECT_FULLY_QUALIFIED_NAMES_OID,
5816 desc: RelationDesc::builder()
5817 .with_column("id", SqlScalarType::String.nullable(false))
5818 .with_column("name", SqlScalarType::String.nullable(false))
5819 .with_column("object_type", SqlScalarType::String.nullable(false))
5820 .with_column("schema_id", SqlScalarType::String.nullable(false))
5821 .with_column("schema_name", SqlScalarType::String.nullable(false))
5822 .with_column("database_id", SqlScalarType::String.nullable(true))
5823 .with_column("database_name", SqlScalarType::String.nullable(true))
5824 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5825 .finish(),
5826 column_comments: BTreeMap::from_iter([
5827 ("id", "Materialize's unique ID for the object."),
5828 ("name", "The name of the object."),
5829 (
5830 "object_type",
5831 "The type of the object: one of `table`, `source`, `view`, `materialized view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`.",
5832 ),
5833 (
5834 "schema_id",
5835 "The ID of the schema to which the object belongs. Corresponds to `mz_schemas.id`.",
5836 ),
5837 (
5838 "schema_name",
5839 "The name of the schema to which the object belongs. Corresponds to `mz_schemas.name`.",
5840 ),
5841 (
5842 "database_id",
5843 "The ID of the database to which the object belongs. Corresponds to `mz_databases.id`.",
5844 ),
5845 (
5846 "database_name",
5847 "The name of the database to which the object belongs. Corresponds to `mz_databases.name`.",
5848 ),
5849 (
5850 "cluster_id",
5851 "The ID of the cluster maintaining the source, materialized view, index, or sink. Corresponds to `mz_clusters.id`. `NULL` for other object types.",
5852 ),
5853 ]),
5854 sql: "
5855 SELECT o.id,
5856 o.name,
5857 o.type as object_type,
5858 sc.id as schema_id,
5859 sc.name as schema_name,
5860 db.id as database_id,
5861 db.name as database_name,
5862 o.cluster_id
5863 FROM mz_catalog.mz_objects o
5864 INNER JOIN mz_catalog.mz_schemas sc ON sc.id = o.schema_id
5865 -- LEFT JOIN accounts for objects in the ambient database.
5866 LEFT JOIN mz_catalog.mz_databases db ON db.id = sc.database_id",
5867 access: vec![PUBLIC_SELECT],
5868});
5869
5870pub static MZ_OBJECT_GLOBAL_IDS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5871 name: "mz_object_global_ids",
5872 schema: MZ_INTERNAL_SCHEMA,
5873 oid: oid::VIEW_MZ_OBJECT_GLOBAL_IDS_OID,
5874 desc: RelationDesc::builder()
5875 .with_column("id", SqlScalarType::String.nullable(false))
5876 .with_column("global_id", SqlScalarType::String.nullable(false))
5877 .finish(),
5878 column_comments: BTreeMap::from_iter([
5879 ("id", "Materialize's unique catalog item ID for the object."),
5880 ("global_id", "A global ID for the object."),
5881 ]),
5882 is_retained_metrics_object: false,
5883 access: vec![PUBLIC_SELECT],
5884});
5885
5886pub static MZ_OBJECT_LIFETIMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5888 name: "mz_object_lifetimes",
5889 schema: MZ_INTERNAL_SCHEMA,
5890 oid: oid::VIEW_MZ_OBJECT_LIFETIMES_OID,
5891 desc: RelationDesc::builder()
5892 .with_column("id", SqlScalarType::String.nullable(true))
5893 .with_column("previous_id", SqlScalarType::String.nullable(true))
5894 .with_column("object_type", SqlScalarType::String.nullable(false))
5895 .with_column("event_type", SqlScalarType::String.nullable(false))
5896 .with_column(
5897 "occurred_at",
5898 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5899 )
5900 .finish(),
5901 column_comments: BTreeMap::from_iter([
5902 ("id", "Materialize's unique ID for the object."),
5903 ("previous_id", "The object's previous ID, if one exists."),
5904 (
5905 "object_type",
5906 "The type of the object: one of `table`, `source`, `view`, `materialized view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`.",
5907 ),
5908 (
5909 "event_type",
5910 "The lifetime event, either `create` or `drop`.",
5911 ),
5912 (
5913 "occurred_at",
5914 "Wall-clock timestamp of when the event occurred.",
5915 ),
5916 ]),
5917 sql: "
5918 SELECT
5919 CASE
5920 WHEN a.object_type = 'cluster-replica' THEN a.details ->> 'replica_id'
5921 ELSE a.details ->> 'id'
5922 END id,
5923 a.details ->> 'previous_id' as previous_id,
5924 a.object_type,
5925 a.event_type,
5926 a.occurred_at
5927 FROM mz_catalog.mz_audit_events a
5928 WHERE a.event_type = 'create' OR a.event_type = 'drop'",
5929 access: vec![PUBLIC_SELECT],
5930});
5931
5932pub static MZ_OBJECT_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5933 name: "mz_object_history",
5934 schema: MZ_INTERNAL_SCHEMA,
5935 oid: oid::VIEW_MZ_OBJECT_HISTORY_OID,
5936 desc: RelationDesc::builder()
5937 .with_column("id", SqlScalarType::String.nullable(true))
5938 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5939 .with_column("object_type", SqlScalarType::String.nullable(false))
5940 .with_column(
5941 "created_at",
5942 SqlScalarType::TimestampTz { precision: None }.nullable(true),
5943 )
5944 .with_column(
5945 "dropped_at",
5946 SqlScalarType::TimestampTz { precision: None }.nullable(true),
5947 )
5948 .finish(),
5949 column_comments: BTreeMap::from_iter([
5950 ("id", "Materialize's unique ID for the object."),
5951 (
5952 "cluster_id",
5953 "The object's cluster ID. `NULL` if the object has no associated cluster.",
5954 ),
5955 (
5956 "object_type",
5957 "The type of the object: one of `table`, `source`, `view`, `materialized view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`.",
5958 ),
5959 (
5960 "created_at",
5961 "Wall-clock timestamp of when the object was created. `NULL` for built in system objects.",
5962 ),
5963 (
5964 "dropped_at",
5965 "Wall-clock timestamp of when the object was dropped. `NULL` for built in system objects or if the object hasn't been dropped.",
5966 ),
5967 ]),
5968 sql: r#"
5969 WITH
5970 creates AS
5971 (
5972 SELECT
5973 details ->> 'id' AS id,
5974 -- We need to backfill cluster_id since older object create events don't include the cluster ID in the audit log
5975 COALESCE(details ->> 'cluster_id', objects.cluster_id) AS cluster_id,
5976 object_type,
5977 occurred_at
5978 FROM
5979 mz_catalog.mz_audit_events AS events
5980 LEFT JOIN mz_catalog.mz_objects AS objects ON details ->> 'id' = objects.id
5981 WHERE event_type = 'create' AND object_type IN ( SELECT object_type FROM mz_internal.mz_objects_id_namespace_types )
5982 ),
5983 drops AS
5984 (
5985 SELECT details ->> 'id' AS id, occurred_at
5986 FROM mz_catalog.mz_audit_events
5987 WHERE event_type = 'drop' AND object_type IN ( SELECT object_type FROM mz_internal.mz_objects_id_namespace_types )
5988 ),
5989 user_object_history AS
5990 (
5991 SELECT
5992 creates.id,
5993 creates.cluster_id,
5994 creates.object_type,
5995 creates.occurred_at AS created_at,
5996 drops.occurred_at AS dropped_at
5997 FROM creates LEFT JOIN drops ON creates.id = drops.id
5998 WHERE creates.id LIKE 'u%'
5999 ),
6000 -- We need to union built in objects since they aren't in the audit log
6001 built_in_objects AS
6002 (
6003 -- Functions that accept different arguments have different oids but the same id. We deduplicate in this case.
6004 SELECT DISTINCT ON (objects.id)
6005 objects.id,
6006 objects.cluster_id,
6007 objects.type AS object_type,
6008 NULL::timestamptz AS created_at,
6009 NULL::timestamptz AS dropped_at
6010 FROM mz_catalog.mz_objects AS objects
6011 WHERE objects.id LIKE 's%'
6012 )
6013 SELECT * FROM user_object_history UNION ALL (SELECT * FROM built_in_objects)"#,
6014 access: vec![PUBLIC_SELECT],
6015});
6016
6017pub static MZ_DATAFLOWS_PER_WORKER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6018 name: "mz_dataflows_per_worker",
6019 schema: MZ_INTROSPECTION_SCHEMA,
6020 oid: oid::VIEW_MZ_DATAFLOWS_PER_WORKER_OID,
6021 desc: RelationDesc::builder()
6022 .with_column("id", SqlScalarType::UInt64.nullable(true))
6023 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6024 .with_column("name", SqlScalarType::String.nullable(false))
6025 .finish(),
6026 column_comments: BTreeMap::new(),
6027 sql: "SELECT
6028 addrs.address[1] AS id,
6029 ops.worker_id,
6030 ops.name
6031FROM
6032 mz_introspection.mz_dataflow_addresses_per_worker addrs,
6033 mz_introspection.mz_dataflow_operators_per_worker ops
6034WHERE
6035 addrs.id = ops.id AND
6036 addrs.worker_id = ops.worker_id AND
6037 mz_catalog.list_length(addrs.address) = 1",
6038 access: vec![PUBLIC_SELECT],
6039});
6040
6041pub static MZ_DATAFLOWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6042 name: "mz_dataflows",
6043 schema: MZ_INTROSPECTION_SCHEMA,
6044 oid: oid::VIEW_MZ_DATAFLOWS_OID,
6045 desc: RelationDesc::builder()
6046 .with_column("id", SqlScalarType::UInt64.nullable(true))
6047 .with_column("name", SqlScalarType::String.nullable(false))
6048 .finish(),
6049 column_comments: BTreeMap::from_iter([
6050 ("id", "The ID of the dataflow."),
6051 ("name", "The internal name of the dataflow."),
6052 ]),
6053 sql: "
6054SELECT id, name
6055FROM mz_introspection.mz_dataflows_per_worker
6056WHERE worker_id = 0",
6057 access: vec![PUBLIC_SELECT],
6058});
6059
6060pub static MZ_DATAFLOW_ADDRESSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6061 name: "mz_dataflow_addresses",
6062 schema: MZ_INTROSPECTION_SCHEMA,
6063 oid: oid::VIEW_MZ_DATAFLOW_ADDRESSES_OID,
6064 desc: RelationDesc::builder()
6065 .with_column("id", SqlScalarType::UInt64.nullable(false))
6066 .with_column(
6067 "address",
6068 SqlScalarType::List {
6069 element_type: Box::new(SqlScalarType::UInt64),
6070 custom_id: None,
6071 }
6072 .nullable(false),
6073 )
6074 .finish(),
6075 column_comments: BTreeMap::from_iter([
6076 (
6077 "id",
6078 "The ID of the channel or operator. Corresponds to `mz_dataflow_channels.id` or `mz_dataflow_operators.id`.",
6079 ),
6080 (
6081 "address",
6082 "A list of scope-local indexes indicating the path from the root to this channel or operator.",
6083 ),
6084 ]),
6085 sql: "
6086SELECT id, address
6087FROM mz_introspection.mz_dataflow_addresses_per_worker
6088WHERE worker_id = 0",
6089 access: vec![PUBLIC_SELECT],
6090});
6091
6092pub static MZ_DATAFLOW_CHANNELS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6093 name: "mz_dataflow_channels",
6094 schema: MZ_INTROSPECTION_SCHEMA,
6095 oid: oid::VIEW_MZ_DATAFLOW_CHANNELS_OID,
6096 desc: RelationDesc::builder()
6097 .with_column("id", SqlScalarType::UInt64.nullable(false))
6098 .with_column("from_index", SqlScalarType::UInt64.nullable(false))
6099 .with_column("from_port", SqlScalarType::UInt64.nullable(false))
6100 .with_column("to_index", SqlScalarType::UInt64.nullable(false))
6101 .with_column("to_port", SqlScalarType::UInt64.nullable(false))
6102 .with_column("type", SqlScalarType::String.nullable(false))
6103 .finish(),
6104 column_comments: BTreeMap::from_iter([
6105 ("id", "The ID of the channel."),
6106 (
6107 "from_index",
6108 "The scope-local index of the source operator. Corresponds to `mz_dataflow_addresses.address`.",
6109 ),
6110 ("from_port", "The source operator's output port."),
6111 (
6112 "to_index",
6113 "The scope-local index of the target operator. Corresponds to `mz_dataflow_addresses.address`.",
6114 ),
6115 ("to_port", "The target operator's input port."),
6116 ("type", "The container type of the channel."),
6117 ]),
6118 sql: "
6119SELECT id, from_index, from_port, to_index, to_port, type
6120FROM mz_introspection.mz_dataflow_channels_per_worker
6121WHERE worker_id = 0",
6122 access: vec![PUBLIC_SELECT],
6123});
6124
6125pub static MZ_DATAFLOW_OPERATORS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6126 name: "mz_dataflow_operators",
6127 schema: MZ_INTROSPECTION_SCHEMA,
6128 oid: oid::VIEW_MZ_DATAFLOW_OPERATORS_OID,
6129 desc: RelationDesc::builder()
6130 .with_column("id", SqlScalarType::UInt64.nullable(false))
6131 .with_column("name", SqlScalarType::String.nullable(false))
6132 .finish(),
6133 column_comments: BTreeMap::from_iter([
6134 ("id", "The ID of the operator."),
6135 ("name", "The internal name of the operator."),
6136 ]),
6137 sql: "
6138SELECT id, name
6139FROM mz_introspection.mz_dataflow_operators_per_worker
6140WHERE worker_id = 0",
6141 access: vec![PUBLIC_SELECT],
6142});
6143
6144pub static MZ_DATAFLOW_GLOBAL_IDS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6145 name: "mz_dataflow_global_ids",
6146 schema: MZ_INTROSPECTION_SCHEMA,
6147 oid: oid::VIEW_MZ_DATAFLOW_GLOBAL_IDS_OID,
6148 desc: RelationDesc::builder()
6149 .with_column("id", SqlScalarType::UInt64.nullable(false))
6150 .with_column("global_id", SqlScalarType::String.nullable(false))
6151 .finish(),
6152 column_comments: BTreeMap::from_iter([
6153 ("id", "The dataflow ID."),
6154 ("global_id", "A global ID associated with that dataflow."),
6155 ]),
6156 sql: "
6157SELECT id, global_id
6158FROM mz_introspection.mz_compute_dataflow_global_ids_per_worker
6159WHERE worker_id = 0",
6160 access: vec![PUBLIC_SELECT],
6161});
6162
6163pub static MZ_MAPPABLE_OBJECTS: LazyLock<BuiltinView> = LazyLock::new(|| {
6164 BuiltinView {
6165 name: "mz_mappable_objects",
6166 schema: MZ_INTROSPECTION_SCHEMA,
6167 oid: oid::VIEW_MZ_MAPPABLE_OBJECTS_OID,
6168 desc: RelationDesc::builder()
6169 .with_column("name", SqlScalarType::String.nullable(false))
6170 .with_column("global_id", SqlScalarType::String.nullable(false))
6171 .finish(),
6172 column_comments: BTreeMap::from_iter([
6173 ("name", "The name of the object."),
6174 ("global_id", "The global ID of the object."),
6175 ]),
6176 sql: "
6177SELECT COALESCE(quote_ident(md.name) || '.', '') || quote_ident(ms.name) || '.' || quote_ident(mo.name) AS name, mgi.global_id AS global_id
6178FROM mz_catalog.mz_objects mo
6179 JOIN mz_introspection.mz_compute_exports mce ON (mo.id = mce.export_id)
6180 JOIN mz_catalog.mz_schemas ms ON (mo.schema_id = ms.id)
6181 JOIN mz_introspection.mz_dataflow_global_ids mgi ON (mce.dataflow_id = mgi.id)
6182 LEFT JOIN mz_catalog.mz_databases md ON (ms.database_id = md.id);",
6183 access: vec![PUBLIC_SELECT],
6184}
6185});
6186
6187pub static MZ_LIR_MAPPING: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6188 name: "mz_lir_mapping",
6189 schema: MZ_INTROSPECTION_SCHEMA,
6190 oid: oid::VIEW_MZ_LIR_MAPPING_OID,
6191 desc: RelationDesc::builder()
6192 .with_column("global_id", SqlScalarType::String.nullable(false))
6193 .with_column("lir_id", SqlScalarType::UInt64.nullable(false))
6194 .with_column("operator", SqlScalarType::String.nullable(false))
6195 .with_column("parent_lir_id", SqlScalarType::UInt64.nullable(true))
6196 .with_column("nesting", SqlScalarType::UInt16.nullable(false))
6197 .with_column("operator_id_start", SqlScalarType::UInt64.nullable(false))
6198 .with_column("operator_id_end", SqlScalarType::UInt64.nullable(false))
6199 .finish(),
6200 column_comments: BTreeMap::from_iter([
6201 ("global_id", "The global ID."),
6202 ("lir_id", "The LIR node ID."),
6203 (
6204 "operator",
6205 "The LIR operator, in the format `OperatorName INPUTS [OPTIONS]`.",
6206 ),
6207 (
6208 "parent_lir_id",
6209 "The parent of this LIR node. May be `NULL`.",
6210 ),
6211 ("nesting", "The nesting level of this LIR node."),
6212 (
6213 "operator_id_start",
6214 "The first dataflow operator ID implementing this LIR operator (inclusive).",
6215 ),
6216 (
6217 "operator_id_end",
6218 "The first dataflow operator ID after this LIR operator (exclusive).",
6219 ),
6220 ]),
6221 sql: "
6222SELECT global_id, lir_id, operator, parent_lir_id, nesting, operator_id_start, operator_id_end
6223FROM mz_introspection.mz_compute_lir_mapping_per_worker
6224WHERE worker_id = 0",
6225 access: vec![PUBLIC_SELECT],
6226});
6227
6228pub static MZ_DATAFLOW_OPERATOR_DATAFLOWS_PER_WORKER: LazyLock<BuiltinView> =
6229 LazyLock::new(|| BuiltinView {
6230 name: "mz_dataflow_operator_dataflows_per_worker",
6231 schema: MZ_INTROSPECTION_SCHEMA,
6232 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_DATAFLOWS_PER_WORKER_OID,
6233 desc: RelationDesc::builder()
6234 .with_column("id", SqlScalarType::UInt64.nullable(false))
6235 .with_column("name", SqlScalarType::String.nullable(false))
6236 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6237 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6238 .with_column("dataflow_name", SqlScalarType::String.nullable(false))
6239 .finish(),
6240 column_comments: BTreeMap::new(),
6241 sql: "SELECT
6242 ops.id,
6243 ops.name,
6244 ops.worker_id,
6245 dfs.id as dataflow_id,
6246 dfs.name as dataflow_name
6247FROM
6248 mz_introspection.mz_dataflow_operators_per_worker ops,
6249 mz_introspection.mz_dataflow_addresses_per_worker addrs,
6250 mz_introspection.mz_dataflows_per_worker dfs
6251WHERE
6252 ops.id = addrs.id AND
6253 ops.worker_id = addrs.worker_id AND
6254 dfs.id = addrs.address[1] AND
6255 dfs.worker_id = addrs.worker_id",
6256 access: vec![PUBLIC_SELECT],
6257 });
6258
6259pub static MZ_DATAFLOW_OPERATOR_DATAFLOWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6260 name: "mz_dataflow_operator_dataflows",
6261 schema: MZ_INTROSPECTION_SCHEMA,
6262 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_DATAFLOWS_OID,
6263 desc: RelationDesc::builder()
6264 .with_column("id", SqlScalarType::UInt64.nullable(false))
6265 .with_column("name", SqlScalarType::String.nullable(false))
6266 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6267 .with_column("dataflow_name", SqlScalarType::String.nullable(false))
6268 .finish(),
6269 column_comments: BTreeMap::from_iter([
6270 (
6271 "id",
6272 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
6273 ),
6274 ("name", "The internal name of the operator."),
6275 (
6276 "dataflow_id",
6277 "The ID of the dataflow hosting the operator. Corresponds to `mz_dataflows.id`.",
6278 ),
6279 (
6280 "dataflow_name",
6281 "The internal name of the dataflow hosting the operator.",
6282 ),
6283 ]),
6284 sql: "
6285SELECT id, name, dataflow_id, dataflow_name
6286FROM mz_introspection.mz_dataflow_operator_dataflows_per_worker
6287WHERE worker_id = 0",
6288 access: vec![PUBLIC_SELECT],
6289});
6290
6291pub static MZ_OBJECT_TRANSITIVE_DEPENDENCIES: LazyLock<BuiltinView> = LazyLock::new(|| {
6292 BuiltinView {
6293 name: "mz_object_transitive_dependencies",
6294 schema: MZ_INTERNAL_SCHEMA,
6295 oid: oid::VIEW_MZ_OBJECT_TRANSITIVE_DEPENDENCIES_OID,
6296 desc: RelationDesc::builder()
6297 .with_column("object_id", SqlScalarType::String.nullable(false))
6298 .with_column(
6299 "referenced_object_id",
6300 SqlScalarType::String.nullable(false),
6301 )
6302 .with_key(vec![0, 1])
6303 .finish(),
6304 column_comments: BTreeMap::from_iter([
6305 (
6306 "object_id",
6307 "The ID of the dependent object. Corresponds to `mz_objects.id`.",
6308 ),
6309 (
6310 "referenced_object_id",
6311 "The ID of the (possibly transitively) referenced object. Corresponds to `mz_objects.id`.",
6312 ),
6313 ]),
6314 sql: "
6315WITH MUTUALLY RECURSIVE
6316 reach(object_id text, referenced_object_id text) AS (
6317 SELECT object_id, referenced_object_id FROM mz_internal.mz_object_dependencies
6318 UNION
6319 SELECT x, z FROM reach r1(x, y) JOIN reach r2(y, z) USING(y)
6320 )
6321SELECT object_id, referenced_object_id FROM reach;",
6322 access: vec![PUBLIC_SELECT],
6323 }
6324});
6325
6326pub static MZ_COMPUTE_EXPORTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6327 name: "mz_compute_exports",
6328 schema: MZ_INTROSPECTION_SCHEMA,
6329 oid: oid::VIEW_MZ_COMPUTE_EXPORTS_OID,
6330 desc: RelationDesc::builder()
6331 .with_column("export_id", SqlScalarType::String.nullable(false))
6332 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6333 .finish(),
6334 column_comments: BTreeMap::from_iter([
6335 (
6336 "export_id",
6337 "The ID of the index, materialized view, or subscription exported by the dataflow. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, or `mz_internal.mz_subscriptions`.",
6338 ),
6339 (
6340 "dataflow_id",
6341 "The ID of the dataflow. Corresponds to `mz_dataflows.id`.",
6342 ),
6343 ]),
6344 sql: "
6345SELECT export_id, dataflow_id
6346FROM mz_introspection.mz_compute_exports_per_worker
6347WHERE worker_id = 0",
6348 access: vec![PUBLIC_SELECT],
6349});
6350
6351pub static MZ_COMPUTE_FRONTIERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6352 name: "mz_compute_frontiers",
6353 schema: MZ_INTROSPECTION_SCHEMA,
6354 oid: oid::VIEW_MZ_COMPUTE_FRONTIERS_OID,
6355 desc: RelationDesc::builder()
6356 .with_column("export_id", SqlScalarType::String.nullable(false))
6357 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
6358 .with_key(vec![0])
6359 .finish(),
6360 column_comments: BTreeMap::from_iter([
6361 (
6362 "export_id",
6363 "The ID of the dataflow export. Corresponds to `mz_compute_exports.export_id`.",
6364 ),
6365 (
6366 "time",
6367 "The next timestamp at which the dataflow output may change.",
6368 ),
6369 ]),
6370 sql: "SELECT
6371 export_id, pg_catalog.min(time) AS time
6372FROM mz_introspection.mz_compute_frontiers_per_worker
6373GROUP BY export_id",
6374 access: vec![PUBLIC_SELECT],
6375});
6376
6377pub static MZ_DATAFLOW_CHANNEL_OPERATORS_PER_WORKER: LazyLock<BuiltinView> =
6378 LazyLock::new(|| BuiltinView {
6379 name: "mz_dataflow_channel_operators_per_worker",
6380 schema: MZ_INTROSPECTION_SCHEMA,
6381 oid: oid::VIEW_MZ_DATAFLOW_CHANNEL_OPERATORS_PER_WORKER_OID,
6382 desc: RelationDesc::builder()
6383 .with_column("id", SqlScalarType::UInt64.nullable(false))
6384 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6385 .with_column("from_operator_id", SqlScalarType::UInt64.nullable(true))
6386 .with_column(
6387 "from_operator_address",
6388 SqlScalarType::List {
6389 element_type: Box::new(SqlScalarType::UInt64),
6390 custom_id: None,
6391 }
6392 .nullable(true),
6393 )
6394 .with_column("to_operator_id", SqlScalarType::UInt64.nullable(true))
6395 .with_column(
6396 "to_operator_address",
6397 SqlScalarType::List {
6398 element_type: Box::new(SqlScalarType::UInt64),
6399 custom_id: None,
6400 }
6401 .nullable(true),
6402 )
6403 .with_column("type", SqlScalarType::String.nullable(false))
6404 .finish(),
6405 column_comments: BTreeMap::new(),
6406 sql: "
6407WITH
6408channel_addresses(id, worker_id, address, from_index, to_index, type) AS (
6409 SELECT id, worker_id, address, from_index, to_index, type
6410 FROM mz_introspection.mz_dataflow_channels_per_worker mdc
6411 INNER JOIN mz_introspection.mz_dataflow_addresses_per_worker mda
6412 USING (id, worker_id)
6413),
6414channel_operator_addresses(id, worker_id, from_address, to_address, type) AS (
6415 SELECT id, worker_id,
6416 address || from_index AS from_address,
6417 address || to_index AS to_address,
6418 type
6419 FROM channel_addresses
6420),
6421operator_addresses(id, worker_id, address) AS (
6422 SELECT id, worker_id, address
6423 FROM mz_introspection.mz_dataflow_addresses_per_worker mda
6424 INNER JOIN mz_introspection.mz_dataflow_operators_per_worker mdo
6425 USING (id, worker_id)
6426)
6427SELECT coa.id,
6428 coa.worker_id,
6429 from_ops.id AS from_operator_id,
6430 coa.from_address AS from_operator_address,
6431 to_ops.id AS to_operator_id,
6432 coa.to_address AS to_operator_address,
6433 coa.type
6434FROM channel_operator_addresses coa
6435 LEFT OUTER JOIN operator_addresses from_ops
6436 ON coa.from_address = from_ops.address AND
6437 coa.worker_id = from_ops.worker_id
6438 LEFT OUTER JOIN operator_addresses to_ops
6439 ON coa.to_address = to_ops.address AND
6440 coa.worker_id = to_ops.worker_id
6441",
6442 access: vec![PUBLIC_SELECT],
6443 });
6444
6445pub static MZ_DATAFLOW_CHANNEL_OPERATORS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6446 name: "mz_dataflow_channel_operators",
6447 schema: MZ_INTROSPECTION_SCHEMA,
6448 oid: oid::VIEW_MZ_DATAFLOW_CHANNEL_OPERATORS_OID,
6449 desc: RelationDesc::builder()
6450 .with_column("id", SqlScalarType::UInt64.nullable(false))
6451 .with_column("from_operator_id", SqlScalarType::UInt64.nullable(true))
6452 .with_column(
6453 "from_operator_address",
6454 SqlScalarType::List {
6455 element_type: Box::new(SqlScalarType::UInt64),
6456 custom_id: None,
6457 }
6458 .nullable(true),
6459 )
6460 .with_column("to_operator_id", SqlScalarType::UInt64.nullable(true))
6461 .with_column(
6462 "to_operator_address",
6463 SqlScalarType::List {
6464 element_type: Box::new(SqlScalarType::UInt64),
6465 custom_id: None,
6466 }
6467 .nullable(true),
6468 )
6469 .with_column("type", SqlScalarType::String.nullable(false))
6470 .finish(),
6471 column_comments: BTreeMap::from_iter([
6472 (
6473 "id",
6474 "The ID of the channel. Corresponds to `mz_dataflow_channels.id`.",
6475 ),
6476 (
6477 "from_operator_id",
6478 "The ID of the source of the channel. Corresponds to `mz_dataflow_operators.id`.",
6479 ),
6480 (
6481 "from_operator_address",
6482 "The address of the source of the channel. Corresponds to `mz_dataflow_addresses.address`.",
6483 ),
6484 (
6485 "to_operator_id",
6486 "The ID of the target of the channel. Corresponds to `mz_dataflow_operators.id`.",
6487 ),
6488 (
6489 "to_operator_address",
6490 "The address of the target of the channel. Corresponds to `mz_dataflow_addresses.address`.",
6491 ),
6492 ("type", "The container type of the channel."),
6493 ]),
6494 sql: "
6495SELECT id, from_operator_id, from_operator_address, to_operator_id, to_operator_address, type
6496FROM mz_introspection.mz_dataflow_channel_operators_per_worker
6497WHERE worker_id = 0",
6498 access: vec![PUBLIC_SELECT],
6499});
6500
6501pub static MZ_COMPUTE_IMPORT_FRONTIERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6502 name: "mz_compute_import_frontiers",
6503 schema: MZ_INTROSPECTION_SCHEMA,
6504 oid: oid::VIEW_MZ_COMPUTE_IMPORT_FRONTIERS_OID,
6505 desc: RelationDesc::builder()
6506 .with_column("export_id", SqlScalarType::String.nullable(false))
6507 .with_column("import_id", SqlScalarType::String.nullable(false))
6508 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
6509 .with_key(vec![0, 1])
6510 .finish(),
6511 column_comments: BTreeMap::from_iter([
6512 (
6513 "export_id",
6514 "The ID of the dataflow export. Corresponds to `mz_compute_exports.export_id`.",
6515 ),
6516 (
6517 "import_id",
6518 "The ID of the dataflow import. Corresponds to `mz_catalog.mz_sources.id` or `mz_catalog.mz_tables.id` or `mz_compute_exports.export_id`.",
6519 ),
6520 (
6521 "time",
6522 "The next timestamp at which the dataflow input may change.",
6523 ),
6524 ]),
6525 sql: "SELECT
6526 export_id, import_id, pg_catalog.min(time) AS time
6527FROM mz_introspection.mz_compute_import_frontiers_per_worker
6528GROUP BY export_id, import_id",
6529 access: vec![PUBLIC_SELECT],
6530});
6531
6532pub static MZ_RECORDS_PER_DATAFLOW_OPERATOR_PER_WORKER: LazyLock<BuiltinView> =
6533 LazyLock::new(|| BuiltinView {
6534 name: "mz_records_per_dataflow_operator_per_worker",
6535 schema: MZ_INTROSPECTION_SCHEMA,
6536 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_OPERATOR_PER_WORKER_OID,
6537 desc: RelationDesc::builder()
6538 .with_column("id", SqlScalarType::UInt64.nullable(false))
6539 .with_column("name", SqlScalarType::String.nullable(false))
6540 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6541 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6542 .with_column("records", SqlScalarType::Int64.nullable(true))
6543 .with_column("batches", SqlScalarType::Int64.nullable(true))
6544 .with_column("size", SqlScalarType::Int64.nullable(true))
6545 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6546 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6547 .finish(),
6548 column_comments: BTreeMap::new(),
6549 sql: "
6550SELECT
6551 dod.id,
6552 dod.name,
6553 dod.worker_id,
6554 dod.dataflow_id,
6555 ar_size.records AS records,
6556 ar_size.batches AS batches,
6557 ar_size.size AS size,
6558 ar_size.capacity AS capacity,
6559 ar_size.allocations AS allocations
6560FROM
6561 mz_introspection.mz_dataflow_operator_dataflows_per_worker dod
6562 LEFT OUTER JOIN mz_introspection.mz_arrangement_sizes_per_worker ar_size ON
6563 dod.id = ar_size.operator_id AND
6564 dod.worker_id = ar_size.worker_id",
6565 access: vec![PUBLIC_SELECT],
6566 });
6567
6568pub static MZ_RECORDS_PER_DATAFLOW_OPERATOR: LazyLock<BuiltinView> =
6569 LazyLock::new(|| BuiltinView {
6570 name: "mz_records_per_dataflow_operator",
6571 schema: MZ_INTROSPECTION_SCHEMA,
6572 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_OPERATOR_OID,
6573 desc: RelationDesc::builder()
6574 .with_column("id", SqlScalarType::UInt64.nullable(false))
6575 .with_column("name", SqlScalarType::String.nullable(false))
6576 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6577 .with_column("records", SqlScalarType::Int64.nullable(true))
6578 .with_column("batches", SqlScalarType::Int64.nullable(true))
6579 .with_column("size", SqlScalarType::Int64.nullable(true))
6580 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6581 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6582 .with_key(vec![0, 1, 2])
6583 .finish(),
6584 column_comments: BTreeMap::from_iter([
6585 (
6586 "id",
6587 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
6588 ),
6589 ("name", "The internal name of the operator."),
6590 (
6591 "dataflow_id",
6592 "The ID of the dataflow. Corresponds to `mz_dataflows.id`.",
6593 ),
6594 ("records", "The number of records in the operator."),
6595 ("batches", "The number of batches in the dataflow."),
6596 ("size", "The utilized size in bytes of the arrangement."),
6597 (
6598 "capacity",
6599 "The capacity in bytes of the arrangement. Can be larger than the size.",
6600 ),
6601 (
6602 "allocations",
6603 "The number of separate memory allocations backing the arrangement.",
6604 ),
6605 ]),
6606 sql: "
6607SELECT
6608 id,
6609 name,
6610 dataflow_id,
6611 SUM(records)::int8 AS records,
6612 SUM(batches)::int8 AS batches,
6613 SUM(size)::int8 AS size,
6614 SUM(capacity)::int8 AS capacity,
6615 SUM(allocations)::int8 AS allocations
6616FROM mz_introspection.mz_records_per_dataflow_operator_per_worker
6617GROUP BY id, name, dataflow_id",
6618 access: vec![PUBLIC_SELECT],
6619 });
6620
6621pub static MZ_RECORDS_PER_DATAFLOW_PER_WORKER: LazyLock<BuiltinView> =
6622 LazyLock::new(|| BuiltinView {
6623 name: "mz_records_per_dataflow_per_worker",
6624 schema: MZ_INTROSPECTION_SCHEMA,
6625 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_PER_WORKER_OID,
6626 desc: RelationDesc::builder()
6627 .with_column("id", SqlScalarType::UInt64.nullable(false))
6628 .with_column("name", SqlScalarType::String.nullable(false))
6629 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6630 .with_column("records", SqlScalarType::Int64.nullable(true))
6631 .with_column("batches", SqlScalarType::Int64.nullable(true))
6632 .with_column("size", SqlScalarType::Int64.nullable(true))
6633 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6634 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6635 .with_key(vec![0, 1, 2])
6636 .finish(),
6637 column_comments: BTreeMap::new(),
6638 sql: "
6639SELECT
6640 rdo.dataflow_id as id,
6641 dfs.name,
6642 rdo.worker_id,
6643 SUM(rdo.records)::int8 as records,
6644 SUM(rdo.batches)::int8 as batches,
6645 SUM(rdo.size)::int8 as size,
6646 SUM(rdo.capacity)::int8 as capacity,
6647 SUM(rdo.allocations)::int8 as allocations
6648FROM
6649 mz_introspection.mz_records_per_dataflow_operator_per_worker rdo,
6650 mz_introspection.mz_dataflows_per_worker dfs
6651WHERE
6652 rdo.dataflow_id = dfs.id AND
6653 rdo.worker_id = dfs.worker_id
6654GROUP BY
6655 rdo.dataflow_id,
6656 dfs.name,
6657 rdo.worker_id",
6658 access: vec![PUBLIC_SELECT],
6659 });
6660
6661pub static MZ_RECORDS_PER_DATAFLOW: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6662 name: "mz_records_per_dataflow",
6663 schema: MZ_INTROSPECTION_SCHEMA,
6664 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_OID,
6665 desc: RelationDesc::builder()
6666 .with_column("id", SqlScalarType::UInt64.nullable(false))
6667 .with_column("name", SqlScalarType::String.nullable(false))
6668 .with_column("records", SqlScalarType::Int64.nullable(true))
6669 .with_column("batches", SqlScalarType::Int64.nullable(true))
6670 .with_column("size", SqlScalarType::Int64.nullable(true))
6671 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6672 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6673 .with_key(vec![0, 1])
6674 .finish(),
6675 column_comments: BTreeMap::from_iter([
6676 (
6677 "id",
6678 "The ID of the dataflow. Corresponds to `mz_dataflows.id`.",
6679 ),
6680 ("name", "The internal name of the dataflow."),
6681 ("records", "The number of records in the dataflow."),
6682 ("batches", "The number of batches in the dataflow."),
6683 ("size", "The utilized size in bytes of the arrangements."),
6684 (
6685 "capacity",
6686 "The capacity in bytes of the arrangements. Can be larger than the size.",
6687 ),
6688 (
6689 "allocations",
6690 "The number of separate memory allocations backing the arrangements.",
6691 ),
6692 ]),
6693 sql: "
6694SELECT
6695 id,
6696 name,
6697 SUM(records)::int8 as records,
6698 SUM(batches)::int8 as batches,
6699 SUM(size)::int8 as size,
6700 SUM(capacity)::int8 as capacity,
6701 SUM(allocations)::int8 as allocations
6702FROM
6703 mz_introspection.mz_records_per_dataflow_per_worker
6704GROUP BY
6705 id,
6706 name",
6707 access: vec![PUBLIC_SELECT],
6708});
6709
6710pub static PG_NAMESPACE_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6716 name: "pg_namespace_all_databases",
6717 schema: MZ_INTERNAL_SCHEMA,
6718 oid: oid::VIEW_PG_NAMESPACE_ALL_DATABASES_OID,
6719 desc: RelationDesc::builder()
6720 .with_column("oid", SqlScalarType::Oid.nullable(false))
6721 .with_column("nspname", SqlScalarType::String.nullable(false))
6722 .with_column("nspowner", SqlScalarType::Oid.nullable(false))
6723 .with_column(
6724 "nspacl",
6725 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
6726 )
6727 .with_column("database_name", SqlScalarType::String.nullable(true))
6728 .finish(),
6729 column_comments: BTreeMap::new(),
6730 sql: "
6731SELECT
6732 s.oid AS oid,
6733 s.name AS nspname,
6734 role_owner.oid AS nspowner,
6735 NULL::pg_catalog.text[] AS nspacl,
6736 d.name as database_name
6737FROM mz_catalog.mz_schemas s
6738LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
6739JOIN mz_catalog.mz_roles role_owner ON role_owner.id = s.owner_id",
6740 access: vec![PUBLIC_SELECT],
6741});
6742
6743pub const PG_NAMESPACE_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
6744 name: "pg_namespace_all_databases_ind",
6745 schema: MZ_INTERNAL_SCHEMA,
6746 oid: oid::INDEX_PG_NAMESPACE_ALL_DATABASES_IND_OID,
6747 sql: "IN CLUSTER mz_catalog_server
6748ON mz_internal.pg_namespace_all_databases (nspname)",
6749 is_retained_metrics_object: false,
6750};
6751
6752pub static PG_NAMESPACE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6753 name: "pg_namespace",
6754 schema: PG_CATALOG_SCHEMA,
6755 oid: oid::VIEW_PG_NAMESPACE_OID,
6756 desc: RelationDesc::builder()
6757 .with_column("oid", SqlScalarType::Oid.nullable(false))
6758 .with_column("nspname", SqlScalarType::String.nullable(false))
6759 .with_column("nspowner", SqlScalarType::Oid.nullable(false))
6760 .with_column(
6761 "nspacl",
6762 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
6763 )
6764 .finish(),
6765 column_comments: BTreeMap::new(),
6766 sql: "
6767SELECT
6768 oid, nspname, nspowner, nspacl
6769FROM mz_internal.pg_namespace_all_databases
6770WHERE database_name IS NULL OR database_name = pg_catalog.current_database();",
6771 access: vec![PUBLIC_SELECT],
6772});
6773
6774pub static PG_CLASS_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
6780 BuiltinView {
6781 name: "pg_class_all_databases",
6782 schema: MZ_INTERNAL_SCHEMA,
6783 oid: oid::VIEW_PG_CLASS_ALL_DATABASES_OID,
6784 desc: RelationDesc::builder()
6785 .with_column("oid", SqlScalarType::Oid.nullable(false))
6786 .with_column("relname", SqlScalarType::String.nullable(false))
6787 .with_column("relnamespace", SqlScalarType::Oid.nullable(false))
6788 .with_column("reloftype", SqlScalarType::Oid.nullable(false))
6789 .with_column("relowner", SqlScalarType::Oid.nullable(false))
6790 .with_column("relam", SqlScalarType::Oid.nullable(false))
6791 .with_column("reltablespace", SqlScalarType::Oid.nullable(false))
6792 .with_column("reltuples", SqlScalarType::Float32.nullable(false))
6793 .with_column("reltoastrelid", SqlScalarType::Oid.nullable(false))
6794 .with_column("relhasindex", SqlScalarType::Bool.nullable(false))
6795 .with_column("relpersistence", SqlScalarType::PgLegacyChar.nullable(false))
6796 .with_column("relkind", SqlScalarType::String.nullable(true))
6797 .with_column("relnatts", SqlScalarType::Int16.nullable(false))
6798 .with_column("relchecks", SqlScalarType::Int16.nullable(false))
6799 .with_column("relhasrules", SqlScalarType::Bool.nullable(false))
6800 .with_column("relhastriggers", SqlScalarType::Bool.nullable(false))
6801 .with_column("relhassubclass", SqlScalarType::Bool.nullable(false))
6802 .with_column("relrowsecurity", SqlScalarType::Bool.nullable(false))
6803 .with_column("relforcerowsecurity", SqlScalarType::Bool.nullable(false))
6804 .with_column("relreplident", SqlScalarType::PgLegacyChar.nullable(false))
6805 .with_column("relispartition", SqlScalarType::Bool.nullable(false))
6806 .with_column("relhasoids", SqlScalarType::Bool.nullable(false))
6807 .with_column("reloptions", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true))
6808 .with_column("database_name", SqlScalarType::String.nullable(true))
6809 .finish(),
6810 column_comments: BTreeMap::new(),
6811 sql: "
6812SELECT
6813 class_objects.oid,
6814 class_objects.name AS relname,
6815 mz_schemas.oid AS relnamespace,
6816 -- MZ doesn't support typed tables so reloftype is filled with 0
6817 0::pg_catalog.oid AS reloftype,
6818 role_owner.oid AS relowner,
6819 0::pg_catalog.oid AS relam,
6820 -- MZ doesn't have tablespaces so reltablespace is filled in with 0 implying the default tablespace
6821 0::pg_catalog.oid AS reltablespace,
6822 -- MZ doesn't support (estimated) row counts currently.
6823 -- Postgres defines a value of -1 as unknown.
6824 -1::float4 as reltuples,
6825 -- MZ doesn't use TOAST tables so reltoastrelid is filled with 0
6826 0::pg_catalog.oid AS reltoastrelid,
6827 EXISTS (SELECT id, oid, name, on_id, cluster_id FROM mz_catalog.mz_indexes where mz_indexes.on_id = class_objects.id) AS relhasindex,
6828 -- MZ doesn't have unlogged tables and because of (https://github.com/MaterializeInc/database-issues/issues/2689)
6829 -- temporary objects don't show up here, so relpersistence is filled with 'p' for permanent.
6830 -- TODO(jkosh44): update this column when issue is resolved.
6831 'p'::pg_catalog.\"char\" AS relpersistence,
6832 CASE
6833 WHEN class_objects.type = 'table' THEN 'r'
6834 WHEN class_objects.type = 'source' THEN 'r'
6835 WHEN class_objects.type = 'index' THEN 'i'
6836 WHEN class_objects.type = 'view' THEN 'v'
6837 WHEN class_objects.type = 'materialized-view' THEN 'm'
6838 END relkind,
6839 COALESCE(
6840 (
6841 SELECT count(*)::pg_catalog.int2
6842 FROM mz_catalog.mz_columns
6843 WHERE mz_columns.id = class_objects.id
6844 ),
6845 0::pg_catalog.int2
6846 ) AS relnatts,
6847 -- MZ doesn't support CHECK constraints so relchecks is filled with 0
6848 0::pg_catalog.int2 AS relchecks,
6849 -- MZ doesn't support creating rules so relhasrules is filled with false
6850 false AS relhasrules,
6851 -- MZ doesn't support creating triggers so relhastriggers is filled with false
6852 false AS relhastriggers,
6853 -- MZ doesn't support table inheritance or partitions so relhassubclass is filled with false
6854 false AS relhassubclass,
6855 -- MZ doesn't have row level security so relrowsecurity and relforcerowsecurity is filled with false
6856 false AS relrowsecurity,
6857 false AS relforcerowsecurity,
6858 -- MZ doesn't support replication so relreplident is filled with 'd' for default
6859 'd'::pg_catalog.\"char\" AS relreplident,
6860 -- MZ doesn't support table partitioning so relispartition is filled with false
6861 false AS relispartition,
6862 -- PG removed relhasoids in v12 so it's filled with false
6863 false AS relhasoids,
6864 -- MZ doesn't support options for relations
6865 NULL::pg_catalog.text[] as reloptions,
6866 d.name as database_name
6867FROM (
6868 -- pg_class catalogs relations and indexes
6869 SELECT id, oid, schema_id, name, type, owner_id FROM mz_catalog.mz_relations
6870 UNION ALL
6871 SELECT mz_indexes.id, mz_indexes.oid, mz_relations.schema_id, mz_indexes.name, 'index' AS type, mz_indexes.owner_id
6872 FROM mz_catalog.mz_indexes
6873 JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
6874) AS class_objects
6875JOIN mz_catalog.mz_schemas ON mz_schemas.id = class_objects.schema_id
6876LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
6877JOIN mz_catalog.mz_roles role_owner ON role_owner.id = class_objects.owner_id",
6878 access: vec![PUBLIC_SELECT],
6879 }
6880});
6881
6882pub const PG_CLASS_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
6883 name: "pg_class_all_databases_ind",
6884 schema: MZ_INTERNAL_SCHEMA,
6885 oid: oid::INDEX_PG_CLASS_ALL_DATABASES_IND_OID,
6886 sql: "IN CLUSTER mz_catalog_server
6887ON mz_internal.pg_class_all_databases (relname)",
6888 is_retained_metrics_object: false,
6889};
6890
6891pub static PG_CLASS: LazyLock<BuiltinView> = LazyLock::new(|| {
6892 BuiltinView {
6893 name: "pg_class",
6894 schema: PG_CATALOG_SCHEMA,
6895 oid: oid::VIEW_PG_CLASS_OID,
6896 desc: RelationDesc::builder()
6897 .with_column("oid", SqlScalarType::Oid.nullable(false))
6898 .with_column("relname", SqlScalarType::String.nullable(false))
6899 .with_column("relnamespace", SqlScalarType::Oid.nullable(false))
6900 .with_column("reloftype", SqlScalarType::Oid.nullable(false))
6901 .with_column("relowner", SqlScalarType::Oid.nullable(false))
6902 .with_column("relam", SqlScalarType::Oid.nullable(false))
6903 .with_column("reltablespace", SqlScalarType::Oid.nullable(false))
6904 .with_column("reltuples", SqlScalarType::Float32.nullable(false))
6905 .with_column("reltoastrelid", SqlScalarType::Oid.nullable(false))
6906 .with_column("relhasindex", SqlScalarType::Bool.nullable(false))
6907 .with_column("relpersistence", SqlScalarType::PgLegacyChar.nullable(false))
6908 .with_column("relkind", SqlScalarType::String.nullable(true))
6909 .with_column("relnatts", SqlScalarType::Int16.nullable(false))
6910 .with_column("relchecks", SqlScalarType::Int16.nullable(false))
6911 .with_column("relhasrules", SqlScalarType::Bool.nullable(false))
6912 .with_column("relhastriggers", SqlScalarType::Bool.nullable(false))
6913 .with_column("relhassubclass", SqlScalarType::Bool.nullable(false))
6914 .with_column("relrowsecurity", SqlScalarType::Bool.nullable(false))
6915 .with_column("relforcerowsecurity", SqlScalarType::Bool.nullable(false))
6916 .with_column("relreplident", SqlScalarType::PgLegacyChar.nullable(false))
6917 .with_column("relispartition", SqlScalarType::Bool.nullable(false))
6918 .with_column("relhasoids", SqlScalarType::Bool.nullable(false))
6919 .with_column(
6920 "reloptions",
6921 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
6922 )
6923 .finish(),
6924 column_comments: BTreeMap::new(),
6925 sql: "
6926SELECT
6927 oid, relname, relnamespace, reloftype, relowner, relam, reltablespace, reltuples, reltoastrelid,
6928 relhasindex, relpersistence, relkind, relnatts, relchecks, relhasrules, relhastriggers, relhassubclass,
6929 relrowsecurity, relforcerowsecurity, relreplident, relispartition, relhasoids, reloptions
6930FROM mz_internal.pg_class_all_databases
6931WHERE database_name IS NULL OR database_name = pg_catalog.current_database();
6932",
6933 access: vec![PUBLIC_SELECT],
6934}
6935});
6936
6937pub static PG_DEPEND: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6938 name: "pg_depend",
6939 schema: PG_CATALOG_SCHEMA,
6940 oid: oid::VIEW_PG_DEPEND_OID,
6941 desc: RelationDesc::builder()
6942 .with_column("classid", SqlScalarType::Oid.nullable(true))
6943 .with_column("objid", SqlScalarType::Oid.nullable(false))
6944 .with_column("objsubid", SqlScalarType::Int32.nullable(false))
6945 .with_column("refclassid", SqlScalarType::Oid.nullable(true))
6946 .with_column("refobjid", SqlScalarType::Oid.nullable(false))
6947 .with_column("refobjsubid", SqlScalarType::Int32.nullable(false))
6948 .with_column("deptype", SqlScalarType::PgLegacyChar.nullable(false))
6949 .finish(),
6950 column_comments: BTreeMap::new(),
6951 sql: "
6952WITH class_objects AS (
6953 SELECT
6954 CASE
6955 WHEN type = 'table' THEN 'pg_tables'::pg_catalog.regclass::pg_catalog.oid
6956 WHEN type = 'source' THEN 'pg_tables'::pg_catalog.regclass::pg_catalog.oid
6957 WHEN type = 'view' THEN 'pg_views'::pg_catalog.regclass::pg_catalog.oid
6958 WHEN type = 'materialized-view' THEN 'pg_matviews'::pg_catalog.regclass::pg_catalog.oid
6959 END classid,
6960 id,
6961 oid,
6962 schema_id
6963 FROM mz_catalog.mz_relations
6964 UNION ALL
6965 SELECT
6966 'pg_index'::pg_catalog.regclass::pg_catalog.oid AS classid,
6967 i.id,
6968 i.oid,
6969 r.schema_id
6970 FROM mz_catalog.mz_indexes i
6971 JOIN mz_catalog.mz_relations r ON i.on_id = r.id
6972),
6973
6974current_objects AS (
6975 SELECT class_objects.*
6976 FROM class_objects
6977 JOIN mz_catalog.mz_schemas ON mz_schemas.id = class_objects.schema_id
6978 LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
6979 -- This filter is tricky, as it filters out not just objects outside the
6980 -- database, but *dependencies* on objects outside this database. It's not
6981 -- clear that this is the right choice, but because PostgreSQL doesn't
6982 -- support cross-database references, it's not clear that the other choice
6983 -- is better.
6984 WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()
6985)
6986
6987SELECT
6988 objects.classid::pg_catalog.oid,
6989 objects.oid::pg_catalog.oid AS objid,
6990 0::pg_catalog.int4 AS objsubid,
6991 dependents.classid::pg_catalog.oid AS refclassid,
6992 dependents.oid::pg_catalog.oid AS refobjid,
6993 0::pg_catalog.int4 AS refobjsubid,
6994 'n'::pg_catalog.char AS deptype
6995FROM mz_internal.mz_object_dependencies
6996JOIN current_objects objects ON object_id = objects.id
6997JOIN current_objects dependents ON referenced_object_id = dependents.id",
6998 access: vec![PUBLIC_SELECT],
6999});
7000
7001pub static PG_DATABASE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7002 name: "pg_database",
7003 schema: PG_CATALOG_SCHEMA,
7004 oid: oid::VIEW_PG_DATABASE_OID,
7005 desc: RelationDesc::builder()
7006 .with_column("oid", SqlScalarType::Oid.nullable(false))
7007 .with_column("datname", SqlScalarType::String.nullable(false))
7008 .with_column("datdba", SqlScalarType::Oid.nullable(false))
7009 .with_column("encoding", SqlScalarType::Int32.nullable(false))
7010 .with_column("datistemplate", SqlScalarType::Bool.nullable(false))
7011 .with_column("datallowconn", SqlScalarType::Bool.nullable(false))
7012 .with_column("datcollate", SqlScalarType::String.nullable(false))
7013 .with_column("datctype", SqlScalarType::String.nullable(false))
7014 .with_column(
7015 "datacl",
7016 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
7017 )
7018 .with_key(vec![0])
7019 .finish(),
7020 column_comments: BTreeMap::new(),
7021 sql: "SELECT
7022 d.oid as oid,
7023 d.name as datname,
7024 role_owner.oid as datdba,
7025 6 as encoding,
7026 -- Materialize doesn't support database cloning.
7027 FALSE AS datistemplate,
7028 TRUE AS datallowconn,
7029 'C' as datcollate,
7030 'C' as datctype,
7031 NULL::pg_catalog.text[] as datacl
7032FROM mz_catalog.mz_databases d
7033JOIN mz_catalog.mz_roles role_owner ON role_owner.id = d.owner_id",
7034 access: vec![PUBLIC_SELECT],
7035});
7036
7037pub static PG_INDEX: LazyLock<BuiltinView> = LazyLock::new(|| {
7038 BuiltinView {
7039 name: "pg_index",
7040 schema: PG_CATALOG_SCHEMA,
7041 oid: oid::VIEW_PG_INDEX_OID,
7042 desc: RelationDesc::builder()
7043 .with_column("indexrelid", SqlScalarType::Oid.nullable(false))
7044 .with_column("indrelid", SqlScalarType::Oid.nullable(false))
7045 .with_column("indnatts", SqlScalarType::Int16.nullable(false))
7046 .with_column("indisunique", SqlScalarType::Bool.nullable(false))
7047 .with_column("indisprimary", SqlScalarType::Bool.nullable(false))
7048 .with_column("indimmediate", SqlScalarType::Bool.nullable(false))
7049 .with_column("indisclustered", SqlScalarType::Bool.nullable(false))
7050 .with_column("indisvalid", SqlScalarType::Bool.nullable(false))
7051 .with_column("indisreplident", SqlScalarType::Bool.nullable(false))
7052 .with_column("indkey", SqlScalarType::Int2Vector.nullable(false))
7053 .with_column("indoption", SqlScalarType::Int2Vector.nullable(false))
7054 .with_column("indexprs", SqlScalarType::String.nullable(true))
7055 .with_column("indpred", SqlScalarType::String.nullable(true))
7056 .with_key(vec![0, 1])
7057 .finish(),
7058 column_comments: BTreeMap::new(),
7059 sql: "SELECT
7060 mz_indexes.oid AS indexrelid,
7061 mz_relations.oid AS indrelid,
7062 COALESCE(
7063 (
7064 SELECT count(*)::pg_catalog.int2
7065 FROM mz_catalog.mz_columns
7066 JOIN mz_catalog.mz_relations mri ON mz_columns.id = mri.id
7067 WHERE mri.oid = mz_catalog.mz_relations.oid
7068 ),
7069 0::pg_catalog.int2
7070 ) AS indnatts,
7071 -- MZ doesn't support creating unique indexes so indisunique is filled with false
7072 false::pg_catalog.bool AS indisunique,
7073 false::pg_catalog.bool AS indisprimary,
7074 -- MZ doesn't support unique indexes so indimmediate is filled with false
7075 false::pg_catalog.bool AS indimmediate,
7076 -- MZ doesn't support CLUSTER so indisclustered is filled with false
7077 false::pg_catalog.bool AS indisclustered,
7078 -- MZ never creates invalid indexes so indisvalid is filled with true
7079 true::pg_catalog.bool AS indisvalid,
7080 -- MZ doesn't support replication so indisreplident is filled with false
7081 false::pg_catalog.bool AS indisreplident,
7082 -- Return zero if the index attribute is not a simple column reference, column position otherwise
7083 pg_catalog.string_agg(coalesce(mz_index_columns.on_position::int8, 0)::pg_catalog.text, ' ' ORDER BY mz_index_columns.index_position::int8)::pg_catalog.int2vector AS indkey,
7084 -- MZ doesn't have per-column flags, so returning a 0 for each column in the index
7085 pg_catalog.string_agg('0', ' ')::pg_catalog.int2vector AS indoption,
7086 -- Index expressions are returned in MZ format
7087 CASE pg_catalog.string_agg(mz_index_columns.on_expression, ' ' ORDER BY mz_index_columns.index_position::int8)
7088 WHEN NULL THEN NULL
7089 ELSE '{' || pg_catalog.string_agg(mz_index_columns.on_expression, '}, {' ORDER BY mz_index_columns.index_position::int8) || '}'
7090 END AS indexprs,
7091 -- MZ doesn't support indexes with predicates
7092 NULL::pg_catalog.text AS indpred
7093FROM mz_catalog.mz_indexes
7094JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
7095JOIN mz_catalog.mz_index_columns ON mz_index_columns.index_id = mz_indexes.id
7096JOIN mz_catalog.mz_schemas ON mz_schemas.id = mz_relations.schema_id
7097LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
7098WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()
7099GROUP BY mz_indexes.oid, mz_relations.oid",
7100 access: vec![PUBLIC_SELECT],
7101 }
7102});
7103
7104pub static PG_INDEXES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7105 name: "pg_indexes",
7106 schema: PG_CATALOG_SCHEMA,
7107 oid: oid::VIEW_PG_INDEXES_OID,
7108 desc: RelationDesc::builder()
7109 .with_column("table_catalog", SqlScalarType::String.nullable(false))
7110 .with_column("schemaname", SqlScalarType::String.nullable(false))
7111 .with_column("tablename", SqlScalarType::String.nullable(false))
7112 .with_column("indexname", SqlScalarType::String.nullable(false))
7113 .with_column("tablespace", SqlScalarType::String.nullable(true))
7114 .with_column("indexdef", SqlScalarType::String.nullable(true))
7115 .finish(),
7116 column_comments: BTreeMap::new(),
7117 sql: "SELECT
7118 current_database() as table_catalog,
7119 s.name AS schemaname,
7120 r.name AS tablename,
7121 i.name AS indexname,
7122 NULL::text AS tablespace,
7123 -- TODO(jkosh44) Fill in with actual index definition.
7124 NULL::text AS indexdef
7125FROM mz_catalog.mz_indexes i
7126JOIN mz_catalog.mz_relations r ON i.on_id = r.id
7127JOIN mz_catalog.mz_schemas s ON s.id = r.schema_id
7128LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
7129WHERE s.database_id IS NULL OR d.name = current_database()",
7130 access: vec![PUBLIC_SELECT],
7131});
7132
7133pub static PG_DESCRIPTION_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
7139 BuiltinView {
7140 name: "pg_description_all_databases",
7141 schema: MZ_INTERNAL_SCHEMA,
7142 oid: oid::VIEW_PG_DESCRIPTION_ALL_DATABASES_OID,
7143 desc: RelationDesc::builder()
7144 .with_column("objoid", SqlScalarType::Oid.nullable(false))
7145 .with_column("classoid", SqlScalarType::Oid.nullable(true))
7146 .with_column("objsubid", SqlScalarType::Int32.nullable(false))
7147 .with_column("description", SqlScalarType::String.nullable(false))
7148 .with_column("oid_database_name", SqlScalarType::String.nullable(true))
7149 .with_column("class_database_name", SqlScalarType::String.nullable(true))
7150 .finish(),
7151 column_comments: BTreeMap::new(),
7152 sql: "
7153(
7154 -- Gather all of the class oid's for objects that can have comments.
7155 WITH pg_classoids AS (
7156 SELECT oid, database_name as oid_database_name,
7157 (SELECT oid FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_class') AS classoid,
7158 (SELECT database_name FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_class') AS class_database_name
7159 FROM mz_internal.pg_class_all_databases
7160 UNION ALL
7161 SELECT oid, database_name as oid_database_name,
7162 (SELECT oid FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_type') AS classoid,
7163 (SELECT database_name FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_type') AS class_database_name
7164 FROM mz_internal.pg_type_all_databases
7165 UNION ALL
7166 SELECT oid, database_name as oid_database_name,
7167 (SELECT oid FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_namespace') AS classoid,
7168 (SELECT database_name FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_namespace') AS class_database_name
7169 FROM mz_internal.pg_namespace_all_databases
7170 ),
7171
7172 -- Gather all of the MZ ids for objects that can have comments.
7173 mz_objects AS (
7174 SELECT id, oid, type FROM mz_catalog.mz_objects
7175 UNION ALL
7176 SELECT id, oid, 'schema' AS type FROM mz_catalog.mz_schemas
7177 )
7178 SELECT
7179 pg_classoids.oid AS objoid,
7180 pg_classoids.classoid as classoid,
7181 COALESCE(cmt.object_sub_id, 0) AS objsubid,
7182 cmt.comment AS description,
7183 -- Columns added because of the peeling. (Note that there are 2 of these here.)
7184 oid_database_name,
7185 class_database_name
7186 FROM
7187 pg_classoids
7188 JOIN
7189 mz_objects ON pg_classoids.oid = mz_objects.oid
7190 JOIN
7191 mz_internal.mz_comments AS cmt ON mz_objects.id = cmt.id AND lower(mz_objects.type) = lower(cmt.object_type)
7192)",
7193 access: vec![PUBLIC_SELECT],
7194 }
7195});
7196
7197pub const PG_DESCRIPTION_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7198 name: "pg_description_all_databases_ind",
7199 schema: MZ_INTERNAL_SCHEMA,
7200 oid: oid::INDEX_PG_DESCRIPTION_ALL_DATABASES_IND_OID,
7201 sql: "IN CLUSTER mz_catalog_server
7202ON mz_internal.pg_description_all_databases (objoid, classoid, objsubid, description, oid_database_name, class_database_name)",
7203 is_retained_metrics_object: false,
7204};
7205
7206pub static PG_DESCRIPTION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7210 name: "pg_description",
7211 schema: PG_CATALOG_SCHEMA,
7212 oid: oid::VIEW_PG_DESCRIPTION_OID,
7213 desc: RelationDesc::builder()
7214 .with_column("objoid", SqlScalarType::Oid.nullable(false))
7215 .with_column("classoid", SqlScalarType::Oid.nullable(true))
7216 .with_column("objsubid", SqlScalarType::Int32.nullable(false))
7217 .with_column("description", SqlScalarType::String.nullable(false))
7218 .finish(),
7219 column_comments: BTreeMap::new(),
7220 sql: "
7221SELECT
7222 objoid,
7223 classoid,
7224 objsubid,
7225 description
7226FROM
7227 mz_internal.pg_description_all_databases
7228WHERE
7229 (oid_database_name IS NULL OR oid_database_name = pg_catalog.current_database()) AND
7230 (class_database_name IS NULL OR class_database_name = pg_catalog.current_database());",
7231 access: vec![PUBLIC_SELECT],
7232});
7233
7234pub static PG_TYPE_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
7240 BuiltinView {
7241 name: "pg_type_all_databases",
7242 schema: MZ_INTERNAL_SCHEMA,
7243 oid: oid::VIEW_PG_TYPE_ALL_DATABASES_OID,
7244 desc: RelationDesc::builder()
7245 .with_column("oid", SqlScalarType::Oid.nullable(false))
7246 .with_column("typname", SqlScalarType::String.nullable(false))
7247 .with_column("typnamespace", SqlScalarType::Oid.nullable(false))
7248 .with_column("typowner", SqlScalarType::Oid.nullable(false))
7249 .with_column("typlen", SqlScalarType::Int16.nullable(true))
7250 .with_column("typtype", SqlScalarType::PgLegacyChar.nullable(false))
7251 .with_column("typcategory", SqlScalarType::PgLegacyChar.nullable(true))
7252 .with_column("typdelim", SqlScalarType::PgLegacyChar.nullable(false))
7253 .with_column("typrelid", SqlScalarType::Oid.nullable(false))
7254 .with_column("typelem", SqlScalarType::Oid.nullable(false))
7255 .with_column("typarray", SqlScalarType::Oid.nullable(false))
7256 .with_column("typinput", SqlScalarType::RegProc.nullable(true))
7257 .with_column("typreceive", SqlScalarType::Oid.nullable(false))
7258 .with_column("typnotnull", SqlScalarType::Bool.nullable(false))
7259 .with_column("typbasetype", SqlScalarType::Oid.nullable(false))
7260 .with_column("typtypmod", SqlScalarType::Int32.nullable(false))
7261 .with_column("typcollation", SqlScalarType::Oid.nullable(false))
7262 .with_column("typdefault", SqlScalarType::String.nullable(true))
7263 .with_column("database_name", SqlScalarType::String.nullable(true))
7264 .finish(),
7265 column_comments: BTreeMap::new(),
7266 sql: "
7267SELECT
7268 mz_types.oid,
7269 mz_types.name AS typname,
7270 mz_schemas.oid AS typnamespace,
7271 role_owner.oid AS typowner,
7272 NULL::pg_catalog.int2 AS typlen,
7273 -- 'a' is used internally to denote an array type, but in postgres they show up
7274 -- as 'b'.
7275 (CASE mztype WHEN 'a' THEN 'b' ELSE mztype END)::pg_catalog.char AS typtype,
7276 (CASE category
7277 WHEN 'array' THEN 'A'
7278 WHEN 'bit-string' THEN 'V'
7279 WHEN 'boolean' THEN 'B'
7280 WHEN 'composite' THEN 'C'
7281 WHEN 'date-time' THEN 'D'
7282 WHEN 'enum' THEN 'E'
7283 WHEN 'geometric' THEN 'G'
7284 WHEN 'list' THEN 'U' -- List types are user-defined from PostgreSQL's perspective.
7285 WHEN 'network-address' THEN 'I'
7286 WHEN 'numeric' THEN 'N'
7287 WHEN 'pseudo' THEN 'P'
7288 WHEN 'string' THEN 'S'
7289 WHEN 'timespan' THEN 'T'
7290 WHEN 'user-defined' THEN 'U'
7291 WHEN 'unknown' THEN 'X'
7292 END)::pg_catalog.char AS typcategory,
7293 -- In pg only the 'box' type is not ','.
7294 ','::pg_catalog.char AS typdelim,
7295 0::pg_catalog.oid AS typrelid,
7296 coalesce(
7297 (
7298 SELECT t.oid
7299 FROM mz_catalog.mz_array_types a
7300 JOIN mz_catalog.mz_types t ON a.element_id = t.id
7301 WHERE a.id = mz_types.id
7302 ),
7303 0
7304 ) AS typelem,
7305 coalesce(
7306 (
7307 SELECT
7308 t.oid
7309 FROM
7310 mz_catalog.mz_array_types AS a
7311 JOIN mz_catalog.mz_types AS t ON a.id = t.id
7312 WHERE
7313 a.element_id = mz_types.id
7314 ),
7315 0
7316 )
7317 AS typarray,
7318 mz_internal.mz_type_pg_metadata.typinput::pg_catalog.regproc AS typinput,
7319 COALESCE(mz_internal.mz_type_pg_metadata.typreceive, 0) AS typreceive,
7320 false::pg_catalog.bool AS typnotnull,
7321 0::pg_catalog.oid AS typbasetype,
7322 -1::pg_catalog.int4 AS typtypmod,
7323 -- MZ doesn't support COLLATE so typcollation is filled with 0
7324 0::pg_catalog.oid AS typcollation,
7325 NULL::pg_catalog.text AS typdefault,
7326 d.name as database_name
7327FROM
7328 mz_catalog.mz_types
7329 LEFT JOIN mz_internal.mz_type_pg_metadata ON mz_catalog.mz_types.id = mz_internal.mz_type_pg_metadata.id
7330 JOIN mz_catalog.mz_schemas ON mz_schemas.id = mz_types.schema_id
7331 JOIN (
7332 -- 'a' is not a supported typtype, but we use it to denote an array. It is
7333 -- converted to the correct value above.
7334 SELECT id, 'a' AS mztype FROM mz_catalog.mz_array_types
7335 UNION ALL SELECT id, 'b' FROM mz_catalog.mz_base_types
7336 UNION ALL SELECT id, 'l' FROM mz_catalog.mz_list_types
7337 UNION ALL SELECT id, 'm' FROM mz_catalog.mz_map_types
7338 UNION ALL SELECT id, 'p' FROM mz_catalog.mz_pseudo_types
7339 )
7340 AS t ON mz_types.id = t.id
7341 LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
7342 JOIN mz_catalog.mz_roles role_owner ON role_owner.id = mz_types.owner_id",
7343 access: vec![PUBLIC_SELECT],
7344 }
7345});
7346
7347pub const PG_TYPE_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7348 name: "pg_type_all_databases_ind",
7349 schema: MZ_INTERNAL_SCHEMA,
7350 oid: oid::INDEX_PG_TYPE_ALL_DATABASES_IND_OID,
7351 sql: "IN CLUSTER mz_catalog_server
7352ON mz_internal.pg_type_all_databases (oid)",
7353 is_retained_metrics_object: false,
7354};
7355
7356pub static PG_TYPE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7357 name: "pg_type",
7358 schema: PG_CATALOG_SCHEMA,
7359 oid: oid::VIEW_PG_TYPE_OID,
7360 desc: RelationDesc::builder()
7361 .with_column("oid", SqlScalarType::Oid.nullable(false))
7362 .with_column("typname", SqlScalarType::String.nullable(false))
7363 .with_column("typnamespace", SqlScalarType::Oid.nullable(false))
7364 .with_column("typowner", SqlScalarType::Oid.nullable(false))
7365 .with_column("typlen", SqlScalarType::Int16.nullable(true))
7366 .with_column("typtype", SqlScalarType::PgLegacyChar.nullable(false))
7367 .with_column("typcategory", SqlScalarType::PgLegacyChar.nullable(true))
7368 .with_column("typdelim", SqlScalarType::PgLegacyChar.nullable(false))
7369 .with_column("typrelid", SqlScalarType::Oid.nullable(false))
7370 .with_column("typelem", SqlScalarType::Oid.nullable(false))
7371 .with_column("typarray", SqlScalarType::Oid.nullable(false))
7372 .with_column("typinput", SqlScalarType::RegProc.nullable(true))
7373 .with_column("typreceive", SqlScalarType::Oid.nullable(false))
7374 .with_column("typnotnull", SqlScalarType::Bool.nullable(false))
7375 .with_column("typbasetype", SqlScalarType::Oid.nullable(false))
7376 .with_column("typtypmod", SqlScalarType::Int32.nullable(false))
7377 .with_column("typcollation", SqlScalarType::Oid.nullable(false))
7378 .with_column("typdefault", SqlScalarType::String.nullable(true))
7379 .finish(),
7380 column_comments: BTreeMap::new(),
7381 sql: "SELECT
7382 oid, typname, typnamespace, typowner, typlen, typtype, typcategory, typdelim, typrelid, typelem,
7383 typarray, typinput, typreceive, typnotnull, typbasetype, typtypmod, typcollation, typdefault
7384FROM mz_internal.pg_type_all_databases
7385WHERE database_name IS NULL OR database_name = pg_catalog.current_database();",
7386 access: vec![PUBLIC_SELECT],
7387});
7388
7389pub static PG_ATTRIBUTE_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
7395 BuiltinView {
7396 name: "pg_attribute_all_databases",
7397 schema: MZ_INTERNAL_SCHEMA,
7398 oid: oid::VIEW_PG_ATTRIBUTE_ALL_DATABASES_OID,
7399 desc: RelationDesc::builder()
7400 .with_column("attrelid", SqlScalarType::Oid.nullable(false))
7401 .with_column("attname", SqlScalarType::String.nullable(false))
7402 .with_column("atttypid", SqlScalarType::Oid.nullable(false))
7403 .with_column("attlen", SqlScalarType::Int16.nullable(true))
7404 .with_column("attnum", SqlScalarType::Int16.nullable(false))
7405 .with_column("atttypmod", SqlScalarType::Int32.nullable(false))
7406 .with_column("attnotnull", SqlScalarType::Bool.nullable(false))
7407 .with_column("atthasdef", SqlScalarType::Bool.nullable(false))
7408 .with_column("attidentity", SqlScalarType::PgLegacyChar.nullable(false))
7409 .with_column("attgenerated", SqlScalarType::PgLegacyChar.nullable(false))
7410 .with_column("attisdropped", SqlScalarType::Bool.nullable(false))
7411 .with_column("attcollation", SqlScalarType::Oid.nullable(false))
7412 .with_column("database_name", SqlScalarType::String.nullable(true))
7413 .with_column("pg_type_database_name", SqlScalarType::String.nullable(true))
7414 .finish(),
7415 column_comments: BTreeMap::new(),
7416 sql: "
7417SELECT
7418 class_objects.oid as attrelid,
7419 mz_columns.name as attname,
7420 mz_columns.type_oid AS atttypid,
7421 pg_type_all_databases.typlen AS attlen,
7422 position::int8::int2 as attnum,
7423 mz_columns.type_mod as atttypmod,
7424 NOT nullable as attnotnull,
7425 mz_columns.default IS NOT NULL as atthasdef,
7426 ''::pg_catalog.\"char\" as attidentity,
7427 -- MZ doesn't support generated columns so attgenerated is filled with ''
7428 ''::pg_catalog.\"char\" as attgenerated,
7429 FALSE as attisdropped,
7430 -- MZ doesn't support COLLATE so attcollation is filled with 0
7431 0::pg_catalog.oid as attcollation,
7432 -- Columns added because of the peeling. (Note that there are 2 of these here.)
7433 d.name as database_name,
7434 pg_type_all_databases.database_name as pg_type_database_name
7435FROM (
7436 -- pg_attribute catalogs columns on relations and indexes
7437 SELECT id, oid, schema_id, name, type FROM mz_catalog.mz_relations
7438 UNION ALL
7439 SELECT mz_indexes.id, mz_indexes.oid, mz_relations.schema_id, mz_indexes.name, 'index' AS type
7440 FROM mz_catalog.mz_indexes
7441 JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
7442) AS class_objects
7443JOIN mz_catalog.mz_columns ON class_objects.id = mz_columns.id
7444JOIN mz_internal.pg_type_all_databases ON pg_type_all_databases.oid = mz_columns.type_oid
7445JOIN mz_catalog.mz_schemas ON mz_schemas.id = class_objects.schema_id
7446LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id",
7447 access: vec![PUBLIC_SELECT],
7450 }
7451});
7452
7453pub const PG_ATTRIBUTE_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7454 name: "pg_attribute_all_databases_ind",
7455 schema: MZ_INTERNAL_SCHEMA,
7456 oid: oid::INDEX_PG_ATTRIBUTE_ALL_DATABASES_IND_OID,
7457 sql: "IN CLUSTER mz_catalog_server
7458ON mz_internal.pg_attribute_all_databases (
7459 attrelid, attname, atttypid, attlen, attnum, atttypmod, attnotnull, atthasdef, attidentity,
7460 attgenerated, attisdropped, attcollation, database_name, pg_type_database_name
7461)",
7462 is_retained_metrics_object: false,
7463};
7464
7465pub static PG_ATTRIBUTE: LazyLock<BuiltinView> = LazyLock::new(|| {
7466 BuiltinView {
7467 name: "pg_attribute",
7468 schema: PG_CATALOG_SCHEMA,
7469 oid: oid::VIEW_PG_ATTRIBUTE_OID,
7470 desc: RelationDesc::builder()
7471 .with_column("attrelid", SqlScalarType::Oid.nullable(false))
7472 .with_column("attname", SqlScalarType::String.nullable(false))
7473 .with_column("atttypid", SqlScalarType::Oid.nullable(false))
7474 .with_column("attlen", SqlScalarType::Int16.nullable(true))
7475 .with_column("attnum", SqlScalarType::Int16.nullable(false))
7476 .with_column("atttypmod", SqlScalarType::Int32.nullable(false))
7477 .with_column("attnotnull", SqlScalarType::Bool.nullable(false))
7478 .with_column("atthasdef", SqlScalarType::Bool.nullable(false))
7479 .with_column("attidentity", SqlScalarType::PgLegacyChar.nullable(false))
7480 .with_column("attgenerated", SqlScalarType::PgLegacyChar.nullable(false))
7481 .with_column("attisdropped", SqlScalarType::Bool.nullable(false))
7482 .with_column("attcollation", SqlScalarType::Oid.nullable(false))
7483 .finish(),
7484 column_comments: BTreeMap::new(),
7485 sql: "
7486SELECT
7487 attrelid, attname, atttypid, attlen, attnum, atttypmod, attnotnull, atthasdef, attidentity,
7488 attgenerated, attisdropped, attcollation
7489FROM mz_internal.pg_attribute_all_databases
7490WHERE
7491 (database_name IS NULL OR database_name = pg_catalog.current_database()) AND
7492 (pg_type_database_name IS NULL OR pg_type_database_name = pg_catalog.current_database());",
7493 access: vec![PUBLIC_SELECT],
7496 }
7497});
7498
7499pub static PG_PROC: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7500 name: "pg_proc",
7501 schema: PG_CATALOG_SCHEMA,
7502 oid: oid::VIEW_PG_PROC_OID,
7503 desc: RelationDesc::builder()
7504 .with_column("oid", SqlScalarType::Oid.nullable(false))
7505 .with_column("proname", SqlScalarType::String.nullable(false))
7506 .with_column("pronamespace", SqlScalarType::Oid.nullable(false))
7507 .with_column("proowner", SqlScalarType::Oid.nullable(false))
7508 .with_column("proargdefaults", SqlScalarType::String.nullable(true))
7509 .with_column("prorettype", SqlScalarType::Oid.nullable(false))
7510 .finish(),
7511 column_comments: BTreeMap::new(),
7512 sql: "SELECT
7513 mz_functions.oid,
7514 mz_functions.name AS proname,
7515 mz_schemas.oid AS pronamespace,
7516 role_owner.oid AS proowner,
7517 NULL::pg_catalog.text AS proargdefaults,
7518 ret_type.oid AS prorettype
7519FROM mz_catalog.mz_functions
7520JOIN mz_catalog.mz_schemas ON mz_functions.schema_id = mz_schemas.id
7521LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
7522JOIN mz_catalog.mz_types AS ret_type ON mz_functions.return_type_id = ret_type.id
7523JOIN mz_catalog.mz_roles role_owner ON role_owner.id = mz_functions.owner_id
7524WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()",
7525 access: vec![PUBLIC_SELECT],
7526});
7527
7528pub static PG_OPERATOR: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7529 name: "pg_operator",
7530 schema: PG_CATALOG_SCHEMA,
7531 oid: oid::VIEW_PG_OPERATOR_OID,
7532 desc: RelationDesc::builder()
7533 .with_column("oid", SqlScalarType::Oid.nullable(false))
7534 .with_column("oprname", SqlScalarType::String.nullable(false))
7535 .with_column("oprresult", SqlScalarType::Oid.nullable(false))
7536 .with_column("oprleft", SqlScalarType::Oid.nullable(false))
7537 .with_column("oprright", SqlScalarType::Oid.nullable(false))
7538 .with_key(vec![0, 1, 2, 3, 4])
7539 .finish(),
7540 column_comments: BTreeMap::new(),
7541 sql: "SELECT
7542 mz_operators.oid,
7543 mz_operators.name AS oprname,
7544 ret_type.oid AS oprresult,
7545 left_type.oid as oprleft,
7546 right_type.oid as oprright
7547FROM mz_catalog.mz_operators
7548JOIN mz_catalog.mz_types AS ret_type ON mz_operators.return_type_id = ret_type.id
7549JOIN mz_catalog.mz_types AS left_type ON mz_operators.argument_type_ids[1] = left_type.id
7550JOIN mz_catalog.mz_types AS right_type ON mz_operators.argument_type_ids[2] = right_type.id
7551WHERE array_length(mz_operators.argument_type_ids, 1) = 2
7552UNION SELECT
7553 mz_operators.oid,
7554 mz_operators.name AS oprname,
7555 ret_type.oid AS oprresult,
7556 0 as oprleft,
7557 right_type.oid as oprright
7558FROM mz_catalog.mz_operators
7559JOIN mz_catalog.mz_types AS ret_type ON mz_operators.return_type_id = ret_type.id
7560JOIN mz_catalog.mz_types AS right_type ON mz_operators.argument_type_ids[1] = right_type.id
7561WHERE array_length(mz_operators.argument_type_ids, 1) = 1",
7562 access: vec![PUBLIC_SELECT],
7563});
7564
7565pub static PG_RANGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7566 name: "pg_range",
7567 schema: PG_CATALOG_SCHEMA,
7568 oid: oid::VIEW_PG_RANGE_OID,
7569 desc: RelationDesc::builder()
7570 .with_column("rngtypid", SqlScalarType::Oid.nullable(false))
7571 .with_column("rngsubtype", SqlScalarType::Oid.nullable(false))
7572 .with_key(vec![])
7573 .finish(),
7574 column_comments: BTreeMap::new(),
7575 sql: "SELECT
7576 NULL::pg_catalog.oid AS rngtypid,
7577 NULL::pg_catalog.oid AS rngsubtype
7578WHERE false",
7579 access: vec![PUBLIC_SELECT],
7580});
7581
7582pub static PG_ENUM: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7583 name: "pg_enum",
7584 schema: PG_CATALOG_SCHEMA,
7585 oid: oid::VIEW_PG_ENUM_OID,
7586 desc: RelationDesc::builder()
7587 .with_column("oid", SqlScalarType::Oid.nullable(false))
7588 .with_column("enumtypid", SqlScalarType::Oid.nullable(false))
7589 .with_column("enumsortorder", SqlScalarType::Float32.nullable(false))
7590 .with_column("enumlabel", SqlScalarType::String.nullable(false))
7591 .with_key(vec![])
7592 .finish(),
7593 column_comments: BTreeMap::new(),
7594 sql: "SELECT
7595 NULL::pg_catalog.oid AS oid,
7596 NULL::pg_catalog.oid AS enumtypid,
7597 NULL::pg_catalog.float4 AS enumsortorder,
7598 NULL::pg_catalog.text AS enumlabel
7599WHERE false",
7600 access: vec![PUBLIC_SELECT],
7601});
7602
7603pub static PG_ATTRDEF_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7607 name: "pg_attrdef_all_databases",
7608 schema: MZ_INTERNAL_SCHEMA,
7609 oid: oid::VIEW_PG_ATTRDEF_ALL_DATABASES_OID,
7610 desc: RelationDesc::builder()
7611 .with_column("oid", SqlScalarType::Oid.nullable(true))
7612 .with_column("adrelid", SqlScalarType::Oid.nullable(false))
7613 .with_column("adnum", SqlScalarType::Int64.nullable(false))
7614 .with_column("adbin", SqlScalarType::String.nullable(false))
7615 .with_column("adsrc", SqlScalarType::String.nullable(false))
7616 .finish(),
7617 column_comments: BTreeMap::new(),
7618 sql: "
7619SELECT
7620 NULL::pg_catalog.oid AS oid,
7621 mz_objects.oid AS adrelid,
7622 mz_columns.position::int8 AS adnum,
7623 mz_columns.default AS adbin,
7624 mz_columns.default AS adsrc
7625FROM mz_catalog.mz_columns
7626 JOIN mz_catalog.mz_objects ON mz_columns.id = mz_objects.id
7627WHERE default IS NOT NULL",
7628 access: vec![PUBLIC_SELECT],
7629});
7630
7631pub const PG_ATTRDEF_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7632 name: "pg_attrdef_all_databases_ind",
7633 schema: MZ_INTERNAL_SCHEMA,
7634 oid: oid::INDEX_PG_ATTRDEF_ALL_DATABASES_IND_OID,
7635 sql: "IN CLUSTER mz_catalog_server
7636ON mz_internal.pg_attrdef_all_databases (oid, adrelid, adnum, adbin, adsrc)",
7637 is_retained_metrics_object: false,
7638};
7639
7640pub static PG_ATTRDEF: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7641 name: "pg_attrdef",
7642 schema: PG_CATALOG_SCHEMA,
7643 oid: oid::VIEW_PG_ATTRDEF_OID,
7644 desc: RelationDesc::builder()
7645 .with_column("oid", SqlScalarType::Oid.nullable(true))
7646 .with_column("adrelid", SqlScalarType::Oid.nullable(false))
7647 .with_column("adnum", SqlScalarType::Int64.nullable(false))
7648 .with_column("adbin", SqlScalarType::String.nullable(false))
7649 .with_column("adsrc", SqlScalarType::String.nullable(false))
7650 .finish(),
7651 column_comments: BTreeMap::new(),
7652 sql: "
7653SELECT
7654 pg_attrdef_all_databases.oid as oid,
7655 adrelid,
7656 adnum,
7657 adbin,
7658 adsrc
7659FROM mz_internal.pg_attrdef_all_databases
7660 JOIN mz_catalog.mz_databases d ON (d.id IS NULL OR d.name = pg_catalog.current_database());",
7661 access: vec![PUBLIC_SELECT],
7662});
7663
7664pub static PG_SETTINGS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7665 name: "pg_settings",
7666 schema: PG_CATALOG_SCHEMA,
7667 oid: oid::VIEW_PG_SETTINGS_OID,
7668 desc: RelationDesc::builder()
7669 .with_column("name", SqlScalarType::String.nullable(false))
7670 .with_column("setting", SqlScalarType::String.nullable(false))
7671 .with_key(vec![])
7672 .finish(),
7673 column_comments: BTreeMap::new(),
7674 sql: "SELECT
7675 name, setting
7676FROM (VALUES
7677 ('max_index_keys'::pg_catalog.text, '1000'::pg_catalog.text)
7678) AS _ (name, setting)",
7679 access: vec![PUBLIC_SELECT],
7680});
7681
7682pub static PG_AUTH_MEMBERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7683 name: "pg_auth_members",
7684 schema: PG_CATALOG_SCHEMA,
7685 oid: oid::VIEW_PG_AUTH_MEMBERS_OID,
7686 desc: RelationDesc::builder()
7687 .with_column("roleid", SqlScalarType::Oid.nullable(false))
7688 .with_column("member", SqlScalarType::Oid.nullable(false))
7689 .with_column("grantor", SqlScalarType::Oid.nullable(false))
7690 .with_column("admin_option", SqlScalarType::Bool.nullable(false))
7691 .finish(),
7692 column_comments: BTreeMap::new(),
7693 sql: "SELECT
7694 role.oid AS roleid,
7695 member.oid AS member,
7696 grantor.oid AS grantor,
7697 -- Materialize hasn't implemented admin_option.
7698 false as admin_option
7699FROM mz_catalog.mz_role_members membership
7700JOIN mz_catalog.mz_roles role ON membership.role_id = role.id
7701JOIN mz_catalog.mz_roles member ON membership.member = member.id
7702JOIN mz_catalog.mz_roles grantor ON membership.grantor = grantor.id",
7703 access: vec![PUBLIC_SELECT],
7704});
7705
7706pub static PG_EVENT_TRIGGER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7707 name: "pg_event_trigger",
7708 schema: PG_CATALOG_SCHEMA,
7709 oid: oid::VIEW_PG_EVENT_TRIGGER_OID,
7710 desc: RelationDesc::builder()
7711 .with_column("oid", SqlScalarType::Oid.nullable(false))
7712 .with_column("evtname", SqlScalarType::String.nullable(false))
7713 .with_column("evtevent", SqlScalarType::String.nullable(false))
7714 .with_column("evtowner", SqlScalarType::Oid.nullable(false))
7715 .with_column("evtfoid", SqlScalarType::Oid.nullable(false))
7716 .with_column("evtenabled", SqlScalarType::PgLegacyChar.nullable(false))
7717 .with_column(
7718 "evttags",
7719 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
7720 )
7721 .with_key(vec![])
7722 .finish(),
7723 column_comments: BTreeMap::new(),
7724 sql: "SELECT
7725 NULL::pg_catalog.oid AS oid,
7726 NULL::pg_catalog.text AS evtname,
7727 NULL::pg_catalog.text AS evtevent,
7728 NULL::pg_catalog.oid AS evtowner,
7729 NULL::pg_catalog.oid AS evtfoid,
7730 NULL::pg_catalog.char AS evtenabled,
7731 NULL::pg_catalog.text[] AS evttags
7732 WHERE false",
7733 access: vec![PUBLIC_SELECT],
7734});
7735
7736pub static PG_LANGUAGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7737 name: "pg_language",
7738 schema: PG_CATALOG_SCHEMA,
7739 oid: oid::VIEW_PG_LANGUAGE_OID,
7740 desc: RelationDesc::builder()
7741 .with_column("oid", SqlScalarType::Oid.nullable(false))
7742 .with_column("lanname", SqlScalarType::String.nullable(false))
7743 .with_column("lanowner", SqlScalarType::Oid.nullable(false))
7744 .with_column("lanispl", SqlScalarType::Bool.nullable(false))
7745 .with_column("lanpltrusted", SqlScalarType::Bool.nullable(false))
7746 .with_column("lanplcallfoid", SqlScalarType::Oid.nullable(false))
7747 .with_column("laninline", SqlScalarType::Oid.nullable(false))
7748 .with_column("lanvalidator", SqlScalarType::Oid.nullable(false))
7749 .with_column(
7750 "lanacl",
7751 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
7752 )
7753 .with_key(vec![])
7754 .finish(),
7755 column_comments: BTreeMap::new(),
7756 sql: "SELECT
7757 NULL::pg_catalog.oid AS oid,
7758 NULL::pg_catalog.text AS lanname,
7759 NULL::pg_catalog.oid AS lanowner,
7760 NULL::pg_catalog.bool AS lanispl,
7761 NULL::pg_catalog.bool AS lanpltrusted,
7762 NULL::pg_catalog.oid AS lanplcallfoid,
7763 NULL::pg_catalog.oid AS laninline,
7764 NULL::pg_catalog.oid AS lanvalidator,
7765 NULL::pg_catalog.text[] AS lanacl
7766 WHERE false",
7767 access: vec![PUBLIC_SELECT],
7768});
7769
7770pub static PG_SHDESCRIPTION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7771 name: "pg_shdescription",
7772 schema: PG_CATALOG_SCHEMA,
7773 oid: oid::VIEW_PG_SHDESCRIPTION_OID,
7774 desc: RelationDesc::builder()
7775 .with_column("objoid", SqlScalarType::Oid.nullable(false))
7776 .with_column("classoid", SqlScalarType::Oid.nullable(false))
7777 .with_column("description", SqlScalarType::String.nullable(false))
7778 .with_key(vec![])
7779 .finish(),
7780 column_comments: BTreeMap::new(),
7781 sql: "SELECT
7782 NULL::pg_catalog.oid AS objoid,
7783 NULL::pg_catalog.oid AS classoid,
7784 NULL::pg_catalog.text AS description
7785 WHERE false",
7786 access: vec![PUBLIC_SELECT],
7787});
7788
7789pub static PG_TIMEZONE_ABBREVS: LazyLock<BuiltinView> = LazyLock::new(|| {
7790 BuiltinView {
7791 name: "pg_timezone_abbrevs",
7792 schema: PG_CATALOG_SCHEMA,
7793 oid: oid::VIEW_PG_TIMEZONE_ABBREVS_OID,
7794 desc: RelationDesc::builder()
7795 .with_column("abbrev", SqlScalarType::String.nullable(false))
7796 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
7797 .with_column("is_dst", SqlScalarType::Bool.nullable(true))
7798 .with_key(vec![0])
7799 .finish(),
7800 column_comments: BTreeMap::new(),
7801 sql: "SELECT
7802 abbreviation AS abbrev,
7803 COALESCE(utc_offset, timezone_offset(timezone_name, now()).base_utc_offset + timezone_offset(timezone_name, now()).dst_offset)
7804 AS utc_offset,
7805 COALESCE(dst, timezone_offset(timezone_name, now()).dst_offset <> INTERVAL '0')
7806 AS is_dst
7807FROM mz_catalog.mz_timezone_abbreviations",
7808 access: vec![PUBLIC_SELECT],
7809 }
7810});
7811
7812pub static PG_TIMEZONE_NAMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7813 name: "pg_timezone_names",
7814 schema: PG_CATALOG_SCHEMA,
7815 oid: oid::VIEW_PG_TIMEZONE_NAMES_OID,
7816 desc: RelationDesc::builder()
7817 .with_column("name", SqlScalarType::String.nullable(false))
7818 .with_column("abbrev", SqlScalarType::String.nullable(true))
7819 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
7820 .with_column("is_dst", SqlScalarType::Bool.nullable(true))
7821 .with_key(vec![0])
7822 .finish(),
7823 column_comments: BTreeMap::new(),
7824 sql: "SELECT
7825 name,
7826 timezone_offset(name, now()).abbrev AS abbrev,
7827 timezone_offset(name, now()).base_utc_offset + timezone_offset(name, now()).dst_offset
7828 AS utc_offset,
7829 timezone_offset(name, now()).dst_offset <> INTERVAL '0'
7830 AS is_dst
7831FROM mz_catalog.mz_timezone_names",
7832 access: vec![PUBLIC_SELECT],
7833});
7834
7835pub static MZ_TIMEZONE_ABBREVIATIONS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7836 name: "mz_timezone_abbreviations",
7837 schema: MZ_CATALOG_SCHEMA,
7838 oid: oid::VIEW_MZ_TIMEZONE_ABBREVIATIONS_OID,
7839 desc: RelationDesc::builder()
7840 .with_column("abbreviation", SqlScalarType::String.nullable(false))
7841 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
7842 .with_column("dst", SqlScalarType::Bool.nullable(true))
7843 .with_column("timezone_name", SqlScalarType::String.nullable(true))
7844 .with_key(vec![0])
7845 .finish(),
7846 column_comments: BTreeMap::from_iter([
7847 ("abbreviation", "The timezone abbreviation."),
7848 (
7849 "utc_offset",
7850 "The UTC offset of the timezone or `NULL` if fixed.",
7851 ),
7852 (
7853 "dst",
7854 "Whether the timezone is in daylight savings or `NULL` if fixed.",
7855 ),
7856 (
7857 "timezone_name",
7858 "The full name of the non-fixed timezone or `NULL` if not fixed.",
7859 ),
7860 ]),
7861 sql: format!(
7862 "SELECT * FROM ({}) _ (abbreviation, utc_offset, dst, timezone_name)",
7863 mz_pgtz::abbrev::MZ_CATALOG_TIMEZONE_ABBREVIATIONS_SQL,
7864 )
7865 .leak(),
7866 access: vec![PUBLIC_SELECT],
7867});
7868
7869pub static MZ_TIMEZONE_NAMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7870 name: "mz_timezone_names",
7871 schema: MZ_CATALOG_SCHEMA,
7872 oid: oid::VIEW_MZ_TIMEZONE_NAMES_OID,
7873 desc: RelationDesc::builder()
7874 .with_column("name", SqlScalarType::String.nullable(false))
7875 .with_key(vec![0])
7876 .finish(),
7877 column_comments: BTreeMap::from_iter([("name", "The timezone name.")]),
7878 sql: format!(
7879 "SELECT * FROM ({}) _ (name)",
7880 mz_pgtz::timezone::MZ_CATALOG_TIMEZONE_NAMES_SQL,
7881 )
7882 .leak(),
7883 access: vec![PUBLIC_SELECT],
7884});
7885
7886pub static MZ_PEEK_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
7887 LazyLock::new(|| BuiltinView {
7888 name: "mz_peek_durations_histogram_per_worker",
7889 schema: MZ_INTROSPECTION_SCHEMA,
7890 oid: oid::VIEW_MZ_PEEK_DURATIONS_HISTOGRAM_PER_WORKER_OID,
7891 desc: RelationDesc::builder()
7892 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
7893 .with_column("type", SqlScalarType::String.nullable(false))
7894 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7895 .with_column("count", SqlScalarType::Int64.nullable(false))
7896 .with_key(vec![0, 1, 2])
7897 .finish(),
7898 column_comments: BTreeMap::new(),
7899 sql: "SELECT
7900 worker_id, type, duration_ns, pg_catalog.count(*) AS count
7901FROM
7902 mz_introspection.mz_peek_durations_histogram_raw
7903GROUP BY
7904 worker_id, type, duration_ns",
7905 access: vec![PUBLIC_SELECT],
7906 });
7907
7908pub static MZ_PEEK_DURATIONS_HISTOGRAM: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7909 name: "mz_peek_durations_histogram",
7910 schema: MZ_INTROSPECTION_SCHEMA,
7911 oid: oid::VIEW_MZ_PEEK_DURATIONS_HISTOGRAM_OID,
7912 desc: RelationDesc::builder()
7913 .with_column("type", SqlScalarType::String.nullable(false))
7914 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7915 .with_column(
7916 "count",
7917 SqlScalarType::Numeric {
7918 max_scale: Some(NumericMaxScale::ZERO),
7919 }
7920 .nullable(false),
7921 )
7922 .with_key(vec![0, 1])
7923 .finish(),
7924 column_comments: BTreeMap::from_iter([
7925 ("type", "The peek variant: `index` or `persist`."),
7926 (
7927 "duration_ns",
7928 "The upper bound of the bucket in nanoseconds.",
7929 ),
7930 (
7931 "count",
7932 "The (noncumulative) count of peeks in this bucket.",
7933 ),
7934 ]),
7935 sql: "
7936SELECT
7937 type, duration_ns,
7938 pg_catalog.sum(count) AS count
7939FROM mz_introspection.mz_peek_durations_histogram_per_worker
7940GROUP BY type, duration_ns",
7941 access: vec![PUBLIC_SELECT],
7942});
7943
7944pub static MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
7945 LazyLock::new(|| BuiltinView {
7946 name: "mz_dataflow_shutdown_durations_histogram_per_worker",
7947 schema: MZ_INTROSPECTION_SCHEMA,
7948 oid: oid::VIEW_MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_PER_WORKER_OID,
7949 desc: RelationDesc::builder()
7950 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
7951 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7952 .with_column("count", SqlScalarType::Int64.nullable(false))
7953 .with_key(vec![0, 1])
7954 .finish(),
7955 column_comments: BTreeMap::new(),
7956 sql: "SELECT
7957 worker_id, duration_ns, pg_catalog.count(*) AS count
7958FROM
7959 mz_introspection.mz_dataflow_shutdown_durations_histogram_raw
7960GROUP BY
7961 worker_id, duration_ns",
7962 access: vec![PUBLIC_SELECT],
7963 });
7964
7965pub static MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM: LazyLock<BuiltinView> =
7966 LazyLock::new(|| BuiltinView {
7967 name: "mz_dataflow_shutdown_durations_histogram",
7968 schema: MZ_INTROSPECTION_SCHEMA,
7969 oid: oid::VIEW_MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_OID,
7970 desc: RelationDesc::builder()
7971 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7972 .with_column(
7973 "count",
7974 SqlScalarType::Numeric {
7975 max_scale: Some(NumericMaxScale::ZERO),
7976 }
7977 .nullable(false),
7978 )
7979 .with_key(vec![0])
7980 .finish(),
7981 column_comments: BTreeMap::from_iter([
7982 (
7983 "duration_ns",
7984 "The upper bound of the bucket in nanoseconds.",
7985 ),
7986 (
7987 "count",
7988 "The (noncumulative) count of dataflows in this bucket.",
7989 ),
7990 ]),
7991 sql: "
7992SELECT
7993 duration_ns,
7994 pg_catalog.sum(count) AS count
7995FROM mz_introspection.mz_dataflow_shutdown_durations_histogram_per_worker
7996GROUP BY duration_ns",
7997 access: vec![PUBLIC_SELECT],
7998 });
7999
8000pub static MZ_SCHEDULING_ELAPSED_PER_WORKER: LazyLock<BuiltinView> =
8001 LazyLock::new(|| BuiltinView {
8002 name: "mz_scheduling_elapsed_per_worker",
8003 schema: MZ_INTROSPECTION_SCHEMA,
8004 oid: oid::VIEW_MZ_SCHEDULING_ELAPSED_PER_WORKER_OID,
8005 desc: RelationDesc::builder()
8006 .with_column("id", SqlScalarType::UInt64.nullable(false))
8007 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8008 .with_column("elapsed_ns", SqlScalarType::Int64.nullable(false))
8009 .with_key(vec![0, 1])
8010 .finish(),
8011 column_comments: BTreeMap::new(),
8012 sql: "SELECT
8013 id, worker_id, pg_catalog.count(*) AS elapsed_ns
8014FROM
8015 mz_introspection.mz_scheduling_elapsed_raw
8016GROUP BY
8017 id, worker_id",
8018 access: vec![PUBLIC_SELECT],
8019 });
8020
8021pub static MZ_SCHEDULING_ELAPSED: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8022 name: "mz_scheduling_elapsed",
8023 schema: MZ_INTROSPECTION_SCHEMA,
8024 oid: oid::VIEW_MZ_SCHEDULING_ELAPSED_OID,
8025 desc: RelationDesc::builder()
8026 .with_column("id", SqlScalarType::UInt64.nullable(false))
8027 .with_column(
8028 "elapsed_ns",
8029 SqlScalarType::Numeric {
8030 max_scale: Some(NumericMaxScale::ZERO),
8031 }
8032 .nullable(false),
8033 )
8034 .with_key(vec![0])
8035 .finish(),
8036 column_comments: BTreeMap::from_iter([
8037 (
8038 "id",
8039 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
8040 ),
8041 (
8042 "elapsed_ns",
8043 "The total elapsed time spent in the operator in nanoseconds.",
8044 ),
8045 ]),
8046 sql: "
8047SELECT
8048 id,
8049 pg_catalog.sum(elapsed_ns) AS elapsed_ns
8050FROM mz_introspection.mz_scheduling_elapsed_per_worker
8051GROUP BY id",
8052 access: vec![PUBLIC_SELECT],
8053});
8054
8055pub static MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
8056 LazyLock::new(|| BuiltinView {
8057 name: "mz_compute_operator_durations_histogram_per_worker",
8058 schema: MZ_INTROSPECTION_SCHEMA,
8059 oid: oid::VIEW_MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_PER_WORKER_OID,
8060 desc: RelationDesc::builder()
8061 .with_column("id", SqlScalarType::UInt64.nullable(false))
8062 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8063 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
8064 .with_column("count", SqlScalarType::Int64.nullable(false))
8065 .with_key(vec![0, 1, 2])
8066 .finish(),
8067 column_comments: BTreeMap::new(),
8068 sql: "SELECT
8069 id, worker_id, duration_ns, pg_catalog.count(*) AS count
8070FROM
8071 mz_introspection.mz_compute_operator_durations_histogram_raw
8072GROUP BY
8073 id, worker_id, duration_ns",
8074 access: vec![PUBLIC_SELECT],
8075 });
8076
8077pub static MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM: LazyLock<BuiltinView> =
8078 LazyLock::new(|| BuiltinView {
8079 name: "mz_compute_operator_durations_histogram",
8080 schema: MZ_INTROSPECTION_SCHEMA,
8081 oid: oid::VIEW_MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_OID,
8082 desc: RelationDesc::builder()
8083 .with_column("id", SqlScalarType::UInt64.nullable(false))
8084 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
8085 .with_column(
8086 "count",
8087 SqlScalarType::Numeric {
8088 max_scale: Some(NumericMaxScale::ZERO),
8089 }
8090 .nullable(false),
8091 )
8092 .with_key(vec![0, 1])
8093 .finish(),
8094 column_comments: BTreeMap::from_iter([
8095 (
8096 "id",
8097 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
8098 ),
8099 (
8100 "duration_ns",
8101 "The upper bound of the duration bucket in nanoseconds.",
8102 ),
8103 (
8104 "count",
8105 "The (noncumulative) count of invocations in the bucket.",
8106 ),
8107 ]),
8108 sql: "
8109SELECT
8110 id,
8111 duration_ns,
8112 pg_catalog.sum(count) AS count
8113FROM mz_introspection.mz_compute_operator_durations_histogram_per_worker
8114GROUP BY id, duration_ns",
8115 access: vec![PUBLIC_SELECT],
8116 });
8117
8118pub static MZ_SCHEDULING_PARKS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
8119 LazyLock::new(|| BuiltinView {
8120 name: "mz_scheduling_parks_histogram_per_worker",
8121 schema: MZ_INTROSPECTION_SCHEMA,
8122 oid: oid::VIEW_MZ_SCHEDULING_PARKS_HISTOGRAM_PER_WORKER_OID,
8123 desc: RelationDesc::builder()
8124 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8125 .with_column("slept_for_ns", SqlScalarType::UInt64.nullable(false))
8126 .with_column("requested_ns", SqlScalarType::UInt64.nullable(false))
8127 .with_column("count", SqlScalarType::Int64.nullable(false))
8128 .with_key(vec![0, 1, 2])
8129 .finish(),
8130 column_comments: BTreeMap::new(),
8131 sql: "SELECT
8132 worker_id, slept_for_ns, requested_ns, pg_catalog.count(*) AS count
8133FROM
8134 mz_introspection.mz_scheduling_parks_histogram_raw
8135GROUP BY
8136 worker_id, slept_for_ns, requested_ns",
8137 access: vec![PUBLIC_SELECT],
8138 });
8139
8140pub static MZ_SCHEDULING_PARKS_HISTOGRAM: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8141 name: "mz_scheduling_parks_histogram",
8142 schema: MZ_INTROSPECTION_SCHEMA,
8143 oid: oid::VIEW_MZ_SCHEDULING_PARKS_HISTOGRAM_OID,
8144 desc: RelationDesc::builder()
8145 .with_column("slept_for_ns", SqlScalarType::UInt64.nullable(false))
8146 .with_column("requested_ns", SqlScalarType::UInt64.nullable(false))
8147 .with_column(
8148 "count",
8149 SqlScalarType::Numeric {
8150 max_scale: Some(NumericMaxScale::ZERO),
8151 }
8152 .nullable(false),
8153 )
8154 .with_key(vec![0, 1])
8155 .finish(),
8156 column_comments: BTreeMap::from_iter([
8157 (
8158 "slept_for_ns",
8159 "The actual length of the park event in nanoseconds.",
8160 ),
8161 (
8162 "requested_ns",
8163 "The requested length of the park event in nanoseconds.",
8164 ),
8165 (
8166 "count",
8167 "The (noncumulative) count of park events in this bucket.",
8168 ),
8169 ]),
8170 sql: "
8171SELECT
8172 slept_for_ns,
8173 requested_ns,
8174 pg_catalog.sum(count) AS count
8175FROM mz_introspection.mz_scheduling_parks_histogram_per_worker
8176GROUP BY slept_for_ns, requested_ns",
8177 access: vec![PUBLIC_SELECT],
8178});
8179
8180pub static MZ_COMPUTE_ERROR_COUNTS_PER_WORKER: LazyLock<BuiltinView> =
8181 LazyLock::new(|| BuiltinView {
8182 name: "mz_compute_error_counts_per_worker",
8183 schema: MZ_INTROSPECTION_SCHEMA,
8184 oid: oid::VIEW_MZ_COMPUTE_ERROR_COUNTS_PER_WORKER_OID,
8185 desc: RelationDesc::builder()
8186 .with_column("export_id", SqlScalarType::String.nullable(false))
8187 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8188 .with_column("count", SqlScalarType::Int64.nullable(false))
8189 .with_key(vec![0, 1, 2])
8190 .finish(),
8191 column_comments: BTreeMap::new(),
8192 sql: "
8193WITH MUTUALLY RECURSIVE
8194 -- Indexes that reuse existing indexes rather than maintaining separate dataflows.
8195 -- For these we don't log error counts separately, so we need to forward the error counts from
8196 -- their dependencies instead.
8197 index_reuses(reuse_id text, index_id text) AS (
8198 SELECT d.object_id, d.dependency_id
8199 FROM mz_internal.mz_compute_dependencies d
8200 JOIN mz_introspection.mz_compute_exports e ON (e.export_id = d.object_id)
8201 WHERE NOT EXISTS (
8202 SELECT 1 FROM mz_introspection.mz_dataflows
8203 WHERE id = e.dataflow_id
8204 )
8205 ),
8206 -- Error counts that were directly logged on compute exports.
8207 direct_errors(export_id text, worker_id uint8, count int8) AS (
8208 SELECT export_id, worker_id, count
8209 FROM mz_introspection.mz_compute_error_counts_raw
8210 ),
8211 -- Error counts propagated to index reused.
8212 all_errors(export_id text, worker_id uint8, count int8) AS (
8213 SELECT * FROM direct_errors
8214 UNION
8215 SELECT r.reuse_id, e.worker_id, e.count
8216 FROM all_errors e
8217 JOIN index_reuses r ON (r.index_id = e.export_id)
8218 )
8219SELECT * FROM all_errors",
8220 access: vec![PUBLIC_SELECT],
8221 });
8222
8223pub static MZ_COMPUTE_ERROR_COUNTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8224 name: "mz_compute_error_counts",
8225 schema: MZ_INTROSPECTION_SCHEMA,
8226 oid: oid::VIEW_MZ_COMPUTE_ERROR_COUNTS_OID,
8227 desc: RelationDesc::builder()
8228 .with_column("export_id", SqlScalarType::String.nullable(false))
8229 .with_column(
8230 "count",
8231 SqlScalarType::Numeric {
8232 max_scale: Some(NumericMaxScale::ZERO),
8233 }
8234 .nullable(false),
8235 )
8236 .with_key(vec![0])
8237 .finish(),
8238 column_comments: BTreeMap::from_iter([
8239 (
8240 "export_id",
8241 "The ID of the dataflow export. Corresponds to `mz_compute_exports.export_id`.",
8242 ),
8243 (
8244 "count",
8245 "The count of errors present in this dataflow export.",
8246 ),
8247 ]),
8248 sql: "
8249SELECT
8250 export_id,
8251 pg_catalog.sum(count) AS count
8252FROM mz_introspection.mz_compute_error_counts_per_worker
8253GROUP BY export_id
8254HAVING pg_catalog.sum(count) != 0",
8255 access: vec![PUBLIC_SELECT],
8256});
8257
8258pub static MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED: LazyLock<BuiltinSource> =
8259 LazyLock::new(|| BuiltinSource {
8260 name: "mz_compute_error_counts_raw_unified",
8264 schema: MZ_INTERNAL_SCHEMA,
8265 oid: oid::SOURCE_MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED_OID,
8266 desc: RelationDesc::builder()
8267 .with_column("replica_id", SqlScalarType::String.nullable(false))
8268 .with_column("object_id", SqlScalarType::String.nullable(false))
8269 .with_column(
8270 "count",
8271 SqlScalarType::Numeric { max_scale: None }.nullable(false),
8272 )
8273 .finish(),
8274 data_source: IntrospectionType::ComputeErrorCounts,
8275 column_comments: BTreeMap::new(),
8276 is_retained_metrics_object: false,
8277 access: vec![PUBLIC_SELECT],
8278 });
8279
8280pub static MZ_COMPUTE_HYDRATION_TIMES: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
8281 name: "mz_compute_hydration_times",
8282 schema: MZ_INTERNAL_SCHEMA,
8283 oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_TIMES_OID,
8284 desc: RelationDesc::builder()
8285 .with_column("replica_id", SqlScalarType::String.nullable(false))
8286 .with_column("object_id", SqlScalarType::String.nullable(false))
8287 .with_column("time_ns", SqlScalarType::UInt64.nullable(true))
8288 .finish(),
8289 data_source: IntrospectionType::ComputeHydrationTimes,
8290 column_comments: BTreeMap::new(),
8291 is_retained_metrics_object: true,
8292 access: vec![PUBLIC_SELECT],
8293});
8294
8295pub static MZ_COMPUTE_HYDRATION_TIMES_IND: LazyLock<BuiltinIndex> =
8296 LazyLock::new(|| BuiltinIndex {
8297 name: "mz_compute_hydration_times_ind",
8298 schema: MZ_INTERNAL_SCHEMA,
8299 oid: oid::INDEX_MZ_COMPUTE_HYDRATION_TIMES_IND_OID,
8300 sql: "IN CLUSTER mz_catalog_server
8301 ON mz_internal.mz_compute_hydration_times (replica_id)",
8302 is_retained_metrics_object: true,
8303 });
8304
8305pub static MZ_COMPUTE_HYDRATION_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8306 name: "mz_compute_hydration_statuses",
8307 schema: MZ_INTERNAL_SCHEMA,
8308 oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_STATUSES_OID,
8309 desc: RelationDesc::builder()
8310 .with_column("object_id", SqlScalarType::String.nullable(false))
8311 .with_column("replica_id", SqlScalarType::String.nullable(false))
8312 .with_column("hydrated", SqlScalarType::Bool.nullable(false))
8313 .with_column("hydration_time", SqlScalarType::Interval.nullable(true))
8314 .finish(),
8315 column_comments: BTreeMap::from_iter([
8316 (
8317 "object_id",
8318 "The ID of a compute object. Corresponds to `mz_catalog.mz_indexes.id` or `mz_catalog.mz_materialized_views.id`",
8319 ),
8320 ("replica_id", "The ID of a cluster replica."),
8321 (
8322 "hydrated",
8323 "Whether the compute object is hydrated on the replica.",
8324 ),
8325 (
8326 "hydration_time",
8327 "The amount of time it took for the replica to hydrate the compute object.",
8328 ),
8329 ]),
8330 sql: "
8331WITH
8332 dataflows AS (
8333 SELECT
8334 object_id,
8335 replica_id,
8336 time_ns IS NOT NULL AS hydrated,
8337 ((time_ns / 1000) || 'microseconds')::interval AS hydration_time
8338 FROM mz_internal.mz_compute_hydration_times
8339 ),
8340 -- MVs that have advanced to the empty frontier don't have a dataflow installed anymore and
8341 -- therefore don't show up in `mz_compute_hydration_times`. We still want to show them here to
8342 -- avoid surprises for people joining `mz_materialized_views` against this relation (like the
8343 -- blue-green readiness query does), so we include them as 'hydrated'.
8344 complete_mvs AS (
8345 SELECT
8346 mv.id,
8347 f.replica_id,
8348 true AS hydrated,
8349 NULL::interval AS hydration_time
8350 FROM mz_materialized_views mv
8351 JOIN mz_catalog.mz_cluster_replica_frontiers f ON f.object_id = mv.id
8352 WHERE f.write_frontier IS NULL
8353 ),
8354 -- Ditto CTs
8355 complete_cts AS (
8356 SELECT
8357 ct.id,
8358 f.replica_id,
8359 true AS hydrated,
8360 NULL::interval AS hydration_time
8361 FROM mz_internal.mz_continual_tasks ct
8362 JOIN mz_catalog.mz_cluster_replica_frontiers f ON f.object_id = ct.id
8363 WHERE f.write_frontier IS NULL
8364 )
8365SELECT * FROM dataflows
8366UNION ALL
8367SELECT * FROM complete_mvs
8368UNION ALL
8369SELECT * FROM complete_cts",
8370 access: vec![PUBLIC_SELECT],
8371});
8372
8373pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES: LazyLock<BuiltinSource> = LazyLock::new(|| {
8374 BuiltinSource {
8375 name: "mz_compute_operator_hydration_statuses",
8376 schema: MZ_INTERNAL_SCHEMA,
8377 oid: oid::SOURCE_MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_OID,
8378 desc: RelationDesc::builder()
8379 .with_column("replica_id", SqlScalarType::String.nullable(false))
8380 .with_column("object_id", SqlScalarType::String.nullable(false))
8381 .with_column(
8382 "physical_plan_node_id",
8383 SqlScalarType::UInt64.nullable(false),
8384 )
8385 .with_column("hydrated", SqlScalarType::Bool.nullable(false))
8386 .with_key(vec![0, 1, 2])
8387 .finish(),
8388 data_source: IntrospectionType::ComputeOperatorHydrationStatus,
8389 column_comments: BTreeMap::from_iter([
8390 ("replica_id", "The ID of a cluster replica."),
8391 (
8392 "object_id",
8393 "The ID of a compute object. Corresponds to `mz_catalog.mz_indexes.id` or `mz_catalog.mz_materialized_views.id`.",
8394 ),
8395 (
8396 "physical_plan_node_id",
8397 "The ID of a node in the physical plan of the compute object. Corresponds to a `node_id` displayed in the output of `EXPLAIN PHYSICAL PLAN WITH (node identifiers)`.",
8398 ),
8399 ("hydrated", "Whether the node is hydrated on the replica."),
8400 ]),
8401 is_retained_metrics_object: false,
8402 access: vec![PUBLIC_SELECT],
8403 }
8404});
8405
8406pub static MZ_MESSAGE_COUNTS_PER_WORKER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8407 name: "mz_message_counts_per_worker",
8408 schema: MZ_INTROSPECTION_SCHEMA,
8409 oid: oid::VIEW_MZ_MESSAGE_COUNTS_PER_WORKER_OID,
8410 desc: RelationDesc::builder()
8411 .with_column("channel_id", SqlScalarType::UInt64.nullable(false))
8412 .with_column("from_worker_id", SqlScalarType::UInt64.nullable(false))
8413 .with_column("to_worker_id", SqlScalarType::UInt64.nullable(false))
8414 .with_column("sent", SqlScalarType::Int64.nullable(false))
8415 .with_column("received", SqlScalarType::Int64.nullable(false))
8416 .with_column("batch_sent", SqlScalarType::Int64.nullable(false))
8417 .with_column("batch_received", SqlScalarType::Int64.nullable(false))
8418 .with_key(vec![0, 1, 2])
8419 .finish(),
8420 column_comments: BTreeMap::new(),
8421 sql: "
8422WITH batch_sent_cte AS (
8423 SELECT
8424 channel_id,
8425 from_worker_id,
8426 to_worker_id,
8427 pg_catalog.count(*) AS sent
8428 FROM
8429 mz_introspection.mz_message_batch_counts_sent_raw
8430 GROUP BY
8431 channel_id, from_worker_id, to_worker_id
8432),
8433batch_received_cte AS (
8434 SELECT
8435 channel_id,
8436 from_worker_id,
8437 to_worker_id,
8438 pg_catalog.count(*) AS received
8439 FROM
8440 mz_introspection.mz_message_batch_counts_received_raw
8441 GROUP BY
8442 channel_id, from_worker_id, to_worker_id
8443),
8444sent_cte AS (
8445 SELECT
8446 channel_id,
8447 from_worker_id,
8448 to_worker_id,
8449 pg_catalog.count(*) AS sent
8450 FROM
8451 mz_introspection.mz_message_counts_sent_raw
8452 GROUP BY
8453 channel_id, from_worker_id, to_worker_id
8454),
8455received_cte AS (
8456 SELECT
8457 channel_id,
8458 from_worker_id,
8459 to_worker_id,
8460 pg_catalog.count(*) AS received
8461 FROM
8462 mz_introspection.mz_message_counts_received_raw
8463 GROUP BY
8464 channel_id, from_worker_id, to_worker_id
8465)
8466SELECT
8467 sent_cte.channel_id,
8468 sent_cte.from_worker_id,
8469 sent_cte.to_worker_id,
8470 sent_cte.sent,
8471 received_cte.received,
8472 batch_sent_cte.sent AS batch_sent,
8473 batch_received_cte.received AS batch_received
8474FROM sent_cte
8475JOIN received_cte USING (channel_id, from_worker_id, to_worker_id)
8476JOIN batch_sent_cte USING (channel_id, from_worker_id, to_worker_id)
8477JOIN batch_received_cte USING (channel_id, from_worker_id, to_worker_id)",
8478 access: vec![PUBLIC_SELECT],
8479});
8480
8481pub static MZ_MESSAGE_COUNTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8482 name: "mz_message_counts",
8483 schema: MZ_INTROSPECTION_SCHEMA,
8484 oid: oid::VIEW_MZ_MESSAGE_COUNTS_OID,
8485 desc: RelationDesc::builder()
8486 .with_column("channel_id", SqlScalarType::UInt64.nullable(false))
8487 .with_column(
8488 "sent",
8489 SqlScalarType::Numeric {
8490 max_scale: Some(NumericMaxScale::ZERO),
8491 }
8492 .nullable(false),
8493 )
8494 .with_column(
8495 "received",
8496 SqlScalarType::Numeric {
8497 max_scale: Some(NumericMaxScale::ZERO),
8498 }
8499 .nullable(false),
8500 )
8501 .with_column(
8502 "batch_sent",
8503 SqlScalarType::Numeric {
8504 max_scale: Some(NumericMaxScale::ZERO),
8505 }
8506 .nullable(false),
8507 )
8508 .with_column(
8509 "batch_received",
8510 SqlScalarType::Numeric {
8511 max_scale: Some(NumericMaxScale::ZERO),
8512 }
8513 .nullable(false),
8514 )
8515 .with_key(vec![0])
8516 .finish(),
8517 column_comments: BTreeMap::from_iter([
8518 (
8519 "channel_id",
8520 "The ID of the channel. Corresponds to `mz_dataflow_channels.id`.",
8521 ),
8522 ("sent", "The number of messages sent."),
8523 ("received", "The number of messages received."),
8524 ("batch_sent", "The number of batches sent."),
8525 ("batch_received", "The number of batches received."),
8526 ]),
8527 sql: "
8528SELECT
8529 channel_id,
8530 pg_catalog.sum(sent) AS sent,
8531 pg_catalog.sum(received) AS received,
8532 pg_catalog.sum(batch_sent) AS batch_sent,
8533 pg_catalog.sum(batch_received) AS batch_received
8534FROM mz_introspection.mz_message_counts_per_worker
8535GROUP BY channel_id",
8536 access: vec![PUBLIC_SELECT],
8537});
8538
8539pub static MZ_ACTIVE_PEEKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8540 name: "mz_active_peeks",
8541 schema: MZ_INTROSPECTION_SCHEMA,
8542 oid: oid::VIEW_MZ_ACTIVE_PEEKS_OID,
8543 desc: RelationDesc::builder()
8544 .with_column("id", SqlScalarType::Uuid.nullable(false))
8545 .with_column("object_id", SqlScalarType::String.nullable(false))
8546 .with_column("type", SqlScalarType::String.nullable(false))
8547 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
8548 .finish(),
8549 column_comments: BTreeMap::from_iter([
8550 ("id", "The ID of the peek request."),
8551 (
8552 "object_id",
8553 "The ID of the collection the peek is targeting. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, `mz_catalog.mz_sources.id`, or `mz_catalog.mz_tables.id`.",
8554 ),
8555 (
8556 "type",
8557 "The type of the corresponding peek: `index` if targeting an index or temporary dataflow; `persist` for a source, materialized view, or table.",
8558 ),
8559 ("time", "The timestamp the peek has requested."),
8560 ]),
8561 sql: "
8562SELECT id, object_id, type, time
8563FROM mz_introspection.mz_active_peeks_per_worker
8564WHERE worker_id = 0",
8565 access: vec![PUBLIC_SELECT],
8566});
8567
8568pub static MZ_DATAFLOW_OPERATOR_REACHABILITY_PER_WORKER: LazyLock<BuiltinView> =
8569 LazyLock::new(|| BuiltinView {
8570 name: "mz_dataflow_operator_reachability_per_worker",
8571 schema: MZ_INTROSPECTION_SCHEMA,
8572 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_REACHABILITY_PER_WORKER_OID,
8573 desc: RelationDesc::builder()
8574 .with_column("id", SqlScalarType::UInt64.nullable(false))
8575 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8576 .with_column("port", SqlScalarType::UInt64.nullable(false))
8577 .with_column("update_type", SqlScalarType::String.nullable(false))
8578 .with_column("time", SqlScalarType::MzTimestamp.nullable(true))
8579 .with_column("count", SqlScalarType::Int64.nullable(false))
8580 .with_key(vec![0, 1, 2, 3, 4])
8581 .finish(),
8582 column_comments: BTreeMap::new(),
8583 sql: "SELECT
8584 addr2.id,
8585 reachability.worker_id,
8586 port,
8587 update_type,
8588 time,
8589 pg_catalog.count(*) as count
8590FROM
8591 mz_introspection.mz_dataflow_operator_reachability_raw reachability,
8592 mz_introspection.mz_dataflow_addresses_per_worker addr1,
8593 mz_introspection.mz_dataflow_addresses_per_worker addr2
8594WHERE
8595 addr2.address =
8596 CASE
8597 WHEN source = 0 THEN addr1.address
8598 ELSE addr1.address || reachability.source
8599 END
8600 AND addr1.id = reachability.id
8601 AND addr1.worker_id = reachability.worker_id
8602 AND addr2.worker_id = reachability.worker_id
8603GROUP BY addr2.id, reachability.worker_id, port, update_type, time",
8604 access: vec![PUBLIC_SELECT],
8605 });
8606
8607pub static MZ_DATAFLOW_OPERATOR_REACHABILITY: LazyLock<BuiltinView> =
8608 LazyLock::new(|| BuiltinView {
8609 name: "mz_dataflow_operator_reachability",
8610 schema: MZ_INTROSPECTION_SCHEMA,
8611 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_REACHABILITY_OID,
8612 desc: RelationDesc::builder()
8613 .with_column("id", SqlScalarType::UInt64.nullable(false))
8614 .with_column("port", SqlScalarType::UInt64.nullable(false))
8615 .with_column("update_type", SqlScalarType::String.nullable(false))
8616 .with_column("time", SqlScalarType::MzTimestamp.nullable(true))
8617 .with_column(
8618 "count",
8619 SqlScalarType::Numeric {
8620 max_scale: Some(NumericMaxScale::ZERO),
8621 }
8622 .nullable(false),
8623 )
8624 .with_key(vec![0, 1, 2, 3])
8625 .finish(),
8626 column_comments: BTreeMap::new(),
8627 sql: "
8628SELECT
8629 id,
8630 port,
8631 update_type,
8632 time,
8633 pg_catalog.sum(count) as count
8634FROM mz_introspection.mz_dataflow_operator_reachability_per_worker
8635GROUP BY id, port, update_type, time",
8636 access: vec![PUBLIC_SELECT],
8637 });
8638
8639pub static MZ_ARRANGEMENT_SIZES_PER_WORKER: LazyLock<BuiltinView> = LazyLock::new(|| {
8640 BuiltinView {
8641 name: "mz_arrangement_sizes_per_worker",
8642 schema: MZ_INTROSPECTION_SCHEMA,
8643 oid: oid::VIEW_MZ_ARRANGEMENT_SIZES_PER_WORKER_OID,
8644 desc: RelationDesc::builder()
8645 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8646 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8647 .with_column("records", SqlScalarType::Int64.nullable(true))
8648 .with_column("batches", SqlScalarType::Int64.nullable(true))
8649 .with_column("size", SqlScalarType::Int64.nullable(true))
8650 .with_column("capacity", SqlScalarType::Int64.nullable(true))
8651 .with_column("allocations", SqlScalarType::Int64.nullable(true))
8652 .finish(),
8653 column_comments: BTreeMap::new(),
8654 sql: "
8655WITH operators_per_worker_cte AS (
8656 SELECT
8657 id AS operator_id,
8658 worker_id
8659 FROM
8660 mz_introspection.mz_dataflow_operators_per_worker
8661),
8662batches_cte AS (
8663 SELECT
8664 operator_id,
8665 worker_id,
8666 COUNT(*) AS batches
8667 FROM
8668 mz_introspection.mz_arrangement_batches_raw
8669 GROUP BY
8670 operator_id, worker_id
8671),
8672records_cte AS (
8673 SELECT
8674 operator_id,
8675 worker_id,
8676 COUNT(*) AS records
8677 FROM
8678 mz_introspection.mz_arrangement_records_raw
8679 GROUP BY
8680 operator_id, worker_id
8681),
8682heap_size_cte AS (
8683 SELECT
8684 operator_id,
8685 worker_id,
8686 COUNT(*) AS size
8687 FROM
8688 mz_introspection.mz_arrangement_heap_size_raw
8689 GROUP BY
8690 operator_id, worker_id
8691),
8692heap_capacity_cte AS (
8693 SELECT
8694 operator_id,
8695 worker_id,
8696 COUNT(*) AS capacity
8697 FROM
8698 mz_introspection.mz_arrangement_heap_capacity_raw
8699 GROUP BY
8700 operator_id, worker_id
8701),
8702heap_allocations_cte AS (
8703 SELECT
8704 operator_id,
8705 worker_id,
8706 COUNT(*) AS allocations
8707 FROM
8708 mz_introspection.mz_arrangement_heap_allocations_raw
8709 GROUP BY
8710 operator_id, worker_id
8711),
8712batcher_records_cte AS (
8713 SELECT
8714 operator_id,
8715 worker_id,
8716 COUNT(*) AS records
8717 FROM
8718 mz_introspection.mz_arrangement_batcher_records_raw
8719 GROUP BY
8720 operator_id, worker_id
8721),
8722batcher_size_cte AS (
8723 SELECT
8724 operator_id,
8725 worker_id,
8726 COUNT(*) AS size
8727 FROM
8728 mz_introspection.mz_arrangement_batcher_size_raw
8729 GROUP BY
8730 operator_id, worker_id
8731),
8732batcher_capacity_cte AS (
8733 SELECT
8734 operator_id,
8735 worker_id,
8736 COUNT(*) AS capacity
8737 FROM
8738 mz_introspection.mz_arrangement_batcher_capacity_raw
8739 GROUP BY
8740 operator_id, worker_id
8741),
8742batcher_allocations_cte AS (
8743 SELECT
8744 operator_id,
8745 worker_id,
8746 COUNT(*) AS allocations
8747 FROM
8748 mz_introspection.mz_arrangement_batcher_allocations_raw
8749 GROUP BY
8750 operator_id, worker_id
8751),
8752combined AS (
8753 SELECT
8754 opw.operator_id,
8755 opw.worker_id,
8756 CASE
8757 WHEN records_cte.records IS NULL AND batcher_records_cte.records IS NULL THEN NULL
8758 ELSE COALESCE(records_cte.records, 0) + COALESCE(batcher_records_cte.records, 0)
8759 END AS records,
8760 batches_cte.batches AS batches,
8761 CASE
8762 WHEN heap_size_cte.size IS NULL AND batcher_size_cte.size IS NULL THEN NULL
8763 ELSE COALESCE(heap_size_cte.size, 0) + COALESCE(batcher_size_cte.size, 0)
8764 END AS size,
8765 CASE
8766 WHEN heap_capacity_cte.capacity IS NULL AND batcher_capacity_cte.capacity IS NULL THEN NULL
8767 ELSE COALESCE(heap_capacity_cte.capacity, 0) + COALESCE(batcher_capacity_cte.capacity, 0)
8768 END AS capacity,
8769 CASE
8770 WHEN heap_allocations_cte.allocations IS NULL AND batcher_allocations_cte.allocations IS NULL THEN NULL
8771 ELSE COALESCE(heap_allocations_cte.allocations, 0) + COALESCE(batcher_allocations_cte.allocations, 0)
8772 END AS allocations
8773 FROM
8774 operators_per_worker_cte opw
8775 LEFT OUTER JOIN batches_cte USING (operator_id, worker_id)
8776 LEFT OUTER JOIN records_cte USING (operator_id, worker_id)
8777 LEFT OUTER JOIN heap_size_cte USING (operator_id, worker_id)
8778 LEFT OUTER JOIN heap_capacity_cte USING (operator_id, worker_id)
8779 LEFT OUTER JOIN heap_allocations_cte USING (operator_id, worker_id)
8780 LEFT OUTER JOIN batcher_records_cte USING (operator_id, worker_id)
8781 LEFT OUTER JOIN batcher_size_cte USING (operator_id, worker_id)
8782 LEFT OUTER JOIN batcher_capacity_cte USING (operator_id, worker_id)
8783 LEFT OUTER JOIN batcher_allocations_cte USING (operator_id, worker_id)
8784)
8785SELECT
8786 operator_id, worker_id, records, batches, size, capacity, allocations
8787FROM combined
8788WHERE
8789 records IS NOT NULL
8790 OR batches IS NOT NULL
8791 OR size IS NOT NULL
8792 OR capacity IS NOT NULL
8793 OR allocations IS NOT NULL
8794",
8795 access: vec![PUBLIC_SELECT],
8796 }
8797});
8798
8799pub static MZ_ARRANGEMENT_SIZES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8800 name: "mz_arrangement_sizes",
8801 schema: MZ_INTROSPECTION_SCHEMA,
8802 oid: oid::VIEW_MZ_ARRANGEMENT_SIZES_OID,
8803 desc: RelationDesc::builder()
8804 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8805 .with_column("records", SqlScalarType::Int64.nullable(true))
8806 .with_column("batches", SqlScalarType::Int64.nullable(true))
8807 .with_column("size", SqlScalarType::Int64.nullable(true))
8808 .with_column("capacity", SqlScalarType::Int64.nullable(true))
8809 .with_column("allocations", SqlScalarType::Int64.nullable(true))
8810 .with_key(vec![0])
8811 .finish(),
8812 column_comments: BTreeMap::from_iter([
8813 (
8814 "operator_id",
8815 "The ID of the operator that created the arrangement. Corresponds to `mz_dataflow_operators.id`.",
8816 ),
8817 ("records", "The number of records in the arrangement."),
8818 ("batches", "The number of batches in the arrangement."),
8819 ("size", "The utilized size in bytes of the arrangement."),
8820 (
8821 "capacity",
8822 "The capacity in bytes of the arrangement. Can be larger than the size.",
8823 ),
8824 (
8825 "allocations",
8826 "The number of separate memory allocations backing the arrangement.",
8827 ),
8828 ]),
8829 sql: "
8830SELECT
8831 operator_id,
8832 SUM(records)::int8 AS records,
8833 SUM(batches)::int8 AS batches,
8834 SUM(size)::int8 AS size,
8835 SUM(capacity)::int8 AS capacity,
8836 SUM(allocations)::int8 AS allocations
8837FROM mz_introspection.mz_arrangement_sizes_per_worker
8838GROUP BY operator_id",
8839 access: vec![PUBLIC_SELECT],
8840});
8841
8842pub static MZ_ARRANGEMENT_SHARING_PER_WORKER: LazyLock<BuiltinView> =
8843 LazyLock::new(|| BuiltinView {
8844 name: "mz_arrangement_sharing_per_worker",
8845 schema: MZ_INTROSPECTION_SCHEMA,
8846 oid: oid::VIEW_MZ_ARRANGEMENT_SHARING_PER_WORKER_OID,
8847 desc: RelationDesc::builder()
8848 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8849 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8850 .with_column("count", SqlScalarType::Int64.nullable(false))
8851 .with_key(vec![0, 1])
8852 .finish(),
8853 column_comments: BTreeMap::new(),
8854 sql: "
8855SELECT
8856 operator_id,
8857 worker_id,
8858 pg_catalog.count(*) AS count
8859FROM mz_introspection.mz_arrangement_sharing_raw
8860GROUP BY operator_id, worker_id",
8861 access: vec![PUBLIC_SELECT],
8862 });
8863
8864pub static MZ_ARRANGEMENT_SHARING: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8865 name: "mz_arrangement_sharing",
8866 schema: MZ_INTROSPECTION_SCHEMA,
8867 oid: oid::VIEW_MZ_ARRANGEMENT_SHARING_OID,
8868 desc: RelationDesc::builder()
8869 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8870 .with_column("count", SqlScalarType::Int64.nullable(false))
8871 .finish(),
8872 column_comments: BTreeMap::from_iter([
8873 (
8874 "operator_id",
8875 "The ID of the operator that created the arrangement. Corresponds to `mz_dataflow_operators.id`.",
8876 ),
8877 (
8878 "count",
8879 "The number of operators that share the arrangement.",
8880 ),
8881 ]),
8882 sql: "
8883SELECT operator_id, count
8884FROM mz_introspection.mz_arrangement_sharing_per_worker
8885WHERE worker_id = 0",
8886 access: vec![PUBLIC_SELECT],
8887});
8888
8889pub static MZ_CLUSTER_REPLICA_UTILIZATION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8890 name: "mz_cluster_replica_utilization",
8891 schema: MZ_INTERNAL_SCHEMA,
8892 oid: oid::VIEW_MZ_CLUSTER_REPLICA_UTILIZATION_OID,
8893 desc: RelationDesc::builder()
8894 .with_column("replica_id", SqlScalarType::String.nullable(false))
8895 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
8896 .with_column("cpu_percent", SqlScalarType::Float64.nullable(true))
8897 .with_column("memory_percent", SqlScalarType::Float64.nullable(true))
8898 .with_column("disk_percent", SqlScalarType::Float64.nullable(true))
8899 .with_column("heap_percent", SqlScalarType::Float64.nullable(true))
8900 .finish(),
8901 column_comments: BTreeMap::from_iter([
8902 ("replica_id", "The ID of a cluster replica."),
8903 ("process_id", "The ID of a process within the replica."),
8904 (
8905 "cpu_percent",
8906 "Approximate CPU usage, in percent of the total allocation.",
8907 ),
8908 (
8909 "memory_percent",
8910 "Approximate RAM usage, in percent of the total allocation.",
8911 ),
8912 (
8913 "disk_percent",
8914 "Approximate disk usage, in percent of the total allocation.",
8915 ),
8916 (
8917 "heap_percent",
8918 "Approximate heap (RAM + swap) usage, in percent of the total allocation.",
8919 ),
8920 ]),
8921 sql: "
8922SELECT
8923 r.id AS replica_id,
8924 m.process_id,
8925 m.cpu_nano_cores::float8 / NULLIF(s.cpu_nano_cores, 0) * 100 AS cpu_percent,
8926 m.memory_bytes::float8 / NULLIF(s.memory_bytes, 0) * 100 AS memory_percent,
8927 m.disk_bytes::float8 / NULLIF(s.disk_bytes, 0) * 100 AS disk_percent,
8928 m.heap_bytes::float8 / NULLIF(m.heap_limit, 0) * 100 AS heap_percent
8929FROM
8930 mz_catalog.mz_cluster_replicas AS r
8931 JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size
8932 JOIN mz_internal.mz_cluster_replica_metrics AS m ON m.replica_id = r.id",
8933 access: vec![PUBLIC_SELECT],
8934});
8935
8936pub static MZ_CLUSTER_REPLICA_UTILIZATION_HISTORY: LazyLock<BuiltinView> =
8937 LazyLock::new(|| BuiltinView {
8938 name: "mz_cluster_replica_utilization_history",
8939 schema: MZ_INTERNAL_SCHEMA,
8940 oid: oid::VIEW_MZ_CLUSTER_REPLICA_UTILIZATION_HISTORY_OID,
8941 desc: RelationDesc::builder()
8942 .with_column("replica_id", SqlScalarType::String.nullable(false))
8943 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
8944 .with_column("cpu_percent", SqlScalarType::Float64.nullable(true))
8945 .with_column("memory_percent", SqlScalarType::Float64.nullable(true))
8946 .with_column("disk_percent", SqlScalarType::Float64.nullable(true))
8947 .with_column("heap_percent", SqlScalarType::Float64.nullable(true))
8948 .with_column(
8949 "occurred_at",
8950 SqlScalarType::TimestampTz { precision: None }.nullable(false),
8951 )
8952 .finish(),
8953 column_comments: BTreeMap::from_iter([
8954 ("replica_id", "The ID of a cluster replica."),
8955 ("process_id", "The ID of a process within the replica."),
8956 (
8957 "cpu_percent",
8958 "Approximate CPU usage, in percent of the total allocation.",
8959 ),
8960 (
8961 "memory_percent",
8962 "Approximate RAM usage, in percent of the total allocation.",
8963 ),
8964 (
8965 "disk_percent",
8966 "Approximate disk usage, in percent of the total allocation.",
8967 ),
8968 (
8969 "heap_percent",
8970 "Approximate heap (RAM + swap) usage, in percent of the total allocation.",
8971 ),
8972 (
8973 "occurred_at",
8974 "Wall-clock timestamp at which the event occurred.",
8975 ),
8976 ]),
8977 sql: "
8978SELECT
8979 r.id AS replica_id,
8980 m.process_id,
8981 m.cpu_nano_cores::float8 / NULLIF(s.cpu_nano_cores, 0) * 100 AS cpu_percent,
8982 m.memory_bytes::float8 / NULLIF(s.memory_bytes, 0) * 100 AS memory_percent,
8983 m.disk_bytes::float8 / NULLIF(s.disk_bytes, 0) * 100 AS disk_percent,
8984 m.heap_bytes::float8 / NULLIF(m.heap_limit, 0) * 100 AS heap_percent,
8985 m.occurred_at
8986FROM
8987 mz_catalog.mz_cluster_replicas AS r
8988 JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size
8989 JOIN mz_internal.mz_cluster_replica_metrics_history AS m ON m.replica_id = r.id",
8990 access: vec![PUBLIC_SELECT],
8991 });
8992
8993pub static MZ_DATAFLOW_OPERATOR_PARENTS_PER_WORKER: LazyLock<BuiltinView> =
8994 LazyLock::new(|| BuiltinView {
8995 name: "mz_dataflow_operator_parents_per_worker",
8996 schema: MZ_INTROSPECTION_SCHEMA,
8997 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_PARENTS_PER_WORKER_OID,
8998 desc: RelationDesc::builder()
8999 .with_column("id", SqlScalarType::UInt64.nullable(false))
9000 .with_column("parent_id", SqlScalarType::UInt64.nullable(false))
9001 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
9002 .finish(),
9003 column_comments: BTreeMap::new(),
9004 sql: "
9005WITH operator_addrs AS(
9006 SELECT
9007 id, address, worker_id
9008 FROM mz_introspection.mz_dataflow_addresses_per_worker
9009 INNER JOIN mz_introspection.mz_dataflow_operators_per_worker
9010 USING (id, worker_id)
9011),
9012parent_addrs AS (
9013 SELECT
9014 id,
9015 address[1:list_length(address) - 1] AS parent_address,
9016 worker_id
9017 FROM operator_addrs
9018)
9019SELECT pa.id, oa.id AS parent_id, pa.worker_id
9020FROM parent_addrs AS pa
9021 INNER JOIN operator_addrs AS oa
9022 ON pa.parent_address = oa.address
9023 AND pa.worker_id = oa.worker_id",
9024 access: vec![PUBLIC_SELECT],
9025 });
9026
9027pub static MZ_DATAFLOW_OPERATOR_PARENTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9028 name: "mz_dataflow_operator_parents",
9029 schema: MZ_INTROSPECTION_SCHEMA,
9030 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_PARENTS_OID,
9031 desc: RelationDesc::builder()
9032 .with_column("id", SqlScalarType::UInt64.nullable(false))
9033 .with_column("parent_id", SqlScalarType::UInt64.nullable(false))
9034 .finish(),
9035 column_comments: BTreeMap::from_iter([
9036 (
9037 "id",
9038 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
9039 ),
9040 (
9041 "parent_id",
9042 "The ID of the operator's parent operator. Corresponds to `mz_dataflow_operators.id`.",
9043 ),
9044 ]),
9045 sql: "
9046SELECT id, parent_id
9047FROM mz_introspection.mz_dataflow_operator_parents_per_worker
9048WHERE worker_id = 0",
9049 access: vec![PUBLIC_SELECT],
9050});
9051
9052pub static MZ_DATAFLOW_ARRANGEMENT_SIZES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9053 name: "mz_dataflow_arrangement_sizes",
9054 schema: MZ_INTROSPECTION_SCHEMA,
9055 oid: oid::VIEW_MZ_DATAFLOW_ARRANGEMENT_SIZES_OID,
9056 desc: RelationDesc::builder()
9057 .with_column("id", SqlScalarType::UInt64.nullable(false))
9058 .with_column("name", SqlScalarType::String.nullable(false))
9059 .with_column("records", SqlScalarType::Int64.nullable(true))
9060 .with_column("batches", SqlScalarType::Int64.nullable(true))
9061 .with_column("size", SqlScalarType::Int64.nullable(true))
9062 .with_column("capacity", SqlScalarType::Int64.nullable(true))
9063 .with_column("allocations", SqlScalarType::Int64.nullable(true))
9064 .with_key(vec![0, 1])
9065 .finish(),
9066 column_comments: BTreeMap::from_iter([
9067 (
9068 "id",
9069 "The ID of the [dataflow]. Corresponds to `mz_dataflows.id`.",
9070 ),
9071 ("name", "The name of the [dataflow]."),
9072 (
9073 "records",
9074 "The number of records in all arrangements in the dataflow.",
9075 ),
9076 (
9077 "batches",
9078 "The number of batches in all arrangements in the dataflow.",
9079 ),
9080 ("size", "The utilized size in bytes of the arrangements."),
9081 (
9082 "capacity",
9083 "The capacity in bytes of the arrangements. Can be larger than the size.",
9084 ),
9085 (
9086 "allocations",
9087 "The number of separate memory allocations backing the arrangements.",
9088 ),
9089 ]),
9090 sql: "
9091SELECT
9092 mdod.dataflow_id AS id,
9093 mdod.dataflow_name AS name,
9094 SUM(mas.records)::int8 AS records,
9095 SUM(mas.batches)::int8 AS batches,
9096 SUM(mas.size)::int8 AS size,
9097 SUM(mas.capacity)::int8 AS capacity,
9098 SUM(mas.allocations)::int8 AS allocations
9099FROM mz_introspection.mz_dataflow_operator_dataflows AS mdod
9100LEFT JOIN mz_introspection.mz_arrangement_sizes AS mas
9101 ON mdod.id = mas.operator_id
9102GROUP BY mdod.dataflow_id, mdod.dataflow_name",
9103 access: vec![PUBLIC_SELECT],
9104});
9105
9106pub static MZ_EXPECTED_GROUP_SIZE_ADVICE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9107 name: "mz_expected_group_size_advice",
9108 schema: MZ_INTROSPECTION_SCHEMA,
9109 oid: oid::VIEW_MZ_EXPECTED_GROUP_SIZE_ADVICE_OID,
9110 desc: RelationDesc::builder()
9111 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
9112 .with_column("dataflow_name", SqlScalarType::String.nullable(false))
9113 .with_column("region_id", SqlScalarType::UInt64.nullable(false))
9114 .with_column("region_name", SqlScalarType::String.nullable(false))
9115 .with_column("levels", SqlScalarType::Int64.nullable(false))
9116 .with_column("to_cut", SqlScalarType::Int64.nullable(false))
9117 .with_column(
9118 "savings",
9119 SqlScalarType::Numeric {
9120 max_scale: Some(NumericMaxScale::ZERO),
9121 }
9122 .nullable(true),
9123 )
9124 .with_column("hint", SqlScalarType::Float64.nullable(false))
9125 .finish(),
9126 column_comments: BTreeMap::from_iter([
9127 (
9128 "dataflow_id",
9129 "The ID of the [dataflow]. Corresponds to `mz_dataflows.id`.",
9130 ),
9131 (
9132 "dataflow_name",
9133 "The internal name of the dataflow hosting the min/max aggregation or Top K.",
9134 ),
9135 (
9136 "region_id",
9137 "The ID of the root operator scope. Corresponds to `mz_dataflow_operators.id`.",
9138 ),
9139 (
9140 "region_name",
9141 "The internal name of the root operator scope for the min/max aggregation or Top K.",
9142 ),
9143 (
9144 "levels",
9145 "The number of levels in the hierarchical scheme implemented by the region.",
9146 ),
9147 (
9148 "to_cut",
9149 "The number of levels that can be eliminated (cut) from the region's hierarchy.",
9150 ),
9151 (
9152 "savings",
9153 "A conservative estimate of the amount of memory in bytes to be saved by applying the hint.",
9154 ),
9155 (
9156 "hint",
9157 "The hint value that will eliminate `to_cut` levels from the region's hierarchy.",
9158 ),
9159 ]),
9160 sql: "
9161 -- The mz_expected_group_size_advice view provides tuning suggestions for the GROUP SIZE
9162 -- query hints. This tuning hint is effective for min/max/top-k patterns, where a stack
9163 -- of arrangements must be built. For each dataflow and region corresponding to one
9164 -- such pattern, we look for how many levels can be eliminated without hitting a level
9165 -- that actually substantially filters the input. The advice is constructed so that
9166 -- setting the hint for the affected region will eliminate these redundant levels of
9167 -- the hierarchical rendering.
9168 --
9169 -- A number of helper CTEs are used for the view definition. The first one, operators,
9170 -- looks for operator names that comprise arrangements of inputs to each level of a
9171 -- min/max/top-k hierarchy.
9172 WITH operators AS (
9173 SELECT
9174 dod.dataflow_id,
9175 dor.id AS region_id,
9176 dod.id,
9177 ars.records,
9178 ars.size
9179 FROM
9180 mz_introspection.mz_dataflow_operator_dataflows dod
9181 JOIN mz_introspection.mz_dataflow_addresses doa
9182 ON dod.id = doa.id
9183 JOIN mz_introspection.mz_dataflow_addresses dra
9184 ON dra.address = doa.address[:list_length(doa.address) - 1]
9185 JOIN mz_introspection.mz_dataflow_operators dor
9186 ON dor.id = dra.id
9187 JOIN mz_introspection.mz_arrangement_sizes ars
9188 ON ars.operator_id = dod.id
9189 WHERE
9190 dod.name = 'Arranged TopK input'
9191 OR dod.name = 'Arranged MinsMaxesHierarchical input'
9192 OR dod.name = 'Arrange ReduceMinsMaxes'
9193 ),
9194 -- The second CTE, levels, simply computes the heights of the min/max/top-k hierarchies
9195 -- identified in operators above.
9196 levels AS (
9197 SELECT o.dataflow_id, o.region_id, COUNT(*) AS levels
9198 FROM operators o
9199 GROUP BY o.dataflow_id, o.region_id
9200 ),
9201 -- The third CTE, pivot, determines for each min/max/top-k hierarchy, the first input
9202 -- operator. This operator is crucially important, as it records the number of records
9203 -- that was given as input to the gadget as a whole.
9204 pivot AS (
9205 SELECT
9206 o1.dataflow_id,
9207 o1.region_id,
9208 o1.id,
9209 o1.records
9210 FROM operators o1
9211 WHERE
9212 o1.id = (
9213 SELECT MIN(o2.id)
9214 FROM operators o2
9215 WHERE
9216 o2.dataflow_id = o1.dataflow_id
9217 AND o2.region_id = o1.region_id
9218 OPTIONS (AGGREGATE INPUT GROUP SIZE = 8)
9219 )
9220 ),
9221 -- The fourth CTE, candidates, will look for operators where the number of records
9222 -- maintained is not significantly different from the number at the pivot (excluding
9223 -- the pivot itself). These are the candidates for being cut from the dataflow region
9224 -- by adjusting the hint. The query includes a constant, heuristically tuned on TPC-H
9225 -- load generator data, to give some room for small deviations in number of records.
9226 -- The intuition for allowing for this deviation is that we are looking for a strongly
9227 -- reducing point in the hierarchy. To see why one such operator ought to exist in an
9228 -- untuned hierarchy, consider that at each level, we use hashing to distribute rows
9229 -- among groups where the min/max/top-k computation is (partially) applied. If the
9230 -- hierarchy has too many levels, the first-level (pivot) groups will be such that many
9231 -- groups might be empty or contain only one row. Each subsequent level will have a number
9232 -- of groups that is reduced exponentially. So at some point, we will find the level where
9233 -- we actually start having a few rows per group. That's where we will see the row counts
9234 -- significantly drop off.
9235 candidates AS (
9236 SELECT
9237 o.dataflow_id,
9238 o.region_id,
9239 o.id,
9240 o.records,
9241 o.size
9242 FROM
9243 operators o
9244 JOIN pivot p
9245 ON o.dataflow_id = p.dataflow_id
9246 AND o.region_id = p.region_id
9247 AND o.id <> p.id
9248 WHERE o.records >= p.records * (1 - 0.15)
9249 ),
9250 -- The fifth CTE, cuts, computes for each relevant dataflow region, the number of
9251 -- candidate levels that should be cut. We only return here dataflow regions where at
9252 -- least one level must be cut. Note that once we hit a point where the hierarchy starts
9253 -- to have a filtering effect, i.e., after the last candidate, it is dangerous to suggest
9254 -- cutting the height of the hierarchy further. This is because we will have way less
9255 -- groups in the next level, so there should be even further reduction happening or there
9256 -- is some substantial skew in the data. But if the latter is the case, then we should not
9257 -- tune the GROUP SIZE hints down anyway to avoid hurting latency upon updates directed
9258 -- at these unusually large groups. In addition to selecting the levels to cut, we also
9259 -- compute a conservative estimate of the memory savings in bytes that will result from
9260 -- cutting these levels from the hierarchy. The estimate is based on the sizes of the
9261 -- input arrangements for each level to be cut. These arrangements should dominate the
9262 -- size of each level that can be cut, since the reduction gadget internal to the level
9263 -- does not remove much data at these levels.
9264 cuts AS (
9265 SELECT c.dataflow_id, c.region_id, COUNT(*) AS to_cut, SUM(c.size) AS savings
9266 FROM candidates c
9267 GROUP BY c.dataflow_id, c.region_id
9268 HAVING COUNT(*) > 0
9269 )
9270 -- Finally, we compute the hint suggestion for each dataflow region based on the number of
9271 -- levels and the number of candidates to be cut. The hint is computed taking into account
9272 -- the fan-in used in rendering for the hash partitioning and reduction of the groups,
9273 -- currently equal to 16.
9274 SELECT
9275 dod.dataflow_id,
9276 dod.dataflow_name,
9277 dod.id AS region_id,
9278 dod.name AS region_name,
9279 l.levels,
9280 c.to_cut,
9281 c.savings,
9282 pow(16, l.levels - c.to_cut) - 1 AS hint
9283 FROM cuts c
9284 JOIN levels l
9285 ON c.dataflow_id = l.dataflow_id AND c.region_id = l.region_id
9286 JOIN mz_introspection.mz_dataflow_operator_dataflows dod
9287 ON dod.dataflow_id = c.dataflow_id AND dod.id = c.region_id",
9288 access: vec![PUBLIC_SELECT],
9289});
9290
9291pub static MZ_INDEX_ADVICE: LazyLock<BuiltinView> = LazyLock::new(|| {
9292 BuiltinView {
9293 name: "mz_index_advice",
9294 schema: MZ_INTERNAL_SCHEMA,
9295 oid: oid::VIEW_MZ_INDEX_ADVICE_OID,
9296 desc: RelationDesc::builder()
9297 .with_column("object_id", SqlScalarType::String.nullable(true))
9298 .with_column("hint", SqlScalarType::String.nullable(false))
9299 .with_column("details", SqlScalarType::String.nullable(false))
9300 .with_column("referenced_object_ids", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(true))
9301 .finish(),
9302 column_comments: BTreeMap::from_iter([
9303 ("object_id", "The ID of the object. Corresponds to mz_objects.id."),
9304 ("hint", "A suggestion to either change the object (e.g. create an index, turn a materialized view into an indexed view) or keep the object unchanged."),
9305 ("details", "Additional details on why the `hint` was proposed based on the dependencies of the object."),
9306 ("referenced_object_ids", "The IDs of objects referenced by `details`. Corresponds to mz_objects.id."),
9307 ]),
9308 sql: "
9309-- To avoid confusion with sources and sinks in the materialize sense,
9310-- the following uses the terms leafs (instead of sinks) and roots (instead of sources)
9311-- when referring to the object dependency graph.
9312--
9313-- The basic idea is to walk up the dependency graph to propagate the transitive dependencies
9314-- of maintained objected upwards. The leaves of the dependency graph are maintained objects
9315-- that are not depended on by other maintained objects and have a justification why they must
9316-- be maintained (e.g. a materialized view that is depended on by a sink).
9317-- Starting from these leaves, the dependencies are propagated upwards towards the roots according
9318-- to the object dependencies. Whenever there is a node that is being depended on by multiple
9319-- downstream objects, that node is marked to be converted into a maintained object and this
9320-- node is then propagated further up. Once completed, the list of objects that are marked as
9321-- maintained is checked against all objects to generate appropriate recommendations.
9322--
9323-- Note that the recommendations only incorporate dependencies between objects.
9324-- This can lead to bad recommendations, e.g. filters can no longer be pushed into (or close to)
9325-- a sink if an index is added in between the sink and the filter. For very selective filters,
9326-- this can lead to redundant work: the index is computing stuff only to discarded by the selective
9327-- filter later on. But these kind of aspects cannot be understood by merely looking at the
9328-- dependencies.
9329WITH MUTUALLY RECURSIVE
9330 -- for all objects, understand if they have an index on them and on which cluster they are running
9331 -- this avoids having different cases for views with an index and materialized views later on
9332 objects(id text, type text, cluster_id text, indexes text list) AS (
9333 -- views and materialized views without an index
9334 SELECT
9335 o.id,
9336 o.type,
9337 o.cluster_id,
9338 '{}'::text list AS indexes
9339 FROM mz_catalog.mz_objects o
9340 WHERE o.id LIKE 'u%' AND o.type IN ('materialized-view', 'view') AND NOT EXISTS (
9341 SELECT FROM mz_internal.mz_object_dependencies d
9342 JOIN mz_catalog.mz_objects AS i
9343 ON (i.id = d.object_id AND i.type = 'index')
9344 WHERE (o.id = d.referenced_object_id)
9345 )
9346
9347 UNION ALL
9348
9349 -- views and materialized views with an index
9350 SELECT
9351 o.id,
9352 o.type,
9353 -- o.cluster_id is always NULL for views, so use the cluster of the index instead
9354 COALESCE(o.cluster_id, i.cluster_id) AS cluster_id,
9355 list_agg(i.id) AS indexes
9356 FROM mz_catalog.mz_objects o
9357 JOIN mz_internal.mz_object_dependencies AS d
9358 ON (o.id = d.referenced_object_id)
9359 JOIN mz_catalog.mz_objects AS i
9360 ON (i.id = d.object_id AND i.type = 'index')
9361 WHERE o.id LIKE 'u%' AND o.type IN ('materialized-view', 'view', 'source')
9362 GROUP BY o.id, o.type, o.cluster_id, i.cluster_id
9363 ),
9364
9365 -- maintained objects that are at the leafs of the dependency graph with respect to a specific cluster
9366 maintained_leafs(id text, justification text) AS (
9367 -- materialized views that are connected to a sink
9368 SELECT
9369 m.id,
9370 s.id AS justification
9371 FROM objects AS m
9372 JOIN mz_internal.mz_object_dependencies AS d
9373 ON (m.id = d.referenced_object_id)
9374 JOIN mz_catalog.mz_objects AS s
9375 ON (s.id = d.object_id AND s.type = 'sink')
9376 WHERE m.type = 'materialized-view'
9377
9378 UNION ALL
9379
9380 -- (materialized) views with an index that are not transitively depend on by maintained objects on the same cluster
9381 SELECT
9382 v.id,
9383 unnest(v.indexes) AS justification
9384 FROM objects AS v
9385 WHERE v.type IN ('view', 'materialized-view', 'source') AND NOT EXISTS (
9386 SELECT FROM mz_internal.mz_object_transitive_dependencies AS d
9387 INNER JOIN mz_catalog.mz_objects AS child
9388 ON (d.object_id = child.id)
9389 WHERE d.referenced_object_id = v.id AND child.type IN ('materialized-view', 'index') AND v.cluster_id = child.cluster_id AND NOT v.indexes @> LIST[child.id]
9390 )
9391 ),
9392
9393 -- this is just a helper cte to union multiple lists as part of an aggregation, which is not directly possible in SQL
9394 agg_maintained_children(id text, maintained_children text list) AS (
9395 SELECT
9396 parent_id AS id,
9397 list_agg(maintained_child) AS maintained_leafs
9398 FROM (
9399 SELECT DISTINCT
9400 d.referenced_object_id AS parent_id,
9401 -- it's not possible to union lists in an aggregation, so we have to unnest the list first
9402 unnest(child.maintained_children) AS maintained_child
9403 FROM propagate_dependencies AS child
9404 INNER JOIN mz_internal.mz_object_dependencies AS d
9405 ON (child.id = d.object_id)
9406 )
9407 GROUP BY parent_id
9408 ),
9409
9410 -- propagate dependencies of maintained objects from the leafs to the roots of the dependency graph and
9411 -- record a justification when an object should be maintained, e.g. when it is depended on by more than one maintained object
9412 -- when an object should be maintained, maintained_children will just contain that object so that further upstream objects refer to it in their maintained_children
9413 propagate_dependencies(id text, maintained_children text list, justification text list) AS (
9414 -- base case: start with the leafs
9415 SELECT DISTINCT
9416 id,
9417 LIST[id] AS maintained_children,
9418 list_agg(justification) AS justification
9419 FROM maintained_leafs
9420 GROUP BY id
9421
9422 UNION
9423
9424 -- recursive case: if there is a child with the same dependencies as the parent,
9425 -- the parent is only reused by a single child
9426 SELECT
9427 parent.id,
9428 child.maintained_children,
9429 NULL::text list AS justification
9430 FROM agg_maintained_children AS parent
9431 INNER JOIN mz_internal.mz_object_dependencies AS d
9432 ON (parent.id = d.referenced_object_id)
9433 INNER JOIN propagate_dependencies AS child
9434 ON (d.object_id = child.id)
9435 WHERE parent.maintained_children = child.maintained_children
9436
9437 UNION
9438
9439 -- recursive case: if there is NO child with the same dependencies as the parent,
9440 -- different children are reusing the parent so maintaining the object is justified by itself
9441 SELECT DISTINCT
9442 parent.id,
9443 LIST[parent.id] AS maintained_children,
9444 parent.maintained_children AS justification
9445 FROM agg_maintained_children AS parent
9446 WHERE NOT EXISTS (
9447 SELECT FROM mz_internal.mz_object_dependencies AS d
9448 INNER JOIN propagate_dependencies AS child
9449 ON (d.object_id = child.id AND d.referenced_object_id = parent.id)
9450 WHERE parent.maintained_children = child.maintained_children
9451 )
9452 ),
9453
9454 objects_with_justification(id text, type text, cluster_id text, maintained_children text list, justification text list, indexes text list) AS (
9455 SELECT
9456 p.id,
9457 o.type,
9458 o.cluster_id,
9459 p.maintained_children,
9460 p.justification,
9461 o.indexes
9462 FROM propagate_dependencies p
9463 JOIN objects AS o
9464 ON (p.id = o.id)
9465 ),
9466
9467 hints(id text, hint text, details text, justification text list) AS (
9468 -- materialized views that are not required
9469 SELECT
9470 id,
9471 'convert to a view' AS hint,
9472 'no dependencies from sinks nor from objects on different clusters' AS details,
9473 justification
9474 FROM objects_with_justification
9475 WHERE type = 'materialized-view' AND justification IS NULL
9476
9477 UNION ALL
9478
9479 -- materialized views that are required because a sink or a maintained object from a different cluster depends on them
9480 SELECT
9481 id,
9482 'keep' AS hint,
9483 'dependencies from sinks or objects on different clusters: ' AS details,
9484 justification
9485 FROM objects_with_justification AS m
9486 WHERE type = 'materialized-view' AND justification IS NOT NULL AND EXISTS (
9487 SELECT FROM unnest(justification) AS dependency
9488 JOIN mz_catalog.mz_objects s ON (s.type = 'sink' AND s.id = dependency)
9489
9490 UNION ALL
9491
9492 SELECT FROM unnest(justification) AS dependency
9493 JOIN mz_catalog.mz_objects AS d ON (d.id = dependency)
9494 WHERE d.cluster_id != m.cluster_id
9495 )
9496
9497 UNION ALL
9498
9499 -- materialized views that can be converted to a view with or without an index because NO sink or a maintained object from a different cluster depends on them
9500 SELECT
9501 id,
9502 'convert to a view with an index' AS hint,
9503 'no dependencies from sinks nor from objects on different clusters, but maintained dependencies on the same cluster: ' AS details,
9504 justification
9505 FROM objects_with_justification AS m
9506 WHERE type = 'materialized-view' AND justification IS NOT NULL AND NOT EXISTS (
9507 SELECT FROM unnest(justification) AS dependency
9508 JOIN mz_catalog.mz_objects s ON (s.type = 'sink' AND s.id = dependency)
9509
9510 UNION ALL
9511
9512 SELECT FROM unnest(justification) AS dependency
9513 JOIN mz_catalog.mz_objects AS d ON (d.id = dependency)
9514 WHERE d.cluster_id != m.cluster_id
9515 )
9516
9517 UNION ALL
9518
9519 -- views that have indexes on different clusters should be a materialized view
9520 SELECT
9521 o.id,
9522 'convert to materialized view' AS hint,
9523 'dependencies on multiple clusters: ' AS details,
9524 o.justification
9525 FROM objects_with_justification o,
9526 LATERAL unnest(o.justification) j
9527 LEFT JOIN mz_catalog.mz_objects AS m
9528 ON (m.id = j AND m.type IN ('index', 'materialized-view'))
9529 WHERE o.type = 'view' AND o.justification IS NOT NULL
9530 GROUP BY o.id, o.justification
9531 HAVING count(DISTINCT m.cluster_id) >= 2
9532
9533 UNION ALL
9534
9535 -- views without an index that should be maintained
9536 SELECT
9537 id,
9538 'add index' AS hint,
9539 'multiple downstream dependencies: ' AS details,
9540 justification
9541 FROM objects_with_justification
9542 WHERE type = 'view' AND justification IS NOT NULL AND indexes = '{}'::text list
9543
9544 UNION ALL
9545
9546 -- index inside the dependency graph (not a leaf)
9547 SELECT
9548 unnest(indexes) AS id,
9549 'drop unless queried directly' AS hint,
9550 'fewer than two downstream dependencies: ' AS details,
9551 maintained_children AS justification
9552 FROM objects_with_justification
9553 WHERE type = 'view' AND NOT indexes = '{}'::text list AND justification IS NULL
9554
9555 UNION ALL
9556
9557 -- index on a leaf of the dependency graph
9558 SELECT
9559 unnest(indexes) AS id,
9560 'drop unless queried directly' AS hint,
9561 'associated object does not have any dependencies (maintained or not maintained)' AS details,
9562 NULL::text list AS justification
9563 FROM objects_with_justification
9564 -- indexes can only be part of justification for leaf nodes
9565 WHERE type IN ('view', 'materialized-view') AND NOT indexes = '{}'::text list AND justification @> indexes
9566
9567 UNION ALL
9568
9569 -- index on a source
9570 SELECT
9571 unnest(indexes) AS id,
9572 'drop unless queried directly' AS hint,
9573 'sources do not transform data and can expose data directly' AS details,
9574 NULL::text list AS justification
9575 FROM objects_with_justification
9576 -- indexes can only be part of justification for leaf nodes
9577 WHERE type = 'source' AND NOT indexes = '{}'::text list
9578
9579 UNION ALL
9580
9581 -- indexes on views inside the dependency graph
9582 SELECT
9583 unnest(indexes) AS id,
9584 'keep' AS hint,
9585 'multiple downstream dependencies: ' AS details,
9586 justification
9587 FROM objects_with_justification
9588 -- indexes can only be part of justification for leaf nodes
9589 WHERE type = 'view' AND justification IS NOT NULL AND NOT indexes = '{}'::text list AND NOT justification @> indexes
9590 ),
9591
9592 hints_resolved_ids(id text, hint text, details text, justification text list) AS (
9593 SELECT
9594 h.id,
9595 h.hint,
9596 h.details || list_agg(o.name)::text AS details,
9597 h.justification
9598 FROM hints AS h,
9599 LATERAL unnest(h.justification) j
9600 JOIN mz_catalog.mz_objects AS o
9601 ON (o.id = j)
9602 GROUP BY h.id, h.hint, h.details, h.justification
9603
9604 UNION ALL
9605
9606 SELECT
9607 id,
9608 hint,
9609 details,
9610 justification
9611 FROM hints
9612 WHERE justification IS NULL
9613 )
9614
9615SELECT
9616 h.id AS object_id,
9617 h.hint AS hint,
9618 h.details,
9619 h.justification AS referenced_object_ids
9620FROM hints_resolved_ids AS h",
9621 access: vec![PUBLIC_SELECT],
9622 }
9623});
9624
9625pub static PG_CONSTRAINT: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9628 name: "pg_constraint",
9629 schema: PG_CATALOG_SCHEMA,
9630 oid: oid::VIEW_PG_CONSTRAINT_OID,
9631 desc: RelationDesc::builder()
9632 .with_column("oid", SqlScalarType::Oid.nullable(false))
9633 .with_column("conname", SqlScalarType::String.nullable(false))
9634 .with_column("connamespace", SqlScalarType::Oid.nullable(false))
9635 .with_column("contype", SqlScalarType::PgLegacyChar.nullable(false))
9636 .with_column("condeferrable", SqlScalarType::Bool.nullable(false))
9637 .with_column("condeferred", SqlScalarType::Bool.nullable(false))
9638 .with_column("convalidated", SqlScalarType::Bool.nullable(false))
9639 .with_column("conrelid", SqlScalarType::Oid.nullable(false))
9640 .with_column("contypid", SqlScalarType::Oid.nullable(false))
9641 .with_column("conindid", SqlScalarType::Oid.nullable(false))
9642 .with_column("conparentid", SqlScalarType::Oid.nullable(false))
9643 .with_column("confrelid", SqlScalarType::Oid.nullable(false))
9644 .with_column("confupdtype", SqlScalarType::PgLegacyChar.nullable(false))
9645 .with_column("confdeltype", SqlScalarType::PgLegacyChar.nullable(false))
9646 .with_column("confmatchtype", SqlScalarType::PgLegacyChar.nullable(false))
9647 .with_column("conislocal", SqlScalarType::Bool.nullable(false))
9648 .with_column("coninhcount", SqlScalarType::Int32.nullable(false))
9649 .with_column("connoinherit", SqlScalarType::Bool.nullable(false))
9650 .with_column(
9651 "conkey",
9652 SqlScalarType::Array(Box::new(SqlScalarType::Int16)).nullable(false),
9653 )
9654 .with_column(
9655 "confkey",
9656 SqlScalarType::Array(Box::new(SqlScalarType::Int16)).nullable(false),
9657 )
9658 .with_column(
9659 "conpfeqop",
9660 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9661 )
9662 .with_column(
9663 "conppeqop",
9664 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9665 )
9666 .with_column(
9667 "conffeqop",
9668 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9669 )
9670 .with_column(
9671 "conexclop",
9672 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9673 )
9674 .with_column("conbin", SqlScalarType::String.nullable(false))
9675 .with_key(vec![])
9676 .finish(),
9677 column_comments: BTreeMap::new(),
9678 sql: "SELECT
9679 NULL::pg_catalog.oid as oid,
9680 NULL::pg_catalog.text as conname,
9681 NULL::pg_catalog.oid as connamespace,
9682 NULL::pg_catalog.\"char\" as contype,
9683 NULL::pg_catalog.bool as condeferrable,
9684 NULL::pg_catalog.bool as condeferred,
9685 NULL::pg_catalog.bool as convalidated,
9686 NULL::pg_catalog.oid as conrelid,
9687 NULL::pg_catalog.oid as contypid,
9688 NULL::pg_catalog.oid as conindid,
9689 NULL::pg_catalog.oid as conparentid,
9690 NULL::pg_catalog.oid as confrelid,
9691 NULL::pg_catalog.\"char\" as confupdtype,
9692 NULL::pg_catalog.\"char\" as confdeltype,
9693 NULL::pg_catalog.\"char\" as confmatchtype,
9694 NULL::pg_catalog.bool as conislocal,
9695 NULL::pg_catalog.int4 as coninhcount,
9696 NULL::pg_catalog.bool as connoinherit,
9697 NULL::pg_catalog.int2[] as conkey,
9698 NULL::pg_catalog.int2[] as confkey,
9699 NULL::pg_catalog.oid[] as conpfeqop,
9700 NULL::pg_catalog.oid[] as conppeqop,
9701 NULL::pg_catalog.oid[] as conffeqop,
9702 NULL::pg_catalog.oid[] as conexclop,
9703 NULL::pg_catalog.text as conbin
9704WHERE false",
9705 access: vec![PUBLIC_SELECT],
9706});
9707
9708pub static PG_TABLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9709 name: "pg_tables",
9710 schema: PG_CATALOG_SCHEMA,
9711 oid: oid::VIEW_PG_TABLES_OID,
9712 desc: RelationDesc::builder()
9713 .with_column("schemaname", SqlScalarType::String.nullable(true))
9714 .with_column("tablename", SqlScalarType::String.nullable(false))
9715 .with_column("tableowner", SqlScalarType::String.nullable(false))
9716 .finish(),
9717 column_comments: BTreeMap::new(),
9718 sql: "
9719SELECT n.nspname AS schemaname,
9720 c.relname AS tablename,
9721 pg_catalog.pg_get_userbyid(c.relowner) AS tableowner
9722FROM pg_catalog.pg_class c
9723LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
9724WHERE c.relkind IN ('r', 'p')",
9725 access: vec![PUBLIC_SELECT],
9726});
9727
9728pub static PG_TABLESPACE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9729 name: "pg_tablespace",
9730 schema: PG_CATALOG_SCHEMA,
9731 oid: oid::VIEW_PG_TABLESPACE_OID,
9732 desc: RelationDesc::builder()
9733 .with_column("oid", SqlScalarType::Oid.nullable(false))
9734 .with_column("spcname", SqlScalarType::String.nullable(false))
9735 .with_column("spcowner", SqlScalarType::Oid.nullable(true))
9736 .with_column(
9737 "spcacl",
9738 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9739 )
9740 .with_column(
9741 "spcoptions",
9742 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9743 )
9744 .with_key(vec![])
9745 .finish(),
9746 column_comments: BTreeMap::new(),
9747 sql: "
9748 SELECT oid, spcname, spcowner, spcacl, spcoptions
9749 FROM (
9750 VALUES (
9751 --These are the same defaults CockroachDB uses.
9752 0::pg_catalog.oid,
9753 'pg_default'::pg_catalog.text,
9754 NULL::pg_catalog.oid,
9755 NULL::pg_catalog.text[],
9756 NULL::pg_catalog.text[]
9757 )
9758 ) AS _ (oid, spcname, spcowner, spcacl, spcoptions)
9759",
9760 access: vec![PUBLIC_SELECT],
9761});
9762
9763pub static PG_ACCESS_METHODS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9764 name: "pg_am",
9765 schema: PG_CATALOG_SCHEMA,
9766 oid: oid::VIEW_PG_AM_OID,
9767 desc: RelationDesc::builder()
9768 .with_column("oid", SqlScalarType::Oid.nullable(false))
9769 .with_column("amname", SqlScalarType::String.nullable(false))
9770 .with_column("amhandler", SqlScalarType::RegProc.nullable(false))
9771 .with_column("amtype", SqlScalarType::PgLegacyChar.nullable(false))
9772 .with_key(vec![])
9773 .finish(),
9774 column_comments: BTreeMap::new(),
9775 sql: "
9776SELECT NULL::pg_catalog.oid AS oid,
9777 NULL::pg_catalog.text AS amname,
9778 NULL::pg_catalog.regproc AS amhandler,
9779 NULL::pg_catalog.\"char\" AS amtype
9780WHERE false",
9781 access: vec![PUBLIC_SELECT],
9782});
9783
9784pub static PG_ROLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9785 name: "pg_roles",
9786 schema: PG_CATALOG_SCHEMA,
9787 oid: oid::VIEW_PG_ROLES_OID,
9788 desc: RelationDesc::builder()
9789 .with_column("rolname", SqlScalarType::String.nullable(false))
9790 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
9791 .with_column("rolinherit", SqlScalarType::Bool.nullable(false))
9792 .with_column("rolcreaterole", SqlScalarType::Bool.nullable(true))
9793 .with_column("rolcreatedb", SqlScalarType::Bool.nullable(true))
9794 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(false))
9795 .with_column("rolreplication", SqlScalarType::Bool.nullable(false))
9796 .with_column("rolconnlimit", SqlScalarType::Int32.nullable(false))
9797 .with_column("rolpassword", SqlScalarType::String.nullable(false))
9798 .with_column(
9799 "rolvaliduntil",
9800 SqlScalarType::TimestampTz { precision: None }.nullable(true),
9801 )
9802 .with_column("rolbypassrls", SqlScalarType::Bool.nullable(false))
9803 .with_column(
9804 "rolconfig",
9805 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9806 )
9807 .with_column("oid", SqlScalarType::Oid.nullable(false))
9808 .finish(),
9809 column_comments: BTreeMap::new(),
9810 sql: "SELECT
9811 rolname,
9812 rolsuper,
9813 rolinherit,
9814 rolcreaterole,
9815 rolcreatedb,
9816 COALESCE(rolcanlogin, false) AS rolcanlogin,
9817 rolreplication,
9818 rolconnlimit,
9819 '********' as rolpassword,
9820 rolvaliduntil,
9821 rolbypassrls,
9822 (
9823 SELECT array_agg(parameter_name || '=' || parameter_value)
9824 FROM mz_catalog.mz_role_parameters rp
9825 JOIN mz_catalog.mz_roles r ON r.id = rp.role_id
9826 WHERE ai.oid = r.oid
9827 ) AS rolconfig,
9828 oid
9829FROM pg_catalog.pg_authid ai",
9830 access: vec![PUBLIC_SELECT],
9831});
9832
9833pub static PG_USER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9834 name: "pg_user",
9835 schema: PG_CATALOG_SCHEMA,
9836 oid: oid::VIEW_PG_USER_OID,
9837 desc: RelationDesc::builder()
9838 .with_column("usename", SqlScalarType::String.nullable(false))
9839 .with_column("usesysid", SqlScalarType::Oid.nullable(false))
9840 .with_column("usecreatedb", SqlScalarType::Bool.nullable(true))
9841 .with_column("usesuper", SqlScalarType::Bool.nullable(true))
9842 .with_column("userepl", SqlScalarType::Bool.nullable(false))
9843 .with_column("usebypassrls", SqlScalarType::Bool.nullable(false))
9844 .with_column("passwd", SqlScalarType::String.nullable(true))
9845 .with_column(
9846 "valuntil",
9847 SqlScalarType::TimestampTz { precision: None }.nullable(true),
9848 )
9849 .with_column(
9850 "useconfig",
9851 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9852 )
9853 .finish(),
9854 column_comments: BTreeMap::new(),
9855 sql: "
9856SELECT
9857 rolname as usename,
9858 ai.oid as usesysid,
9859 rolcreatedb AS usecreatedb,
9860 rolsuper AS usesuper,
9861 rolreplication AS userepl,
9862 rolbypassrls AS usebypassrls,
9863 rolpassword as passwd,
9864 rolvaliduntil as valuntil,
9865 (
9866 SELECT array_agg(parameter_name || '=' || parameter_value)
9867 FROM mz_catalog.mz_role_parameters rp
9868 JOIN mz_catalog.mz_roles r ON r.id = rp.role_id
9869 WHERE ai.oid = r.oid
9870 ) AS useconfig
9871FROM pg_catalog.pg_authid ai
9872WHERE rolcanlogin",
9873 access: vec![PUBLIC_SELECT],
9874});
9875
9876pub static PG_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9877 name: "pg_views",
9878 schema: PG_CATALOG_SCHEMA,
9879 oid: oid::VIEW_PG_VIEWS_OID,
9880 desc: RelationDesc::builder()
9881 .with_column("schemaname", SqlScalarType::String.nullable(true))
9882 .with_column("viewname", SqlScalarType::String.nullable(false))
9883 .with_column("viewowner", SqlScalarType::Oid.nullable(false))
9884 .with_column("definition", SqlScalarType::String.nullable(false))
9885 .finish(),
9886 column_comments: BTreeMap::new(),
9887 sql: "SELECT
9888 s.name AS schemaname,
9889 v.name AS viewname,
9890 role_owner.oid AS viewowner,
9891 v.definition AS definition
9892FROM mz_catalog.mz_views v
9893LEFT JOIN mz_catalog.mz_schemas s ON s.id = v.schema_id
9894LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
9895JOIN mz_catalog.mz_roles role_owner ON role_owner.id = v.owner_id
9896WHERE s.database_id IS NULL OR d.name = current_database()",
9897 access: vec![PUBLIC_SELECT],
9898});
9899
9900pub static PG_MATVIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9901 name: "pg_matviews",
9902 schema: PG_CATALOG_SCHEMA,
9903 oid: oid::VIEW_PG_MATVIEWS_OID,
9904 desc: RelationDesc::builder()
9905 .with_column("schemaname", SqlScalarType::String.nullable(true))
9906 .with_column("matviewname", SqlScalarType::String.nullable(false))
9907 .with_column("matviewowner", SqlScalarType::Oid.nullable(false))
9908 .with_column("definition", SqlScalarType::String.nullable(false))
9909 .finish(),
9910 column_comments: BTreeMap::new(),
9911 sql: "SELECT
9912 s.name AS schemaname,
9913 m.name AS matviewname,
9914 role_owner.oid AS matviewowner,
9915 m.definition AS definition
9916FROM mz_catalog.mz_materialized_views m
9917LEFT JOIN mz_catalog.mz_schemas s ON s.id = m.schema_id
9918LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
9919JOIN mz_catalog.mz_roles role_owner ON role_owner.id = m.owner_id
9920WHERE s.database_id IS NULL OR d.name = current_database()",
9921 access: vec![PUBLIC_SELECT],
9922});
9923
9924pub static INFORMATION_SCHEMA_APPLICABLE_ROLES: LazyLock<BuiltinView> =
9925 LazyLock::new(|| BuiltinView {
9926 name: "applicable_roles",
9927 schema: INFORMATION_SCHEMA,
9928 oid: oid::VIEW_APPLICABLE_ROLES_OID,
9929 desc: RelationDesc::builder()
9930 .with_column("grantee", SqlScalarType::String.nullable(false))
9931 .with_column("role_name", SqlScalarType::String.nullable(false))
9932 .with_column("is_grantable", SqlScalarType::String.nullable(false))
9933 .finish(),
9934 column_comments: BTreeMap::new(),
9935 sql: "
9936SELECT
9937 member.name AS grantee,
9938 role.name AS role_name,
9939 -- ADMIN OPTION isn't implemented.
9940 'NO' AS is_grantable
9941FROM mz_catalog.mz_role_members membership
9942JOIN mz_catalog.mz_roles role ON membership.role_id = role.id
9943JOIN mz_catalog.mz_roles member ON membership.member = member.id
9944WHERE mz_catalog.mz_is_superuser() OR pg_has_role(current_role, member.oid, 'USAGE')",
9945 access: vec![PUBLIC_SELECT],
9946 });
9947
9948pub static INFORMATION_SCHEMA_COLUMNS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9949 name: "columns",
9950 schema: INFORMATION_SCHEMA,
9951 oid: oid::VIEW_COLUMNS_OID,
9952 desc: RelationDesc::builder()
9953 .with_column("table_catalog", SqlScalarType::String.nullable(false))
9954 .with_column("table_schema", SqlScalarType::String.nullable(false))
9955 .with_column("table_name", SqlScalarType::String.nullable(false))
9956 .with_column("column_name", SqlScalarType::String.nullable(false))
9957 .with_column("ordinal_position", SqlScalarType::Int64.nullable(false))
9958 .with_column("column_default", SqlScalarType::String.nullable(true))
9959 .with_column("is_nullable", SqlScalarType::String.nullable(false))
9960 .with_column("data_type", SqlScalarType::String.nullable(false))
9961 .with_column(
9962 "character_maximum_length",
9963 SqlScalarType::Int32.nullable(true),
9964 )
9965 .with_column("numeric_precision", SqlScalarType::Int32.nullable(true))
9966 .with_column("numeric_scale", SqlScalarType::Int32.nullable(true))
9967 .finish(),
9968 column_comments: BTreeMap::new(),
9969 sql: "
9970SELECT
9971 current_database() as table_catalog,
9972 s.name AS table_schema,
9973 o.name AS table_name,
9974 c.name AS column_name,
9975 c.position::int8 AS ordinal_position,
9976 c.default AS column_default,
9977 CASE WHEN c.nullable THEN 'YES' ELSE 'NO' END AS is_nullable,
9978 c.type AS data_type,
9979 NULL::pg_catalog.int4 AS character_maximum_length,
9980 NULL::pg_catalog.int4 AS numeric_precision,
9981 NULL::pg_catalog.int4 AS numeric_scale
9982FROM mz_catalog.mz_columns c
9983JOIN mz_catalog.mz_objects o ON o.id = c.id
9984JOIN mz_catalog.mz_schemas s ON s.id = o.schema_id
9985LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
9986WHERE s.database_id IS NULL OR d.name = current_database()",
9987 access: vec![PUBLIC_SELECT],
9988});
9989
9990pub static INFORMATION_SCHEMA_ENABLED_ROLES: LazyLock<BuiltinView> =
9991 LazyLock::new(|| BuiltinView {
9992 name: "enabled_roles",
9993 schema: INFORMATION_SCHEMA,
9994 oid: oid::VIEW_ENABLED_ROLES_OID,
9995 desc: RelationDesc::builder()
9996 .with_column("role_name", SqlScalarType::String.nullable(false))
9997 .finish(),
9998 column_comments: BTreeMap::new(),
9999 sql: "
10000SELECT name AS role_name
10001FROM mz_catalog.mz_roles
10002WHERE mz_catalog.mz_is_superuser() OR pg_has_role(current_role, oid, 'USAGE')",
10003 access: vec![PUBLIC_SELECT],
10004 });
10005
10006pub static INFORMATION_SCHEMA_ROLE_TABLE_GRANTS: LazyLock<BuiltinView> = LazyLock::new(|| {
10007 BuiltinView {
10008 name: "role_table_grants",
10009 schema: INFORMATION_SCHEMA,
10010 oid: oid::VIEW_ROLE_TABLE_GRANTS_OID,
10011 desc: RelationDesc::builder()
10012 .with_column("grantor", SqlScalarType::String.nullable(false))
10013 .with_column("grantee", SqlScalarType::String.nullable(true))
10014 .with_column("table_catalog", SqlScalarType::String.nullable(true))
10015 .with_column("table_schema", SqlScalarType::String.nullable(false))
10016 .with_column("table_name", SqlScalarType::String.nullable(false))
10017 .with_column("privilege_type", SqlScalarType::String.nullable(true))
10018 .with_column("is_grantable", SqlScalarType::String.nullable(false))
10019 .with_column("with_hierarchy", SqlScalarType::String.nullable(false))
10020 .finish(),
10021 column_comments: BTreeMap::new(),
10022 sql: "
10023SELECT grantor, grantee, table_catalog, table_schema, table_name, privilege_type, is_grantable, with_hierarchy
10024FROM information_schema.table_privileges
10025WHERE
10026 grantor IN (SELECT role_name FROM information_schema.enabled_roles)
10027 OR grantee IN (SELECT role_name FROM information_schema.enabled_roles)",
10028 access: vec![PUBLIC_SELECT],
10029 }
10030});
10031
10032pub static INFORMATION_SCHEMA_KEY_COLUMN_USAGE: LazyLock<BuiltinView> =
10033 LazyLock::new(|| BuiltinView {
10034 name: "key_column_usage",
10035 schema: INFORMATION_SCHEMA,
10036 oid: oid::VIEW_KEY_COLUMN_USAGE_OID,
10037 desc: RelationDesc::builder()
10038 .with_column("constraint_catalog", SqlScalarType::String.nullable(false))
10039 .with_column("constraint_schema", SqlScalarType::String.nullable(false))
10040 .with_column("constraint_name", SqlScalarType::String.nullable(false))
10041 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10042 .with_column("table_schema", SqlScalarType::String.nullable(false))
10043 .with_column("table_name", SqlScalarType::String.nullable(false))
10044 .with_column("column_name", SqlScalarType::String.nullable(false))
10045 .with_column("ordinal_position", SqlScalarType::Int32.nullable(false))
10046 .with_column(
10047 "position_in_unique_constraint",
10048 SqlScalarType::Int32.nullable(false),
10049 )
10050 .with_key(vec![])
10051 .finish(),
10052 column_comments: BTreeMap::new(),
10053 sql: "SELECT
10054 NULL::text AS constraint_catalog,
10055 NULL::text AS constraint_schema,
10056 NULL::text AS constraint_name,
10057 NULL::text AS table_catalog,
10058 NULL::text AS table_schema,
10059 NULL::text AS table_name,
10060 NULL::text AS column_name,
10061 NULL::integer AS ordinal_position,
10062 NULL::integer AS position_in_unique_constraint
10063WHERE false",
10064 access: vec![PUBLIC_SELECT],
10065 });
10066
10067pub static INFORMATION_SCHEMA_REFERENTIAL_CONSTRAINTS: LazyLock<BuiltinView> =
10068 LazyLock::new(|| BuiltinView {
10069 name: "referential_constraints",
10070 schema: INFORMATION_SCHEMA,
10071 oid: oid::VIEW_REFERENTIAL_CONSTRAINTS_OID,
10072 desc: RelationDesc::builder()
10073 .with_column("constraint_catalog", SqlScalarType::String.nullable(false))
10074 .with_column("constraint_schema", SqlScalarType::String.nullable(false))
10075 .with_column("constraint_name", SqlScalarType::String.nullable(false))
10076 .with_column(
10077 "unique_constraint_catalog",
10078 SqlScalarType::String.nullable(false),
10079 )
10080 .with_column(
10081 "unique_constraint_schema",
10082 SqlScalarType::String.nullable(false),
10083 )
10084 .with_column(
10085 "unique_constraint_name",
10086 SqlScalarType::String.nullable(false),
10087 )
10088 .with_column("match_option", SqlScalarType::String.nullable(false))
10089 .with_column("update_rule", SqlScalarType::String.nullable(false))
10090 .with_column("delete_rule", SqlScalarType::String.nullable(false))
10091 .with_key(vec![])
10092 .finish(),
10093 column_comments: BTreeMap::new(),
10094 sql: "SELECT
10095 NULL::text AS constraint_catalog,
10096 NULL::text AS constraint_schema,
10097 NULL::text AS constraint_name,
10098 NULL::text AS unique_constraint_catalog,
10099 NULL::text AS unique_constraint_schema,
10100 NULL::text AS unique_constraint_name,
10101 NULL::text AS match_option,
10102 NULL::text AS update_rule,
10103 NULL::text AS delete_rule
10104WHERE false",
10105 access: vec![PUBLIC_SELECT],
10106 });
10107
10108pub static INFORMATION_SCHEMA_ROUTINES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10109 name: "routines",
10110 schema: INFORMATION_SCHEMA,
10111 oid: oid::VIEW_ROUTINES_OID,
10112 desc: RelationDesc::builder()
10113 .with_column("routine_catalog", SqlScalarType::String.nullable(false))
10114 .with_column("routine_schema", SqlScalarType::String.nullable(false))
10115 .with_column("routine_name", SqlScalarType::String.nullable(false))
10116 .with_column("routine_type", SqlScalarType::String.nullable(false))
10117 .with_column("routine_definition", SqlScalarType::String.nullable(true))
10118 .finish(),
10119 column_comments: BTreeMap::new(),
10120 sql: "SELECT
10121 current_database() as routine_catalog,
10122 s.name AS routine_schema,
10123 f.name AS routine_name,
10124 'FUNCTION' AS routine_type,
10125 NULL::text AS routine_definition
10126FROM mz_catalog.mz_functions f
10127JOIN mz_catalog.mz_schemas s ON s.id = f.schema_id
10128LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10129WHERE s.database_id IS NULL OR d.name = current_database()",
10130 access: vec![PUBLIC_SELECT],
10131});
10132
10133pub static INFORMATION_SCHEMA_SCHEMATA: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10134 name: "schemata",
10135 schema: INFORMATION_SCHEMA,
10136 oid: oid::VIEW_SCHEMATA_OID,
10137 desc: RelationDesc::builder()
10138 .with_column("catalog_name", SqlScalarType::String.nullable(false))
10139 .with_column("schema_name", SqlScalarType::String.nullable(false))
10140 .finish(),
10141 column_comments: BTreeMap::new(),
10142 sql: "
10143SELECT
10144 current_database() as catalog_name,
10145 s.name AS schema_name
10146FROM mz_catalog.mz_schemas s
10147LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10148WHERE s.database_id IS NULL OR d.name = current_database()",
10149 access: vec![PUBLIC_SELECT],
10150});
10151
10152pub static INFORMATION_SCHEMA_TABLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10153 name: "tables",
10154 schema: INFORMATION_SCHEMA,
10155 oid: oid::VIEW_TABLES_OID,
10156 desc: RelationDesc::builder()
10157 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10158 .with_column("table_schema", SqlScalarType::String.nullable(false))
10159 .with_column("table_name", SqlScalarType::String.nullable(false))
10160 .with_column("table_type", SqlScalarType::String.nullable(false))
10161 .finish(),
10162 column_comments: BTreeMap::new(),
10163 sql: "SELECT
10164 current_database() as table_catalog,
10165 s.name AS table_schema,
10166 r.name AS table_name,
10167 CASE r.type
10168 WHEN 'materialized-view' THEN 'MATERIALIZED VIEW'
10169 WHEN 'table' THEN 'BASE TABLE'
10170 ELSE pg_catalog.upper(r.type)
10171 END AS table_type
10172FROM mz_catalog.mz_relations r
10173JOIN mz_catalog.mz_schemas s ON s.id = r.schema_id
10174LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10175WHERE s.database_id IS NULL OR d.name = current_database()",
10176 access: vec![PUBLIC_SELECT],
10177});
10178
10179pub static INFORMATION_SCHEMA_TABLE_CONSTRAINTS: LazyLock<BuiltinView> =
10180 LazyLock::new(|| BuiltinView {
10181 name: "table_constraints",
10182 schema: INFORMATION_SCHEMA,
10183 oid: oid::VIEW_TABLE_CONSTRAINTS_OID,
10184 desc: RelationDesc::builder()
10185 .with_column("constraint_catalog", SqlScalarType::String.nullable(false))
10186 .with_column("constraint_schema", SqlScalarType::String.nullable(false))
10187 .with_column("constraint_name", SqlScalarType::String.nullable(false))
10188 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10189 .with_column("table_schema", SqlScalarType::String.nullable(false))
10190 .with_column("table_name", SqlScalarType::String.nullable(false))
10191 .with_column("constraint_type", SqlScalarType::String.nullable(false))
10192 .with_column("is_deferrable", SqlScalarType::String.nullable(false))
10193 .with_column("initially_deferred", SqlScalarType::String.nullable(false))
10194 .with_column("enforced", SqlScalarType::String.nullable(false))
10195 .with_column("nulls_distinct", SqlScalarType::String.nullable(false))
10196 .with_key(vec![])
10197 .finish(),
10198 column_comments: BTreeMap::new(),
10199 sql: "SELECT
10200 NULL::text AS constraint_catalog,
10201 NULL::text AS constraint_schema,
10202 NULL::text AS constraint_name,
10203 NULL::text AS table_catalog,
10204 NULL::text AS table_schema,
10205 NULL::text AS table_name,
10206 NULL::text AS constraint_type,
10207 NULL::text AS is_deferrable,
10208 NULL::text AS initially_deferred,
10209 NULL::text AS enforced,
10210 NULL::text AS nulls_distinct
10211WHERE false",
10212 access: vec![PUBLIC_SELECT],
10213 });
10214
10215pub static INFORMATION_SCHEMA_TABLE_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| {
10216 BuiltinView {
10217 name: "table_privileges",
10218 schema: INFORMATION_SCHEMA,
10219 oid: oid::VIEW_TABLE_PRIVILEGES_OID,
10220 desc: RelationDesc::builder()
10221 .with_column("grantor", SqlScalarType::String.nullable(false))
10222 .with_column("grantee", SqlScalarType::String.nullable(true))
10223 .with_column("table_catalog", SqlScalarType::String.nullable(true))
10224 .with_column("table_schema", SqlScalarType::String.nullable(false))
10225 .with_column("table_name", SqlScalarType::String.nullable(false))
10226 .with_column("privilege_type", SqlScalarType::String.nullable(true))
10227 .with_column("is_grantable", SqlScalarType::String.nullable(false))
10228 .with_column("with_hierarchy", SqlScalarType::String.nullable(false))
10229 .finish(),
10230 column_comments: BTreeMap::new(),
10231 sql: "
10232SELECT
10233 grantor,
10234 grantee,
10235 table_catalog,
10236 table_schema,
10237 table_name,
10238 privilege_type,
10239 is_grantable,
10240 CASE privilege_type
10241 WHEN 'SELECT' THEN 'YES'
10242 ELSE 'NO'
10243 END AS with_hierarchy
10244FROM
10245 (SELECT
10246 grantor.name AS grantor,
10247 CASE mz_internal.mz_aclitem_grantee(privileges)
10248 WHEN 'p' THEN 'PUBLIC'
10249 ELSE grantee.name
10250 END AS grantee,
10251 table_catalog,
10252 table_schema,
10253 table_name,
10254 unnest(mz_internal.mz_format_privileges(mz_internal.mz_aclitem_privileges(privileges))) AS privilege_type,
10255 -- ADMIN OPTION isn't implemented.
10256 'NO' AS is_grantable
10257 FROM
10258 (SELECT
10259 unnest(relations.privileges) AS privileges,
10260 CASE
10261 WHEN schemas.database_id IS NULL THEN current_database()
10262 ELSE databases.name
10263 END AS table_catalog,
10264 schemas.name AS table_schema,
10265 relations.name AS table_name
10266 FROM mz_catalog.mz_relations AS relations
10267 JOIN mz_catalog.mz_schemas AS schemas ON relations.schema_id = schemas.id
10268 LEFT JOIN mz_catalog.mz_databases AS databases ON schemas.database_id = databases.id
10269 WHERE schemas.database_id IS NULL OR databases.name = current_database())
10270 JOIN mz_catalog.mz_roles AS grantor ON mz_internal.mz_aclitem_grantor(privileges) = grantor.id
10271 LEFT JOIN mz_catalog.mz_roles AS grantee ON mz_internal.mz_aclitem_grantee(privileges) = grantee.id)
10272WHERE
10273 -- WHERE clause is not guaranteed to short-circuit and 'PUBLIC' will cause an error when passed
10274 -- to pg_has_role. Therefore we need to use a CASE statement.
10275 CASE
10276 WHEN grantee = 'PUBLIC' THEN true
10277 ELSE mz_catalog.mz_is_superuser()
10278 OR pg_has_role(current_role, grantee, 'USAGE')
10279 OR pg_has_role(current_role, grantor, 'USAGE')
10280 END",
10281 access: vec![PUBLIC_SELECT],
10282 }
10283});
10284
10285pub static INFORMATION_SCHEMA_TRIGGERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10286 name: "triggers",
10287 schema: INFORMATION_SCHEMA,
10288 oid: oid::VIEW_TRIGGERS_OID,
10289 desc: RelationDesc::builder()
10290 .with_column("trigger_catalog", SqlScalarType::String.nullable(false))
10291 .with_column("trigger_schema", SqlScalarType::String.nullable(false))
10292 .with_column("trigger_name", SqlScalarType::String.nullable(false))
10293 .with_column("event_manipulation", SqlScalarType::String.nullable(false))
10294 .with_column(
10295 "event_object_catalog",
10296 SqlScalarType::String.nullable(false),
10297 )
10298 .with_column("event_object_schema", SqlScalarType::String.nullable(false))
10299 .with_column("event_object_table", SqlScalarType::String.nullable(false))
10300 .with_column("action_order", SqlScalarType::Int32.nullable(false))
10301 .with_column("action_condition", SqlScalarType::String.nullable(false))
10302 .with_column("action_statement", SqlScalarType::String.nullable(false))
10303 .with_column("action_orientation", SqlScalarType::String.nullable(false))
10304 .with_column("action_timing", SqlScalarType::String.nullable(false))
10305 .with_column(
10306 "action_reference_old_table",
10307 SqlScalarType::String.nullable(false),
10308 )
10309 .with_column(
10310 "action_reference_new_table",
10311 SqlScalarType::String.nullable(false),
10312 )
10313 .with_key(vec![])
10314 .finish(),
10315 column_comments: BTreeMap::new(),
10316 sql: "SELECT
10317 NULL::text as trigger_catalog,
10318 NULL::text AS trigger_schema,
10319 NULL::text AS trigger_name,
10320 NULL::text AS event_manipulation,
10321 NULL::text AS event_object_catalog,
10322 NULL::text AS event_object_schema,
10323 NULL::text AS event_object_table,
10324 NULL::integer AS action_order,
10325 NULL::text AS action_condition,
10326 NULL::text AS action_statement,
10327 NULL::text AS action_orientation,
10328 NULL::text AS action_timing,
10329 NULL::text AS action_reference_old_table,
10330 NULL::text AS action_reference_new_table
10331WHERE FALSE",
10332 access: vec![PUBLIC_SELECT],
10333});
10334
10335pub static INFORMATION_SCHEMA_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10336 name: "views",
10337 schema: INFORMATION_SCHEMA,
10338 oid: oid::VIEW_VIEWS_OID,
10339 desc: RelationDesc::builder()
10340 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10341 .with_column("table_schema", SqlScalarType::String.nullable(false))
10342 .with_column("table_name", SqlScalarType::String.nullable(false))
10343 .with_column("view_definition", SqlScalarType::String.nullable(false))
10344 .finish(),
10345 column_comments: BTreeMap::new(),
10346 sql: "SELECT
10347 current_database() as table_catalog,
10348 s.name AS table_schema,
10349 v.name AS table_name,
10350 v.definition AS view_definition
10351FROM mz_catalog.mz_views v
10352JOIN mz_catalog.mz_schemas s ON s.id = v.schema_id
10353LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10354WHERE s.database_id IS NULL OR d.name = current_database()",
10355 access: vec![PUBLIC_SELECT],
10356});
10357
10358pub static INFORMATION_SCHEMA_CHARACTER_SETS: LazyLock<BuiltinView> =
10359 LazyLock::new(|| BuiltinView {
10360 name: "character_sets",
10361 schema: INFORMATION_SCHEMA,
10362 oid: oid::VIEW_CHARACTER_SETS_OID,
10363 desc: RelationDesc::builder()
10364 .with_column(
10365 "character_set_catalog",
10366 SqlScalarType::String.nullable(true),
10367 )
10368 .with_column("character_set_schema", SqlScalarType::String.nullable(true))
10369 .with_column("character_set_name", SqlScalarType::String.nullable(false))
10370 .with_column(
10371 "character_repertoire",
10372 SqlScalarType::String.nullable(false),
10373 )
10374 .with_column("form_of_use", SqlScalarType::String.nullable(false))
10375 .with_column(
10376 "default_collate_catalog",
10377 SqlScalarType::String.nullable(false),
10378 )
10379 .with_column(
10380 "default_collate_schema",
10381 SqlScalarType::String.nullable(false),
10382 )
10383 .with_column(
10384 "default_collate_name",
10385 SqlScalarType::String.nullable(false),
10386 )
10387 .with_key(vec![])
10388 .finish(),
10389 column_comments: BTreeMap::new(),
10390 sql: "SELECT
10391 NULL as character_set_catalog,
10392 NULL as character_set_schema,
10393 'UTF8' as character_set_name,
10394 'UCS' as character_repertoire,
10395 'UTF8' as form_of_use,
10396 current_database() as default_collate_catalog,
10397 'pg_catalog' as default_collate_schema,
10398 'en_US.utf8' as default_collate_name",
10399 access: vec![PUBLIC_SELECT],
10400 });
10401
10402pub static PG_COLLATION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10405 name: "pg_collation",
10406 schema: PG_CATALOG_SCHEMA,
10407 oid: oid::VIEW_PG_COLLATION_OID,
10408 desc: RelationDesc::builder()
10409 .with_column("oid", SqlScalarType::Oid.nullable(false))
10410 .with_column("collname", SqlScalarType::String.nullable(false))
10411 .with_column("collnamespace", SqlScalarType::Oid.nullable(false))
10412 .with_column("collowner", SqlScalarType::Oid.nullable(false))
10413 .with_column("collprovider", SqlScalarType::PgLegacyChar.nullable(false))
10414 .with_column("collisdeterministic", SqlScalarType::Bool.nullable(false))
10415 .with_column("collencoding", SqlScalarType::Int32.nullable(false))
10416 .with_column("collcollate", SqlScalarType::String.nullable(false))
10417 .with_column("collctype", SqlScalarType::String.nullable(false))
10418 .with_column("collversion", SqlScalarType::String.nullable(false))
10419 .with_key(vec![])
10420 .finish(),
10421 column_comments: BTreeMap::new(),
10422 sql: "
10423SELECT
10424 NULL::pg_catalog.oid AS oid,
10425 NULL::pg_catalog.text AS collname,
10426 NULL::pg_catalog.oid AS collnamespace,
10427 NULL::pg_catalog.oid AS collowner,
10428 NULL::pg_catalog.\"char\" AS collprovider,
10429 NULL::pg_catalog.bool AS collisdeterministic,
10430 NULL::pg_catalog.int4 AS collencoding,
10431 NULL::pg_catalog.text AS collcollate,
10432 NULL::pg_catalog.text AS collctype,
10433 NULL::pg_catalog.text AS collversion
10434WHERE false",
10435 access: vec![PUBLIC_SELECT],
10436});
10437
10438pub static PG_POLICY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10440 name: "pg_policy",
10441 schema: PG_CATALOG_SCHEMA,
10442 oid: oid::VIEW_PG_POLICY_OID,
10443 desc: RelationDesc::builder()
10444 .with_column("oid", SqlScalarType::Oid.nullable(false))
10445 .with_column("polname", SqlScalarType::String.nullable(false))
10446 .with_column("polrelid", SqlScalarType::Oid.nullable(false))
10447 .with_column("polcmd", SqlScalarType::PgLegacyChar.nullable(false))
10448 .with_column("polpermissive", SqlScalarType::Bool.nullable(false))
10449 .with_column(
10450 "polroles",
10451 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
10452 )
10453 .with_column("polqual", SqlScalarType::String.nullable(false))
10454 .with_column("polwithcheck", SqlScalarType::String.nullable(false))
10455 .with_key(vec![])
10456 .finish(),
10457 column_comments: BTreeMap::new(),
10458 sql: "
10459SELECT
10460 NULL::pg_catalog.oid AS oid,
10461 NULL::pg_catalog.text AS polname,
10462 NULL::pg_catalog.oid AS polrelid,
10463 NULL::pg_catalog.\"char\" AS polcmd,
10464 NULL::pg_catalog.bool AS polpermissive,
10465 NULL::pg_catalog.oid[] AS polroles,
10466 NULL::pg_catalog.text AS polqual,
10467 NULL::pg_catalog.text AS polwithcheck
10468WHERE false",
10469 access: vec![PUBLIC_SELECT],
10470});
10471
10472pub static PG_INHERITS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10474 name: "pg_inherits",
10475 schema: PG_CATALOG_SCHEMA,
10476 oid: oid::VIEW_PG_INHERITS_OID,
10477 desc: RelationDesc::builder()
10478 .with_column("inhrelid", SqlScalarType::Oid.nullable(false))
10479 .with_column("inhparent", SqlScalarType::Oid.nullable(false))
10480 .with_column("inhseqno", SqlScalarType::Int32.nullable(false))
10481 .with_column("inhdetachpending", SqlScalarType::Bool.nullable(false))
10482 .with_key(vec![])
10483 .finish(),
10484 column_comments: BTreeMap::new(),
10485 sql: "
10486SELECT
10487 NULL::pg_catalog.oid AS inhrelid,
10488 NULL::pg_catalog.oid AS inhparent,
10489 NULL::pg_catalog.int4 AS inhseqno,
10490 NULL::pg_catalog.bool AS inhdetachpending
10491WHERE false",
10492 access: vec![PUBLIC_SELECT],
10493});
10494
10495pub static PG_LOCKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10496 name: "pg_locks",
10497 schema: PG_CATALOG_SCHEMA,
10498 oid: oid::VIEW_PG_LOCKS_OID,
10499 desc: RelationDesc::builder()
10500 .with_column("locktype", SqlScalarType::String.nullable(false))
10501 .with_column("database", SqlScalarType::Oid.nullable(false))
10502 .with_column("relation", SqlScalarType::Oid.nullable(false))
10503 .with_column("page", SqlScalarType::Int32.nullable(false))
10504 .with_column("tuple", SqlScalarType::Int16.nullable(false))
10505 .with_column("virtualxid", SqlScalarType::String.nullable(false))
10506 .with_column("transactionid", SqlScalarType::String.nullable(false))
10507 .with_column("classid", SqlScalarType::Oid.nullable(false))
10508 .with_column("objid", SqlScalarType::Oid.nullable(false))
10509 .with_column("objsubid", SqlScalarType::Int16.nullable(false))
10510 .with_column("virtualtransaction", SqlScalarType::String.nullable(false))
10511 .with_column("pid", SqlScalarType::Int32.nullable(false))
10512 .with_column("mode", SqlScalarType::String.nullable(false))
10513 .with_column("granted", SqlScalarType::Bool.nullable(false))
10514 .with_column("fastpath", SqlScalarType::Bool.nullable(false))
10515 .with_column(
10516 "waitstart",
10517 SqlScalarType::TimestampTz { precision: None }.nullable(false),
10518 )
10519 .with_key(vec![])
10520 .finish(),
10521 column_comments: BTreeMap::new(),
10522 sql: "
10523SELECT
10524-- While there exist locks in Materialize, we don't expose them, so all of these fields are NULL.
10525 NULL::pg_catalog.text AS locktype,
10526 NULL::pg_catalog.oid AS database,
10527 NULL::pg_catalog.oid AS relation,
10528 NULL::pg_catalog.int4 AS page,
10529 NULL::pg_catalog.int2 AS tuple,
10530 NULL::pg_catalog.text AS virtualxid,
10531 NULL::pg_catalog.text AS transactionid,
10532 NULL::pg_catalog.oid AS classid,
10533 NULL::pg_catalog.oid AS objid,
10534 NULL::pg_catalog.int2 AS objsubid,
10535 NULL::pg_catalog.text AS virtualtransaction,
10536 NULL::pg_catalog.int4 AS pid,
10537 NULL::pg_catalog.text AS mode,
10538 NULL::pg_catalog.bool AS granted,
10539 NULL::pg_catalog.bool AS fastpath,
10540 NULL::pg_catalog.timestamptz AS waitstart
10541WHERE false",
10542 access: vec![PUBLIC_SELECT],
10543});
10544
10545pub static PG_AUTHID: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10546 name: "pg_authid",
10547 schema: PG_CATALOG_SCHEMA,
10548 oid: oid::VIEW_PG_AUTHID_OID,
10549 desc: RelationDesc::builder()
10550 .with_column("oid", SqlScalarType::Oid.nullable(false))
10551 .with_column("rolname", SqlScalarType::String.nullable(false))
10552 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
10553 .with_column("rolinherit", SqlScalarType::Bool.nullable(false))
10554 .with_column("rolcreaterole", SqlScalarType::Bool.nullable(true))
10555 .with_column("rolcreatedb", SqlScalarType::Bool.nullable(true))
10556 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(false))
10557 .with_column("rolreplication", SqlScalarType::Bool.nullable(false))
10558 .with_column("rolbypassrls", SqlScalarType::Bool.nullable(false))
10559 .with_column("rolconnlimit", SqlScalarType::Int32.nullable(false))
10560 .with_column("rolpassword", SqlScalarType::String.nullable(true))
10561 .with_column(
10562 "rolvaliduntil",
10563 SqlScalarType::TimestampTz { precision: None }.nullable(true),
10564 )
10565 .finish(),
10566 column_comments: BTreeMap::new(),
10567 sql: r#"
10568SELECT
10569 r.oid AS oid,
10570 r.name AS rolname,
10571 rolsuper,
10572 inherit AS rolinherit,
10573 mz_catalog.has_system_privilege(r.oid, 'CREATEROLE') AS rolcreaterole,
10574 mz_catalog.has_system_privilege(r.oid, 'CREATEDB') AS rolcreatedb,
10575 COALESCE(r.rolcanlogin, false) AS rolcanlogin,
10576 -- MZ doesn't support replication in the same way Postgres does
10577 false AS rolreplication,
10578 -- MZ doesn't how row level security
10579 false AS rolbypassrls,
10580 -- MZ doesn't have a connection limit
10581 -1 AS rolconnlimit,
10582 a.password_hash AS rolpassword,
10583 NULL::pg_catalog.timestamptz AS rolvaliduntil
10584FROM mz_catalog.mz_roles r
10585LEFT JOIN mz_catalog.mz_role_auth a ON r.oid = a.role_oid"#,
10586 access: vec![rbac::owner_privilege(ObjectType::Table, MZ_SYSTEM_ROLE_ID)],
10587});
10588
10589pub static PG_AGGREGATE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10590 name: "pg_aggregate",
10591 schema: PG_CATALOG_SCHEMA,
10592 oid: oid::VIEW_PG_AGGREGATE_OID,
10593 desc: RelationDesc::builder()
10594 .with_column("aggfnoid", SqlScalarType::Oid.nullable(false))
10595 .with_column("aggkind", SqlScalarType::String.nullable(false))
10596 .with_column("aggnumdirectargs", SqlScalarType::Int16.nullable(false))
10597 .with_column("aggtransfn", SqlScalarType::RegProc.nullable(true))
10598 .with_column("aggfinalfn", SqlScalarType::RegProc.nullable(false))
10599 .with_column("aggcombinefn", SqlScalarType::RegProc.nullable(false))
10600 .with_column("aggserialfn", SqlScalarType::RegProc.nullable(false))
10601 .with_column("aggdeserialfn", SqlScalarType::RegProc.nullable(false))
10602 .with_column("aggmtransfn", SqlScalarType::RegProc.nullable(false))
10603 .with_column("aggminvtransfn", SqlScalarType::RegProc.nullable(false))
10604 .with_column("aggmfinalfn", SqlScalarType::RegProc.nullable(false))
10605 .with_column("aggfinalextra", SqlScalarType::Bool.nullable(false))
10606 .with_column("aggmfinalextra", SqlScalarType::Bool.nullable(false))
10607 .with_column("aggfinalmodify", SqlScalarType::PgLegacyChar.nullable(true))
10608 .with_column(
10609 "aggmfinalmodify",
10610 SqlScalarType::PgLegacyChar.nullable(true),
10611 )
10612 .with_column("aggsortop", SqlScalarType::Oid.nullable(false))
10613 .with_column("aggtranstype", SqlScalarType::Oid.nullable(true))
10614 .with_column("aggtransspace", SqlScalarType::Int32.nullable(true))
10615 .with_column("aggmtranstype", SqlScalarType::Oid.nullable(false))
10616 .with_column("aggmtransspace", SqlScalarType::Int32.nullable(true))
10617 .with_column("agginitval", SqlScalarType::String.nullable(true))
10618 .with_column("aggminitval", SqlScalarType::String.nullable(true))
10619 .finish(),
10620 column_comments: BTreeMap::new(),
10621 sql: "SELECT
10622 a.oid as aggfnoid,
10623 -- Currently Materialize only support 'normal' aggregate functions.
10624 a.agg_kind as aggkind,
10625 a.agg_num_direct_args as aggnumdirectargs,
10626 -- Materialize doesn't support these fields.
10627 NULL::pg_catalog.regproc as aggtransfn,
10628 '0'::pg_catalog.regproc as aggfinalfn,
10629 '0'::pg_catalog.regproc as aggcombinefn,
10630 '0'::pg_catalog.regproc as aggserialfn,
10631 '0'::pg_catalog.regproc as aggdeserialfn,
10632 '0'::pg_catalog.regproc as aggmtransfn,
10633 '0'::pg_catalog.regproc as aggminvtransfn,
10634 '0'::pg_catalog.regproc as aggmfinalfn,
10635 false as aggfinalextra,
10636 false as aggmfinalextra,
10637 NULL::pg_catalog.\"char\" AS aggfinalmodify,
10638 NULL::pg_catalog.\"char\" AS aggmfinalmodify,
10639 '0'::pg_catalog.oid as aggsortop,
10640 NULL::pg_catalog.oid as aggtranstype,
10641 NULL::pg_catalog.int4 as aggtransspace,
10642 '0'::pg_catalog.oid as aggmtranstype,
10643 NULL::pg_catalog.int4 as aggmtransspace,
10644 NULL::pg_catalog.text as agginitval,
10645 NULL::pg_catalog.text as aggminitval
10646FROM mz_internal.mz_aggregates a",
10647 access: vec![PUBLIC_SELECT],
10648});
10649
10650pub static PG_TRIGGER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10651 name: "pg_trigger",
10652 schema: PG_CATALOG_SCHEMA,
10653 oid: oid::VIEW_PG_TRIGGER_OID,
10654 desc: RelationDesc::builder()
10655 .with_column("oid", SqlScalarType::Oid.nullable(false))
10656 .with_column("tgrelid", SqlScalarType::Oid.nullable(false))
10657 .with_column("tgparentid", SqlScalarType::Oid.nullable(false))
10658 .with_column("tgname", SqlScalarType::String.nullable(false))
10659 .with_column("tgfoid", SqlScalarType::Oid.nullable(false))
10660 .with_column("tgtype", SqlScalarType::Int16.nullable(false))
10661 .with_column("tgenabled", SqlScalarType::PgLegacyChar.nullable(false))
10662 .with_column("tgisinternal", SqlScalarType::Bool.nullable(false))
10663 .with_column("tgconstrrelid", SqlScalarType::Oid.nullable(false))
10664 .with_column("tgconstrindid", SqlScalarType::Oid.nullable(false))
10665 .with_column("tgconstraint", SqlScalarType::Oid.nullable(false))
10666 .with_column("tgdeferrable", SqlScalarType::Bool.nullable(false))
10667 .with_column("tginitdeferred", SqlScalarType::Bool.nullable(false))
10668 .with_column("tgnargs", SqlScalarType::Int16.nullable(false))
10669 .with_column("tgattr", SqlScalarType::Int2Vector.nullable(false))
10670 .with_column("tgargs", SqlScalarType::Bytes.nullable(false))
10671 .with_column("tgqual", SqlScalarType::String.nullable(false))
10672 .with_column("tgoldtable", SqlScalarType::String.nullable(false))
10673 .with_column("tgnewtable", SqlScalarType::String.nullable(false))
10674 .with_key(vec![])
10675 .finish(),
10676 column_comments: BTreeMap::new(),
10677 sql: "SELECT
10678 -- MZ doesn't support triggers so all of these fields are NULL.
10679 NULL::pg_catalog.oid AS oid,
10680 NULL::pg_catalog.oid AS tgrelid,
10681 NULL::pg_catalog.oid AS tgparentid,
10682 NULL::pg_catalog.text AS tgname,
10683 NULL::pg_catalog.oid AS tgfoid,
10684 NULL::pg_catalog.int2 AS tgtype,
10685 NULL::pg_catalog.\"char\" AS tgenabled,
10686 NULL::pg_catalog.bool AS tgisinternal,
10687 NULL::pg_catalog.oid AS tgconstrrelid,
10688 NULL::pg_catalog.oid AS tgconstrindid,
10689 NULL::pg_catalog.oid AS tgconstraint,
10690 NULL::pg_catalog.bool AS tgdeferrable,
10691 NULL::pg_catalog.bool AS tginitdeferred,
10692 NULL::pg_catalog.int2 AS tgnargs,
10693 NULL::pg_catalog.int2vector AS tgattr,
10694 NULL::pg_catalog.bytea AS tgargs,
10695 -- NOTE: The tgqual column is actually type `pg_node_tree` which we don't support. CockroachDB
10696 -- uses text as a placeholder, so we'll follow their lead here.
10697 NULL::pg_catalog.text AS tgqual,
10698 NULL::pg_catalog.text AS tgoldtable,
10699 NULL::pg_catalog.text AS tgnewtable
10700WHERE false
10701 ",
10702 access: vec![PUBLIC_SELECT],
10703});
10704
10705pub static PG_REWRITE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10706 name: "pg_rewrite",
10707 schema: PG_CATALOG_SCHEMA,
10708 oid: oid::VIEW_PG_REWRITE_OID,
10709 desc: RelationDesc::builder()
10710 .with_column("oid", SqlScalarType::Oid.nullable(false))
10711 .with_column("rulename", SqlScalarType::String.nullable(false))
10712 .with_column("ev_class", SqlScalarType::Oid.nullable(false))
10713 .with_column("ev_type", SqlScalarType::PgLegacyChar.nullable(false))
10714 .with_column("ev_enabled", SqlScalarType::PgLegacyChar.nullable(false))
10715 .with_column("is_instead", SqlScalarType::Bool.nullable(false))
10716 .with_column("ev_qual", SqlScalarType::String.nullable(false))
10717 .with_column("ev_action", SqlScalarType::String.nullable(false))
10718 .with_key(vec![])
10719 .finish(),
10720 column_comments: BTreeMap::new(),
10721 sql: "SELECT
10722 -- MZ doesn't support rewrite rules so all of these fields are NULL.
10723 NULL::pg_catalog.oid AS oid,
10724 NULL::pg_catalog.text AS rulename,
10725 NULL::pg_catalog.oid AS ev_class,
10726 NULL::pg_catalog.\"char\" AS ev_type,
10727 NULL::pg_catalog.\"char\" AS ev_enabled,
10728 NULL::pg_catalog.bool AS is_instead,
10729 -- NOTE: The ev_qual and ev_action columns are actually type `pg_node_tree` which we don't
10730 -- support. CockroachDB uses text as a placeholder, so we'll follow their lead here.
10731 NULL::pg_catalog.text AS ev_qual,
10732 NULL::pg_catalog.text AS ev_action
10733WHERE false
10734 ",
10735 access: vec![PUBLIC_SELECT],
10736});
10737
10738pub static PG_EXTENSION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10739 name: "pg_extension",
10740 schema: PG_CATALOG_SCHEMA,
10741 oid: oid::VIEW_PG_EXTENSION_OID,
10742 desc: RelationDesc::builder()
10743 .with_column("oid", SqlScalarType::Oid.nullable(false))
10744 .with_column("extname", SqlScalarType::String.nullable(false))
10745 .with_column("extowner", SqlScalarType::Oid.nullable(false))
10746 .with_column("extnamespace", SqlScalarType::Oid.nullable(false))
10747 .with_column("extrelocatable", SqlScalarType::Bool.nullable(false))
10748 .with_column("extversion", SqlScalarType::String.nullable(false))
10749 .with_column(
10750 "extconfig",
10751 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
10752 )
10753 .with_column(
10754 "extcondition",
10755 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
10756 )
10757 .with_key(vec![])
10758 .finish(),
10759 column_comments: BTreeMap::new(),
10760 sql: "SELECT
10761 -- MZ doesn't support extensions so all of these fields are NULL.
10762 NULL::pg_catalog.oid AS oid,
10763 NULL::pg_catalog.text AS extname,
10764 NULL::pg_catalog.oid AS extowner,
10765 NULL::pg_catalog.oid AS extnamespace,
10766 NULL::pg_catalog.bool AS extrelocatable,
10767 NULL::pg_catalog.text AS extversion,
10768 NULL::pg_catalog.oid[] AS extconfig,
10769 NULL::pg_catalog.text[] AS extcondition
10770WHERE false
10771 ",
10772 access: vec![PUBLIC_SELECT],
10773});
10774
10775pub static MZ_SHOW_ALL_OBJECTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10776 name: "mz_show_all_objects",
10777 schema: MZ_INTERNAL_SCHEMA,
10778 oid: oid::VIEW_MZ_SHOW_ALL_OBJECTS_OID,
10779 desc: RelationDesc::builder()
10780 .with_column("schema_id", SqlScalarType::String.nullable(false))
10781 .with_column("name", SqlScalarType::String.nullable(false))
10782 .with_column("type", SqlScalarType::String.nullable(false))
10783 .with_column("comment", SqlScalarType::String.nullable(false))
10784 .finish(),
10785 column_comments: BTreeMap::new(),
10786 sql: "WITH comments AS (
10787 SELECT id, object_type, comment
10788 FROM mz_internal.mz_comments
10789 WHERE object_sub_id IS NULL
10790 )
10791 SELECT schema_id, name, type, COALESCE(comment, '') AS comment
10792 FROM mz_catalog.mz_objects AS objs
10793 LEFT JOIN comments ON objs.id = comments.id
10794 WHERE (comments.object_type = objs.type OR comments.object_type IS NULL)",
10795 access: vec![PUBLIC_SELECT],
10796});
10797
10798pub static MZ_SHOW_CLUSTERS: LazyLock<BuiltinView> = LazyLock::new(|| {
10799 BuiltinView {
10800 name: "mz_show_clusters",
10801 schema: MZ_INTERNAL_SCHEMA,
10802 oid: oid::VIEW_MZ_SHOW_CLUSTERS_OID,
10803 desc: RelationDesc::builder()
10804 .with_column("name", SqlScalarType::String.nullable(false))
10805 .with_column("replicas", SqlScalarType::String.nullable(true))
10806 .with_column("comment", SqlScalarType::String.nullable(false))
10807 .finish(),
10808 column_comments: BTreeMap::new(),
10809 sql: "
10810 WITH clusters AS (
10811 SELECT
10812 mc.id,
10813 mc.name,
10814 pg_catalog.string_agg(mcr.name || ' (' || mcr.size || ')', ', ' ORDER BY mcr.name) AS replicas
10815 FROM mz_catalog.mz_clusters mc
10816 LEFT JOIN mz_catalog.mz_cluster_replicas mcr
10817 ON mc.id = mcr.cluster_id
10818 GROUP BY mc.id, mc.name
10819 ),
10820 comments AS (
10821 SELECT id, comment
10822 FROM mz_internal.mz_comments
10823 WHERE object_type = 'cluster' AND object_sub_id IS NULL
10824 )
10825 SELECT name, replicas, COALESCE(comment, '') as comment
10826 FROM clusters
10827 LEFT JOIN comments ON clusters.id = comments.id",
10828 access: vec![PUBLIC_SELECT],
10829}
10830});
10831
10832pub static MZ_SHOW_SECRETS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10833 name: "mz_show_secrets",
10834 schema: MZ_INTERNAL_SCHEMA,
10835 oid: oid::VIEW_MZ_SHOW_SECRETS_OID,
10836 desc: RelationDesc::builder()
10837 .with_column("schema_id", SqlScalarType::String.nullable(false))
10838 .with_column("name", SqlScalarType::String.nullable(false))
10839 .with_column("comment", SqlScalarType::String.nullable(false))
10840 .finish(),
10841 column_comments: BTreeMap::new(),
10842 sql: "WITH comments AS (
10843 SELECT id, comment
10844 FROM mz_internal.mz_comments
10845 WHERE object_type = 'secret' AND object_sub_id IS NULL
10846 )
10847 SELECT schema_id, name, COALESCE(comment, '') as comment
10848 FROM mz_catalog.mz_secrets secrets
10849 LEFT JOIN comments ON secrets.id = comments.id",
10850 access: vec![PUBLIC_SELECT],
10851});
10852
10853pub static MZ_SHOW_COLUMNS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10854 name: "mz_show_columns",
10855 schema: MZ_INTERNAL_SCHEMA,
10856 oid: oid::VIEW_MZ_SHOW_COLUMNS_OID,
10857 desc: RelationDesc::builder()
10858 .with_column("id", SqlScalarType::String.nullable(false))
10859 .with_column("name", SqlScalarType::String.nullable(false))
10860 .with_column("nullable", SqlScalarType::Bool.nullable(false))
10861 .with_column("type", SqlScalarType::String.nullable(false))
10862 .with_column("position", SqlScalarType::UInt64.nullable(false))
10863 .with_column("comment", SqlScalarType::String.nullable(false))
10864 .finish(),
10865 column_comments: BTreeMap::new(),
10866 sql: "
10867 SELECT columns.id, name, nullable, type, position, COALESCE(comment, '') as comment
10868 FROM mz_catalog.mz_columns columns
10869 LEFT JOIN mz_internal.mz_comments comments
10870 ON columns.id = comments.id AND columns.position = comments.object_sub_id",
10871 access: vec![PUBLIC_SELECT],
10872});
10873
10874pub static MZ_SHOW_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10875 name: "mz_show_databases",
10876 schema: MZ_INTERNAL_SCHEMA,
10877 oid: oid::VIEW_MZ_SHOW_DATABASES_OID,
10878 desc: RelationDesc::builder()
10879 .with_column("name", SqlScalarType::String.nullable(false))
10880 .with_column("comment", SqlScalarType::String.nullable(false))
10881 .finish(),
10882 column_comments: BTreeMap::new(),
10883 sql: "WITH comments AS (
10884 SELECT id, comment
10885 FROM mz_internal.mz_comments
10886 WHERE object_type = 'database' AND object_sub_id IS NULL
10887 )
10888 SELECT name, COALESCE(comment, '') as comment
10889 FROM mz_catalog.mz_databases databases
10890 LEFT JOIN comments ON databases.id = comments.id",
10891 access: vec![PUBLIC_SELECT],
10892});
10893
10894pub static MZ_SHOW_SCHEMAS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10895 name: "mz_show_schemas",
10896 schema: MZ_INTERNAL_SCHEMA,
10897 oid: oid::VIEW_MZ_SHOW_SCHEMAS_OID,
10898 desc: RelationDesc::builder()
10899 .with_column("database_id", SqlScalarType::String.nullable(true))
10900 .with_column("name", SqlScalarType::String.nullable(false))
10901 .with_column("comment", SqlScalarType::String.nullable(false))
10902 .finish(),
10903 column_comments: BTreeMap::new(),
10904 sql: "WITH comments AS (
10905 SELECT id, comment
10906 FROM mz_internal.mz_comments
10907 WHERE object_type = 'schema' AND object_sub_id IS NULL
10908 )
10909 SELECT database_id, name, COALESCE(comment, '') as comment
10910 FROM mz_catalog.mz_schemas schemas
10911 LEFT JOIN comments ON schemas.id = comments.id",
10912 access: vec![PUBLIC_SELECT],
10913});
10914
10915pub static MZ_SHOW_ROLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10916 name: "mz_show_roles",
10917 schema: MZ_INTERNAL_SCHEMA,
10918 oid: oid::VIEW_MZ_SHOW_ROLES_OID,
10919 desc: RelationDesc::builder()
10920 .with_column("name", SqlScalarType::String.nullable(false))
10921 .with_column("comment", SqlScalarType::String.nullable(false))
10922 .finish(),
10923 column_comments: BTreeMap::new(),
10924 sql: "WITH comments AS (
10925 SELECT id, comment
10926 FROM mz_internal.mz_comments
10927 WHERE object_type = 'role' AND object_sub_id IS NULL
10928 )
10929 SELECT name, COALESCE(comment, '') as comment
10930 FROM mz_catalog.mz_roles roles
10931 LEFT JOIN comments ON roles.id = comments.id
10932 WHERE roles.id NOT LIKE 's%'
10933 AND roles.id NOT LIKE 'g%'",
10934 access: vec![PUBLIC_SELECT],
10935});
10936
10937pub static MZ_SHOW_TABLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10938 name: "mz_show_tables",
10939 schema: MZ_INTERNAL_SCHEMA,
10940 oid: oid::VIEW_MZ_SHOW_TABLES_OID,
10941 desc: RelationDesc::builder()
10942 .with_column("schema_id", SqlScalarType::String.nullable(false))
10943 .with_column("name", SqlScalarType::String.nullable(false))
10944 .with_column("comment", SqlScalarType::String.nullable(false))
10945 .with_column("source_id", SqlScalarType::String.nullable(true))
10946 .finish(),
10947 column_comments: BTreeMap::new(),
10948 sql: "WITH comments AS (
10949 SELECT id, comment
10950 FROM mz_internal.mz_comments
10951 WHERE object_type = 'table' AND object_sub_id IS NULL
10952 )
10953 SELECT schema_id, name, COALESCE(comment, '') as comment, source_id
10954 FROM mz_catalog.mz_tables tables
10955 LEFT JOIN comments ON tables.id = comments.id",
10956 access: vec![PUBLIC_SELECT],
10957});
10958
10959pub static MZ_SHOW_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10960 name: "mz_show_views",
10961 schema: MZ_INTERNAL_SCHEMA,
10962 oid: oid::VIEW_MZ_SHOW_VIEWS_OID,
10963 desc: RelationDesc::builder()
10964 .with_column("schema_id", SqlScalarType::String.nullable(false))
10965 .with_column("name", SqlScalarType::String.nullable(false))
10966 .with_column("comment", SqlScalarType::String.nullable(false))
10967 .finish(),
10968 column_comments: BTreeMap::new(),
10969 sql: "WITH comments AS (
10970 SELECT id, comment
10971 FROM mz_internal.mz_comments
10972 WHERE object_type = 'view' AND object_sub_id IS NULL
10973 )
10974 SELECT schema_id, name, COALESCE(comment, '') as comment
10975 FROM mz_catalog.mz_views views
10976 LEFT JOIN comments ON views.id = comments.id",
10977 access: vec![PUBLIC_SELECT],
10978});
10979
10980pub static MZ_SHOW_TYPES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10981 name: "mz_show_types",
10982 schema: MZ_INTERNAL_SCHEMA,
10983 oid: oid::VIEW_MZ_SHOW_TYPES_OID,
10984 desc: RelationDesc::builder()
10985 .with_column("schema_id", SqlScalarType::String.nullable(false))
10986 .with_column("name", SqlScalarType::String.nullable(false))
10987 .with_column("comment", SqlScalarType::String.nullable(false))
10988 .finish(),
10989 column_comments: BTreeMap::new(),
10990 sql: "WITH comments AS (
10991 SELECT id, comment
10992 FROM mz_internal.mz_comments
10993 WHERE object_type = 'type' AND object_sub_id IS NULL
10994 )
10995 SELECT schema_id, name, COALESCE(comment, '') as comment
10996 FROM mz_catalog.mz_types types
10997 LEFT JOIN comments ON types.id = comments.id",
10998 access: vec![PUBLIC_SELECT],
10999});
11000
11001pub static MZ_SHOW_CONNECTIONS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11002 name: "mz_show_connections",
11003 schema: MZ_INTERNAL_SCHEMA,
11004 oid: oid::VIEW_MZ_SHOW_CONNECTIONS_OID,
11005 desc: RelationDesc::builder()
11006 .with_column("schema_id", SqlScalarType::String.nullable(false))
11007 .with_column("name", SqlScalarType::String.nullable(false))
11008 .with_column("type", SqlScalarType::String.nullable(false))
11009 .with_column("comment", SqlScalarType::String.nullable(false))
11010 .finish(),
11011 column_comments: BTreeMap::new(),
11012 sql: "WITH comments AS (
11013 SELECT id, comment
11014 FROM mz_internal.mz_comments
11015 WHERE object_type = 'connection' AND object_sub_id IS NULL
11016 )
11017 SELECT schema_id, name, type, COALESCE(comment, '') as comment
11018 FROM mz_catalog.mz_connections connections
11019 LEFT JOIN comments ON connections.id = comments.id",
11020 access: vec![PUBLIC_SELECT],
11021});
11022
11023pub static MZ_SHOW_SOURCES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11024 name: "mz_show_sources",
11025 schema: MZ_INTERNAL_SCHEMA,
11026 oid: oid::VIEW_MZ_SHOW_SOURCES_OID,
11027 desc: RelationDesc::builder()
11028 .with_column("id", SqlScalarType::String.nullable(false))
11029 .with_column("name", SqlScalarType::String.nullable(false))
11030 .with_column("type", SqlScalarType::String.nullable(false))
11031 .with_column("cluster", SqlScalarType::String.nullable(true))
11032 .with_column("schema_id", SqlScalarType::String.nullable(false))
11033 .with_column("cluster_id", SqlScalarType::String.nullable(true))
11034 .with_column("comment", SqlScalarType::String.nullable(false))
11035 .finish(),
11036 column_comments: BTreeMap::new(),
11037 sql: "
11038WITH comments AS (
11039 SELECT id, comment
11040 FROM mz_internal.mz_comments
11041 WHERE object_type = 'source' AND object_sub_id IS NULL
11042)
11043SELECT
11044 sources.id,
11045 sources.name,
11046 sources.type,
11047 clusters.name AS cluster,
11048 schema_id,
11049 cluster_id,
11050 COALESCE(comments.comment, '') as comment
11051FROM
11052 mz_catalog.mz_sources AS sources
11053 LEFT JOIN
11054 mz_catalog.mz_clusters AS clusters
11055 ON clusters.id = sources.cluster_id
11056 LEFT JOIN comments ON sources.id = comments.id",
11057 access: vec![PUBLIC_SELECT],
11058});
11059
11060pub static MZ_SHOW_SINKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11061 name: "mz_show_sinks",
11062 schema: MZ_INTERNAL_SCHEMA,
11063 oid: oid::VIEW_MZ_SHOW_SINKS_OID,
11064 desc: RelationDesc::builder()
11065 .with_column("id", SqlScalarType::String.nullable(false))
11066 .with_column("name", SqlScalarType::String.nullable(false))
11067 .with_column("type", SqlScalarType::String.nullable(false))
11068 .with_column("cluster", SqlScalarType::String.nullable(false))
11069 .with_column("schema_id", SqlScalarType::String.nullable(false))
11070 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11071 .with_column("comment", SqlScalarType::String.nullable(false))
11072 .finish(),
11073 column_comments: BTreeMap::new(),
11074 sql: "
11075WITH comments AS (
11076 SELECT id, comment
11077 FROM mz_internal.mz_comments
11078 WHERE object_type = 'sink' AND object_sub_id IS NULL
11079)
11080SELECT
11081 sinks.id,
11082 sinks.name,
11083 sinks.type,
11084 clusters.name AS cluster,
11085 schema_id,
11086 cluster_id,
11087 COALESCE(comments.comment, '') as comment
11088FROM
11089 mz_catalog.mz_sinks AS sinks
11090 JOIN
11091 mz_catalog.mz_clusters AS clusters
11092 ON clusters.id = sinks.cluster_id
11093 LEFT JOIN comments ON sinks.id = comments.id",
11094 access: vec![PUBLIC_SELECT],
11095});
11096
11097pub static MZ_SHOW_MATERIALIZED_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11098 name: "mz_show_materialized_views",
11099 schema: MZ_INTERNAL_SCHEMA,
11100 oid: oid::VIEW_MZ_SHOW_MATERIALIZED_VIEWS_OID,
11101 desc: RelationDesc::builder()
11102 .with_column("id", SqlScalarType::String.nullable(false))
11103 .with_column("name", SqlScalarType::String.nullable(false))
11104 .with_column("cluster", SqlScalarType::String.nullable(false))
11105 .with_column("schema_id", SqlScalarType::String.nullable(false))
11106 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11107 .with_column("comment", SqlScalarType::String.nullable(false))
11108 .finish(),
11109 column_comments: BTreeMap::new(),
11110 sql: "
11111WITH comments AS (
11112 SELECT id, comment
11113 FROM mz_internal.mz_comments
11114 WHERE object_type = 'materialized-view' AND object_sub_id IS NULL
11115)
11116SELECT
11117 mviews.id as id,
11118 mviews.name,
11119 clusters.name AS cluster,
11120 schema_id,
11121 cluster_id,
11122 COALESCE(comments.comment, '') as comment
11123FROM
11124 mz_catalog.mz_materialized_views AS mviews
11125 JOIN mz_catalog.mz_clusters AS clusters ON clusters.id = mviews.cluster_id
11126 LEFT JOIN comments ON mviews.id = comments.id",
11127 access: vec![PUBLIC_SELECT],
11128});
11129
11130pub static MZ_SHOW_INDEXES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11131 name: "mz_show_indexes",
11132 schema: MZ_INTERNAL_SCHEMA,
11133 oid: oid::VIEW_MZ_SHOW_INDEXES_OID,
11134 desc: RelationDesc::builder()
11135 .with_column("id", SqlScalarType::String.nullable(false))
11136 .with_column("name", SqlScalarType::String.nullable(false))
11137 .with_column("on", SqlScalarType::String.nullable(false))
11138 .with_column("cluster", SqlScalarType::String.nullable(false))
11139 .with_column(
11140 "key",
11141 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
11142 )
11143 .with_column("on_id", SqlScalarType::String.nullable(false))
11144 .with_column("schema_id", SqlScalarType::String.nullable(false))
11145 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11146 .with_column("comment", SqlScalarType::String.nullable(false))
11147 .finish(),
11148 column_comments: BTreeMap::new(),
11149 sql: "
11150WITH comments AS (
11151 SELECT id, comment
11152 FROM mz_internal.mz_comments
11153 WHERE object_type = 'index' AND object_sub_id IS NULL
11154)
11155SELECT
11156 idxs.id AS id,
11157 idxs.name AS name,
11158 objs.name AS on,
11159 clusters.name AS cluster,
11160 COALESCE(keys.key, '{}'::_text) AS key,
11161 idxs.on_id AS on_id,
11162 objs.schema_id AS schema_id,
11163 clusters.id AS cluster_id,
11164 COALESCE(comments.comment, '') as comment
11165FROM
11166 mz_catalog.mz_indexes AS idxs
11167 JOIN mz_catalog.mz_objects AS objs ON idxs.on_id = objs.id
11168 JOIN mz_catalog.mz_clusters AS clusters ON clusters.id = idxs.cluster_id
11169 LEFT JOIN
11170 (SELECT
11171 idxs.id,
11172 ARRAY_AGG(
11173 CASE
11174 WHEN idx_cols.on_expression IS NULL THEN obj_cols.name
11175 ELSE idx_cols.on_expression
11176 END
11177 ORDER BY idx_cols.index_position ASC
11178 ) AS key
11179 FROM
11180 mz_catalog.mz_indexes AS idxs
11181 JOIN mz_catalog.mz_index_columns idx_cols ON idxs.id = idx_cols.index_id
11182 LEFT JOIN mz_catalog.mz_columns obj_cols ON
11183 idxs.on_id = obj_cols.id AND idx_cols.on_position = obj_cols.position
11184 GROUP BY idxs.id) AS keys
11185 ON idxs.id = keys.id
11186 LEFT JOIN comments ON idxs.id = comments.id",
11187 access: vec![PUBLIC_SELECT],
11188});
11189
11190pub static MZ_SHOW_CLUSTER_REPLICAS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11191 name: "mz_show_cluster_replicas",
11192 schema: MZ_INTERNAL_SCHEMA,
11193 oid: oid::VIEW_MZ_SHOW_CLUSTER_REPLICAS_OID,
11194 desc: RelationDesc::builder()
11195 .with_column("cluster", SqlScalarType::String.nullable(false))
11196 .with_column("replica", SqlScalarType::String.nullable(false))
11197 .with_column("replica_id", SqlScalarType::String.nullable(false))
11198 .with_column("size", SqlScalarType::String.nullable(true))
11199 .with_column("ready", SqlScalarType::Bool.nullable(false))
11200 .with_column("comment", SqlScalarType::String.nullable(false))
11201 .finish(),
11202 column_comments: BTreeMap::new(),
11203 sql: r#"SELECT
11204 mz_catalog.mz_clusters.name AS cluster,
11205 mz_catalog.mz_cluster_replicas.name AS replica,
11206 mz_catalog.mz_cluster_replicas.id as replica_id,
11207 mz_catalog.mz_cluster_replicas.size AS size,
11208 coalesce(statuses.ready, FALSE) AS ready,
11209 coalesce(comments.comment, '') as comment
11210FROM
11211 mz_catalog.mz_cluster_replicas
11212 JOIN mz_catalog.mz_clusters
11213 ON mz_catalog.mz_cluster_replicas.cluster_id = mz_catalog.mz_clusters.id
11214 LEFT JOIN
11215 (
11216 SELECT
11217 replica_id,
11218 bool_and(hydrated) AS ready
11219 FROM mz_internal.mz_hydration_statuses
11220 WHERE replica_id is not null
11221 GROUP BY replica_id
11222 ) AS statuses
11223 ON mz_catalog.mz_cluster_replicas.id = statuses.replica_id
11224 LEFT JOIN mz_internal.mz_comments comments
11225 ON mz_catalog.mz_cluster_replicas.id = comments.id
11226WHERE (comments.object_type = 'cluster-replica' OR comments.object_type IS NULL)
11227ORDER BY 1, 2"#,
11228 access: vec![PUBLIC_SELECT],
11229});
11230
11231pub static MZ_SHOW_CONTINUAL_TASKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11232 name: "mz_show_continual_tasks",
11233 schema: MZ_INTERNAL_SCHEMA,
11234 oid: oid::VIEW_MZ_SHOW_CONTINUAL_TASKS_OID,
11235 desc: RelationDesc::builder()
11236 .with_column("id", SqlScalarType::String.nullable(false))
11237 .with_column("name", SqlScalarType::String.nullable(false))
11238 .with_column("cluster", SqlScalarType::String.nullable(false))
11239 .with_column("schema_id", SqlScalarType::String.nullable(false))
11240 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11241 .with_column("comment", SqlScalarType::String.nullable(false))
11242 .finish(),
11243 column_comments: BTreeMap::new(),
11244 sql: "
11245WITH comments AS (
11246 SELECT id, comment
11247 FROM mz_internal.mz_comments
11248 WHERE object_type = 'continual-task' AND object_sub_id IS NULL
11249)
11250SELECT
11251 cts.id as id,
11252 cts.name,
11253 clusters.name AS cluster,
11254 schema_id,
11255 cluster_id,
11256 COALESCE(comments.comment, '') as comment
11257FROM
11258 mz_internal.mz_continual_tasks AS cts
11259 JOIN mz_catalog.mz_clusters AS clusters ON clusters.id = cts.cluster_id
11260 LEFT JOIN comments ON cts.id = comments.id",
11261 access: vec![PUBLIC_SELECT],
11262});
11263
11264pub static MZ_SHOW_ROLE_MEMBERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11265 name: "mz_show_role_members",
11266 schema: MZ_INTERNAL_SCHEMA,
11267 oid: oid::VIEW_MZ_SHOW_ROLE_MEMBERS_OID,
11268 desc: RelationDesc::builder()
11269 .with_column("role", SqlScalarType::String.nullable(false))
11270 .with_column("member", SqlScalarType::String.nullable(false))
11271 .with_column("grantor", SqlScalarType::String.nullable(false))
11272 .finish(),
11273 column_comments: BTreeMap::from_iter([
11274 ("role", "The role that `member` is a member of."),
11275 ("member", "The role that is a member of `role`."),
11276 (
11277 "grantor",
11278 "The role that granted membership of `member` to `role`.",
11279 ),
11280 ]),
11281 sql: r#"SELECT
11282 r1.name AS role,
11283 r2.name AS member,
11284 r3.name AS grantor
11285FROM mz_catalog.mz_role_members rm
11286JOIN mz_catalog.mz_roles r1 ON r1.id = rm.role_id
11287JOIN mz_catalog.mz_roles r2 ON r2.id = rm.member
11288JOIN mz_catalog.mz_roles r3 ON r3.id = rm.grantor
11289ORDER BY role"#,
11290 access: vec![PUBLIC_SELECT],
11291});
11292
11293pub static MZ_SHOW_MY_ROLE_MEMBERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11294 name: "mz_show_my_role_members",
11295 schema: MZ_INTERNAL_SCHEMA,
11296 oid: oid::VIEW_MZ_SHOW_MY_ROLE_MEMBERS_OID,
11297 desc: RelationDesc::builder()
11298 .with_column("role", SqlScalarType::String.nullable(false))
11299 .with_column("member", SqlScalarType::String.nullable(false))
11300 .with_column("grantor", SqlScalarType::String.nullable(false))
11301 .finish(),
11302 column_comments: BTreeMap::from_iter([
11303 ("role", "The role that `member` is a member of."),
11304 ("member", "The role that is a member of `role`."),
11305 (
11306 "grantor",
11307 "The role that granted membership of `member` to `role`.",
11308 ),
11309 ]),
11310 sql: r#"SELECT role, member, grantor
11311FROM mz_internal.mz_show_role_members
11312WHERE pg_has_role(member, 'USAGE')"#,
11313 access: vec![PUBLIC_SELECT],
11314});
11315
11316pub static MZ_SHOW_SYSTEM_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11317 name: "mz_show_system_privileges",
11318 schema: MZ_INTERNAL_SCHEMA,
11319 oid: oid::VIEW_MZ_SHOW_SYSTEM_PRIVILEGES_OID,
11320 desc: RelationDesc::builder()
11321 .with_column("grantor", SqlScalarType::String.nullable(true))
11322 .with_column("grantee", SqlScalarType::String.nullable(true))
11323 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11324 .finish(),
11325 column_comments: BTreeMap::from_iter([
11326 ("grantor", "The role that granted the privilege."),
11327 ("grantee", "The role that the privilege was granted to."),
11328 ("privilege_type", "They type of privilege granted."),
11329 ]),
11330 sql: r#"SELECT
11331 grantor.name AS grantor,
11332 CASE privileges.grantee
11333 WHEN 'p' THEN 'PUBLIC'
11334 ELSE grantee.name
11335 END AS grantee,
11336 privileges.privilege_type AS privilege_type
11337FROM
11338 (SELECT mz_internal.mz_aclexplode(ARRAY[privileges]).*
11339 FROM mz_catalog.mz_system_privileges) AS privileges
11340LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11341LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11342WHERE privileges.grantee NOT LIKE 's%'"#,
11343 access: vec![PUBLIC_SELECT],
11344});
11345
11346pub static MZ_SHOW_MY_SYSTEM_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11347 name: "mz_show_my_system_privileges",
11348 schema: MZ_INTERNAL_SCHEMA,
11349 oid: oid::VIEW_MZ_SHOW_MY_SYSTEM_PRIVILEGES_OID,
11350 desc: RelationDesc::builder()
11351 .with_column("grantor", SqlScalarType::String.nullable(true))
11352 .with_column("grantee", SqlScalarType::String.nullable(true))
11353 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11354 .finish(),
11355 column_comments: BTreeMap::from_iter([
11356 ("grantor", "The role that granted the privilege."),
11357 ("grantee", "The role that the privilege was granted to."),
11358 ("privilege_type", "They type of privilege granted."),
11359 ]),
11360 sql: r#"SELECT grantor, grantee, privilege_type
11361FROM mz_internal.mz_show_system_privileges
11362WHERE
11363 CASE
11364 WHEN grantee = 'PUBLIC' THEN true
11365 ELSE pg_has_role(grantee, 'USAGE')
11366 END"#,
11367 access: vec![PUBLIC_SELECT],
11368});
11369
11370pub static MZ_SHOW_CLUSTER_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11371 name: "mz_show_cluster_privileges",
11372 schema: MZ_INTERNAL_SCHEMA,
11373 oid: oid::VIEW_MZ_SHOW_CLUSTER_PRIVILEGES_OID,
11374 desc: RelationDesc::builder()
11375 .with_column("grantor", SqlScalarType::String.nullable(true))
11376 .with_column("grantee", SqlScalarType::String.nullable(true))
11377 .with_column("name", SqlScalarType::String.nullable(false))
11378 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11379 .finish(),
11380 column_comments: BTreeMap::from_iter([
11381 ("grantor", "The role that granted the privilege."),
11382 ("grantee", "The role that the privilege was granted to."),
11383 ("name", "The name of the cluster."),
11384 ("privilege_type", "They type of privilege granted."),
11385 ]),
11386 sql: r#"SELECT
11387 grantor.name AS grantor,
11388 CASE privileges.grantee
11389 WHEN 'p' THEN 'PUBLIC'
11390 ELSE grantee.name
11391 END AS grantee,
11392 privileges.name AS name,
11393 privileges.privilege_type AS privilege_type
11394FROM
11395 (SELECT mz_internal.mz_aclexplode(privileges).*, name
11396 FROM mz_catalog.mz_clusters
11397 WHERE id NOT LIKE 's%') AS privileges
11398LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11399LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11400WHERE privileges.grantee NOT LIKE 's%'"#,
11401 access: vec![PUBLIC_SELECT],
11402});
11403
11404pub static MZ_SHOW_MY_CLUSTER_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11405 name: "mz_show_my_cluster_privileges",
11406 schema: MZ_INTERNAL_SCHEMA,
11407 oid: oid::VIEW_MZ_SHOW_MY_CLUSTER_PRIVILEGES_OID,
11408 desc: RelationDesc::builder()
11409 .with_column("grantor", SqlScalarType::String.nullable(true))
11410 .with_column("grantee", SqlScalarType::String.nullable(true))
11411 .with_column("name", SqlScalarType::String.nullable(false))
11412 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11413 .finish(),
11414 column_comments: BTreeMap::from_iter([
11415 ("grantor", "The role that granted the privilege."),
11416 ("grantee", "The role that the privilege was granted to."),
11417 ("name", "The name of the cluster."),
11418 ("privilege_type", "They type of privilege granted."),
11419 ]),
11420 sql: r#"SELECT grantor, grantee, name, privilege_type
11421FROM mz_internal.mz_show_cluster_privileges
11422WHERE
11423 CASE
11424 WHEN grantee = 'PUBLIC' THEN true
11425 ELSE pg_has_role(grantee, 'USAGE')
11426 END"#,
11427 access: vec![PUBLIC_SELECT],
11428});
11429
11430pub static MZ_SHOW_DATABASE_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11431 name: "mz_show_database_privileges",
11432 schema: MZ_INTERNAL_SCHEMA,
11433 oid: oid::VIEW_MZ_SHOW_DATABASE_PRIVILEGES_OID,
11434 desc: RelationDesc::builder()
11435 .with_column("grantor", SqlScalarType::String.nullable(true))
11436 .with_column("grantee", SqlScalarType::String.nullable(true))
11437 .with_column("name", SqlScalarType::String.nullable(false))
11438 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11439 .finish(),
11440 column_comments: BTreeMap::from_iter([
11441 ("grantor", "The role that granted the privilege."),
11442 ("grantee", "The role that the privilege was granted to."),
11443 ("name", "The name of the database."),
11444 ("privilege_type", "They type of privilege granted."),
11445 ]),
11446 sql: r#"SELECT
11447 grantor.name AS grantor,
11448 CASE privileges.grantee
11449 WHEN 'p' THEN 'PUBLIC'
11450 ELSE grantee.name
11451 END AS grantee,
11452 privileges.name AS name,
11453 privileges.privilege_type AS privilege_type
11454FROM
11455 (SELECT mz_internal.mz_aclexplode(privileges).*, name
11456 FROM mz_catalog.mz_databases
11457 WHERE id NOT LIKE 's%') AS privileges
11458LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11459LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11460WHERE privileges.grantee NOT LIKE 's%'"#,
11461 access: vec![PUBLIC_SELECT],
11462});
11463
11464pub static MZ_SHOW_MY_DATABASE_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11465 name: "mz_show_my_database_privileges",
11466 schema: MZ_INTERNAL_SCHEMA,
11467 oid: oid::VIEW_MZ_SHOW_MY_DATABASE_PRIVILEGES_OID,
11468 desc: RelationDesc::builder()
11469 .with_column("grantor", SqlScalarType::String.nullable(true))
11470 .with_column("grantee", SqlScalarType::String.nullable(true))
11471 .with_column("name", SqlScalarType::String.nullable(false))
11472 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11473 .finish(),
11474 column_comments: BTreeMap::from_iter([
11475 ("grantor", "The role that granted the privilege."),
11476 ("grantee", "The role that the privilege was granted to."),
11477 ("name", "The name of the cluster."),
11478 ("privilege_type", "They type of privilege granted."),
11479 ]),
11480 sql: r#"SELECT grantor, grantee, name, privilege_type
11481FROM mz_internal.mz_show_database_privileges
11482WHERE
11483 CASE
11484 WHEN grantee = 'PUBLIC' THEN true
11485 ELSE pg_has_role(grantee, 'USAGE')
11486 END"#,
11487 access: vec![PUBLIC_SELECT],
11488});
11489
11490pub static MZ_SHOW_SCHEMA_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11491 name: "mz_show_schema_privileges",
11492 schema: MZ_INTERNAL_SCHEMA,
11493 oid: oid::VIEW_MZ_SHOW_SCHEMA_PRIVILEGES_OID,
11494 desc: RelationDesc::builder()
11495 .with_column("grantor", SqlScalarType::String.nullable(true))
11496 .with_column("grantee", SqlScalarType::String.nullable(true))
11497 .with_column("database", SqlScalarType::String.nullable(true))
11498 .with_column("name", SqlScalarType::String.nullable(false))
11499 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11500 .finish(),
11501 column_comments: BTreeMap::from_iter([
11502 ("grantor", "The role that granted the privilege."),
11503 ("grantee", "The role that the privilege was granted to."),
11504 (
11505 "database",
11506 "The name of the database containing the schema.",
11507 ),
11508 ("name", "The name of the schema."),
11509 ("privilege_type", "They type of privilege granted."),
11510 ]),
11511 sql: r#"SELECT
11512 grantor.name AS grantor,
11513 CASE privileges.grantee
11514 WHEN 'p' THEN 'PUBLIC'
11515 ELSE grantee.name
11516 END AS grantee,
11517 databases.name AS database,
11518 privileges.name AS name,
11519 privileges.privilege_type AS privilege_type
11520FROM
11521 (SELECT mz_internal.mz_aclexplode(privileges).*, database_id, name
11522 FROM mz_catalog.mz_schemas
11523 WHERE id NOT LIKE 's%') AS privileges
11524LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11525LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11526LEFT JOIN mz_catalog.mz_databases databases ON privileges.database_id = databases.id
11527WHERE privileges.grantee NOT LIKE 's%'"#,
11528 access: vec![PUBLIC_SELECT],
11529});
11530
11531pub static MZ_SHOW_MY_SCHEMA_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11532 name: "mz_show_my_schema_privileges",
11533 schema: MZ_INTERNAL_SCHEMA,
11534 oid: oid::VIEW_MZ_SHOW_MY_SCHEMA_PRIVILEGES_OID,
11535 desc: RelationDesc::builder()
11536 .with_column("grantor", SqlScalarType::String.nullable(true))
11537 .with_column("grantee", SqlScalarType::String.nullable(true))
11538 .with_column("database", SqlScalarType::String.nullable(true))
11539 .with_column("name", SqlScalarType::String.nullable(false))
11540 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11541 .finish(),
11542 column_comments: BTreeMap::from_iter([
11543 ("grantor", "The role that granted the privilege."),
11544 ("grantee", "The role that the privilege was granted to."),
11545 (
11546 "database",
11547 "The name of the database containing the schema.",
11548 ),
11549 ("name", "The name of the schema."),
11550 ("privilege_type", "They type of privilege granted."),
11551 ]),
11552 sql: r#"SELECT grantor, grantee, database, name, privilege_type
11553FROM mz_internal.mz_show_schema_privileges
11554WHERE
11555 CASE
11556 WHEN grantee = 'PUBLIC' THEN true
11557 ELSE pg_has_role(grantee, 'USAGE')
11558 END"#,
11559 access: vec![PUBLIC_SELECT],
11560});
11561
11562pub static MZ_SHOW_OBJECT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11563 name: "mz_show_object_privileges",
11564 schema: MZ_INTERNAL_SCHEMA,
11565 oid: oid::VIEW_MZ_SHOW_OBJECT_PRIVILEGES_OID,
11566 desc: RelationDesc::builder()
11567 .with_column("grantor", SqlScalarType::String.nullable(true))
11568 .with_column("grantee", SqlScalarType::String.nullable(true))
11569 .with_column("database", SqlScalarType::String.nullable(true))
11570 .with_column("schema", SqlScalarType::String.nullable(true))
11571 .with_column("name", SqlScalarType::String.nullable(false))
11572 .with_column("object_type", SqlScalarType::String.nullable(false))
11573 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11574 .finish(),
11575 column_comments: BTreeMap::from_iter([
11576 ("grantor", "The role that granted the privilege."),
11577 ("grantee", "The role that the privilege was granted to."),
11578 (
11579 "database",
11580 "The name of the database containing the object.",
11581 ),
11582 ("schema", "The name of the schema containing the object."),
11583 ("name", "The name of the object."),
11584 (
11585 "object_type",
11586 "The type of object the privilege is granted on.",
11587 ),
11588 ("privilege_type", "They type of privilege granted."),
11589 ]),
11590 sql: r#"SELECT
11591 grantor.name AS grantor,
11592 CASE privileges.grantee
11593 WHEN 'p' THEN 'PUBLIC'
11594 ELSE grantee.name
11595 END AS grantee,
11596 databases.name AS database,
11597 schemas.name AS schema,
11598 privileges.name AS name,
11599 privileges.type AS object_type,
11600 privileges.privilege_type AS privilege_type
11601FROM
11602 (SELECT mz_internal.mz_aclexplode(privileges).*, schema_id, name, type
11603 FROM mz_catalog.mz_objects
11604 WHERE id NOT LIKE 's%') AS privileges
11605LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11606LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11607LEFT JOIN mz_catalog.mz_schemas schemas ON privileges.schema_id = schemas.id
11608LEFT JOIN mz_catalog.mz_databases databases ON schemas.database_id = databases.id
11609WHERE privileges.grantee NOT LIKE 's%'"#,
11610 access: vec![PUBLIC_SELECT],
11611});
11612
11613pub static MZ_SHOW_MY_OBJECT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11614 name: "mz_show_my_object_privileges",
11615 schema: MZ_INTERNAL_SCHEMA,
11616 oid: oid::VIEW_MZ_SHOW_MY_OBJECT_PRIVILEGES_OID,
11617 desc: RelationDesc::builder()
11618 .with_column("grantor", SqlScalarType::String.nullable(true))
11619 .with_column("grantee", SqlScalarType::String.nullable(true))
11620 .with_column("database", SqlScalarType::String.nullable(true))
11621 .with_column("schema", SqlScalarType::String.nullable(true))
11622 .with_column("name", SqlScalarType::String.nullable(false))
11623 .with_column("object_type", SqlScalarType::String.nullable(false))
11624 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11625 .finish(),
11626 column_comments: BTreeMap::from_iter([
11627 ("grantor", "The role that granted the privilege."),
11628 ("grantee", "The role that the privilege was granted to."),
11629 (
11630 "database",
11631 "The name of the database containing the object.",
11632 ),
11633 ("schema", "The name of the schema containing the object."),
11634 ("name", "The name of the object."),
11635 (
11636 "object_type",
11637 "The type of object the privilege is granted on.",
11638 ),
11639 ("privilege_type", "They type of privilege granted."),
11640 ]),
11641 sql: r#"SELECT grantor, grantee, database, schema, name, object_type, privilege_type
11642FROM mz_internal.mz_show_object_privileges
11643WHERE
11644 CASE
11645 WHEN grantee = 'PUBLIC' THEN true
11646 ELSE pg_has_role(grantee, 'USAGE')
11647 END"#,
11648 access: vec![PUBLIC_SELECT],
11649});
11650
11651pub static MZ_SHOW_ALL_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11652 name: "mz_show_all_privileges",
11653 schema: MZ_INTERNAL_SCHEMA,
11654 oid: oid::VIEW_MZ_SHOW_ALL_PRIVILEGES_OID,
11655 desc: RelationDesc::builder()
11656 .with_column("grantor", SqlScalarType::String.nullable(true))
11657 .with_column("grantee", SqlScalarType::String.nullable(true))
11658 .with_column("database", SqlScalarType::String.nullable(true))
11659 .with_column("schema", SqlScalarType::String.nullable(true))
11660 .with_column("name", SqlScalarType::String.nullable(true))
11661 .with_column("object_type", SqlScalarType::String.nullable(false))
11662 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11663 .finish(),
11664 column_comments: BTreeMap::from_iter([
11665 ("grantor", "The role that granted the privilege."),
11666 ("grantee", "The role that the privilege was granted to."),
11667 (
11668 "database",
11669 "The name of the database containing the object.",
11670 ),
11671 ("schema", "The name of the schema containing the object."),
11672 ("name", "The name of the privilege target."),
11673 (
11674 "object_type",
11675 "The type of object the privilege is granted on.",
11676 ),
11677 ("privilege_type", "They type of privilege granted."),
11678 ]),
11679 sql: r#"SELECT grantor, grantee, NULL AS database, NULL AS schema, NULL AS name, 'system' AS object_type, privilege_type
11680FROM mz_internal.mz_show_system_privileges
11681UNION ALL
11682SELECT grantor, grantee, NULL AS database, NULL AS schema, name, 'cluster' AS object_type, privilege_type
11683FROM mz_internal.mz_show_cluster_privileges
11684UNION ALL
11685SELECT grantor, grantee, NULL AS database, NULL AS schema, name, 'database' AS object_type, privilege_type
11686FROM mz_internal.mz_show_database_privileges
11687UNION ALL
11688SELECT grantor, grantee, database, NULL AS schema, name, 'schema' AS object_type, privilege_type
11689FROM mz_internal.mz_show_schema_privileges
11690UNION ALL
11691SELECT grantor, grantee, database, schema, name, object_type, privilege_type
11692FROM mz_internal.mz_show_object_privileges"#,
11693 access: vec![PUBLIC_SELECT],
11694});
11695
11696pub static MZ_SHOW_ALL_MY_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11697 name: "mz_show_all_my_privileges",
11698 schema: MZ_INTERNAL_SCHEMA,
11699 oid: oid::VIEW_MZ_SHOW_ALL_MY_PRIVILEGES_OID,
11700 desc: RelationDesc::builder()
11701 .with_column("grantor", SqlScalarType::String.nullable(true))
11702 .with_column("grantee", SqlScalarType::String.nullable(true))
11703 .with_column("database", SqlScalarType::String.nullable(true))
11704 .with_column("schema", SqlScalarType::String.nullable(true))
11705 .with_column("name", SqlScalarType::String.nullable(true))
11706 .with_column("object_type", SqlScalarType::String.nullable(false))
11707 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11708 .finish(),
11709 column_comments: BTreeMap::from_iter([
11710 ("grantor", "The role that granted the privilege."),
11711 ("grantee", "The role that the privilege was granted to."),
11712 (
11713 "database",
11714 "The name of the database containing the object.",
11715 ),
11716 ("schema", "The name of the schema containing the object."),
11717 ("name", "The name of the privilege target."),
11718 (
11719 "object_type",
11720 "The type of object the privilege is granted on.",
11721 ),
11722 ("privilege_type", "They type of privilege granted."),
11723 ]),
11724 sql: r#"SELECT grantor, grantee, database, schema, name, object_type, privilege_type
11725FROM mz_internal.mz_show_all_privileges
11726WHERE
11727 CASE
11728 WHEN grantee = 'PUBLIC' THEN true
11729 ELSE pg_has_role(grantee, 'USAGE')
11730 END"#,
11731 access: vec![PUBLIC_SELECT],
11732});
11733
11734pub static MZ_SHOW_DEFAULT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11735 name: "mz_show_default_privileges",
11736 schema: MZ_INTERNAL_SCHEMA,
11737 oid: oid::VIEW_MZ_SHOW_DEFAULT_PRIVILEGES_OID,
11738 desc: RelationDesc::builder()
11739 .with_column("object_owner", SqlScalarType::String.nullable(true))
11740 .with_column("database", SqlScalarType::String.nullable(true))
11741 .with_column("schema", SqlScalarType::String.nullable(true))
11742 .with_column("object_type", SqlScalarType::String.nullable(false))
11743 .with_column("grantee", SqlScalarType::String.nullable(true))
11744 .with_column("privilege_type", SqlScalarType::String.nullable(true))
11745 .finish(),
11746 column_comments: BTreeMap::from_iter([
11747 (
11748 "object_owner",
11749 "Privileges described in this row will be granted on objects created by `object_owner`.",
11750 ),
11751 (
11752 "database",
11753 "Privileges described in this row will be granted only on objects created in `database` if non-null.",
11754 ),
11755 (
11756 "schema",
11757 "Privileges described in this row will be granted only on objects created in `schema` if non-null.",
11758 ),
11759 (
11760 "object_type",
11761 "Privileges described in this row will be granted only on objects of type `object_type`.",
11762 ),
11763 (
11764 "grantee",
11765 "Privileges described in this row will be granted to `grantee`.",
11766 ),
11767 ("privilege_type", "They type of privilege to be granted."),
11768 ]),
11769 sql: r#"SELECT
11770 CASE defaults.role_id
11771 WHEN 'p' THEN 'PUBLIC'
11772 ELSE object_owner.name
11773 END AS object_owner,
11774 databases.name AS database,
11775 schemas.name AS schema,
11776 object_type,
11777 CASE defaults.grantee
11778 WHEN 'p' THEN 'PUBLIC'
11779 ELSE grantee.name
11780 END AS grantee,
11781 unnest(mz_internal.mz_format_privileges(defaults.privileges)) AS privilege_type
11782FROM mz_catalog.mz_default_privileges defaults
11783LEFT JOIN mz_catalog.mz_roles AS object_owner ON defaults.role_id = object_owner.id
11784LEFT JOIN mz_catalog.mz_roles AS grantee ON defaults.grantee = grantee.id
11785LEFT JOIN mz_catalog.mz_databases AS databases ON defaults.database_id = databases.id
11786LEFT JOIN mz_catalog.mz_schemas AS schemas ON defaults.schema_id = schemas.id
11787WHERE defaults.grantee NOT LIKE 's%'
11788 AND defaults.database_id IS NULL OR defaults.database_id NOT LIKE 's%'
11789 AND defaults.schema_id IS NULL OR defaults.schema_id NOT LIKE 's%'"#,
11790 access: vec![PUBLIC_SELECT],
11791});
11792
11793pub static MZ_SHOW_MY_DEFAULT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11794 name: "mz_show_my_default_privileges",
11795 schema: MZ_INTERNAL_SCHEMA,
11796 oid: oid::VIEW_MZ_SHOW_MY_DEFAULT_PRIVILEGES_OID,
11797 desc: RelationDesc::builder()
11798 .with_column("object_owner", SqlScalarType::String.nullable(true))
11799 .with_column("database", SqlScalarType::String.nullable(true))
11800 .with_column("schema", SqlScalarType::String.nullable(true))
11801 .with_column("object_type", SqlScalarType::String.nullable(false))
11802 .with_column("grantee", SqlScalarType::String.nullable(true))
11803 .with_column("privilege_type", SqlScalarType::String.nullable(true))
11804 .finish(),
11805 column_comments: BTreeMap::from_iter([
11806 (
11807 "object_owner",
11808 "Privileges described in this row will be granted on objects created by `object_owner`.",
11809 ),
11810 (
11811 "database",
11812 "Privileges described in this row will be granted only on objects created in `database` if non-null.",
11813 ),
11814 (
11815 "schema",
11816 "Privileges described in this row will be granted only on objects created in `schema` if non-null.",
11817 ),
11818 (
11819 "object_type",
11820 "Privileges described in this row will be granted only on objects of type `object_type`.",
11821 ),
11822 (
11823 "grantee",
11824 "Privileges described in this row will be granted to `grantee`.",
11825 ),
11826 ("privilege_type", "They type of privilege to be granted."),
11827 ]),
11828 sql: r#"SELECT object_owner, database, schema, object_type, grantee, privilege_type
11829FROM mz_internal.mz_show_default_privileges
11830WHERE
11831 CASE
11832 WHEN grantee = 'PUBLIC' THEN true
11833 ELSE pg_has_role(grantee, 'USAGE')
11834 END"#,
11835 access: vec![PUBLIC_SELECT],
11836});
11837
11838pub static MZ_SHOW_NETWORK_POLICIES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11839 name: "mz_show_network_policies",
11840 schema: MZ_INTERNAL_SCHEMA,
11841 oid: oid::VIEW_MZ_SHOW_NETWORK_POLICIES_OID,
11842 desc: RelationDesc::builder()
11843 .with_column("name", SqlScalarType::String.nullable(false))
11844 .with_column("rules", SqlScalarType::String.nullable(true))
11845 .with_column("comment", SqlScalarType::String.nullable(false))
11846 .finish(),
11847 column_comments: BTreeMap::new(),
11848 sql: "
11849WITH comments AS (
11850 SELECT id, comment
11851 FROM mz_internal.mz_comments
11852 WHERE object_type = 'network-policy' AND object_sub_id IS NULL
11853)
11854SELECT
11855 policy.name,
11856 pg_catalog.string_agg(rule.name,',' ORDER BY rule.name) as rules,
11857 COALESCE(comment, '') as comment
11858FROM
11859 mz_internal.mz_network_policies as policy
11860LEFT JOIN
11861 mz_internal.mz_network_policy_rules as rule ON policy.id = rule.policy_id
11862LEFT JOIN
11863 comments ON policy.id = comments.id
11864WHERE
11865 policy.id NOT LIKE 's%'
11866AND
11867 policy.id NOT LIKE 'g%'
11868GROUP BY policy.name, comments.comment;",
11869 access: vec![PUBLIC_SELECT],
11870});
11871
11872pub static MZ_CLUSTER_REPLICA_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11873 name: "mz_cluster_replica_history",
11874 schema: MZ_INTERNAL_SCHEMA,
11875 oid: oid::VIEW_MZ_CLUSTER_REPLICA_HISTORY_OID,
11876 desc: RelationDesc::builder()
11877 .with_column("replica_id", SqlScalarType::String.nullable(true))
11878 .with_column("size", SqlScalarType::String.nullable(true))
11879 .with_column("cluster_id", SqlScalarType::String.nullable(true))
11880 .with_column("cluster_name", SqlScalarType::String.nullable(true))
11881 .with_column("replica_name", SqlScalarType::String.nullable(true))
11882 .with_column(
11883 "created_at",
11884 SqlScalarType::TimestampTz { precision: None }.nullable(false),
11885 )
11886 .with_column(
11887 "dropped_at",
11888 SqlScalarType::TimestampTz { precision: None }.nullable(true),
11889 )
11890 .with_column(
11891 "credits_per_hour",
11892 SqlScalarType::Numeric { max_scale: None }.nullable(true),
11893 )
11894 .finish(),
11895 column_comments: BTreeMap::from_iter([
11896 ("replica_id", "The ID of a cluster replica."),
11897 (
11898 "size",
11899 "The size of the cluster replica. Corresponds to `mz_cluster_replica_sizes.size`.",
11900 ),
11901 (
11902 "cluster_id",
11903 "The ID of the cluster associated with the replica.",
11904 ),
11905 (
11906 "cluster_name",
11907 "The name of the cluster associated with the replica.",
11908 ),
11909 ("replica_name", "The name of the replica."),
11910 ("created_at", "The time at which the replica was created."),
11911 (
11912 "dropped_at",
11913 "The time at which the replica was dropped, or `NULL` if it still exists.",
11914 ),
11915 (
11916 "credits_per_hour",
11917 "The number of compute credits consumed per hour. Corresponds to `mz_cluster_replica_sizes.credits_per_hour`.",
11918 ),
11919 ]),
11920 sql: r#"
11921 WITH
11922 creates AS
11923 (
11924 SELECT
11925 details ->> 'logical_size' AS size,
11926 details ->> 'replica_id' AS replica_id,
11927 details ->> 'replica_name' AS replica_name,
11928 details ->> 'cluster_name' AS cluster_name,
11929 details ->> 'cluster_id' AS cluster_id,
11930 occurred_at
11931 FROM mz_catalog.mz_audit_events
11932 WHERE
11933 object_type = 'cluster-replica' AND event_type = 'create'
11934 AND
11935 details ->> 'replica_id' IS NOT NULL
11936 AND
11937 details ->> 'cluster_id' !~~ 's%'
11938 ),
11939 drops AS
11940 (
11941 SELECT details ->> 'replica_id' AS replica_id, occurred_at
11942 FROM mz_catalog.mz_audit_events
11943 WHERE object_type = 'cluster-replica' AND event_type = 'drop'
11944 )
11945 SELECT
11946 creates.replica_id,
11947 creates.size,
11948 creates.cluster_id,
11949 creates.cluster_name,
11950 creates.replica_name,
11951 creates.occurred_at AS created_at,
11952 drops.occurred_at AS dropped_at,
11953 mz_cluster_replica_sizes.credits_per_hour as credits_per_hour
11954 FROM
11955 creates
11956 LEFT JOIN drops ON creates.replica_id = drops.replica_id
11957 LEFT JOIN
11958 mz_catalog.mz_cluster_replica_sizes
11959 ON mz_cluster_replica_sizes.size = creates.size"#,
11960 access: vec![PUBLIC_SELECT],
11961});
11962
11963pub static MZ_CLUSTER_REPLICA_NAME_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11964 name: "mz_cluster_replica_name_history",
11965 schema: MZ_INTERNAL_SCHEMA,
11966 oid: oid::VIEW_MZ_CLUSTER_REPLICA_NAME_HISTORY_OID,
11967 desc: RelationDesc::builder()
11968 .with_column(
11969 "occurred_at",
11970 SqlScalarType::TimestampTz { precision: None }.nullable(true),
11971 )
11972 .with_column("id", SqlScalarType::String.nullable(true))
11973 .with_column("previous_name", SqlScalarType::String.nullable(true))
11974 .with_column("new_name", SqlScalarType::String.nullable(true))
11975 .finish(),
11976 column_comments: BTreeMap::from_iter([
11977 (
11978 "occurred_at",
11979 "The time at which the cluster replica was created or renamed. `NULL` if it's a built in system cluster replica.",
11980 ),
11981 ("id", "The ID of the cluster replica."),
11982 (
11983 "previous_name",
11984 "The previous name of the cluster replica. `NULL` if there was no previous name.",
11985 ),
11986 ("new_name", "The new name of the cluster replica."),
11987 ]),
11988 sql: r#"WITH user_replica_alter_history AS (
11989 SELECT occurred_at,
11990 audit_events.details->>'replica_id' AS id,
11991 audit_events.details->>'old_name' AS previous_name,
11992 audit_events.details->>'new_name' AS new_name
11993 FROM mz_catalog.mz_audit_events AS audit_events
11994 WHERE object_type = 'cluster-replica'
11995 AND audit_events.event_type = 'alter'
11996 AND audit_events.details->>'replica_id' like 'u%'
11997),
11998user_replica_create_history AS (
11999 SELECT occurred_at,
12000 audit_events.details->>'replica_id' AS id,
12001 NULL AS previous_name,
12002 audit_events.details->>'replica_name' AS new_name
12003 FROM mz_catalog.mz_audit_events AS audit_events
12004 WHERE object_type = 'cluster-replica'
12005 AND audit_events.event_type = 'create'
12006 AND audit_events.details->>'replica_id' like 'u%'
12007),
12008-- Because built in system cluster replicas don't have audit events, we need to manually add them
12009system_replicas AS (
12010 -- We assume that the system cluster replicas were created at the beginning of time
12011 SELECT NULL::timestamptz AS occurred_at,
12012 id,
12013 NULL AS previous_name,
12014 name AS new_name
12015 FROM mz_catalog.mz_cluster_replicas
12016 WHERE id LIKE 's%'
12017)
12018SELECT *
12019FROM user_replica_alter_history
12020UNION ALL
12021SELECT *
12022FROM user_replica_create_history
12023UNION ALL
12024SELECT *
12025FROM system_replicas"#,
12026 access: vec![PUBLIC_SELECT],
12027});
12028
12029pub static MZ_HYDRATION_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12030 name: "mz_hydration_statuses",
12031 schema: MZ_INTERNAL_SCHEMA,
12032 oid: oid::VIEW_MZ_HYDRATION_STATUSES_OID,
12033 desc: RelationDesc::builder()
12034 .with_column("object_id", SqlScalarType::String.nullable(false))
12035 .with_column("replica_id", SqlScalarType::String.nullable(true))
12036 .with_column("hydrated", SqlScalarType::Bool.nullable(true))
12037 .finish(),
12038 column_comments: BTreeMap::from_iter([
12039 (
12040 "object_id",
12041 "The ID of a dataflow-powered object. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, `mz_internal.mz_subscriptions`, `mz_catalog.mz_sources.id`, or `mz_catalog.mz_sinks.id`.",
12042 ),
12043 ("replica_id", "The ID of a cluster replica."),
12044 ("hydrated", "Whether the object is hydrated on the replica."),
12045 ]),
12046 sql: r#"WITH
12047-- Joining against the linearizable catalog tables ensures that this view
12048-- always contains the set of installed objects, even when it depends
12049-- on introspection relations that may received delayed updates.
12050--
12051-- Note that this view only includes objects that are maintained by dataflows.
12052-- In particular, some source types (webhook, introspection, ...) are not and
12053-- are therefore omitted.
12054indexes AS (
12055 SELECT
12056 i.id AS object_id,
12057 h.replica_id,
12058 COALESCE(h.hydrated, false) AS hydrated
12059 FROM mz_catalog.mz_indexes i
12060 LEFT JOIN mz_internal.mz_compute_hydration_statuses h
12061 ON (h.object_id = i.id)
12062),
12063materialized_views AS (
12064 SELECT
12065 i.id AS object_id,
12066 h.replica_id,
12067 COALESCE(h.hydrated, false) AS hydrated
12068 FROM mz_catalog.mz_materialized_views i
12069 LEFT JOIN mz_internal.mz_compute_hydration_statuses h
12070 ON (h.object_id = i.id)
12071),
12072continual_tasks AS (
12073 SELECT
12074 i.id AS object_id,
12075 h.replica_id,
12076 COALESCE(h.hydrated, false) AS hydrated
12077 FROM mz_internal.mz_continual_tasks i
12078 LEFT JOIN mz_internal.mz_compute_hydration_statuses h
12079 ON (h.object_id = i.id)
12080),
12081-- Hydration is a dataflow concept and not all sources are maintained by
12082-- dataflows, so we need to find the ones that are. Generally, sources that
12083-- have a cluster ID are maintained by a dataflow running on that cluster.
12084-- Webhook sources are an exception to this rule.
12085sources_with_clusters AS (
12086 SELECT id, cluster_id
12087 FROM mz_catalog.mz_sources
12088 WHERE cluster_id IS NOT NULL AND type != 'webhook'
12089),
12090sources AS (
12091 SELECT
12092 s.id AS object_id,
12093 ss.replica_id AS replica_id,
12094 ss.rehydration_latency IS NOT NULL AS hydrated
12095 FROM sources_with_clusters s
12096 LEFT JOIN mz_internal.mz_source_statistics ss USING (id)
12097),
12098-- We don't yet report sink hydration status (database-issues#8331), so we do a best effort attempt here and
12099-- define a sink as hydrated when it's both "running" and has a frontier greater than the minimum.
12100-- There is likely still a possibility of FPs.
12101sinks AS (
12102 SELECT
12103 s.id AS object_id,
12104 r.id AS replica_id,
12105 ss.status = 'running' AND COALESCE(f.write_frontier, 0) > 0 AS hydrated
12106 FROM mz_catalog.mz_sinks s
12107 LEFT JOIN mz_internal.mz_sink_statuses ss USING (id)
12108 JOIN mz_catalog.mz_cluster_replicas r
12109 ON (r.cluster_id = s.cluster_id)
12110 LEFT JOIN mz_catalog.mz_cluster_replica_frontiers f
12111 ON (f.object_id = s.id AND f.replica_id = r.id)
12112)
12113SELECT * FROM indexes
12114UNION ALL
12115SELECT * FROM materialized_views
12116UNION ALL
12117SELECT * FROM continual_tasks
12118UNION ALL
12119SELECT * FROM sources
12120UNION ALL
12121SELECT * FROM sinks"#,
12122 access: vec![PUBLIC_SELECT],
12123});
12124
12125pub static MZ_MATERIALIZATION_DEPENDENCIES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12126 name: "mz_materialization_dependencies",
12127 schema: MZ_INTERNAL_SCHEMA,
12128 oid: oid::VIEW_MZ_MATERIALIZATION_DEPENDENCIES_OID,
12129 desc: RelationDesc::builder()
12130 .with_column("object_id", SqlScalarType::String.nullable(false))
12131 .with_column("dependency_id", SqlScalarType::String.nullable(false))
12132 .finish(),
12133 column_comments: BTreeMap::from_iter([
12134 (
12135 "object_id",
12136 "The ID of a materialization. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, or `mz_catalog.mz_sinks.id`.",
12137 ),
12138 (
12139 "dependency_id",
12140 "The ID of a dataflow dependency. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, `mz_catalog.mz_sources.id`, or `mz_catalog.mz_tables.id`.",
12141 ),
12142 ]),
12143 sql: "
12144SELECT object_id, dependency_id
12145FROM mz_internal.mz_compute_dependencies
12146UNION ALL
12147SELECT s.id, d.referenced_object_id AS dependency_id
12148FROM mz_internal.mz_object_dependencies d
12149JOIN mz_catalog.mz_sinks s ON (s.id = d.object_id)
12150JOIN mz_catalog.mz_relations r ON (r.id = d.referenced_object_id)",
12151 access: vec![PUBLIC_SELECT],
12152});
12153
12154pub static MZ_MATERIALIZATION_LAG: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12155 name: "mz_materialization_lag",
12156 schema: MZ_INTERNAL_SCHEMA,
12157 oid: oid::VIEW_MZ_MATERIALIZATION_LAG_OID,
12158 desc: RelationDesc::builder()
12159 .with_column("object_id", SqlScalarType::String.nullable(false))
12160 .with_column("local_lag", SqlScalarType::Interval.nullable(true))
12161 .with_column("global_lag", SqlScalarType::Interval.nullable(true))
12162 .with_column(
12163 "slowest_local_input_id",
12164 SqlScalarType::String.nullable(false),
12165 )
12166 .with_column(
12167 "slowest_global_input_id",
12168 SqlScalarType::String.nullable(false),
12169 )
12170 .finish(),
12171 column_comments: BTreeMap::from_iter([
12172 (
12173 "object_id",
12174 "The ID of the materialized view, index, or sink.",
12175 ),
12176 (
12177 "local_lag",
12178 "The amount of time the materialization lags behind its direct inputs.",
12179 ),
12180 (
12181 "global_lag",
12182 "The amount of time the materialization lags behind its root inputs (sources and tables).",
12183 ),
12184 (
12185 "slowest_local_input_id",
12186 "The ID of the slowest direct input.",
12187 ),
12188 (
12189 "slowest_global_input_id",
12190 "The ID of the slowest root input.",
12191 ),
12192 ]),
12193 sql: "
12194WITH MUTUALLY RECURSIVE
12195 -- IDs of objects for which we want to know the lag.
12196 materializations (id text) AS (
12197 SELECT id FROM mz_catalog.mz_indexes
12198 UNION ALL
12199 SELECT id FROM mz_catalog.mz_materialized_views
12200 UNION ALL
12201 SELECT id FROM mz_internal.mz_continual_tasks
12202 UNION ALL
12203 SELECT id FROM mz_catalog.mz_sinks
12204 ),
12205 -- Direct dependencies of materializations.
12206 direct_dependencies (id text, dep_id text) AS (
12207 SELECT m.id, d.dependency_id
12208 FROM materializations m
12209 JOIN mz_internal.mz_materialization_dependencies d ON (m.id = d.object_id)
12210 ),
12211 -- All transitive dependencies of materializations.
12212 transitive_dependencies (id text, dep_id text) AS (
12213 SELECT id, dep_id FROM direct_dependencies
12214 UNION
12215 SELECT td.id, dd.dep_id
12216 FROM transitive_dependencies td
12217 JOIN direct_dependencies dd ON (dd.id = td.dep_id)
12218 ),
12219 -- Root dependencies of materializations (sources and tables).
12220 root_dependencies (id text, dep_id text) AS (
12221 SELECT *
12222 FROM transitive_dependencies td
12223 WHERE NOT EXISTS (
12224 SELECT 1
12225 FROM direct_dependencies dd
12226 WHERE dd.id = td.dep_id
12227 )
12228 ),
12229 -- Write progress times of materializations.
12230 materialization_times (id text, time timestamptz) AS (
12231 SELECT m.id, to_timestamp(f.write_frontier::text::double / 1000)
12232 FROM materializations m
12233 JOIN mz_internal.mz_frontiers f ON (m.id = f.object_id)
12234 ),
12235 -- Write progress times of direct dependencies of materializations.
12236 input_times (id text, slowest_dep text, time timestamptz) AS (
12237 SELECT DISTINCT ON (d.id)
12238 d.id,
12239 d.dep_id,
12240 to_timestamp(f.write_frontier::text::double / 1000)
12241 FROM direct_dependencies d
12242 JOIN mz_internal.mz_frontiers f ON (d.dep_id = f.object_id)
12243 ORDER BY d.id, f.write_frontier ASC
12244 ),
12245 -- Write progress times of root dependencies of materializations.
12246 root_times (id text, slowest_dep text, time timestamptz) AS (
12247 SELECT DISTINCT ON (d.id)
12248 d.id,
12249 d.dep_id,
12250 to_timestamp(f.write_frontier::text::double / 1000)
12251 FROM root_dependencies d
12252 JOIN mz_internal.mz_frontiers f ON (d.dep_id = f.object_id)
12253 ORDER BY d.id, f.write_frontier ASC
12254 )
12255SELECT
12256 id AS object_id,
12257 -- Ensure that lag values are always NULL for materializations that have reached the empty
12258 -- frontier, as those have processed all their input data.
12259 -- Also make sure that lag values are never negative, even when input frontiers are before
12260 -- output frontiers (as can happen during hydration).
12261 CASE
12262 WHEN m.time IS NULL THEN INTERVAL '0'
12263 WHEN i.time IS NULL THEN NULL
12264 ELSE greatest(i.time - m.time, INTERVAL '0')
12265 END AS local_lag,
12266 CASE
12267 WHEN m.time IS NULL THEN INTERVAL '0'
12268 WHEN r.time IS NULL THEN NULL
12269 ELSE greatest(r.time - m.time, INTERVAL '0')
12270 END AS global_lag,
12271 i.slowest_dep AS slowest_local_input_id,
12272 r.slowest_dep AS slowest_global_input_id
12273FROM materialization_times m
12274JOIN input_times i USING (id)
12275JOIN root_times r USING (id)",
12276 access: vec![PUBLIC_SELECT],
12277});
12278
12279pub static MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW: LazyLock<BuiltinView> = LazyLock::new(|| {
12285 BuiltinView {
12286 name: "mz_console_cluster_utilization_overview",
12287 schema: MZ_INTERNAL_SCHEMA,
12288 oid: oid::VIEW_MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_OID,
12289 desc: RelationDesc::builder()
12290 .with_column(
12291 "bucket_start",
12292 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12293 )
12294 .with_column("replica_id", SqlScalarType::String.nullable(false))
12295 .with_column("memory_percent", SqlScalarType::Float64.nullable(true))
12296 .with_column(
12297 "max_memory_at",
12298 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12299 )
12300 .with_column("disk_percent", SqlScalarType::Float64.nullable(true))
12301 .with_column(
12302 "max_disk_at",
12303 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12304 )
12305 .with_column(
12306 "memory_and_disk_percent",
12307 SqlScalarType::Float64.nullable(true),
12308 )
12309 .with_column(
12310 "max_memory_and_disk_memory_percent",
12311 SqlScalarType::Float64.nullable(true),
12312 )
12313 .with_column(
12314 "max_memory_and_disk_disk_percent",
12315 SqlScalarType::Float64.nullable(true),
12316 )
12317 .with_column(
12318 "max_memory_and_disk_at",
12319 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12320 )
12321 .with_column("heap_percent", SqlScalarType::Float64.nullable(true))
12322 .with_column(
12323 "max_heap_at",
12324 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12325 )
12326 .with_column("max_cpu_percent", SqlScalarType::Float64.nullable(true))
12327 .with_column(
12328 "max_cpu_at",
12329 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12330 )
12331 .with_column("offline_events", SqlScalarType::Jsonb.nullable(true))
12332 .with_column(
12333 "bucket_end",
12334 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12335 )
12336 .with_column("name", SqlScalarType::String.nullable(true))
12337 .with_column("cluster_id", SqlScalarType::String.nullable(true))
12338 .with_column("size", SqlScalarType::String.nullable(true))
12339 .finish(),
12340 column_comments: BTreeMap::new(),
12341 sql: r#"WITH replica_history AS (
12342 SELECT replica_id,
12343 size,
12344 cluster_id
12345 FROM mz_internal.mz_cluster_replica_history
12346 UNION
12347 -- We need to union the current set of cluster replicas since mz_cluster_replica_history doesn't include system clusters
12348 SELECT id AS replica_id,
12349 size,
12350 cluster_id
12351 FROM mz_catalog.mz_cluster_replicas
12352),
12353replica_metrics_history AS (
12354 SELECT
12355 m.occurred_at,
12356 m.replica_id,
12357 r.size,
12358 (SUM(m.cpu_nano_cores::float8) / NULLIF(s.cpu_nano_cores, 0)) / NULLIF(s.processes, 0) AS cpu_percent,
12359 (SUM(m.memory_bytes::float8) / NULLIF(s.memory_bytes, 0)) / NULLIF(s.processes, 0) AS memory_percent,
12360 (SUM(m.disk_bytes::float8) / NULLIF(s.disk_bytes, 0)) / NULLIF(s.processes, 0) AS disk_percent,
12361 (SUM(m.heap_bytes::float8) / NULLIF(m.heap_limit, 0)) / NULLIF(s.processes, 0) AS heap_percent,
12362 SUM(m.disk_bytes::float8) AS disk_bytes,
12363 SUM(m.memory_bytes::float8) AS memory_bytes,
12364 s.disk_bytes::numeric * s.processes AS total_disk_bytes,
12365 s.memory_bytes::numeric * s.processes AS total_memory_bytes
12366 FROM
12367 replica_history AS r
12368 INNER JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size
12369 INNER JOIN mz_internal.mz_cluster_replica_metrics_history AS m ON m.replica_id = r.replica_id
12370 GROUP BY
12371 m.occurred_at,
12372 m.replica_id,
12373 r.size,
12374 s.cpu_nano_cores,
12375 s.memory_bytes,
12376 s.disk_bytes,
12377 m.heap_limit,
12378 s.processes
12379),
12380replica_utilization_history_binned AS (
12381 SELECT m.occurred_at,
12382 m.replica_id,
12383 m.cpu_percent,
12384 m.memory_percent,
12385 m.memory_bytes,
12386 m.disk_percent,
12387 m.disk_bytes,
12388 m.heap_percent,
12389 m.total_disk_bytes,
12390 m.total_memory_bytes,
12391 m.size,
12392 date_bin(
12393 '8 HOURS',
12394 occurred_at,
12395 '1970-01-01'::timestamp
12396 ) AS bucket_start
12397 FROM replica_history AS r
12398 JOIN replica_metrics_history AS m ON m.replica_id = r.replica_id
12399 WHERE mz_now() <= date_bin(
12400 '8 HOURS',
12401 occurred_at,
12402 '1970-01-01'::timestamp
12403 ) + INTERVAL '14 DAYS'
12404),
12405-- For each (replica, bucket), take the (replica, bucket) with the highest memory
12406max_memory AS (
12407 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12408 replica_id,
12409 memory_percent,
12410 occurred_at
12411 FROM replica_utilization_history_binned
12412 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12413 ORDER BY bucket_start,
12414 replica_id,
12415 COALESCE(memory_bytes, 0) DESC
12416),
12417max_disk AS (
12418 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12419 replica_id,
12420 disk_percent,
12421 occurred_at
12422 FROM replica_utilization_history_binned
12423 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12424 ORDER BY bucket_start,
12425 replica_id,
12426 COALESCE(disk_bytes, 0) DESC
12427),
12428max_cpu AS (
12429 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12430 replica_id,
12431 cpu_percent,
12432 occurred_at
12433 FROM replica_utilization_history_binned
12434 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12435 ORDER BY bucket_start,
12436 replica_id,
12437 COALESCE(cpu_percent, 0) DESC
12438),
12439/*
12440 This is different
12441 from adding max_memory
12442 and max_disk per bucket because both
12443 values may not occur at the same time if the bucket interval is large.
12444 */
12445max_memory_and_disk AS (
12446 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12447 replica_id,
12448 memory_percent,
12449 disk_percent,
12450 memory_and_disk_percent,
12451 occurred_at
12452 FROM (
12453 SELECT *,
12454 CASE
12455 WHEN disk_bytes IS NULL
12456 AND memory_bytes IS NULL THEN NULL
12457 ELSE (COALESCE(disk_bytes, 0) + COALESCE(memory_bytes, 0))
12458 / (total_disk_bytes::numeric + total_memory_bytes::numeric)
12459 END AS memory_and_disk_percent
12460 FROM replica_utilization_history_binned
12461 ) AS max_memory_and_disk_inner
12462 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12463 ORDER BY bucket_start,
12464 replica_id,
12465 COALESCE(memory_and_disk_percent, 0) DESC
12466),
12467max_heap AS (
12468 SELECT DISTINCT ON (bucket_start, replica_id)
12469 bucket_start,
12470 replica_id,
12471 heap_percent,
12472 occurred_at
12473 FROM replica_utilization_history_binned
12474 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12475 ORDER BY bucket_start, replica_id, COALESCE(heap_percent, 0) DESC
12476),
12477-- For each (replica, bucket), get its offline events at that time
12478replica_offline_event_history AS (
12479 SELECT date_bin(
12480 '8 HOURS',
12481 occurred_at,
12482 '1970-01-01'::timestamp
12483 ) AS bucket_start,
12484 replica_id,
12485 jsonb_agg(
12486 jsonb_build_object(
12487 'replicaId',
12488 rsh.replica_id,
12489 'occurredAt',
12490 rsh.occurred_at,
12491 'status',
12492 rsh.status,
12493 'reason',
12494 rsh.reason
12495 )
12496 ) AS offline_events
12497 FROM mz_internal.mz_cluster_replica_status_history AS rsh -- We assume the statuses for process 0 are the same as all processes
12498 WHERE process_id = '0'
12499 AND status = 'offline'
12500 AND mz_now() <= date_bin(
12501 '8 HOURS',
12502 occurred_at,
12503 '1970-01-01'::timestamp
12504 ) + INTERVAL '14 DAYS'
12505 GROUP BY bucket_start,
12506 replica_id
12507)
12508SELECT
12509 bucket_start,
12510 replica_id,
12511 max_memory.memory_percent,
12512 max_memory.occurred_at as max_memory_at,
12513 max_disk.disk_percent,
12514 max_disk.occurred_at as max_disk_at,
12515 max_memory_and_disk.memory_and_disk_percent as memory_and_disk_percent,
12516 max_memory_and_disk.memory_percent as max_memory_and_disk_memory_percent,
12517 max_memory_and_disk.disk_percent as max_memory_and_disk_disk_percent,
12518 max_memory_and_disk.occurred_at as max_memory_and_disk_at,
12519 max_heap.heap_percent,
12520 max_heap.occurred_at as max_heap_at,
12521 max_cpu.cpu_percent as max_cpu_percent,
12522 max_cpu.occurred_at as max_cpu_at,
12523 replica_offline_event_history.offline_events,
12524 bucket_start + INTERVAL '8 HOURS' as bucket_end,
12525 replica_name_history.new_name AS name,
12526 replica_history.cluster_id,
12527 replica_history.size
12528FROM max_memory
12529JOIN max_disk USING (bucket_start, replica_id)
12530JOIN max_cpu USING (bucket_start, replica_id)
12531JOIN max_memory_and_disk USING (bucket_start, replica_id)
12532JOIN max_heap USING (bucket_start, replica_id)
12533JOIN replica_history USING (replica_id)
12534CROSS JOIN LATERAL (
12535 SELECT new_name
12536 FROM mz_internal.mz_cluster_replica_name_history as replica_name_history
12537 WHERE replica_id = replica_name_history.id -- We treat NULLs as the beginning of time
12538 AND bucket_start + INTERVAL '8 HOURS' >= COALESCE(
12539 replica_name_history.occurred_at,
12540 '1970-01-01'::timestamp
12541 )
12542 ORDER BY replica_name_history.occurred_at DESC
12543 LIMIT '1'
12544) AS replica_name_history
12545LEFT JOIN replica_offline_event_history USING (bucket_start, replica_id)"#,
12546 access: vec![PUBLIC_SELECT],
12547 }
12548});
12549
12550pub static MZ_CLUSTER_DEPLOYMENT_LINEAGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12573 name: "mz_cluster_deployment_lineage",
12574 schema: MZ_INTERNAL_SCHEMA,
12575 oid: oid::VIEW_MZ_CLUSTER_DEPLOYMENT_LINEAGE_OID,
12576 desc: RelationDesc::builder()
12577 .with_column("cluster_id", SqlScalarType::String.nullable(true))
12578 .with_column(
12579 "current_deployment_cluster_id",
12580 SqlScalarType::String.nullable(false),
12581 )
12582 .with_column("cluster_name", SqlScalarType::String.nullable(false))
12583 .with_key(vec![0, 1, 2])
12584 .finish(),
12585 column_comments: BTreeMap::from_iter([
12586 (
12587 "cluster_id",
12588 "The ID of the cluster. Corresponds to `mz_clusters.id` (though the cluster may no longer exist).",
12589 ),
12590 (
12591 "current_deployment_cluster_id",
12592 "The cluster ID of the last cluster in `cluster_id`'s blue/green lineage (the cluster is guaranteed to exist).",
12593 ),
12594 ("cluster_name", "The name of the cluster"),
12595 ]),
12596 sql: r#"WITH MUTUALLY RECURSIVE cluster_events (
12597 cluster_id text,
12598 cluster_name text,
12599 event_type text,
12600 occurred_at timestamptz
12601) AS (
12602 SELECT coalesce(details->>'id', details->>'cluster_id') AS cluster_id,
12603 coalesce(details->>'name', details->>'new_name') AS cluster_name,
12604 event_type,
12605 occurred_at
12606 FROM mz_audit_events
12607 WHERE (
12608 event_type IN ('create', 'drop')
12609 OR (
12610 event_type = 'alter'
12611 AND details ? 'new_name'
12612 )
12613 )
12614 AND object_type = 'cluster'
12615 AND mz_now() < occurred_at + INTERVAL '30 days'
12616),
12617mz_cluster_deployment_lineage (
12618 cluster_id text,
12619 current_deployment_cluster_id text,
12620 cluster_name text
12621) AS (
12622 SELECT c.id,
12623 c.id,
12624 c.name
12625 FROM mz_clusters c
12626 WHERE c.id LIKE 'u%'
12627 UNION
12628 SELECT *
12629 FROM dropped_clusters
12630),
12631-- Closest create or rename event based on the current clusters in the result set
12632most_recent_create_or_rename (
12633 cluster_id text,
12634 current_deployment_cluster_id text,
12635 cluster_name text,
12636 occurred_at timestamptz
12637) AS (
12638 SELECT DISTINCT ON (e.cluster_id) e.cluster_id,
12639 c.current_deployment_cluster_id,
12640 e.cluster_name,
12641 e.occurred_at
12642 FROM mz_cluster_deployment_lineage c
12643 JOIN cluster_events e ON c.cluster_id = e.cluster_id
12644 AND c.cluster_name = e.cluster_name
12645 WHERE e.event_type <> 'drop'
12646 ORDER BY e.cluster_id,
12647 e.occurred_at DESC
12648),
12649-- Clusters that were dropped most recently within 1 minute of most_recent_create_or_rename
12650dropped_clusters (
12651 cluster_id text,
12652 current_deployment_cluster_id text,
12653 cluster_name text
12654) AS (
12655 SELECT DISTINCT ON (cr.cluster_id) e.cluster_id,
12656 cr.current_deployment_cluster_id,
12657 cr.cluster_name
12658 FROM most_recent_create_or_rename cr
12659 JOIN cluster_events e ON e.occurred_at BETWEEN cr.occurred_at - interval '1 minute'
12660 AND cr.occurred_at + interval '1 minute'
12661 AND (
12662 e.cluster_name = cr.cluster_name
12663 OR e.cluster_name = cr.cluster_name || '_dbt_deploy'
12664 )
12665 WHERE e.event_type = 'drop'
12666 ORDER BY cr.cluster_id,
12667 abs(
12668 extract(
12669 epoch
12670 FROM cr.occurred_at - e.occurred_at
12671 )
12672 )
12673)
12674SELECT *
12675FROM mz_cluster_deployment_lineage"#,
12676 access: vec![PUBLIC_SELECT],
12677});
12678
12679pub const MZ_SHOW_DATABASES_IND: BuiltinIndex = BuiltinIndex {
12680 name: "mz_show_databases_ind",
12681 schema: MZ_INTERNAL_SCHEMA,
12682 oid: oid::INDEX_MZ_SHOW_DATABASES_IND_OID,
12683 sql: "IN CLUSTER mz_catalog_server
12684ON mz_internal.mz_show_databases (name)",
12685 is_retained_metrics_object: false,
12686};
12687
12688pub const MZ_SHOW_SCHEMAS_IND: BuiltinIndex = BuiltinIndex {
12689 name: "mz_show_schemas_ind",
12690 schema: MZ_INTERNAL_SCHEMA,
12691 oid: oid::INDEX_MZ_SHOW_SCHEMAS_IND_OID,
12692 sql: "IN CLUSTER mz_catalog_server
12693ON mz_internal.mz_show_schemas (database_id)",
12694 is_retained_metrics_object: false,
12695};
12696
12697pub const MZ_SHOW_CONNECTIONS_IND: BuiltinIndex = BuiltinIndex {
12698 name: "mz_show_connections_ind",
12699 schema: MZ_INTERNAL_SCHEMA,
12700 oid: oid::INDEX_MZ_SHOW_CONNECTIONS_IND_OID,
12701 sql: "IN CLUSTER mz_catalog_server
12702ON mz_internal.mz_show_connections (schema_id)",
12703 is_retained_metrics_object: false,
12704};
12705
12706pub const MZ_SHOW_TABLES_IND: BuiltinIndex = BuiltinIndex {
12707 name: "mz_show_tables_ind",
12708 schema: MZ_INTERNAL_SCHEMA,
12709 oid: oid::INDEX_MZ_SHOW_TABLES_IND_OID,
12710 sql: "IN CLUSTER mz_catalog_server
12711ON mz_internal.mz_show_tables (schema_id)",
12712 is_retained_metrics_object: false,
12713};
12714
12715pub const MZ_SHOW_SOURCES_IND: BuiltinIndex = BuiltinIndex {
12716 name: "mz_show_sources_ind",
12717 schema: MZ_INTERNAL_SCHEMA,
12718 oid: oid::INDEX_MZ_SHOW_SOURCES_IND_OID,
12719 sql: "IN CLUSTER mz_catalog_server
12720ON mz_internal.mz_show_sources (schema_id)",
12721 is_retained_metrics_object: false,
12722};
12723
12724pub const MZ_SHOW_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12725 name: "mz_show_views_ind",
12726 schema: MZ_INTERNAL_SCHEMA,
12727 oid: oid::INDEX_MZ_SHOW_VIEWS_IND_OID,
12728 sql: "IN CLUSTER mz_catalog_server
12729ON mz_internal.mz_show_views (schema_id)",
12730 is_retained_metrics_object: false,
12731};
12732
12733pub const MZ_SHOW_MATERIALIZED_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12734 name: "mz_show_materialized_views_ind",
12735 schema: MZ_INTERNAL_SCHEMA,
12736 oid: oid::INDEX_MZ_SHOW_MATERIALIZED_VIEWS_IND_OID,
12737 sql: "IN CLUSTER mz_catalog_server
12738ON mz_internal.mz_show_materialized_views (schema_id)",
12739 is_retained_metrics_object: false,
12740};
12741
12742pub const MZ_SHOW_SINKS_IND: BuiltinIndex = BuiltinIndex {
12743 name: "mz_show_sinks_ind",
12744 schema: MZ_INTERNAL_SCHEMA,
12745 oid: oid::INDEX_MZ_SHOW_SINKS_IND_OID,
12746 sql: "IN CLUSTER mz_catalog_server
12747ON mz_internal.mz_show_sinks (schema_id)",
12748 is_retained_metrics_object: false,
12749};
12750
12751pub const MZ_SHOW_TYPES_IND: BuiltinIndex = BuiltinIndex {
12752 name: "mz_show_types_ind",
12753 schema: MZ_INTERNAL_SCHEMA,
12754 oid: oid::INDEX_MZ_SHOW_TYPES_IND_OID,
12755 sql: "IN CLUSTER mz_catalog_server
12756ON mz_internal.mz_show_types (schema_id)",
12757 is_retained_metrics_object: false,
12758};
12759
12760pub const MZ_SHOW_ROLES_IND: BuiltinIndex = BuiltinIndex {
12761 name: "mz_show_roles_ind",
12762 schema: MZ_INTERNAL_SCHEMA,
12763 oid: oid::INDEX_MZ_SHOW_ROLES_IND_OID,
12764 sql: "IN CLUSTER mz_catalog_server
12765ON mz_internal.mz_show_roles (name)",
12766 is_retained_metrics_object: false,
12767};
12768
12769pub const MZ_SHOW_ALL_OBJECTS_IND: BuiltinIndex = BuiltinIndex {
12770 name: "mz_show_all_objects_ind",
12771 schema: MZ_INTERNAL_SCHEMA,
12772 oid: oid::INDEX_MZ_SHOW_ALL_OBJECTS_IND_OID,
12773 sql: "IN CLUSTER mz_catalog_server
12774ON mz_internal.mz_show_all_objects (schema_id)",
12775 is_retained_metrics_object: false,
12776};
12777
12778pub const MZ_SHOW_INDEXES_IND: BuiltinIndex = BuiltinIndex {
12779 name: "mz_show_indexes_ind",
12780 schema: MZ_INTERNAL_SCHEMA,
12781 oid: oid::INDEX_MZ_SHOW_INDEXES_IND_OID,
12782 sql: "IN CLUSTER mz_catalog_server
12783ON mz_internal.mz_show_indexes (schema_id)",
12784 is_retained_metrics_object: false,
12785};
12786
12787pub const MZ_SHOW_COLUMNS_IND: BuiltinIndex = BuiltinIndex {
12788 name: "mz_show_columns_ind",
12789 schema: MZ_INTERNAL_SCHEMA,
12790 oid: oid::INDEX_MZ_SHOW_COLUMNS_IND_OID,
12791 sql: "IN CLUSTER mz_catalog_server
12792ON mz_internal.mz_show_columns (id)",
12793 is_retained_metrics_object: false,
12794};
12795
12796pub const MZ_SHOW_CLUSTERS_IND: BuiltinIndex = BuiltinIndex {
12797 name: "mz_show_clusters_ind",
12798 schema: MZ_INTERNAL_SCHEMA,
12799 oid: oid::INDEX_MZ_SHOW_CLUSTERS_IND_OID,
12800 sql: "IN CLUSTER mz_catalog_server
12801ON mz_internal.mz_show_clusters (name)",
12802 is_retained_metrics_object: false,
12803};
12804
12805pub const MZ_SHOW_CLUSTER_REPLICAS_IND: BuiltinIndex = BuiltinIndex {
12806 name: "mz_show_cluster_replicas_ind",
12807 schema: MZ_INTERNAL_SCHEMA,
12808 oid: oid::INDEX_MZ_SHOW_CLUSTER_REPLICAS_IND_OID,
12809 sql: "IN CLUSTER mz_catalog_server
12810ON mz_internal.mz_show_cluster_replicas (cluster)",
12811 is_retained_metrics_object: false,
12812};
12813
12814pub const MZ_SHOW_SECRETS_IND: BuiltinIndex = BuiltinIndex {
12815 name: "mz_show_secrets_ind",
12816 schema: MZ_INTERNAL_SCHEMA,
12817 oid: oid::INDEX_MZ_SHOW_SECRETS_IND_OID,
12818 sql: "IN CLUSTER mz_catalog_server
12819ON mz_internal.mz_show_secrets (schema_id)",
12820 is_retained_metrics_object: false,
12821};
12822
12823pub const MZ_DATABASES_IND: BuiltinIndex = BuiltinIndex {
12824 name: "mz_databases_ind",
12825 schema: MZ_CATALOG_SCHEMA,
12826 oid: oid::INDEX_MZ_DATABASES_IND_OID,
12827 sql: "IN CLUSTER mz_catalog_server
12828ON mz_catalog.mz_databases (name)",
12829 is_retained_metrics_object: false,
12830};
12831
12832pub const MZ_SCHEMAS_IND: BuiltinIndex = BuiltinIndex {
12833 name: "mz_schemas_ind",
12834 schema: MZ_CATALOG_SCHEMA,
12835 oid: oid::INDEX_MZ_SCHEMAS_IND_OID,
12836 sql: "IN CLUSTER mz_catalog_server
12837ON mz_catalog.mz_schemas (database_id)",
12838 is_retained_metrics_object: false,
12839};
12840
12841pub const MZ_CONNECTIONS_IND: BuiltinIndex = BuiltinIndex {
12842 name: "mz_connections_ind",
12843 schema: MZ_CATALOG_SCHEMA,
12844 oid: oid::INDEX_MZ_CONNECTIONS_IND_OID,
12845 sql: "IN CLUSTER mz_catalog_server
12846ON mz_catalog.mz_connections (schema_id)",
12847 is_retained_metrics_object: false,
12848};
12849
12850pub const MZ_TABLES_IND: BuiltinIndex = BuiltinIndex {
12851 name: "mz_tables_ind",
12852 schema: MZ_CATALOG_SCHEMA,
12853 oid: oid::INDEX_MZ_TABLES_IND_OID,
12854 sql: "IN CLUSTER mz_catalog_server
12855ON mz_catalog.mz_tables (schema_id)",
12856 is_retained_metrics_object: false,
12857};
12858
12859pub const MZ_TYPES_IND: BuiltinIndex = BuiltinIndex {
12860 name: "mz_types_ind",
12861 schema: MZ_CATALOG_SCHEMA,
12862 oid: oid::INDEX_MZ_TYPES_IND_OID,
12863 sql: "IN CLUSTER mz_catalog_server
12864ON mz_catalog.mz_types (schema_id)",
12865 is_retained_metrics_object: false,
12866};
12867
12868pub const MZ_OBJECTS_IND: BuiltinIndex = BuiltinIndex {
12869 name: "mz_objects_ind",
12870 schema: MZ_CATALOG_SCHEMA,
12871 oid: oid::INDEX_MZ_OBJECTS_IND_OID,
12872 sql: "IN CLUSTER mz_catalog_server
12873ON mz_catalog.mz_objects (schema_id)",
12874 is_retained_metrics_object: false,
12875};
12876
12877pub const MZ_COLUMNS_IND: BuiltinIndex = BuiltinIndex {
12878 name: "mz_columns_ind",
12879 schema: MZ_CATALOG_SCHEMA,
12880 oid: oid::INDEX_MZ_COLUMNS_IND_OID,
12881 sql: "IN CLUSTER mz_catalog_server
12882ON mz_catalog.mz_columns (name)",
12883 is_retained_metrics_object: false,
12884};
12885
12886pub const MZ_SECRETS_IND: BuiltinIndex = BuiltinIndex {
12887 name: "mz_secrets_ind",
12888 schema: MZ_CATALOG_SCHEMA,
12889 oid: oid::INDEX_MZ_SECRETS_IND_OID,
12890 sql: "IN CLUSTER mz_catalog_server
12891ON mz_catalog.mz_secrets (name)",
12892 is_retained_metrics_object: false,
12893};
12894
12895pub const MZ_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12896 name: "mz_views_ind",
12897 schema: MZ_CATALOG_SCHEMA,
12898 oid: oid::INDEX_MZ_VIEWS_IND_OID,
12899 sql: "IN CLUSTER mz_catalog_server
12900ON mz_catalog.mz_views (schema_id)",
12901 is_retained_metrics_object: false,
12902};
12903
12904pub const MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_IND: BuiltinIndex = BuiltinIndex {
12905 name: "mz_console_cluster_utilization_overview_ind",
12906 schema: MZ_INTERNAL_SCHEMA,
12907 oid: oid::INDEX_MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_IND_OID,
12908 sql: "IN CLUSTER mz_catalog_server
12909ON mz_internal.mz_console_cluster_utilization_overview (cluster_id)",
12910 is_retained_metrics_object: false,
12911};
12912
12913pub const MZ_CLUSTER_DEPLOYMENT_LINEAGE_IND: BuiltinIndex = BuiltinIndex {
12914 name: "mz_cluster_deployment_lineage_ind",
12915 schema: MZ_INTERNAL_SCHEMA,
12916 oid: oid::INDEX_MZ_CLUSTER_DEPLOYMENT_LINEAGE_IND_OID,
12917 sql: "IN CLUSTER mz_catalog_server
12918ON mz_internal.mz_cluster_deployment_lineage (cluster_id)",
12919 is_retained_metrics_object: false,
12920};
12921
12922pub const MZ_CLUSTERS_IND: BuiltinIndex = BuiltinIndex {
12923 name: "mz_clusters_ind",
12924 schema: MZ_CATALOG_SCHEMA,
12925 oid: oid::INDEX_MZ_CLUSTERS_IND_OID,
12926 sql: "IN CLUSTER mz_catalog_server
12927ON mz_catalog.mz_clusters (id)",
12928 is_retained_metrics_object: false,
12929};
12930
12931pub const MZ_INDEXES_IND: BuiltinIndex = BuiltinIndex {
12932 name: "mz_indexes_ind",
12933 schema: MZ_CATALOG_SCHEMA,
12934 oid: oid::INDEX_MZ_INDEXES_IND_OID,
12935 sql: "IN CLUSTER mz_catalog_server
12936ON mz_catalog.mz_indexes (id)",
12937 is_retained_metrics_object: false,
12938};
12939
12940pub const MZ_ROLES_IND: BuiltinIndex = BuiltinIndex {
12941 name: "mz_roles_ind",
12942 schema: MZ_CATALOG_SCHEMA,
12943 oid: oid::INDEX_MZ_ROLES_IND_OID,
12944 sql: "IN CLUSTER mz_catalog_server
12945ON mz_catalog.mz_roles (id)",
12946 is_retained_metrics_object: false,
12947};
12948
12949pub const MZ_SOURCES_IND: BuiltinIndex = BuiltinIndex {
12950 name: "mz_sources_ind",
12951 schema: MZ_CATALOG_SCHEMA,
12952 oid: oid::INDEX_MZ_SOURCES_IND_OID,
12953 sql: "IN CLUSTER mz_catalog_server
12954ON mz_catalog.mz_sources (id)",
12955 is_retained_metrics_object: true,
12956};
12957
12958pub const MZ_SINKS_IND: BuiltinIndex = BuiltinIndex {
12959 name: "mz_sinks_ind",
12960 schema: MZ_CATALOG_SCHEMA,
12961 oid: oid::INDEX_MZ_SINKS_IND_OID,
12962 sql: "IN CLUSTER mz_catalog_server
12963ON mz_catalog.mz_sinks (id)",
12964 is_retained_metrics_object: true,
12965};
12966
12967pub const MZ_MATERIALIZED_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12968 name: "mz_materialized_views_ind",
12969 schema: MZ_CATALOG_SCHEMA,
12970 oid: oid::INDEX_MZ_MATERIALIZED_VIEWS_IND_OID,
12971 sql: "IN CLUSTER mz_catalog_server
12972ON mz_catalog.mz_materialized_views (id)",
12973 is_retained_metrics_object: false,
12974};
12975
12976pub const MZ_CONTINUAL_TASKS_IND: BuiltinIndex = BuiltinIndex {
12977 name: "mz_continual_tasks_ind",
12978 schema: MZ_INTERNAL_SCHEMA,
12979 oid: oid::INDEX_MZ_CONTINUAL_TASKS_IND_OID,
12980 sql: "IN CLUSTER mz_catalog_server
12981ON mz_internal.mz_continual_tasks (id)",
12982 is_retained_metrics_object: false,
12983};
12984
12985pub const MZ_SOURCE_STATUSES_IND: BuiltinIndex = BuiltinIndex {
12986 name: "mz_source_statuses_ind",
12987 schema: MZ_INTERNAL_SCHEMA,
12988 oid: oid::INDEX_MZ_SOURCE_STATUSES_IND_OID,
12989 sql: "IN CLUSTER mz_catalog_server
12990ON mz_internal.mz_source_statuses (id)",
12991 is_retained_metrics_object: false,
12992};
12993
12994pub const MZ_SINK_STATUSES_IND: BuiltinIndex = BuiltinIndex {
12995 name: "mz_sink_statuses_ind",
12996 schema: MZ_INTERNAL_SCHEMA,
12997 oid: oid::INDEX_MZ_SINK_STATUSES_IND_OID,
12998 sql: "IN CLUSTER mz_catalog_server
12999ON mz_internal.mz_sink_statuses (id)",
13000 is_retained_metrics_object: false,
13001};
13002
13003pub const MZ_SOURCE_STATUS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13004 name: "mz_source_status_history_ind",
13005 schema: MZ_INTERNAL_SCHEMA,
13006 oid: oid::INDEX_MZ_SOURCE_STATUS_HISTORY_IND_OID,
13007 sql: "IN CLUSTER mz_catalog_server
13008ON mz_internal.mz_source_status_history (source_id)",
13009 is_retained_metrics_object: false,
13010};
13011
13012pub const MZ_SINK_STATUS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13013 name: "mz_sink_status_history_ind",
13014 schema: MZ_INTERNAL_SCHEMA,
13015 oid: oid::INDEX_MZ_SINK_STATUS_HISTORY_IND_OID,
13016 sql: "IN CLUSTER mz_catalog_server
13017ON mz_internal.mz_sink_status_history (sink_id)",
13018 is_retained_metrics_object: false,
13019};
13020
13021pub const MZ_SHOW_CONTINUAL_TASKS_IND: BuiltinIndex = BuiltinIndex {
13022 name: "mz_show_continual_tasks_ind",
13023 schema: MZ_INTERNAL_SCHEMA,
13024 oid: oid::INDEX_MZ_SHOW_CONTINUAL_TASKS_OID,
13025 sql: "IN CLUSTER mz_catalog_server
13026ON mz_internal.mz_show_continual_tasks (id)",
13027 is_retained_metrics_object: false,
13028};
13029
13030pub static MZ_SOURCE_STATISTICS_WITH_HISTORY: LazyLock<BuiltinView> =
13043 LazyLock::new(|| BuiltinView {
13044 name: "mz_source_statistics_with_history",
13045 schema: MZ_INTERNAL_SCHEMA,
13046 oid: oid::VIEW_MZ_SOURCE_STATISTICS_WITH_HISTORY_OID,
13047 desc: RelationDesc::builder()
13048 .with_column("id", SqlScalarType::String.nullable(false))
13049 .with_column("replica_id", SqlScalarType::String.nullable(true))
13050 .with_column("messages_received", SqlScalarType::UInt64.nullable(false))
13051 .with_column("bytes_received", SqlScalarType::UInt64.nullable(false))
13052 .with_column("updates_staged", SqlScalarType::UInt64.nullable(false))
13053 .with_column("updates_committed", SqlScalarType::UInt64.nullable(false))
13054 .with_column("records_indexed", SqlScalarType::UInt64.nullable(false))
13055 .with_column("bytes_indexed", SqlScalarType::UInt64.nullable(false))
13056 .with_column(
13057 "rehydration_latency",
13058 SqlScalarType::Interval.nullable(true),
13059 )
13060 .with_column(
13061 "snapshot_records_known",
13062 SqlScalarType::UInt64.nullable(true),
13063 )
13064 .with_column(
13065 "snapshot_records_staged",
13066 SqlScalarType::UInt64.nullable(true),
13067 )
13068 .with_column("snapshot_committed", SqlScalarType::Bool.nullable(false))
13069 .with_column("offset_known", SqlScalarType::UInt64.nullable(true))
13070 .with_column("offset_committed", SqlScalarType::UInt64.nullable(true))
13071 .with_key(vec![0, 1])
13072 .finish(),
13073 column_comments: BTreeMap::new(),
13074 sql: "
13075WITH
13076 -- For each subsource, statistics are reported as its parent source
13077 subsource_to_parent AS
13078 (
13079 SELECT subsource.id AS id, parent.id AS report_id
13080 FROM mz_catalog.mz_sources AS subsource
13081 JOIN mz_internal.mz_object_dependencies AS dep ON subsource.id = dep.object_id
13082 JOIN mz_catalog.mz_sources AS parent ON parent.id = dep.referenced_object_id
13083 WHERE subsource.type = 'subsource'
13084 ),
13085 -- For each table from source, statistics are reported as its parent source
13086 table_to_parent AS
13087 (
13088 SELECT id, source_id AS report_id
13089 FROM mz_catalog.mz_tables
13090 WHERE source_id IS NOT NULL
13091 ),
13092 -- For each source and subsource, statistics are reported as itself
13093 source_refl AS
13094 (
13095 SELECT id, id AS report_id
13096 FROM mz_catalog.mz_sources
13097 WHERE type NOT IN ('progress', 'log')
13098 ),
13099 -- For each table from source, statistics are reported as itself
13100 table_refl AS
13101 (
13102 SELECT id, id AS report_id
13103 FROM mz_catalog.mz_tables
13104 WHERE source_id IS NOT NULL
13105 ),
13106 report_paths AS
13107 (
13108 SELECT id, report_id FROM subsource_to_parent
13109 UNION ALL SELECT id, report_id FROM table_to_parent
13110 UNION ALL SELECT id, report_id FROM source_refl
13111 UNION ALL SELECT id, report_id FROM table_refl
13112 )
13113SELECT
13114 report_paths.report_id AS id,
13115 replica_id,
13116 -- Counters
13117 SUM(messages_received)::uint8 AS messages_received,
13118 SUM(bytes_received)::uint8 AS bytes_received,
13119 SUM(updates_staged)::uint8 AS updates_staged,
13120 SUM(updates_committed)::uint8 AS updates_committed,
13121 -- Resetting Gauges
13122 SUM(records_indexed)::uint8 AS records_indexed,
13123 SUM(bytes_indexed)::uint8 AS bytes_indexed,
13124 -- Ensure we aggregate to NULL when not all workers are done rehydrating.
13125 CASE
13126 WHEN bool_or(rehydration_latency IS NULL) THEN NULL
13127 ELSE MAX(rehydration_latency)::interval
13128 END AS rehydration_latency,
13129 SUM(snapshot_records_known)::uint8 AS snapshot_records_known,
13130 SUM(snapshot_records_staged)::uint8 AS snapshot_records_staged,
13131 bool_and(snapshot_committed) as snapshot_committed,
13132 -- Gauges
13133 MAX(offset_known)::uint8 AS offset_known,
13134 MIN(offset_committed)::uint8 AS offset_committed
13135FROM mz_internal.mz_source_statistics_raw
13136 JOIN report_paths USING (id)
13137GROUP BY report_paths.report_id, replica_id",
13138 access: vec![PUBLIC_SELECT],
13139 });
13140
13141pub const MZ_SOURCE_STATISTICS_WITH_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13142 name: "mz_source_statistics_with_history_ind",
13143 schema: MZ_INTERNAL_SCHEMA,
13144 oid: oid::INDEX_MZ_SOURCE_STATISTICS_WITH_HISTORY_IND_OID,
13145 sql: "IN CLUSTER mz_catalog_server
13146ON mz_internal.mz_source_statistics_with_history (id, replica_id)",
13147 is_retained_metrics_object: true,
13148};
13149
13150pub static MZ_SOURCE_STATISTICS: LazyLock<BuiltinView> = LazyLock::new(|| {
13153 BuiltinView {
13154 name: "mz_source_statistics",
13155 schema: MZ_INTERNAL_SCHEMA,
13156 oid: oid::VIEW_MZ_SOURCE_STATISTICS_OID,
13157 desc: RelationDesc::builder()
13159 .with_column("id", SqlScalarType::String.nullable(false))
13160 .with_column("replica_id", SqlScalarType::String.nullable(true))
13161 .with_column("messages_received", SqlScalarType::UInt64.nullable(false))
13162 .with_column("bytes_received", SqlScalarType::UInt64.nullable(false))
13163 .with_column("updates_staged", SqlScalarType::UInt64.nullable(false))
13164 .with_column("updates_committed", SqlScalarType::UInt64.nullable(false))
13165 .with_column("records_indexed", SqlScalarType::UInt64.nullable(false))
13166 .with_column("bytes_indexed", SqlScalarType::UInt64.nullable(false))
13167 .with_column(
13168 "rehydration_latency",
13169 SqlScalarType::Interval.nullable(true),
13170 )
13171 .with_column(
13172 "snapshot_records_known",
13173 SqlScalarType::UInt64.nullable(true),
13174 )
13175 .with_column(
13176 "snapshot_records_staged",
13177 SqlScalarType::UInt64.nullable(true),
13178 )
13179 .with_column("snapshot_committed", SqlScalarType::Bool.nullable(false))
13180 .with_column("offset_known", SqlScalarType::UInt64.nullable(true))
13181 .with_column("offset_committed", SqlScalarType::UInt64.nullable(true))
13182 .with_key(vec![0, 1])
13183 .finish(),
13184 column_comments: BTreeMap::from_iter([
13185 (
13186 "id",
13187 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
13188 ),
13189 (
13190 "replica_id",
13191 "The ID of a replica running the source. Corresponds to `mz_catalog.mz_cluster_replicas.id`.",
13192 ),
13193 (
13194 "messages_received",
13195 "The number of messages the source has received from the external system. Messages are counted in a source type-specific manner. Messages do not correspond directly to updates: some messages produce multiple updates, while other messages may be coalesced into a single update.",
13196 ),
13197 (
13198 "bytes_received",
13199 "The number of bytes the source has read from the external system. Bytes are counted in a source type-specific manner and may or may not include protocol overhead.",
13200 ),
13201 (
13202 "updates_staged",
13203 "The number of updates (insertions plus deletions) the source has written but not yet committed to the storage layer.",
13204 ),
13205 (
13206 "updates_committed",
13207 "The number of updates (insertions plus deletions) the source has committed to the storage layer.",
13208 ),
13209 (
13210 "records_indexed",
13211 "The number of individual records indexed in the source envelope state.",
13212 ),
13213 (
13214 "bytes_indexed",
13215 "The number of bytes stored in the source's internal index, if any.",
13216 ),
13217 (
13218 "rehydration_latency",
13219 "The amount of time it took for the source to rehydrate its internal index, if any, after the source last restarted.",
13220 ),
13221 (
13222 "snapshot_records_known",
13223 "The size of the source's snapshot, measured in number of records. See below to learn what constitutes a record.",
13224 ),
13225 (
13226 "snapshot_records_staged",
13227 "The number of records in the source's snapshot that Materialize has read. See below to learn what constitutes a record.",
13228 ),
13229 (
13230 "snapshot_committed",
13231 "Whether the source has committed the initial snapshot for a source.",
13232 ),
13233 (
13234 "offset_known",
13235 "The offset of the most recent data in the source's upstream service that Materialize knows about. See below to learn what constitutes an offset.",
13236 ),
13237 (
13238 "offset_committed",
13239 "The offset of the the data that Materialize has durably ingested. See below to learn what constitutes an offset.",
13240 ),
13241 ]),
13242 sql: "SELECT * FROM mz_internal.mz_source_statistics_with_history WHERE length(id) > 0",
13243 access: vec![PUBLIC_SELECT],
13244 }
13245});
13246
13247pub const MZ_SOURCE_STATISTICS_IND: BuiltinIndex = BuiltinIndex {
13248 name: "mz_source_statistics_ind",
13249 schema: MZ_INTERNAL_SCHEMA,
13250 oid: oid::INDEX_MZ_SOURCE_STATISTICS_IND_OID,
13251 sql: "IN CLUSTER mz_catalog_server
13252ON mz_internal.mz_source_statistics (id, replica_id)",
13253 is_retained_metrics_object: false,
13254};
13255
13256pub static MZ_SINK_STATISTICS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
13257 name: "mz_sink_statistics",
13258 schema: MZ_INTERNAL_SCHEMA,
13259 oid: oid::VIEW_MZ_SINK_STATISTICS_OID,
13260 desc: RelationDesc::builder()
13261 .with_column("id", SqlScalarType::String.nullable(false))
13262 .with_column("replica_id", SqlScalarType::String.nullable(true))
13263 .with_column("messages_staged", SqlScalarType::UInt64.nullable(false))
13264 .with_column("messages_committed", SqlScalarType::UInt64.nullable(false))
13265 .with_column("bytes_staged", SqlScalarType::UInt64.nullable(false))
13266 .with_column("bytes_committed", SqlScalarType::UInt64.nullable(false))
13267 .with_key(vec![0, 1])
13268 .finish(),
13269 column_comments: BTreeMap::from_iter([
13270 (
13271 "id",
13272 "The ID of the sink. Corresponds to `mz_catalog.mz_sources.id`.",
13273 ),
13274 (
13275 "replica_id",
13276 "The ID of a replica running the sink. Corresponds to `mz_catalog.mz_cluster_replicas.id`.",
13277 ),
13278 (
13279 "messages_staged",
13280 "The number of messages staged but possibly not committed to the sink.",
13281 ),
13282 (
13283 "messages_committed",
13284 "The number of messages committed to the sink.",
13285 ),
13286 (
13287 "bytes_staged",
13288 "The number of bytes staged but possibly not committed to the sink. This counts both keys and values, if applicable.",
13289 ),
13290 (
13291 "bytes_committed",
13292 "The number of bytes committed to the sink. This counts both keys and values, if applicable.",
13293 ),
13294 ]),
13295 sql: "
13296SELECT
13297 id,
13298 replica_id,
13299 SUM(messages_staged)::uint8 AS messages_staged,
13300 SUM(messages_committed)::uint8 AS messages_committed,
13301 SUM(bytes_staged)::uint8 AS bytes_staged,
13302 SUM(bytes_committed)::uint8 AS bytes_committed
13303FROM mz_internal.mz_sink_statistics_raw
13304GROUP BY id, replica_id",
13305 access: vec![PUBLIC_SELECT],
13306});
13307
13308pub const MZ_SINK_STATISTICS_IND: BuiltinIndex = BuiltinIndex {
13309 name: "mz_sink_statistics_ind",
13310 schema: MZ_INTERNAL_SCHEMA,
13311 oid: oid::INDEX_MZ_SINK_STATISTICS_IND_OID,
13312 sql: "IN CLUSTER mz_catalog_server
13313ON mz_internal.mz_sink_statistics (id, replica_id)",
13314 is_retained_metrics_object: true,
13315};
13316
13317pub const MZ_CLUSTER_REPLICAS_IND: BuiltinIndex = BuiltinIndex {
13318 name: "mz_cluster_replicas_ind",
13319 schema: MZ_CATALOG_SCHEMA,
13320 oid: oid::INDEX_MZ_CLUSTER_REPLICAS_IND_OID,
13321 sql: "IN CLUSTER mz_catalog_server
13322ON mz_catalog.mz_cluster_replicas (id)",
13323 is_retained_metrics_object: true,
13324};
13325
13326pub const MZ_CLUSTER_REPLICA_SIZES_IND: BuiltinIndex = BuiltinIndex {
13327 name: "mz_cluster_replica_sizes_ind",
13328 schema: MZ_CATALOG_SCHEMA,
13329 oid: oid::INDEX_MZ_CLUSTER_REPLICA_SIZES_IND_OID,
13330 sql: "IN CLUSTER mz_catalog_server
13331ON mz_catalog.mz_cluster_replica_sizes (size)",
13332 is_retained_metrics_object: true,
13333};
13334
13335pub const MZ_CLUSTER_REPLICA_STATUSES_IND: BuiltinIndex = BuiltinIndex {
13336 name: "mz_cluster_replica_statuses_ind",
13337 schema: MZ_INTERNAL_SCHEMA,
13338 oid: oid::INDEX_MZ_CLUSTER_REPLICA_STATUSES_IND_OID,
13339 sql: "IN CLUSTER mz_catalog_server
13340ON mz_internal.mz_cluster_replica_statuses (replica_id)",
13341 is_retained_metrics_object: false,
13342};
13343
13344pub const MZ_CLUSTER_REPLICA_STATUS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13345 name: "mz_cluster_replica_status_history_ind",
13346 schema: MZ_INTERNAL_SCHEMA,
13347 oid: oid::INDEX_MZ_CLUSTER_REPLICA_STATUS_HISTORY_IND_OID,
13348 sql: "IN CLUSTER mz_catalog_server
13349ON mz_internal.mz_cluster_replica_status_history (replica_id)",
13350 is_retained_metrics_object: false,
13351};
13352
13353pub const MZ_CLUSTER_REPLICA_METRICS_IND: BuiltinIndex = BuiltinIndex {
13354 name: "mz_cluster_replica_metrics_ind",
13355 schema: MZ_INTERNAL_SCHEMA,
13356 oid: oid::INDEX_MZ_CLUSTER_REPLICA_METRICS_IND_OID,
13357 sql: "IN CLUSTER mz_catalog_server
13358ON mz_internal.mz_cluster_replica_metrics (replica_id)",
13359 is_retained_metrics_object: false,
13360};
13361
13362pub const MZ_CLUSTER_REPLICA_METRICS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13363 name: "mz_cluster_replica_metrics_history_ind",
13364 schema: MZ_INTERNAL_SCHEMA,
13365 oid: oid::INDEX_MZ_CLUSTER_REPLICA_METRICS_HISTORY_IND_OID,
13366 sql: "IN CLUSTER mz_catalog_server
13367ON mz_internal.mz_cluster_replica_metrics_history (replica_id)",
13368 is_retained_metrics_object: false,
13369};
13370
13371pub const MZ_CLUSTER_REPLICA_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13372 name: "mz_cluster_replica_history_ind",
13373 schema: MZ_INTERNAL_SCHEMA,
13374 oid: oid::INDEX_MZ_CLUSTER_REPLICA_HISTORY_IND_OID,
13375 sql: "IN CLUSTER mz_catalog_server
13376ON mz_internal.mz_cluster_replica_history (dropped_at)",
13377 is_retained_metrics_object: true,
13378};
13379
13380pub const MZ_CLUSTER_REPLICA_NAME_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13381 name: "mz_cluster_replica_name_history_ind",
13382 schema: MZ_INTERNAL_SCHEMA,
13383 oid: oid::INDEX_MZ_CLUSTER_REPLICA_NAME_HISTORY_IND_OID,
13384 sql: "IN CLUSTER mz_catalog_server
13385ON mz_internal.mz_cluster_replica_name_history (id)",
13386 is_retained_metrics_object: false,
13387};
13388
13389pub const MZ_OBJECT_LIFETIMES_IND: BuiltinIndex = BuiltinIndex {
13390 name: "mz_object_lifetimes_ind",
13391 schema: MZ_INTERNAL_SCHEMA,
13392 oid: oid::INDEX_MZ_OBJECT_LIFETIMES_IND_OID,
13393 sql: "IN CLUSTER mz_catalog_server
13394ON mz_internal.mz_object_lifetimes (id)",
13395 is_retained_metrics_object: false,
13396};
13397
13398pub const MZ_OBJECT_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13399 name: "mz_object_history_ind",
13400 schema: MZ_INTERNAL_SCHEMA,
13401 oid: oid::INDEX_MZ_OBJECT_HISTORY_IND_OID,
13402 sql: "IN CLUSTER mz_catalog_server
13403ON mz_internal.mz_object_history (id)",
13404 is_retained_metrics_object: false,
13405};
13406
13407pub const MZ_OBJECT_DEPENDENCIES_IND: BuiltinIndex = BuiltinIndex {
13408 name: "mz_object_dependencies_ind",
13409 schema: MZ_INTERNAL_SCHEMA,
13410 oid: oid::INDEX_MZ_OBJECT_DEPENDENCIES_IND_OID,
13411 sql: "IN CLUSTER mz_catalog_server
13412ON mz_internal.mz_object_dependencies (object_id)",
13413 is_retained_metrics_object: true,
13414};
13415
13416pub const MZ_COMPUTE_DEPENDENCIES_IND: BuiltinIndex = BuiltinIndex {
13417 name: "mz_compute_dependencies_ind",
13418 schema: MZ_INTERNAL_SCHEMA,
13419 oid: oid::INDEX_MZ_COMPUTE_DEPENDENCIES_IND_OID,
13420 sql: "IN CLUSTER mz_catalog_server
13421ON mz_internal.mz_compute_dependencies (dependency_id)",
13422 is_retained_metrics_object: false,
13423};
13424
13425pub const MZ_OBJECT_TRANSITIVE_DEPENDENCIES_IND: BuiltinIndex = BuiltinIndex {
13426 name: "mz_object_transitive_dependencies_ind",
13427 schema: MZ_INTERNAL_SCHEMA,
13428 oid: oid::INDEX_MZ_OBJECT_TRANSITIVE_DEPENDENCIES_IND_OID,
13429 sql: "IN CLUSTER mz_catalog_server
13430ON mz_internal.mz_object_transitive_dependencies (object_id)",
13431 is_retained_metrics_object: false,
13432};
13433
13434pub const MZ_FRONTIERS_IND: BuiltinIndex = BuiltinIndex {
13435 name: "mz_frontiers_ind",
13436 schema: MZ_INTERNAL_SCHEMA,
13437 oid: oid::INDEX_MZ_FRONTIERS_IND_OID,
13438 sql: "IN CLUSTER mz_catalog_server
13439ON mz_internal.mz_frontiers (object_id)",
13440 is_retained_metrics_object: false,
13441};
13442
13443pub const MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13444 name: "mz_wallclock_global_lag_recent_history_ind",
13445 schema: MZ_INTERNAL_SCHEMA,
13446 oid: oid::INDEX_MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_IND_OID,
13447 sql: "IN CLUSTER mz_catalog_server
13448ON mz_internal.mz_wallclock_global_lag_recent_history (object_id)",
13449 is_retained_metrics_object: false,
13450};
13451
13452pub const MZ_RECENT_ACTIVITY_LOG_THINNED_IND: BuiltinIndex = BuiltinIndex {
13453 name: "mz_recent_activity_log_thinned_ind",
13454 schema: MZ_INTERNAL_SCHEMA,
13455 oid: oid::INDEX_MZ_RECENT_ACTIVITY_LOG_THINNED_IND_OID,
13456 sql: "IN CLUSTER mz_catalog_server
13457-- sql_hash because we plan to join
13458-- this against mz_internal.mz_sql_text
13459ON mz_internal.mz_recent_activity_log_thinned (sql_hash)",
13460 is_retained_metrics_object: false,
13461};
13462
13463pub const MZ_KAFKA_SOURCES_IND: BuiltinIndex = BuiltinIndex {
13464 name: "mz_kafka_sources_ind",
13465 schema: MZ_CATALOG_SCHEMA,
13466 oid: oid::INDEX_MZ_KAFKA_SOURCES_IND_OID,
13467 sql: "IN CLUSTER mz_catalog_server
13468ON mz_catalog.mz_kafka_sources (id)",
13469 is_retained_metrics_object: true,
13470};
13471
13472pub const MZ_WEBHOOK_SOURCES_IND: BuiltinIndex = BuiltinIndex {
13473 name: "mz_webhook_sources_ind",
13474 schema: MZ_INTERNAL_SCHEMA,
13475 oid: oid::INDEX_MZ_WEBHOOK_SOURCES_IND_OID,
13476 sql: "IN CLUSTER mz_catalog_server
13477ON mz_internal.mz_webhook_sources (id)",
13478 is_retained_metrics_object: true,
13479};
13480
13481pub const MZ_COMMENTS_IND: BuiltinIndex = BuiltinIndex {
13482 name: "mz_comments_ind",
13483 schema: MZ_INTERNAL_SCHEMA,
13484 oid: oid::INDEX_MZ_COMMENTS_IND_OID,
13485 sql: "IN CLUSTER mz_catalog_server
13486ON mz_internal.mz_comments (id)",
13487 is_retained_metrics_object: true,
13488};
13489
13490pub static MZ_ANALYTICS: BuiltinConnection = BuiltinConnection {
13491 name: "mz_analytics",
13492 schema: MZ_INTERNAL_SCHEMA,
13493 oid: oid::CONNECTION_MZ_ANALYTICS_OID,
13494 sql: "CREATE CONNECTION mz_internal.mz_analytics TO AWS (ASSUME ROLE ARN = '')",
13495 access: &[MzAclItem {
13496 grantee: MZ_SYSTEM_ROLE_ID,
13497 grantor: MZ_ANALYTICS_ROLE_ID,
13498 acl_mode: rbac::all_object_privileges(SystemObjectType::Object(ObjectType::Connection)),
13499 }],
13500 owner_id: &MZ_ANALYTICS_ROLE_ID,
13501 runtime_alterable: true,
13502};
13503
13504pub const MZ_SYSTEM_ROLE: BuiltinRole = BuiltinRole {
13505 id: MZ_SYSTEM_ROLE_ID,
13506 name: SYSTEM_USER_NAME,
13507 oid: oid::ROLE_MZ_SYSTEM_OID,
13508 attributes: RoleAttributesRaw::new().with_all(),
13509};
13510
13511pub const MZ_SUPPORT_ROLE: BuiltinRole = BuiltinRole {
13512 id: MZ_SUPPORT_ROLE_ID,
13513 name: SUPPORT_USER_NAME,
13514 oid: oid::ROLE_MZ_SUPPORT_OID,
13515 attributes: RoleAttributesRaw::new(),
13516};
13517
13518pub const MZ_ANALYTICS_ROLE: BuiltinRole = BuiltinRole {
13519 id: MZ_ANALYTICS_ROLE_ID,
13520 name: ANALYTICS_USER_NAME,
13521 oid: oid::ROLE_MZ_ANALYTICS_OID,
13522 attributes: RoleAttributesRaw::new(),
13523};
13524
13525pub const MZ_MONITOR_ROLE: BuiltinRole = BuiltinRole {
13528 id: MZ_MONITOR_ROLE_ID,
13529 name: "mz_monitor",
13530 oid: oid::ROLE_MZ_MONITOR_OID,
13531 attributes: RoleAttributesRaw::new(),
13532};
13533
13534pub const MZ_MONITOR_REDACTED: BuiltinRole = BuiltinRole {
13537 id: MZ_MONITOR_REDACTED_ROLE_ID,
13538 name: "mz_monitor_redacted",
13539 oid: oid::ROLE_MZ_MONITOR_REDACTED_OID,
13540 attributes: RoleAttributesRaw::new(),
13541};
13542
13543pub const MZ_SYSTEM_CLUSTER: BuiltinCluster = BuiltinCluster {
13544 name: SYSTEM_USER_NAME,
13545 owner_id: &MZ_SYSTEM_ROLE_ID,
13546 privileges: &[
13547 MzAclItem {
13548 grantee: MZ_SUPPORT_ROLE_ID,
13549 grantor: MZ_SYSTEM_ROLE_ID,
13550 acl_mode: AclMode::USAGE,
13551 },
13552 rbac::owner_privilege(ObjectType::Cluster, MZ_SYSTEM_ROLE_ID),
13553 ],
13554};
13555
13556pub const MZ_SYSTEM_CLUSTER_REPLICA: BuiltinClusterReplica = BuiltinClusterReplica {
13557 name: BUILTIN_CLUSTER_REPLICA_NAME,
13558 cluster_name: MZ_SYSTEM_CLUSTER.name,
13559};
13560
13561pub const MZ_CATALOG_SERVER_CLUSTER: BuiltinCluster = BuiltinCluster {
13562 name: "mz_catalog_server",
13563 owner_id: &MZ_SYSTEM_ROLE_ID,
13564 privileges: &[
13565 MzAclItem {
13566 grantee: RoleId::Public,
13567 grantor: MZ_SYSTEM_ROLE_ID,
13568 acl_mode: AclMode::USAGE,
13569 },
13570 MzAclItem {
13571 grantee: MZ_SUPPORT_ROLE_ID,
13572 grantor: MZ_SYSTEM_ROLE_ID,
13573 acl_mode: AclMode::USAGE.union(AclMode::CREATE),
13574 },
13575 rbac::owner_privilege(ObjectType::Cluster, MZ_SYSTEM_ROLE_ID),
13576 ],
13577};
13578
13579pub const MZ_CATALOG_SERVER_CLUSTER_REPLICA: BuiltinClusterReplica = BuiltinClusterReplica {
13580 name: BUILTIN_CLUSTER_REPLICA_NAME,
13581 cluster_name: MZ_CATALOG_SERVER_CLUSTER.name,
13582};
13583
13584pub const MZ_PROBE_CLUSTER: BuiltinCluster = BuiltinCluster {
13585 name: "mz_probe",
13586 owner_id: &MZ_SYSTEM_ROLE_ID,
13587 privileges: &[
13588 MzAclItem {
13589 grantee: MZ_SUPPORT_ROLE_ID,
13590 grantor: MZ_SYSTEM_ROLE_ID,
13591 acl_mode: AclMode::USAGE,
13592 },
13593 MzAclItem {
13594 grantee: MZ_MONITOR_ROLE_ID,
13595 grantor: MZ_SYSTEM_ROLE_ID,
13596 acl_mode: AclMode::USAGE,
13597 },
13598 rbac::owner_privilege(ObjectType::Cluster, MZ_SYSTEM_ROLE_ID),
13599 ],
13600};
13601pub const MZ_PROBE_CLUSTER_REPLICA: BuiltinClusterReplica = BuiltinClusterReplica {
13602 name: BUILTIN_CLUSTER_REPLICA_NAME,
13603 cluster_name: MZ_PROBE_CLUSTER.name,
13604};
13605
13606pub const MZ_SUPPORT_CLUSTER: BuiltinCluster = BuiltinCluster {
13607 name: "mz_support",
13608 owner_id: &MZ_SUPPORT_ROLE_ID,
13609 privileges: &[
13610 MzAclItem {
13611 grantee: MZ_SYSTEM_ROLE_ID,
13612 grantor: MZ_SUPPORT_ROLE_ID,
13613 acl_mode: rbac::all_object_privileges(SystemObjectType::Object(ObjectType::Cluster)),
13614 },
13615 rbac::owner_privilege(ObjectType::Cluster, MZ_SUPPORT_ROLE_ID),
13616 ],
13617};
13618
13619pub const MZ_ANALYTICS_CLUSTER: BuiltinCluster = BuiltinCluster {
13620 name: "mz_analytics",
13621 owner_id: &MZ_ANALYTICS_ROLE_ID,
13622 privileges: &[
13623 MzAclItem {
13624 grantee: MZ_SYSTEM_ROLE_ID,
13625 grantor: MZ_ANALYTICS_ROLE_ID,
13626 acl_mode: rbac::all_object_privileges(SystemObjectType::Object(ObjectType::Cluster)),
13627 },
13628 rbac::owner_privilege(ObjectType::Cluster, MZ_ANALYTICS_ROLE_ID),
13629 ],
13630};
13631
13632pub static BUILTINS_STATIC: LazyLock<Vec<Builtin<NameReference>>> = LazyLock::new(|| {
13634 let mut builtins = vec![
13635 Builtin::Type(&TYPE_ANY),
13636 Builtin::Type(&TYPE_ANYARRAY),
13637 Builtin::Type(&TYPE_ANYELEMENT),
13638 Builtin::Type(&TYPE_ANYNONARRAY),
13639 Builtin::Type(&TYPE_ANYRANGE),
13640 Builtin::Type(&TYPE_BOOL),
13641 Builtin::Type(&TYPE_BOOL_ARRAY),
13642 Builtin::Type(&TYPE_BYTEA),
13643 Builtin::Type(&TYPE_BYTEA_ARRAY),
13644 Builtin::Type(&TYPE_BPCHAR),
13645 Builtin::Type(&TYPE_BPCHAR_ARRAY),
13646 Builtin::Type(&TYPE_CHAR),
13647 Builtin::Type(&TYPE_CHAR_ARRAY),
13648 Builtin::Type(&TYPE_DATE),
13649 Builtin::Type(&TYPE_DATE_ARRAY),
13650 Builtin::Type(&TYPE_FLOAT4),
13651 Builtin::Type(&TYPE_FLOAT4_ARRAY),
13652 Builtin::Type(&TYPE_FLOAT8),
13653 Builtin::Type(&TYPE_FLOAT8_ARRAY),
13654 Builtin::Type(&TYPE_INT4),
13655 Builtin::Type(&TYPE_INT4_ARRAY),
13656 Builtin::Type(&TYPE_INT8),
13657 Builtin::Type(&TYPE_INT8_ARRAY),
13658 Builtin::Type(&TYPE_INTERVAL),
13659 Builtin::Type(&TYPE_INTERVAL_ARRAY),
13660 Builtin::Type(&TYPE_JSONB),
13661 Builtin::Type(&TYPE_JSONB_ARRAY),
13662 Builtin::Type(&TYPE_LIST),
13663 Builtin::Type(&TYPE_MAP),
13664 Builtin::Type(&TYPE_NAME),
13665 Builtin::Type(&TYPE_NAME_ARRAY),
13666 Builtin::Type(&TYPE_NUMERIC),
13667 Builtin::Type(&TYPE_NUMERIC_ARRAY),
13668 Builtin::Type(&TYPE_OID),
13669 Builtin::Type(&TYPE_OID_ARRAY),
13670 Builtin::Type(&TYPE_RECORD),
13671 Builtin::Type(&TYPE_RECORD_ARRAY),
13672 Builtin::Type(&TYPE_REGCLASS),
13673 Builtin::Type(&TYPE_REGCLASS_ARRAY),
13674 Builtin::Type(&TYPE_REGPROC),
13675 Builtin::Type(&TYPE_REGPROC_ARRAY),
13676 Builtin::Type(&TYPE_REGTYPE),
13677 Builtin::Type(&TYPE_REGTYPE_ARRAY),
13678 Builtin::Type(&TYPE_INT2),
13679 Builtin::Type(&TYPE_INT2_ARRAY),
13680 Builtin::Type(&TYPE_TEXT),
13681 Builtin::Type(&TYPE_TEXT_ARRAY),
13682 Builtin::Type(&TYPE_TIME),
13683 Builtin::Type(&TYPE_TIME_ARRAY),
13684 Builtin::Type(&TYPE_TIMESTAMP),
13685 Builtin::Type(&TYPE_TIMESTAMP_ARRAY),
13686 Builtin::Type(&TYPE_TIMESTAMPTZ),
13687 Builtin::Type(&TYPE_TIMESTAMPTZ_ARRAY),
13688 Builtin::Type(&TYPE_UUID),
13689 Builtin::Type(&TYPE_UUID_ARRAY),
13690 Builtin::Type(&TYPE_VARCHAR),
13691 Builtin::Type(&TYPE_VARCHAR_ARRAY),
13692 Builtin::Type(&TYPE_INT2_VECTOR),
13693 Builtin::Type(&TYPE_INT2_VECTOR_ARRAY),
13694 Builtin::Type(&TYPE_ANYCOMPATIBLE),
13695 Builtin::Type(&TYPE_ANYCOMPATIBLEARRAY),
13696 Builtin::Type(&TYPE_ANYCOMPATIBLENONARRAY),
13697 Builtin::Type(&TYPE_ANYCOMPATIBLELIST),
13698 Builtin::Type(&TYPE_ANYCOMPATIBLEMAP),
13699 Builtin::Type(&TYPE_ANYCOMPATIBLERANGE),
13700 Builtin::Type(&TYPE_UINT2),
13701 Builtin::Type(&TYPE_UINT2_ARRAY),
13702 Builtin::Type(&TYPE_UINT4),
13703 Builtin::Type(&TYPE_UINT4_ARRAY),
13704 Builtin::Type(&TYPE_UINT8),
13705 Builtin::Type(&TYPE_UINT8_ARRAY),
13706 Builtin::Type(&TYPE_MZ_TIMESTAMP),
13707 Builtin::Type(&TYPE_MZ_TIMESTAMP_ARRAY),
13708 Builtin::Type(&TYPE_INT4_RANGE),
13709 Builtin::Type(&TYPE_INT4_RANGE_ARRAY),
13710 Builtin::Type(&TYPE_INT8_RANGE),
13711 Builtin::Type(&TYPE_INT8_RANGE_ARRAY),
13712 Builtin::Type(&TYPE_DATE_RANGE),
13713 Builtin::Type(&TYPE_DATE_RANGE_ARRAY),
13714 Builtin::Type(&TYPE_NUM_RANGE),
13715 Builtin::Type(&TYPE_NUM_RANGE_ARRAY),
13716 Builtin::Type(&TYPE_TS_RANGE),
13717 Builtin::Type(&TYPE_TS_RANGE_ARRAY),
13718 Builtin::Type(&TYPE_TSTZ_RANGE),
13719 Builtin::Type(&TYPE_TSTZ_RANGE_ARRAY),
13720 Builtin::Type(&TYPE_MZ_ACL_ITEM),
13721 Builtin::Type(&TYPE_MZ_ACL_ITEM_ARRAY),
13722 Builtin::Type(&TYPE_ACL_ITEM),
13723 Builtin::Type(&TYPE_ACL_ITEM_ARRAY),
13724 Builtin::Type(&TYPE_INTERNAL),
13725 ];
13726 for (schema, funcs) in &[
13727 (PG_CATALOG_SCHEMA, &*mz_sql::func::PG_CATALOG_BUILTINS),
13728 (
13729 INFORMATION_SCHEMA,
13730 &*mz_sql::func::INFORMATION_SCHEMA_BUILTINS,
13731 ),
13732 (MZ_CATALOG_SCHEMA, &*mz_sql::func::MZ_CATALOG_BUILTINS),
13733 (MZ_INTERNAL_SCHEMA, &*mz_sql::func::MZ_INTERNAL_BUILTINS),
13734 (MZ_UNSAFE_SCHEMA, &*mz_sql::func::MZ_UNSAFE_BUILTINS),
13735 ] {
13736 for (name, func) in funcs.iter() {
13737 builtins.push(Builtin::Func(BuiltinFunc {
13738 name,
13739 schema,
13740 inner: func,
13741 }));
13742 }
13743 }
13744 builtins.append(&mut vec![
13745 Builtin::Log(&MZ_ARRANGEMENT_SHARING_RAW),
13746 Builtin::Log(&MZ_ARRANGEMENT_BATCHES_RAW),
13747 Builtin::Log(&MZ_ARRANGEMENT_RECORDS_RAW),
13748 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_RECORDS_RAW),
13749 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_SIZE_RAW),
13750 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_CAPACITY_RAW),
13751 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_ALLOCATIONS_RAW),
13752 Builtin::Log(&MZ_DATAFLOW_CHANNELS_PER_WORKER),
13753 Builtin::Log(&MZ_DATAFLOW_OPERATORS_PER_WORKER),
13754 Builtin::Log(&MZ_DATAFLOW_ADDRESSES_PER_WORKER),
13755 Builtin::Log(&MZ_DATAFLOW_OPERATOR_REACHABILITY_RAW),
13756 Builtin::Log(&MZ_COMPUTE_EXPORTS_PER_WORKER),
13757 Builtin::Log(&MZ_COMPUTE_DATAFLOW_GLOBAL_IDS_PER_WORKER),
13758 Builtin::Log(&MZ_MESSAGE_COUNTS_RECEIVED_RAW),
13759 Builtin::Log(&MZ_MESSAGE_COUNTS_SENT_RAW),
13760 Builtin::Log(&MZ_MESSAGE_BATCH_COUNTS_RECEIVED_RAW),
13761 Builtin::Log(&MZ_MESSAGE_BATCH_COUNTS_SENT_RAW),
13762 Builtin::Log(&MZ_ACTIVE_PEEKS_PER_WORKER),
13763 Builtin::Log(&MZ_PEEK_DURATIONS_HISTOGRAM_RAW),
13764 Builtin::Log(&MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_RAW),
13765 Builtin::Log(&MZ_ARRANGEMENT_HEAP_CAPACITY_RAW),
13766 Builtin::Log(&MZ_ARRANGEMENT_HEAP_ALLOCATIONS_RAW),
13767 Builtin::Log(&MZ_ARRANGEMENT_HEAP_SIZE_RAW),
13768 Builtin::Log(&MZ_SCHEDULING_ELAPSED_RAW),
13769 Builtin::Log(&MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_RAW),
13770 Builtin::Log(&MZ_SCHEDULING_PARKS_HISTOGRAM_RAW),
13771 Builtin::Log(&MZ_COMPUTE_FRONTIERS_PER_WORKER),
13772 Builtin::Log(&MZ_COMPUTE_IMPORT_FRONTIERS_PER_WORKER),
13773 Builtin::Log(&MZ_COMPUTE_ERROR_COUNTS_RAW),
13774 Builtin::Log(&MZ_COMPUTE_HYDRATION_TIMES_PER_WORKER),
13775 Builtin::Log(&MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_PER_WORKER),
13776 Builtin::Table(&MZ_KAFKA_SINKS),
13777 Builtin::Table(&MZ_KAFKA_CONNECTIONS),
13778 Builtin::Table(&MZ_KAFKA_SOURCES),
13779 Builtin::Table(&MZ_OBJECT_DEPENDENCIES),
13780 Builtin::Table(&MZ_ICEBERG_SINKS),
13781 Builtin::Table(&MZ_DATABASES),
13782 Builtin::Table(&MZ_SCHEMAS),
13783 Builtin::Table(&MZ_COLUMNS),
13784 Builtin::Table(&MZ_INDEXES),
13785 Builtin::Table(&MZ_INDEX_COLUMNS),
13786 Builtin::Table(&MZ_TABLES),
13787 Builtin::Table(&MZ_SOURCES),
13788 Builtin::Table(&MZ_SOURCE_REFERENCES),
13789 Builtin::Table(&MZ_POSTGRES_SOURCES),
13790 Builtin::Table(&MZ_POSTGRES_SOURCE_TABLES),
13791 Builtin::Table(&MZ_MYSQL_SOURCE_TABLES),
13792 Builtin::Table(&MZ_SQL_SERVER_SOURCE_TABLES),
13793 Builtin::Table(&MZ_KAFKA_SOURCE_TABLES),
13794 Builtin::Table(&MZ_SINKS),
13795 Builtin::Table(&MZ_VIEWS),
13796 Builtin::Table(&MZ_MATERIALIZED_VIEWS),
13797 Builtin::Table(&MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES),
13798 Builtin::Table(&MZ_TYPES),
13799 Builtin::Table(&MZ_TYPE_PG_METADATA),
13800 Builtin::Table(&MZ_ARRAY_TYPES),
13801 Builtin::Table(&MZ_BASE_TYPES),
13802 Builtin::Table(&MZ_LIST_TYPES),
13803 Builtin::Table(&MZ_MAP_TYPES),
13804 Builtin::Table(&MZ_ROLES),
13805 Builtin::Table(&MZ_ROLE_AUTH),
13806 Builtin::Table(&MZ_ROLE_MEMBERS),
13807 Builtin::Table(&MZ_ROLE_PARAMETERS),
13808 Builtin::Table(&MZ_PSEUDO_TYPES),
13809 Builtin::Table(&MZ_FUNCTIONS),
13810 Builtin::Table(&MZ_OPERATORS),
13811 Builtin::Table(&MZ_AGGREGATES),
13812 Builtin::Table(&MZ_CLUSTERS),
13813 Builtin::Table(&MZ_CLUSTER_WORKLOAD_CLASSES),
13814 Builtin::Table(&MZ_CLUSTER_SCHEDULES),
13815 Builtin::Table(&MZ_SECRETS),
13816 Builtin::Table(&MZ_CONNECTIONS),
13817 Builtin::Table(&MZ_SSH_TUNNEL_CONNECTIONS),
13818 Builtin::Table(&MZ_CLUSTER_REPLICAS),
13819 Builtin::Source(&MZ_CLUSTER_REPLICA_METRICS_HISTORY),
13820 Builtin::View(&MZ_CLUSTER_REPLICA_METRICS),
13821 Builtin::Table(&MZ_CLUSTER_REPLICA_SIZES),
13822 Builtin::Source(&MZ_CLUSTER_REPLICA_STATUS_HISTORY),
13823 Builtin::View(&MZ_CLUSTER_REPLICA_STATUSES),
13824 Builtin::Table(&MZ_INTERNAL_CLUSTER_REPLICAS),
13825 Builtin::Table(&MZ_PENDING_CLUSTER_REPLICAS),
13826 Builtin::Table(&MZ_AUDIT_EVENTS),
13827 Builtin::Table(&MZ_STORAGE_USAGE_BY_SHARD),
13828 Builtin::Table(&MZ_EGRESS_IPS),
13829 Builtin::Table(&MZ_AWS_PRIVATELINK_CONNECTIONS),
13830 Builtin::Table(&MZ_AWS_CONNECTIONS),
13831 Builtin::Table(&MZ_SUBSCRIPTIONS),
13832 Builtin::Table(&MZ_SESSIONS),
13833 Builtin::Table(&MZ_DEFAULT_PRIVILEGES),
13834 Builtin::Table(&MZ_SYSTEM_PRIVILEGES),
13835 Builtin::Table(&MZ_COMMENTS),
13836 Builtin::Table(&MZ_WEBHOOKS_SOURCES),
13837 Builtin::Table(&MZ_HISTORY_RETENTION_STRATEGIES),
13838 Builtin::Table(&MZ_CONTINUAL_TASKS),
13839 Builtin::Table(&MZ_NETWORK_POLICIES),
13840 Builtin::Table(&MZ_NETWORK_POLICY_RULES),
13841 Builtin::Table(&MZ_LICENSE_KEYS),
13842 Builtin::View(&MZ_RELATIONS),
13843 Builtin::View(&MZ_OBJECT_OID_ALIAS),
13844 Builtin::View(&MZ_OBJECTS),
13845 Builtin::View(&MZ_OBJECT_FULLY_QUALIFIED_NAMES),
13846 Builtin::View(&MZ_OBJECTS_ID_NAMESPACE_TYPES),
13847 Builtin::View(&MZ_OBJECT_HISTORY),
13848 Builtin::View(&MZ_OBJECT_LIFETIMES),
13849 Builtin::Table(&MZ_OBJECT_GLOBAL_IDS),
13850 Builtin::View(&MZ_ARRANGEMENT_SHARING_PER_WORKER),
13851 Builtin::View(&MZ_ARRANGEMENT_SHARING),
13852 Builtin::View(&MZ_ARRANGEMENT_SIZES_PER_WORKER),
13853 Builtin::View(&MZ_ARRANGEMENT_SIZES),
13854 Builtin::View(&MZ_DATAFLOWS_PER_WORKER),
13855 Builtin::View(&MZ_DATAFLOWS),
13856 Builtin::View(&MZ_DATAFLOW_ADDRESSES),
13857 Builtin::View(&MZ_DATAFLOW_CHANNELS),
13858 Builtin::View(&MZ_DATAFLOW_OPERATORS),
13859 Builtin::View(&MZ_DATAFLOW_GLOBAL_IDS),
13860 Builtin::View(&MZ_MAPPABLE_OBJECTS),
13861 Builtin::View(&MZ_DATAFLOW_OPERATOR_DATAFLOWS_PER_WORKER),
13862 Builtin::View(&MZ_DATAFLOW_OPERATOR_DATAFLOWS),
13863 Builtin::View(&MZ_OBJECT_TRANSITIVE_DEPENDENCIES),
13864 Builtin::View(&MZ_DATAFLOW_OPERATOR_REACHABILITY_PER_WORKER),
13865 Builtin::View(&MZ_DATAFLOW_OPERATOR_REACHABILITY),
13866 Builtin::View(&MZ_CLUSTER_REPLICA_UTILIZATION),
13867 Builtin::View(&MZ_CLUSTER_REPLICA_UTILIZATION_HISTORY),
13868 Builtin::View(&MZ_DATAFLOW_OPERATOR_PARENTS_PER_WORKER),
13869 Builtin::View(&MZ_DATAFLOW_OPERATOR_PARENTS),
13870 Builtin::View(&MZ_COMPUTE_EXPORTS),
13871 Builtin::View(&MZ_DATAFLOW_ARRANGEMENT_SIZES),
13872 Builtin::View(&MZ_EXPECTED_GROUP_SIZE_ADVICE),
13873 Builtin::View(&MZ_COMPUTE_FRONTIERS),
13874 Builtin::View(&MZ_DATAFLOW_CHANNEL_OPERATORS_PER_WORKER),
13875 Builtin::View(&MZ_DATAFLOW_CHANNEL_OPERATORS),
13876 Builtin::View(&MZ_COMPUTE_IMPORT_FRONTIERS),
13877 Builtin::View(&MZ_MESSAGE_COUNTS_PER_WORKER),
13878 Builtin::View(&MZ_MESSAGE_COUNTS),
13879 Builtin::View(&MZ_ACTIVE_PEEKS),
13880 Builtin::View(&MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_PER_WORKER),
13881 Builtin::View(&MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM),
13882 Builtin::View(&MZ_RECORDS_PER_DATAFLOW_OPERATOR_PER_WORKER),
13883 Builtin::View(&MZ_RECORDS_PER_DATAFLOW_OPERATOR),
13884 Builtin::View(&MZ_RECORDS_PER_DATAFLOW_PER_WORKER),
13885 Builtin::View(&MZ_RECORDS_PER_DATAFLOW),
13886 Builtin::View(&MZ_PEEK_DURATIONS_HISTOGRAM_PER_WORKER),
13887 Builtin::View(&MZ_PEEK_DURATIONS_HISTOGRAM),
13888 Builtin::View(&MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_PER_WORKER),
13889 Builtin::View(&MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM),
13890 Builtin::View(&MZ_SCHEDULING_ELAPSED_PER_WORKER),
13891 Builtin::View(&MZ_SCHEDULING_ELAPSED),
13892 Builtin::View(&MZ_SCHEDULING_PARKS_HISTOGRAM_PER_WORKER),
13893 Builtin::View(&MZ_SCHEDULING_PARKS_HISTOGRAM),
13894 Builtin::View(&MZ_SHOW_ALL_OBJECTS),
13895 Builtin::View(&MZ_SHOW_COLUMNS),
13896 Builtin::View(&MZ_SHOW_CLUSTERS),
13897 Builtin::View(&MZ_SHOW_SECRETS),
13898 Builtin::View(&MZ_SHOW_DATABASES),
13899 Builtin::View(&MZ_SHOW_SCHEMAS),
13900 Builtin::View(&MZ_SHOW_TABLES),
13901 Builtin::View(&MZ_SHOW_VIEWS),
13902 Builtin::View(&MZ_SHOW_TYPES),
13903 Builtin::View(&MZ_SHOW_ROLES),
13904 Builtin::View(&MZ_SHOW_CONNECTIONS),
13905 Builtin::View(&MZ_SHOW_SOURCES),
13906 Builtin::View(&MZ_SHOW_SINKS),
13907 Builtin::View(&MZ_SHOW_MATERIALIZED_VIEWS),
13908 Builtin::View(&MZ_SHOW_INDEXES),
13909 Builtin::View(&MZ_SHOW_CONTINUAL_TASKS),
13910 Builtin::View(&MZ_CLUSTER_REPLICA_HISTORY),
13911 Builtin::View(&MZ_CLUSTER_REPLICA_NAME_HISTORY),
13912 Builtin::View(&MZ_TIMEZONE_NAMES),
13913 Builtin::View(&MZ_TIMEZONE_ABBREVIATIONS),
13914 Builtin::View(&PG_NAMESPACE_ALL_DATABASES),
13915 Builtin::Index(&PG_NAMESPACE_ALL_DATABASES_IND),
13916 Builtin::View(&PG_NAMESPACE),
13917 Builtin::View(&PG_CLASS_ALL_DATABASES),
13918 Builtin::Index(&PG_CLASS_ALL_DATABASES_IND),
13919 Builtin::View(&PG_CLASS),
13920 Builtin::View(&PG_DEPEND),
13921 Builtin::View(&PG_DATABASE),
13922 Builtin::View(&PG_INDEX),
13923 Builtin::View(&PG_TYPE_ALL_DATABASES),
13924 Builtin::Index(&PG_TYPE_ALL_DATABASES_IND),
13925 Builtin::View(&PG_TYPE),
13926 Builtin::View(&PG_DESCRIPTION_ALL_DATABASES),
13927 Builtin::Index(&PG_DESCRIPTION_ALL_DATABASES_IND),
13928 Builtin::View(&PG_DESCRIPTION),
13929 Builtin::View(&PG_ATTRIBUTE_ALL_DATABASES),
13930 Builtin::Index(&PG_ATTRIBUTE_ALL_DATABASES_IND),
13931 Builtin::View(&PG_ATTRIBUTE),
13932 Builtin::View(&PG_PROC),
13933 Builtin::View(&PG_OPERATOR),
13934 Builtin::View(&PG_RANGE),
13935 Builtin::View(&PG_ENUM),
13936 Builtin::View(&PG_ATTRDEF_ALL_DATABASES),
13937 Builtin::Index(&PG_ATTRDEF_ALL_DATABASES_IND),
13938 Builtin::View(&PG_ATTRDEF),
13939 Builtin::View(&PG_SETTINGS),
13940 Builtin::View(&PG_AUTH_MEMBERS),
13941 Builtin::View(&PG_CONSTRAINT),
13942 Builtin::View(&PG_TABLES),
13943 Builtin::View(&PG_TABLESPACE),
13944 Builtin::View(&PG_ACCESS_METHODS),
13945 Builtin::View(&PG_LOCKS),
13946 Builtin::View(&PG_AUTHID),
13947 Builtin::View(&PG_ROLES),
13948 Builtin::View(&PG_USER),
13949 Builtin::View(&PG_VIEWS),
13950 Builtin::View(&PG_MATVIEWS),
13951 Builtin::View(&PG_COLLATION),
13952 Builtin::View(&PG_POLICY),
13953 Builtin::View(&PG_INHERITS),
13954 Builtin::View(&PG_AGGREGATE),
13955 Builtin::View(&PG_TRIGGER),
13956 Builtin::View(&PG_REWRITE),
13957 Builtin::View(&PG_EXTENSION),
13958 Builtin::View(&PG_EVENT_TRIGGER),
13959 Builtin::View(&PG_LANGUAGE),
13960 Builtin::View(&PG_SHDESCRIPTION),
13961 Builtin::View(&PG_INDEXES),
13962 Builtin::View(&PG_TIMEZONE_ABBREVS),
13963 Builtin::View(&PG_TIMEZONE_NAMES),
13964 Builtin::View(&INFORMATION_SCHEMA_APPLICABLE_ROLES),
13965 Builtin::View(&INFORMATION_SCHEMA_COLUMNS),
13966 Builtin::View(&INFORMATION_SCHEMA_ENABLED_ROLES),
13967 Builtin::View(&INFORMATION_SCHEMA_KEY_COLUMN_USAGE),
13968 Builtin::View(&INFORMATION_SCHEMA_REFERENTIAL_CONSTRAINTS),
13969 Builtin::View(&INFORMATION_SCHEMA_ROUTINES),
13970 Builtin::View(&INFORMATION_SCHEMA_SCHEMATA),
13971 Builtin::View(&INFORMATION_SCHEMA_TABLES),
13972 Builtin::View(&INFORMATION_SCHEMA_TABLE_CONSTRAINTS),
13973 Builtin::View(&INFORMATION_SCHEMA_TABLE_PRIVILEGES),
13974 Builtin::View(&INFORMATION_SCHEMA_ROLE_TABLE_GRANTS),
13975 Builtin::View(&INFORMATION_SCHEMA_TRIGGERS),
13976 Builtin::View(&INFORMATION_SCHEMA_VIEWS),
13977 Builtin::View(&INFORMATION_SCHEMA_CHARACTER_SETS),
13978 Builtin::View(&MZ_SHOW_ROLE_MEMBERS),
13979 Builtin::View(&MZ_SHOW_MY_ROLE_MEMBERS),
13980 Builtin::View(&MZ_SHOW_SYSTEM_PRIVILEGES),
13981 Builtin::View(&MZ_SHOW_MY_SYSTEM_PRIVILEGES),
13982 Builtin::View(&MZ_SHOW_CLUSTER_PRIVILEGES),
13983 Builtin::View(&MZ_SHOW_MY_CLUSTER_PRIVILEGES),
13984 Builtin::View(&MZ_SHOW_DATABASE_PRIVILEGES),
13985 Builtin::View(&MZ_SHOW_MY_DATABASE_PRIVILEGES),
13986 Builtin::View(&MZ_SHOW_SCHEMA_PRIVILEGES),
13987 Builtin::View(&MZ_SHOW_MY_SCHEMA_PRIVILEGES),
13988 Builtin::View(&MZ_SHOW_OBJECT_PRIVILEGES),
13989 Builtin::View(&MZ_SHOW_MY_OBJECT_PRIVILEGES),
13990 Builtin::View(&MZ_SHOW_ALL_PRIVILEGES),
13991 Builtin::View(&MZ_SHOW_ALL_MY_PRIVILEGES),
13992 Builtin::View(&MZ_SHOW_DEFAULT_PRIVILEGES),
13993 Builtin::View(&MZ_SHOW_MY_DEFAULT_PRIVILEGES),
13994 Builtin::Source(&MZ_SINK_STATUS_HISTORY),
13995 Builtin::View(&MZ_SINK_STATUSES),
13996 Builtin::Source(&MZ_SOURCE_STATUS_HISTORY),
13997 Builtin::Source(&MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY),
13998 Builtin::View(&MZ_AWS_PRIVATELINK_CONNECTION_STATUSES),
13999 Builtin::Source(&MZ_STATEMENT_EXECUTION_HISTORY),
14000 Builtin::View(&MZ_STATEMENT_EXECUTION_HISTORY_REDACTED),
14001 Builtin::Source(&MZ_PREPARED_STATEMENT_HISTORY),
14002 Builtin::Source(&MZ_SESSION_HISTORY),
14003 Builtin::Source(&MZ_SQL_TEXT),
14004 Builtin::View(&MZ_SQL_TEXT_REDACTED),
14005 Builtin::View(&MZ_RECENT_SQL_TEXT),
14006 Builtin::View(&MZ_RECENT_SQL_TEXT_REDACTED),
14007 Builtin::Index(&MZ_RECENT_SQL_TEXT_IND),
14008 Builtin::View(&MZ_ACTIVITY_LOG_THINNED),
14009 Builtin::View(&MZ_RECENT_ACTIVITY_LOG_THINNED),
14010 Builtin::View(&MZ_RECENT_ACTIVITY_LOG),
14011 Builtin::View(&MZ_RECENT_ACTIVITY_LOG_REDACTED),
14012 Builtin::Index(&MZ_RECENT_ACTIVITY_LOG_THINNED_IND),
14013 Builtin::View(&MZ_SOURCE_STATUSES),
14014 Builtin::Source(&MZ_STATEMENT_LIFECYCLE_HISTORY),
14015 Builtin::Source(&MZ_STORAGE_SHARDS),
14016 Builtin::Source(&MZ_SOURCE_STATISTICS_RAW),
14017 Builtin::Source(&MZ_SINK_STATISTICS_RAW),
14018 Builtin::View(&MZ_SOURCE_STATISTICS_WITH_HISTORY),
14019 Builtin::Index(&MZ_SOURCE_STATISTICS_WITH_HISTORY_IND),
14020 Builtin::View(&MZ_SOURCE_STATISTICS),
14021 Builtin::Index(&MZ_SOURCE_STATISTICS_IND),
14022 Builtin::View(&MZ_SINK_STATISTICS),
14023 Builtin::Index(&MZ_SINK_STATISTICS_IND),
14024 Builtin::View(&MZ_STORAGE_USAGE),
14025 Builtin::Source(&MZ_FRONTIERS),
14026 Builtin::View(&MZ_GLOBAL_FRONTIERS),
14027 Builtin::Source(&MZ_WALLCLOCK_LAG_HISTORY),
14028 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG_HISTORY),
14029 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY),
14030 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG),
14031 Builtin::Source(&MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW),
14032 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM),
14033 Builtin::Source(&MZ_MATERIALIZED_VIEW_REFRESHES),
14034 Builtin::Source(&MZ_COMPUTE_DEPENDENCIES),
14035 Builtin::View(&MZ_MATERIALIZATION_DEPENDENCIES),
14036 Builtin::View(&MZ_MATERIALIZATION_LAG),
14037 Builtin::View(&MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW),
14038 Builtin::View(&MZ_COMPUTE_ERROR_COUNTS_PER_WORKER),
14039 Builtin::View(&MZ_COMPUTE_ERROR_COUNTS),
14040 Builtin::Source(&MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED),
14041 Builtin::Source(&MZ_COMPUTE_HYDRATION_TIMES),
14042 Builtin::Log(&MZ_COMPUTE_LIR_MAPPING_PER_WORKER),
14043 Builtin::View(&MZ_LIR_MAPPING),
14044 Builtin::Source(&MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES),
14045 Builtin::Source(&MZ_CLUSTER_REPLICA_FRONTIERS),
14046 Builtin::View(&MZ_COMPUTE_HYDRATION_STATUSES),
14047 Builtin::View(&MZ_HYDRATION_STATUSES),
14048 Builtin::View(&MZ_SHOW_CLUSTER_REPLICAS),
14049 Builtin::View(&MZ_SHOW_NETWORK_POLICIES),
14050 Builtin::View(&MZ_CLUSTER_DEPLOYMENT_LINEAGE),
14051 Builtin::Index(&MZ_SHOW_DATABASES_IND),
14052 Builtin::Index(&MZ_SHOW_SCHEMAS_IND),
14053 Builtin::Index(&MZ_SHOW_CONNECTIONS_IND),
14054 Builtin::Index(&MZ_SHOW_TABLES_IND),
14055 Builtin::Index(&MZ_SHOW_SOURCES_IND),
14056 Builtin::Index(&MZ_SHOW_VIEWS_IND),
14057 Builtin::Index(&MZ_SHOW_MATERIALIZED_VIEWS_IND),
14058 Builtin::Index(&MZ_SHOW_SINKS_IND),
14059 Builtin::Index(&MZ_SHOW_TYPES_IND),
14060 Builtin::Index(&MZ_SHOW_ALL_OBJECTS_IND),
14061 Builtin::Index(&MZ_SHOW_INDEXES_IND),
14062 Builtin::Index(&MZ_SHOW_COLUMNS_IND),
14063 Builtin::Index(&MZ_SHOW_CLUSTERS_IND),
14064 Builtin::Index(&MZ_SHOW_CLUSTER_REPLICAS_IND),
14065 Builtin::Index(&MZ_SHOW_SECRETS_IND),
14066 Builtin::Index(&MZ_SHOW_ROLES_IND),
14067 Builtin::Index(&MZ_CLUSTERS_IND),
14068 Builtin::Index(&MZ_INDEXES_IND),
14069 Builtin::Index(&MZ_ROLES_IND),
14070 Builtin::Index(&MZ_SOURCES_IND),
14071 Builtin::Index(&MZ_SINKS_IND),
14072 Builtin::Index(&MZ_MATERIALIZED_VIEWS_IND),
14073 Builtin::Index(&MZ_CONTINUAL_TASKS_IND),
14074 Builtin::Index(&MZ_SOURCE_STATUSES_IND),
14075 Builtin::Index(&MZ_SOURCE_STATUS_HISTORY_IND),
14076 Builtin::Index(&MZ_SINK_STATUSES_IND),
14077 Builtin::Index(&MZ_SINK_STATUS_HISTORY_IND),
14078 Builtin::Index(&MZ_CLUSTER_REPLICAS_IND),
14079 Builtin::Index(&MZ_CLUSTER_REPLICA_SIZES_IND),
14080 Builtin::Index(&MZ_CLUSTER_REPLICA_STATUSES_IND),
14081 Builtin::Index(&MZ_CLUSTER_REPLICA_STATUS_HISTORY_IND),
14082 Builtin::Index(&MZ_CLUSTER_REPLICA_METRICS_IND),
14083 Builtin::Index(&MZ_CLUSTER_REPLICA_METRICS_HISTORY_IND),
14084 Builtin::Index(&MZ_CLUSTER_REPLICA_HISTORY_IND),
14085 Builtin::Index(&MZ_CLUSTER_REPLICA_NAME_HISTORY_IND),
14086 Builtin::Index(&MZ_OBJECT_LIFETIMES_IND),
14087 Builtin::Index(&MZ_OBJECT_HISTORY_IND),
14088 Builtin::Index(&MZ_OBJECT_DEPENDENCIES_IND),
14089 Builtin::Index(&MZ_COMPUTE_DEPENDENCIES_IND),
14090 Builtin::Index(&MZ_OBJECT_TRANSITIVE_DEPENDENCIES_IND),
14091 Builtin::Index(&MZ_FRONTIERS_IND),
14092 Builtin::Index(&MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_IND),
14093 Builtin::Index(&MZ_KAFKA_SOURCES_IND),
14094 Builtin::Index(&MZ_WEBHOOK_SOURCES_IND),
14095 Builtin::Index(&MZ_COMMENTS_IND),
14096 Builtin::Index(&MZ_DATABASES_IND),
14097 Builtin::Index(&MZ_SCHEMAS_IND),
14098 Builtin::Index(&MZ_CONNECTIONS_IND),
14099 Builtin::Index(&MZ_TABLES_IND),
14100 Builtin::Index(&MZ_TYPES_IND),
14101 Builtin::Index(&MZ_OBJECTS_IND),
14102 Builtin::Index(&MZ_COLUMNS_IND),
14103 Builtin::Index(&MZ_SECRETS_IND),
14104 Builtin::Index(&MZ_VIEWS_IND),
14105 Builtin::Index(&MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_IND),
14106 Builtin::Index(&MZ_CLUSTER_DEPLOYMENT_LINEAGE_IND),
14107 Builtin::Index(&MZ_CLUSTER_REPLICA_FRONTIERS_IND),
14108 Builtin::Index(&MZ_COMPUTE_HYDRATION_TIMES_IND),
14109 Builtin::View(&MZ_RECENT_STORAGE_USAGE),
14110 Builtin::Index(&MZ_RECENT_STORAGE_USAGE_IND),
14111 Builtin::Connection(&MZ_ANALYTICS),
14112 Builtin::ContinualTask(&MZ_CLUSTER_REPLICA_METRICS_HISTORY_CT),
14113 Builtin::ContinualTask(&MZ_CLUSTER_REPLICA_STATUS_HISTORY_CT),
14114 Builtin::ContinualTask(&MZ_WALLCLOCK_LAG_HISTORY_CT),
14115 Builtin::View(&MZ_INDEX_ADVICE),
14116 ]);
14117
14118 builtins.extend(notice::builtins());
14119
14120 builtins
14121});
14122pub const BUILTIN_ROLES: &[&BuiltinRole] = &[
14123 &MZ_SYSTEM_ROLE,
14124 &MZ_SUPPORT_ROLE,
14125 &MZ_ANALYTICS_ROLE,
14126 &MZ_MONITOR_ROLE,
14127 &MZ_MONITOR_REDACTED,
14128];
14129pub const BUILTIN_CLUSTERS: &[&BuiltinCluster] = &[
14130 &MZ_SYSTEM_CLUSTER,
14131 &MZ_CATALOG_SERVER_CLUSTER,
14132 &MZ_PROBE_CLUSTER,
14133 &MZ_SUPPORT_CLUSTER,
14134 &MZ_ANALYTICS_CLUSTER,
14135];
14136pub const BUILTIN_CLUSTER_REPLICAS: &[&BuiltinClusterReplica] = &[
14137 &MZ_SYSTEM_CLUSTER_REPLICA,
14138 &MZ_CATALOG_SERVER_CLUSTER_REPLICA,
14139 &MZ_PROBE_CLUSTER_REPLICA,
14140];
14141
14142#[allow(non_snake_case)]
14143pub mod BUILTINS {
14144 use mz_sql::catalog::BuiltinsConfig;
14145
14146 use super::*;
14147
14148 pub fn logs() -> impl Iterator<Item = &'static BuiltinLog> {
14149 BUILTINS_STATIC.iter().filter_map(|b| match b {
14150 Builtin::Log(log) => Some(*log),
14151 _ => None,
14152 })
14153 }
14154
14155 pub fn types() -> impl Iterator<Item = &'static BuiltinType<NameReference>> {
14156 BUILTINS_STATIC.iter().filter_map(|b| match b {
14157 Builtin::Type(typ) => Some(*typ),
14158 _ => None,
14159 })
14160 }
14161
14162 pub fn views() -> impl Iterator<Item = &'static BuiltinView> {
14163 BUILTINS_STATIC.iter().filter_map(|b| match b {
14164 Builtin::View(view) => Some(*view),
14165 _ => None,
14166 })
14167 }
14168
14169 pub fn funcs() -> impl Iterator<Item = &'static BuiltinFunc> {
14170 BUILTINS_STATIC.iter().filter_map(|b| match b {
14171 Builtin::Func(func) => Some(func),
14172 _ => None,
14173 })
14174 }
14175
14176 pub fn iter(cfg: &BuiltinsConfig) -> impl Iterator<Item = &'static Builtin<NameReference>> {
14177 let include_continual_tasks = cfg.include_continual_tasks;
14178 BUILTINS_STATIC.iter().filter(move |x| match x {
14179 Builtin::ContinualTask(_) if !include_continual_tasks => false,
14180 _ => true,
14181 })
14182 }
14183}
14184
14185pub static BUILTIN_LOG_LOOKUP: LazyLock<HashMap<&'static str, &'static BuiltinLog>> =
14186 LazyLock::new(|| BUILTINS::logs().map(|log| (log.name, log)).collect());
14187pub static BUILTIN_LOOKUP: LazyLock<
14190 HashMap<SystemObjectDescription, (usize, &'static Builtin<NameReference>)>,
14191> = LazyLock::new(|| {
14192 BUILTINS_STATIC
14197 .iter()
14198 .enumerate()
14199 .map(|(idx, builtin)| {
14200 (
14201 SystemObjectDescription {
14202 schema_name: builtin.schema().to_string(),
14203 object_type: builtin.catalog_item_type(),
14204 object_name: builtin.name().to_string(),
14205 },
14206 (idx, builtin),
14207 )
14208 })
14209 .collect()
14210});
14211
14212#[mz_ore::test]
14213#[cfg_attr(miri, ignore)] fn test_builtin_type_schema() {
14215 use mz_pgrepr::oid::FIRST_MATERIALIZE_OID;
14216
14217 for typ in BUILTINS::types() {
14218 if typ.oid < FIRST_MATERIALIZE_OID {
14219 assert_eq!(
14220 typ.schema, PG_CATALOG_SCHEMA,
14221 "{typ:?} should be in {PG_CATALOG_SCHEMA} schema"
14222 );
14223 } else {
14224 assert_eq!(
14227 typ.schema, MZ_CATALOG_SCHEMA,
14228 "{typ:?} should be in {MZ_CATALOG_SCHEMA} schema"
14229 );
14230 }
14231 }
14232}