1pub mod notice;
26
27use std::collections::BTreeMap;
28use std::hash::Hash;
29use std::string::ToString;
30use std::sync::LazyLock;
31use std::sync::Mutex;
32
33use clap::clap_derive::ValueEnum;
34use mz_compute_client::logging::{ComputeLog, DifferentialLog, LogVariant, TimelyLog};
35use mz_ore::collections::HashMap;
36use mz_pgrepr::oid;
37use mz_repr::adt::mz_acl_item::{AclMode, MzAclItem};
38use mz_repr::adt::numeric::NumericMaxScale;
39use mz_repr::namespaces::{
40 INFORMATION_SCHEMA, MZ_CATALOG_SCHEMA, MZ_INTERNAL_SCHEMA, MZ_INTROSPECTION_SCHEMA,
41 MZ_UNSAFE_SCHEMA, PG_CATALOG_SCHEMA,
42};
43use mz_repr::role_id::RoleId;
44use mz_repr::{RelationDesc, SqlRelationType, SqlScalarType};
45use mz_sql::catalog::RoleAttributesRaw;
46use mz_sql::catalog::{
47 CatalogItemType, CatalogType, CatalogTypeDetails, CatalogTypePgMetadata, NameReference,
48 ObjectType, SystemObjectType, TypeReference,
49};
50use mz_sql::rbac;
51use mz_sql::session::user::{
52 ANALYTICS_USER_NAME, MZ_ANALYTICS_ROLE_ID, MZ_MONITOR_REDACTED_ROLE_ID, MZ_MONITOR_ROLE_ID,
53 MZ_SUPPORT_ROLE_ID, MZ_SYSTEM_ROLE_ID, SUPPORT_USER_NAME, SYSTEM_USER_NAME,
54};
55use mz_storage_client::controller::IntrospectionType;
56use mz_storage_client::healthcheck::WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW_DESC;
57use mz_storage_client::healthcheck::{
58 MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_DESC, MZ_PREPARED_STATEMENT_HISTORY_DESC,
59 MZ_SESSION_HISTORY_DESC, MZ_SINK_STATUS_HISTORY_DESC, MZ_SOURCE_STATUS_HISTORY_DESC,
60 MZ_SQL_TEXT_DESC, MZ_STATEMENT_EXECUTION_HISTORY_DESC, REPLICA_METRICS_HISTORY_DESC,
61 REPLICA_STATUS_HISTORY_DESC, WALLCLOCK_LAG_HISTORY_DESC,
62};
63use mz_storage_client::statistics::{MZ_SINK_STATISTICS_RAW_DESC, MZ_SOURCE_STATISTICS_RAW_DESC};
64use rand::Rng;
65use serde::Serialize;
66
67use crate::durable::objects::SystemObjectDescription;
68
69pub const BUILTIN_PREFIXES: &[&str] = &["mz_", "pg_", "external_"];
70const BUILTIN_CLUSTER_REPLICA_NAME: &str = "r1";
71
72pub const RUNTIME_ALTERABLE_FINGERPRINT_SENTINEL: &str = "<RUNTIME-ALTERABLE>";
88
89#[derive(Debug)]
90pub enum Builtin<T: 'static + TypeReference> {
91 Log(&'static BuiltinLog),
92 Table(&'static BuiltinTable),
93 View(&'static BuiltinView),
94 Type(&'static BuiltinType<T>),
95 Func(BuiltinFunc),
96 Source(&'static BuiltinSource),
97 ContinualTask(&'static BuiltinContinualTask),
98 Index(&'static BuiltinIndex),
99 Connection(&'static BuiltinConnection),
100}
101
102impl<T: TypeReference> Builtin<T> {
103 pub fn name(&self) -> &'static str {
104 match self {
105 Builtin::Log(log) => log.name,
106 Builtin::Table(table) => table.name,
107 Builtin::View(view) => view.name,
108 Builtin::Type(typ) => typ.name,
109 Builtin::Func(func) => func.name,
110 Builtin::Source(coll) => coll.name,
111 Builtin::ContinualTask(ct) => ct.name,
112 Builtin::Index(index) => index.name,
113 Builtin::Connection(connection) => connection.name,
114 }
115 }
116
117 pub fn schema(&self) -> &'static str {
118 match self {
119 Builtin::Log(log) => log.schema,
120 Builtin::Table(table) => table.schema,
121 Builtin::View(view) => view.schema,
122 Builtin::Type(typ) => typ.schema,
123 Builtin::Func(func) => func.schema,
124 Builtin::Source(coll) => coll.schema,
125 Builtin::ContinualTask(ct) => ct.schema,
126 Builtin::Index(index) => index.schema,
127 Builtin::Connection(connection) => connection.schema,
128 }
129 }
130
131 pub fn catalog_item_type(&self) -> CatalogItemType {
132 match self {
133 Builtin::Log(_) => CatalogItemType::Source,
134 Builtin::Source(_) => CatalogItemType::Source,
135 Builtin::ContinualTask(_) => CatalogItemType::ContinualTask,
136 Builtin::Table(_) => CatalogItemType::Table,
137 Builtin::View(_) => CatalogItemType::View,
138 Builtin::Type(_) => CatalogItemType::Type,
139 Builtin::Func(_) => CatalogItemType::Func,
140 Builtin::Index(_) => CatalogItemType::Index,
141 Builtin::Connection(_) => CatalogItemType::Connection,
142 }
143 }
144
145 pub fn runtime_alterable(&self) -> bool {
147 match self {
148 Builtin::Connection(c) => c.runtime_alterable,
149 _ => false,
150 }
151 }
152}
153
154#[derive(Clone, Debug, Hash, Serialize)]
155pub struct BuiltinLog {
156 pub variant: LogVariant,
157 pub name: &'static str,
158 pub schema: &'static str,
159 pub oid: u32,
160 pub access: Vec<MzAclItem>,
162}
163
164#[derive(Hash, Debug, PartialEq, Eq)]
165pub struct BuiltinTable {
166 pub name: &'static str,
167 pub schema: &'static str,
168 pub oid: u32,
169 pub desc: RelationDesc,
170 pub column_comments: BTreeMap<&'static str, &'static str>,
171 pub is_retained_metrics_object: bool,
174 pub access: Vec<MzAclItem>,
176}
177
178#[derive(Clone, Debug, Hash, Serialize)]
179pub struct BuiltinSource {
180 pub name: &'static str,
181 pub schema: &'static str,
182 pub oid: u32,
183 pub desc: RelationDesc,
184 pub column_comments: BTreeMap<&'static str, &'static str>,
185 pub data_source: IntrospectionType,
186 pub is_retained_metrics_object: bool,
189 pub access: Vec<MzAclItem>,
191}
192
193#[derive(Hash, Debug, PartialEq, Eq)]
194pub struct BuiltinContinualTask {
195 pub name: &'static str,
196 pub schema: &'static str,
197 pub oid: u32,
198 pub desc: RelationDesc,
199 pub sql: &'static str,
200 pub access: Vec<MzAclItem>,
202}
203
204#[derive(Hash, Debug)]
205pub struct BuiltinView {
206 pub name: &'static str,
207 pub schema: &'static str,
208 pub oid: u32,
209 pub desc: RelationDesc,
210 pub column_comments: BTreeMap<&'static str, &'static str>,
211 pub sql: &'static str,
212 pub access: Vec<MzAclItem>,
214}
215
216impl BuiltinView {
217 pub fn create_sql(&self) -> String {
218 format!("CREATE VIEW {}.{} AS {}", self.schema, self.name, self.sql)
219 }
220}
221
222#[derive(Debug)]
223pub struct BuiltinType<T: TypeReference> {
224 pub name: &'static str,
225 pub schema: &'static str,
226 pub oid: u32,
227 pub details: CatalogTypeDetails<T>,
228}
229
230#[derive(Debug)]
231pub struct BuiltinFunc {
232 pub schema: &'static str,
233 pub name: &'static str,
234 pub inner: &'static mz_sql::func::Func,
235}
236
237#[derive(Debug)]
243pub struct BuiltinIndex {
244 pub name: &'static str,
245 pub schema: &'static str,
246 pub oid: u32,
247 pub sql: &'static str,
251 pub is_retained_metrics_object: bool,
252}
253
254impl BuiltinIndex {
255 pub fn create_sql(&self) -> String {
256 format!("CREATE INDEX {}\n{}", self.name, self.sql)
257 }
258}
259
260impl BuiltinContinualTask {
261 pub fn create_sql(&self) -> String {
262 format!(
263 "CREATE CONTINUAL TASK {}.{}\n{}",
264 self.schema, self.name, self.sql
265 )
266 }
267}
268
269#[derive(Hash, Debug)]
270pub struct BuiltinConnection {
271 pub name: &'static str,
272 pub schema: &'static str,
273 pub oid: u32,
274 pub sql: &'static str,
275 pub access: &'static [MzAclItem],
276 pub owner_id: &'static RoleId,
277 pub runtime_alterable: bool,
282}
283
284#[derive(Clone, Debug)]
285pub struct BuiltinRole {
286 pub id: RoleId,
287 pub name: &'static str,
291 pub oid: u32,
292 pub attributes: RoleAttributesRaw,
293}
294
295#[derive(Clone, Debug)]
296pub struct BuiltinCluster {
297 pub name: &'static str,
301 pub privileges: &'static [MzAclItem],
302 pub owner_id: &'static RoleId,
303}
304
305#[derive(Clone, Debug, PartialEq, Eq)]
306pub struct BuiltinClusterReplica {
307 pub name: &'static str,
309 pub cluster_name: &'static str,
311}
312
313pub trait Fingerprint {
315 fn fingerprint(&self) -> String;
316}
317
318impl<T: TypeReference> Fingerprint for &Builtin<T> {
319 fn fingerprint(&self) -> String {
320 match self {
321 Builtin::Log(log) => log.fingerprint(),
322 Builtin::Table(table) => table.fingerprint(),
323 Builtin::View(view) => view.fingerprint(),
324 Builtin::Type(typ) => typ.fingerprint(),
325 Builtin::Func(func) => func.fingerprint(),
326 Builtin::Source(coll) => coll.fingerprint(),
327 Builtin::ContinualTask(ct) => ct.fingerprint(),
328 Builtin::Index(index) => index.fingerprint(),
329 Builtin::Connection(connection) => connection.fingerprint(),
330 }
331 }
332}
333
334impl<T: TypeReference> Fingerprint for &BuiltinType<T> {
336 fn fingerprint(&self) -> String {
337 "".to_string()
338 }
339}
340
341impl Fingerprint for &BuiltinFunc {
342 fn fingerprint(&self) -> String {
343 "".to_string()
344 }
345}
346
347impl Fingerprint for &BuiltinLog {
348 fn fingerprint(&self) -> String {
349 self.variant.desc().fingerprint()
350 }
351}
352
353#[derive(Debug, Clone, ValueEnum)]
356pub enum UnsafeBuiltinTableFingerprintWhitespace {
357 All,
359 Half,
362}
363pub static UNSAFE_DO_NOT_CALL_THIS_IN_PRODUCTION_BUILTIN_TABLE_FINGERPRINT_WHITESPACE: Mutex<
364 Option<(UnsafeBuiltinTableFingerprintWhitespace, String)>,
365> = Mutex::new(None);
366
367impl Fingerprint for &BuiltinTable {
368 fn fingerprint(&self) -> String {
369 let guard = UNSAFE_DO_NOT_CALL_THIS_IN_PRODUCTION_BUILTIN_TABLE_FINGERPRINT_WHITESPACE
372 .lock()
373 .expect("lock poisoned");
374 match &*guard {
375 _ if self.schema == MZ_STORAGE_USAGE_BY_SHARD.schema
377 && self.name == MZ_STORAGE_USAGE_BY_SHARD.name =>
378 {
379 self.desc.fingerprint()
380 }
381 Some((UnsafeBuiltinTableFingerprintWhitespace::All, whitespace)) => {
382 format!("{}{}", self.desc.fingerprint(), whitespace)
383 }
384 Some((UnsafeBuiltinTableFingerprintWhitespace::Half, whitespace)) => {
385 let mut rng = rand::thread_rng();
386 let migrate: bool = rng.r#gen();
387 if migrate {
388 format!("{}{}", self.desc.fingerprint(), whitespace)
389 } else {
390 self.desc.fingerprint()
391 }
392 }
393 None => self.desc.fingerprint(),
394 }
395 }
396}
397
398impl Fingerprint for &BuiltinView {
399 fn fingerprint(&self) -> String {
400 self.sql.to_string()
401 }
402}
403
404impl Fingerprint for &BuiltinSource {
405 fn fingerprint(&self) -> String {
406 self.desc.fingerprint()
407 }
408}
409
410impl Fingerprint for &BuiltinContinualTask {
411 fn fingerprint(&self) -> String {
412 self.create_sql()
413 }
414}
415
416impl Fingerprint for &BuiltinIndex {
417 fn fingerprint(&self) -> String {
418 self.create_sql()
419 }
420}
421
422impl Fingerprint for &BuiltinConnection {
423 fn fingerprint(&self) -> String {
424 self.sql.to_string()
425 }
426}
427
428impl Fingerprint for RelationDesc {
429 fn fingerprint(&self) -> String {
430 self.typ().fingerprint()
431 }
432}
433
434impl Fingerprint for SqlRelationType {
435 fn fingerprint(&self) -> String {
436 serde_json::to_string(self).expect("serialization cannot fail")
437 }
438}
439
440pub const TYPE_BOOL: BuiltinType<NameReference> = BuiltinType {
460 name: "bool",
461 schema: PG_CATALOG_SCHEMA,
462 oid: oid::TYPE_BOOL_OID,
463 details: CatalogTypeDetails {
464 typ: CatalogType::Bool,
465 array_id: None,
466 pg_metadata: Some(CatalogTypePgMetadata {
467 typinput_oid: 1242,
468 typreceive_oid: 2436,
469 }),
470 },
471};
472
473pub const TYPE_BYTEA: BuiltinType<NameReference> = BuiltinType {
474 name: "bytea",
475 schema: PG_CATALOG_SCHEMA,
476 oid: oid::TYPE_BYTEA_OID,
477 details: CatalogTypeDetails {
478 typ: CatalogType::Bytes,
479 array_id: None,
480 pg_metadata: Some(CatalogTypePgMetadata {
481 typinput_oid: 1244,
482 typreceive_oid: 2412,
483 }),
484 },
485};
486
487pub const TYPE_INT8: BuiltinType<NameReference> = BuiltinType {
488 name: "int8",
489 schema: PG_CATALOG_SCHEMA,
490 oid: oid::TYPE_INT8_OID,
491 details: CatalogTypeDetails {
492 typ: CatalogType::Int64,
493 array_id: None,
494 pg_metadata: Some(CatalogTypePgMetadata {
495 typinput_oid: 460,
496 typreceive_oid: 2408,
497 }),
498 },
499};
500
501pub const TYPE_INT4: BuiltinType<NameReference> = BuiltinType {
502 name: "int4",
503 schema: PG_CATALOG_SCHEMA,
504 oid: oid::TYPE_INT4_OID,
505 details: CatalogTypeDetails {
506 typ: CatalogType::Int32,
507 array_id: None,
508 pg_metadata: Some(CatalogTypePgMetadata {
509 typinput_oid: 42,
510 typreceive_oid: 2406,
511 }),
512 },
513};
514
515pub const TYPE_TEXT: BuiltinType<NameReference> = BuiltinType {
516 name: "text",
517 schema: PG_CATALOG_SCHEMA,
518 oid: oid::TYPE_TEXT_OID,
519 details: CatalogTypeDetails {
520 typ: CatalogType::String,
521 array_id: None,
522 pg_metadata: Some(CatalogTypePgMetadata {
523 typinput_oid: 46,
524 typreceive_oid: 2414,
525 }),
526 },
527};
528
529pub const TYPE_OID: BuiltinType<NameReference> = BuiltinType {
530 name: "oid",
531 schema: PG_CATALOG_SCHEMA,
532 oid: oid::TYPE_OID_OID,
533 details: CatalogTypeDetails {
534 typ: CatalogType::Oid,
535 array_id: None,
536 pg_metadata: Some(CatalogTypePgMetadata {
537 typinput_oid: 1798,
538 typreceive_oid: 2418,
539 }),
540 },
541};
542
543pub const TYPE_FLOAT4: BuiltinType<NameReference> = BuiltinType {
544 name: "float4",
545 schema: PG_CATALOG_SCHEMA,
546 oid: oid::TYPE_FLOAT4_OID,
547 details: CatalogTypeDetails {
548 typ: CatalogType::Float32,
549 array_id: None,
550 pg_metadata: Some(CatalogTypePgMetadata {
551 typinput_oid: 200,
552 typreceive_oid: 2424,
553 }),
554 },
555};
556
557pub const TYPE_FLOAT8: BuiltinType<NameReference> = BuiltinType {
558 name: "float8",
559 schema: PG_CATALOG_SCHEMA,
560 oid: oid::TYPE_FLOAT8_OID,
561 details: CatalogTypeDetails {
562 typ: CatalogType::Float64,
563 array_id: None,
564 pg_metadata: Some(CatalogTypePgMetadata {
565 typinput_oid: 214,
566 typreceive_oid: 2426,
567 }),
568 },
569};
570
571pub const TYPE_BOOL_ARRAY: BuiltinType<NameReference> = BuiltinType {
572 name: "_bool",
573 schema: PG_CATALOG_SCHEMA,
574 oid: oid::TYPE_BOOL_ARRAY_OID,
575 details: CatalogTypeDetails {
576 typ: CatalogType::Array {
577 element_reference: TYPE_BOOL.name,
578 },
579 array_id: None,
580 pg_metadata: Some(CatalogTypePgMetadata {
581 typinput_oid: 750,
582 typreceive_oid: 2400,
583 }),
584 },
585};
586
587pub const TYPE_BYTEA_ARRAY: BuiltinType<NameReference> = BuiltinType {
588 name: "_bytea",
589 schema: PG_CATALOG_SCHEMA,
590 oid: oid::TYPE_BYTEA_ARRAY_OID,
591 details: CatalogTypeDetails {
592 typ: CatalogType::Array {
593 element_reference: TYPE_BYTEA.name,
594 },
595 array_id: None,
596 pg_metadata: Some(CatalogTypePgMetadata {
597 typinput_oid: 750,
598 typreceive_oid: 2400,
599 }),
600 },
601};
602
603pub const TYPE_INT4_ARRAY: BuiltinType<NameReference> = BuiltinType {
604 name: "_int4",
605 schema: PG_CATALOG_SCHEMA,
606 oid: oid::TYPE_INT4_ARRAY_OID,
607 details: CatalogTypeDetails {
608 typ: CatalogType::Array {
609 element_reference: TYPE_INT4.name,
610 },
611 array_id: None,
612 pg_metadata: Some(CatalogTypePgMetadata {
613 typinput_oid: 750,
614 typreceive_oid: 2400,
615 }),
616 },
617};
618
619pub const TYPE_TEXT_ARRAY: BuiltinType<NameReference> = BuiltinType {
620 name: "_text",
621 schema: PG_CATALOG_SCHEMA,
622 oid: oid::TYPE_TEXT_ARRAY_OID,
623 details: CatalogTypeDetails {
624 typ: CatalogType::Array {
625 element_reference: TYPE_TEXT.name,
626 },
627 array_id: None,
628 pg_metadata: Some(CatalogTypePgMetadata {
629 typinput_oid: 750,
630 typreceive_oid: 2400,
631 }),
632 },
633};
634
635pub const TYPE_INT8_ARRAY: BuiltinType<NameReference> = BuiltinType {
636 name: "_int8",
637 schema: PG_CATALOG_SCHEMA,
638 oid: oid::TYPE_INT8_ARRAY_OID,
639 details: CatalogTypeDetails {
640 typ: CatalogType::Array {
641 element_reference: TYPE_INT8.name,
642 },
643 array_id: None,
644 pg_metadata: Some(CatalogTypePgMetadata {
645 typinput_oid: 750,
646 typreceive_oid: 2400,
647 }),
648 },
649};
650
651pub const TYPE_FLOAT4_ARRAY: BuiltinType<NameReference> = BuiltinType {
652 name: "_float4",
653 schema: PG_CATALOG_SCHEMA,
654 oid: oid::TYPE_FLOAT4_ARRAY_OID,
655 details: CatalogTypeDetails {
656 typ: CatalogType::Array {
657 element_reference: TYPE_FLOAT4.name,
658 },
659 array_id: None,
660 pg_metadata: Some(CatalogTypePgMetadata {
661 typinput_oid: 750,
662 typreceive_oid: 2400,
663 }),
664 },
665};
666
667pub const TYPE_FLOAT8_ARRAY: BuiltinType<NameReference> = BuiltinType {
668 name: "_float8",
669 schema: PG_CATALOG_SCHEMA,
670 oid: oid::TYPE_FLOAT8_ARRAY_OID,
671 details: CatalogTypeDetails {
672 typ: CatalogType::Array {
673 element_reference: TYPE_FLOAT8.name,
674 },
675 array_id: None,
676 pg_metadata: Some(CatalogTypePgMetadata {
677 typinput_oid: 750,
678 typreceive_oid: 2400,
679 }),
680 },
681};
682
683pub const TYPE_OID_ARRAY: BuiltinType<NameReference> = BuiltinType {
684 name: "_oid",
685 schema: PG_CATALOG_SCHEMA,
686 oid: oid::TYPE_OID_ARRAY_OID,
687 details: CatalogTypeDetails {
688 typ: CatalogType::Array {
689 element_reference: TYPE_OID.name,
690 },
691 array_id: None,
692 pg_metadata: Some(CatalogTypePgMetadata {
693 typinput_oid: 750,
694 typreceive_oid: 2400,
695 }),
696 },
697};
698
699pub const TYPE_DATE: BuiltinType<NameReference> = BuiltinType {
700 name: "date",
701 schema: PG_CATALOG_SCHEMA,
702 oid: oid::TYPE_DATE_OID,
703 details: CatalogTypeDetails {
704 typ: CatalogType::Date,
705 array_id: None,
706 pg_metadata: Some(CatalogTypePgMetadata {
707 typinput_oid: 1084,
708 typreceive_oid: 2468,
709 }),
710 },
711};
712
713pub const TYPE_TIME: BuiltinType<NameReference> = BuiltinType {
714 name: "time",
715 schema: PG_CATALOG_SCHEMA,
716 oid: oid::TYPE_TIME_OID,
717 details: CatalogTypeDetails {
718 typ: CatalogType::Time,
719 array_id: None,
720 pg_metadata: Some(CatalogTypePgMetadata {
721 typinput_oid: 1143,
722 typreceive_oid: 2470,
723 }),
724 },
725};
726
727pub const TYPE_TIMESTAMP: BuiltinType<NameReference> = BuiltinType {
728 name: "timestamp",
729 schema: PG_CATALOG_SCHEMA,
730 oid: oid::TYPE_TIMESTAMP_OID,
731 details: CatalogTypeDetails {
732 typ: CatalogType::Timestamp,
733 array_id: None,
734 pg_metadata: Some(CatalogTypePgMetadata {
735 typinput_oid: 1312,
736 typreceive_oid: 2474,
737 }),
738 },
739};
740
741pub const TYPE_TIMESTAMP_ARRAY: BuiltinType<NameReference> = BuiltinType {
742 name: "_timestamp",
743 schema: PG_CATALOG_SCHEMA,
744 oid: oid::TYPE_TIMESTAMP_ARRAY_OID,
745 details: CatalogTypeDetails {
746 typ: CatalogType::Array {
747 element_reference: TYPE_TIMESTAMP.name,
748 },
749 array_id: None,
750 pg_metadata: Some(CatalogTypePgMetadata {
751 typinput_oid: 750,
752 typreceive_oid: 2400,
753 }),
754 },
755};
756
757pub const TYPE_DATE_ARRAY: BuiltinType<NameReference> = BuiltinType {
758 name: "_date",
759 schema: PG_CATALOG_SCHEMA,
760 oid: oid::TYPE_DATE_ARRAY_OID,
761 details: CatalogTypeDetails {
762 typ: CatalogType::Array {
763 element_reference: TYPE_DATE.name,
764 },
765 array_id: None,
766 pg_metadata: Some(CatalogTypePgMetadata {
767 typinput_oid: 750,
768 typreceive_oid: 2400,
769 }),
770 },
771};
772
773pub const TYPE_TIME_ARRAY: BuiltinType<NameReference> = BuiltinType {
774 name: "_time",
775 schema: PG_CATALOG_SCHEMA,
776 oid: oid::TYPE_TIME_ARRAY_OID,
777 details: CatalogTypeDetails {
778 typ: CatalogType::Array {
779 element_reference: TYPE_TIME.name,
780 },
781 array_id: None,
782 pg_metadata: Some(CatalogTypePgMetadata {
783 typinput_oid: 750,
784 typreceive_oid: 2400,
785 }),
786 },
787};
788
789pub const TYPE_TIMESTAMPTZ: BuiltinType<NameReference> = BuiltinType {
790 name: "timestamptz",
791 schema: PG_CATALOG_SCHEMA,
792 oid: oid::TYPE_TIMESTAMPTZ_OID,
793 details: CatalogTypeDetails {
794 typ: CatalogType::TimestampTz,
795 array_id: None,
796 pg_metadata: Some(CatalogTypePgMetadata {
797 typinput_oid: 1150,
798 typreceive_oid: 2476,
799 }),
800 },
801};
802
803pub const TYPE_TIMESTAMPTZ_ARRAY: BuiltinType<NameReference> = BuiltinType {
804 name: "_timestamptz",
805 schema: PG_CATALOG_SCHEMA,
806 oid: oid::TYPE_TIMESTAMPTZ_ARRAY_OID,
807 details: CatalogTypeDetails {
808 typ: CatalogType::Array {
809 element_reference: TYPE_TIMESTAMPTZ.name,
810 },
811 array_id: None,
812 pg_metadata: Some(CatalogTypePgMetadata {
813 typinput_oid: 750,
814 typreceive_oid: 2400,
815 }),
816 },
817};
818
819pub const TYPE_INTERVAL: BuiltinType<NameReference> = BuiltinType {
820 name: "interval",
821 schema: PG_CATALOG_SCHEMA,
822 oid: oid::TYPE_INTERVAL_OID,
823 details: CatalogTypeDetails {
824 typ: CatalogType::Interval,
825 array_id: None,
826 pg_metadata: Some(CatalogTypePgMetadata {
827 typinput_oid: 1160,
828 typreceive_oid: 2478,
829 }),
830 },
831};
832
833pub const TYPE_INTERVAL_ARRAY: BuiltinType<NameReference> = BuiltinType {
834 name: "_interval",
835 schema: PG_CATALOG_SCHEMA,
836 oid: oid::TYPE_INTERVAL_ARRAY_OID,
837 details: CatalogTypeDetails {
838 typ: CatalogType::Array {
839 element_reference: TYPE_INTERVAL.name,
840 },
841 array_id: None,
842 pg_metadata: Some(CatalogTypePgMetadata {
843 typinput_oid: 750,
844 typreceive_oid: 2400,
845 }),
846 },
847};
848
849pub const TYPE_NAME: BuiltinType<NameReference> = BuiltinType {
850 name: "name",
851 schema: PG_CATALOG_SCHEMA,
852 oid: oid::TYPE_NAME_OID,
853 details: CatalogTypeDetails {
854 typ: CatalogType::PgLegacyName,
855 array_id: None,
856 pg_metadata: Some(CatalogTypePgMetadata {
857 typinput_oid: 34,
858 typreceive_oid: 2422,
859 }),
860 },
861};
862
863pub const TYPE_NAME_ARRAY: BuiltinType<NameReference> = BuiltinType {
864 name: "_name",
865 schema: PG_CATALOG_SCHEMA,
866 oid: oid::TYPE_NAME_ARRAY_OID,
867 details: CatalogTypeDetails {
868 typ: CatalogType::Array {
869 element_reference: TYPE_NAME.name,
870 },
871 array_id: None,
872 pg_metadata: Some(CatalogTypePgMetadata {
873 typinput_oid: 750,
874 typreceive_oid: 2400,
875 }),
876 },
877};
878
879pub const TYPE_NUMERIC: BuiltinType<NameReference> = BuiltinType {
880 name: "numeric",
881 schema: PG_CATALOG_SCHEMA,
882 oid: oid::TYPE_NUMERIC_OID,
883 details: CatalogTypeDetails {
884 typ: CatalogType::Numeric,
885 array_id: None,
886 pg_metadata: Some(CatalogTypePgMetadata {
887 typinput_oid: 1701,
888 typreceive_oid: 2460,
889 }),
890 },
891};
892
893pub const TYPE_NUMERIC_ARRAY: BuiltinType<NameReference> = BuiltinType {
894 name: "_numeric",
895 schema: PG_CATALOG_SCHEMA,
896 oid: oid::TYPE_NUMERIC_ARRAY_OID,
897 details: CatalogTypeDetails {
898 typ: CatalogType::Array {
899 element_reference: TYPE_NUMERIC.name,
900 },
901 array_id: None,
902 pg_metadata: Some(CatalogTypePgMetadata {
903 typinput_oid: 750,
904 typreceive_oid: 2400,
905 }),
906 },
907};
908
909pub const TYPE_RECORD: BuiltinType<NameReference> = BuiltinType {
910 name: "record",
911 schema: PG_CATALOG_SCHEMA,
912 oid: oid::TYPE_RECORD_OID,
913 details: CatalogTypeDetails {
914 typ: CatalogType::Pseudo,
915 array_id: None,
916 pg_metadata: Some(CatalogTypePgMetadata {
917 typinput_oid: 2290,
918 typreceive_oid: 2402,
919 }),
920 },
921};
922
923pub const TYPE_RECORD_ARRAY: BuiltinType<NameReference> = BuiltinType {
924 name: "_record",
925 schema: PG_CATALOG_SCHEMA,
926 oid: oid::TYPE_RECORD_ARRAY_OID,
927 details: CatalogTypeDetails {
928 typ: CatalogType::Array {
929 element_reference: TYPE_RECORD.name,
930 },
931 array_id: None,
932 pg_metadata: Some(CatalogTypePgMetadata {
933 typinput_oid: 750,
934 typreceive_oid: 2400,
935 }),
936 },
937};
938
939pub const TYPE_UUID: BuiltinType<NameReference> = BuiltinType {
940 name: "uuid",
941 schema: PG_CATALOG_SCHEMA,
942 oid: oid::TYPE_UUID_OID,
943 details: CatalogTypeDetails {
944 typ: CatalogType::Uuid,
945 array_id: None,
946 pg_metadata: Some(CatalogTypePgMetadata {
947 typinput_oid: 2952,
948 typreceive_oid: 2961,
949 }),
950 },
951};
952
953pub const TYPE_UUID_ARRAY: BuiltinType<NameReference> = BuiltinType {
954 name: "_uuid",
955 schema: PG_CATALOG_SCHEMA,
956 oid: oid::TYPE_UUID_ARRAY_OID,
957 details: CatalogTypeDetails {
958 typ: CatalogType::Array {
959 element_reference: TYPE_UUID.name,
960 },
961 array_id: None,
962 pg_metadata: Some(CatalogTypePgMetadata {
963 typinput_oid: 750,
964 typreceive_oid: 2400,
965 }),
966 },
967};
968
969pub const TYPE_JSONB: BuiltinType<NameReference> = BuiltinType {
970 name: "jsonb",
971 schema: PG_CATALOG_SCHEMA,
972 oid: oid::TYPE_JSONB_OID,
973 details: CatalogTypeDetails {
974 typ: CatalogType::Jsonb,
975 array_id: None,
976 pg_metadata: Some(CatalogTypePgMetadata {
977 typinput_oid: 3806,
978 typreceive_oid: 3805,
979 }),
980 },
981};
982
983pub const TYPE_JSONB_ARRAY: BuiltinType<NameReference> = BuiltinType {
984 name: "_jsonb",
985 schema: PG_CATALOG_SCHEMA,
986 oid: oid::TYPE_JSONB_ARRAY_OID,
987 details: CatalogTypeDetails {
988 typ: CatalogType::Array {
989 element_reference: TYPE_JSONB.name,
990 },
991 array_id: None,
992 pg_metadata: Some(CatalogTypePgMetadata {
993 typinput_oid: 750,
994 typreceive_oid: 2400,
995 }),
996 },
997};
998
999pub const TYPE_ANY: BuiltinType<NameReference> = BuiltinType {
1000 name: "any",
1001 schema: PG_CATALOG_SCHEMA,
1002 oid: oid::TYPE_ANY_OID,
1003 details: CatalogTypeDetails {
1004 typ: CatalogType::Pseudo,
1005 array_id: None,
1006 pg_metadata: Some(CatalogTypePgMetadata {
1007 typinput_oid: 2294,
1008 typreceive_oid: 0,
1009 }),
1010 },
1011};
1012
1013pub const TYPE_ANYARRAY: BuiltinType<NameReference> = BuiltinType {
1014 name: "anyarray",
1015 schema: PG_CATALOG_SCHEMA,
1016 oid: oid::TYPE_ANYARRAY_OID,
1017 details: CatalogTypeDetails {
1018 typ: CatalogType::Pseudo,
1019 array_id: None,
1020 pg_metadata: Some(CatalogTypePgMetadata {
1021 typinput_oid: 2296,
1022 typreceive_oid: 2502,
1023 }),
1024 },
1025};
1026
1027pub const TYPE_ANYELEMENT: BuiltinType<NameReference> = BuiltinType {
1028 name: "anyelement",
1029 schema: PG_CATALOG_SCHEMA,
1030 oid: oid::TYPE_ANYELEMENT_OID,
1031 details: CatalogTypeDetails {
1032 typ: CatalogType::Pseudo,
1033 array_id: None,
1034 pg_metadata: Some(CatalogTypePgMetadata {
1035 typinput_oid: 2312,
1036 typreceive_oid: 0,
1037 }),
1038 },
1039};
1040
1041pub const TYPE_ANYNONARRAY: BuiltinType<NameReference> = BuiltinType {
1042 name: "anynonarray",
1043 schema: PG_CATALOG_SCHEMA,
1044 oid: oid::TYPE_ANYNONARRAY_OID,
1045 details: CatalogTypeDetails {
1046 typ: CatalogType::Pseudo,
1047 array_id: None,
1048 pg_metadata: Some(CatalogTypePgMetadata {
1049 typinput_oid: 2777,
1050 typreceive_oid: 0,
1051 }),
1052 },
1053};
1054
1055pub const TYPE_ANYRANGE: BuiltinType<NameReference> = BuiltinType {
1056 name: "anyrange",
1057 schema: PG_CATALOG_SCHEMA,
1058 oid: oid::TYPE_ANYRANGE_OID,
1059 details: CatalogTypeDetails {
1060 typ: CatalogType::Pseudo,
1061 array_id: None,
1062 pg_metadata: Some(CatalogTypePgMetadata {
1063 typinput_oid: 3832,
1064 typreceive_oid: 0,
1065 }),
1066 },
1067};
1068
1069pub const TYPE_CHAR: BuiltinType<NameReference> = BuiltinType {
1070 name: "char",
1071 schema: PG_CATALOG_SCHEMA,
1072 oid: oid::TYPE_CHAR_OID,
1073 details: CatalogTypeDetails {
1074 typ: CatalogType::PgLegacyChar,
1075 array_id: None,
1076 pg_metadata: Some(CatalogTypePgMetadata {
1077 typinput_oid: 1245,
1078 typreceive_oid: 2434,
1079 }),
1080 },
1081};
1082
1083pub const TYPE_VARCHAR: BuiltinType<NameReference> = BuiltinType {
1084 name: "varchar",
1085 schema: PG_CATALOG_SCHEMA,
1086 oid: oid::TYPE_VARCHAR_OID,
1087 details: CatalogTypeDetails {
1088 typ: CatalogType::VarChar,
1089 array_id: None,
1090 pg_metadata: Some(CatalogTypePgMetadata {
1091 typinput_oid: 1046,
1092 typreceive_oid: 2432,
1093 }),
1094 },
1095};
1096
1097pub const TYPE_INT2: BuiltinType<NameReference> = BuiltinType {
1098 name: "int2",
1099 schema: PG_CATALOG_SCHEMA,
1100 oid: oid::TYPE_INT2_OID,
1101 details: CatalogTypeDetails {
1102 typ: CatalogType::Int16,
1103 array_id: None,
1104 pg_metadata: Some(CatalogTypePgMetadata {
1105 typinput_oid: 38,
1106 typreceive_oid: 2404,
1107 }),
1108 },
1109};
1110
1111pub const TYPE_INT2_ARRAY: BuiltinType<NameReference> = BuiltinType {
1112 name: "_int2",
1113 schema: PG_CATALOG_SCHEMA,
1114 oid: oid::TYPE_INT2_ARRAY_OID,
1115 details: CatalogTypeDetails {
1116 typ: CatalogType::Array {
1117 element_reference: TYPE_INT2.name,
1118 },
1119 array_id: None,
1120 pg_metadata: Some(CatalogTypePgMetadata {
1121 typinput_oid: 750,
1122 typreceive_oid: 2400,
1123 }),
1124 },
1125};
1126
1127pub const TYPE_BPCHAR: BuiltinType<NameReference> = BuiltinType {
1128 name: "bpchar",
1129 schema: PG_CATALOG_SCHEMA,
1130 oid: oid::TYPE_BPCHAR_OID,
1131 details: CatalogTypeDetails {
1132 typ: CatalogType::Char,
1133 array_id: None,
1134 pg_metadata: Some(CatalogTypePgMetadata {
1135 typinput_oid: 1044,
1136 typreceive_oid: 2430,
1137 }),
1138 },
1139};
1140
1141pub const TYPE_CHAR_ARRAY: BuiltinType<NameReference> = BuiltinType {
1142 name: "_char",
1143 schema: PG_CATALOG_SCHEMA,
1144 oid: oid::TYPE_CHAR_ARRAY_OID,
1145 details: CatalogTypeDetails {
1146 typ: CatalogType::Array {
1147 element_reference: TYPE_CHAR.name,
1148 },
1149 array_id: None,
1150 pg_metadata: Some(CatalogTypePgMetadata {
1151 typinput_oid: 750,
1152 typreceive_oid: 2400,
1153 }),
1154 },
1155};
1156
1157pub const TYPE_VARCHAR_ARRAY: BuiltinType<NameReference> = BuiltinType {
1158 name: "_varchar",
1159 schema: PG_CATALOG_SCHEMA,
1160 oid: oid::TYPE_VARCHAR_ARRAY_OID,
1161 details: CatalogTypeDetails {
1162 typ: CatalogType::Array {
1163 element_reference: TYPE_VARCHAR.name,
1164 },
1165 array_id: None,
1166 pg_metadata: Some(CatalogTypePgMetadata {
1167 typinput_oid: 750,
1168 typreceive_oid: 2400,
1169 }),
1170 },
1171};
1172
1173pub const TYPE_BPCHAR_ARRAY: BuiltinType<NameReference> = BuiltinType {
1174 name: "_bpchar",
1175 schema: PG_CATALOG_SCHEMA,
1176 oid: oid::TYPE_BPCHAR_ARRAY_OID,
1177 details: CatalogTypeDetails {
1178 typ: CatalogType::Array {
1179 element_reference: TYPE_BPCHAR.name,
1180 },
1181 array_id: None,
1182 pg_metadata: Some(CatalogTypePgMetadata {
1183 typinput_oid: 750,
1184 typreceive_oid: 2400,
1185 }),
1186 },
1187};
1188
1189pub const TYPE_REGPROC: BuiltinType<NameReference> = BuiltinType {
1190 name: "regproc",
1191 schema: PG_CATALOG_SCHEMA,
1192 oid: oid::TYPE_REGPROC_OID,
1193 details: CatalogTypeDetails {
1194 typ: CatalogType::RegProc,
1195 array_id: None,
1196 pg_metadata: Some(CatalogTypePgMetadata {
1197 typinput_oid: 44,
1198 typreceive_oid: 2444,
1199 }),
1200 },
1201};
1202
1203pub const TYPE_REGPROC_ARRAY: BuiltinType<NameReference> = BuiltinType {
1204 name: "_regproc",
1205 schema: PG_CATALOG_SCHEMA,
1206 oid: oid::TYPE_REGPROC_ARRAY_OID,
1207 details: CatalogTypeDetails {
1208 typ: CatalogType::Array {
1209 element_reference: TYPE_REGPROC.name,
1210 },
1211 array_id: None,
1212 pg_metadata: Some(CatalogTypePgMetadata {
1213 typinput_oid: 750,
1214 typreceive_oid: 2400,
1215 }),
1216 },
1217};
1218
1219pub const TYPE_REGTYPE: BuiltinType<NameReference> = BuiltinType {
1220 name: "regtype",
1221 schema: PG_CATALOG_SCHEMA,
1222 oid: oid::TYPE_REGTYPE_OID,
1223 details: CatalogTypeDetails {
1224 typ: CatalogType::RegType,
1225 array_id: None,
1226 pg_metadata: Some(CatalogTypePgMetadata {
1227 typinput_oid: 2220,
1228 typreceive_oid: 2454,
1229 }),
1230 },
1231};
1232
1233pub const TYPE_REGTYPE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1234 name: "_regtype",
1235 schema: PG_CATALOG_SCHEMA,
1236 oid: oid::TYPE_REGTYPE_ARRAY_OID,
1237 details: CatalogTypeDetails {
1238 typ: CatalogType::Array {
1239 element_reference: TYPE_REGTYPE.name,
1240 },
1241 array_id: None,
1242 pg_metadata: Some(CatalogTypePgMetadata {
1243 typinput_oid: 750,
1244 typreceive_oid: 2400,
1245 }),
1246 },
1247};
1248
1249pub const TYPE_REGCLASS: BuiltinType<NameReference> = BuiltinType {
1250 name: "regclass",
1251 schema: PG_CATALOG_SCHEMA,
1252 oid: oid::TYPE_REGCLASS_OID,
1253 details: CatalogTypeDetails {
1254 typ: CatalogType::RegClass,
1255 array_id: None,
1256 pg_metadata: Some(CatalogTypePgMetadata {
1257 typinput_oid: 2218,
1258 typreceive_oid: 2452,
1259 }),
1260 },
1261};
1262
1263pub const TYPE_REGCLASS_ARRAY: BuiltinType<NameReference> = BuiltinType {
1264 name: "_regclass",
1265 schema: PG_CATALOG_SCHEMA,
1266 oid: oid::TYPE_REGCLASS_ARRAY_OID,
1267 details: CatalogTypeDetails {
1268 typ: CatalogType::Array {
1269 element_reference: TYPE_REGCLASS.name,
1270 },
1271 array_id: None,
1272 pg_metadata: Some(CatalogTypePgMetadata {
1273 typinput_oid: 750,
1274 typreceive_oid: 2400,
1275 }),
1276 },
1277};
1278
1279pub const TYPE_INT2_VECTOR: BuiltinType<NameReference> = BuiltinType {
1280 name: "int2vector",
1281 schema: PG_CATALOG_SCHEMA,
1282 oid: oid::TYPE_INT2_VECTOR_OID,
1283 details: CatalogTypeDetails {
1284 typ: CatalogType::Int2Vector,
1285 array_id: None,
1286 pg_metadata: Some(CatalogTypePgMetadata {
1287 typinput_oid: 40,
1288 typreceive_oid: 2410,
1289 }),
1290 },
1291};
1292
1293pub const TYPE_INT2_VECTOR_ARRAY: BuiltinType<NameReference> = BuiltinType {
1294 name: "_int2vector",
1295 schema: PG_CATALOG_SCHEMA,
1296 oid: oid::TYPE_INT2_VECTOR_ARRAY_OID,
1297 details: CatalogTypeDetails {
1298 typ: CatalogType::Array {
1299 element_reference: TYPE_INT2_VECTOR.name,
1300 },
1301 array_id: None,
1302 pg_metadata: Some(CatalogTypePgMetadata {
1303 typinput_oid: 750,
1304 typreceive_oid: 2400,
1305 }),
1306 },
1307};
1308
1309pub const TYPE_ANYCOMPATIBLE: BuiltinType<NameReference> = BuiltinType {
1310 name: "anycompatible",
1311 schema: PG_CATALOG_SCHEMA,
1312 oid: oid::TYPE_ANYCOMPATIBLE_OID,
1313 details: CatalogTypeDetails {
1314 typ: CatalogType::Pseudo,
1315 array_id: None,
1316 pg_metadata: Some(CatalogTypePgMetadata {
1317 typinput_oid: 5086,
1318 typreceive_oid: 0,
1319 }),
1320 },
1321};
1322
1323pub const TYPE_ANYCOMPATIBLEARRAY: BuiltinType<NameReference> = BuiltinType {
1324 name: "anycompatiblearray",
1325 schema: PG_CATALOG_SCHEMA,
1326 oid: oid::TYPE_ANYCOMPATIBLEARRAY_OID,
1327 details: CatalogTypeDetails {
1328 typ: CatalogType::Pseudo,
1329 array_id: None,
1330 pg_metadata: Some(CatalogTypePgMetadata {
1331 typinput_oid: 5088,
1332 typreceive_oid: 5090,
1333 }),
1334 },
1335};
1336
1337pub const TYPE_ANYCOMPATIBLENONARRAY: BuiltinType<NameReference> = BuiltinType {
1338 name: "anycompatiblenonarray",
1339 schema: PG_CATALOG_SCHEMA,
1340 oid: oid::TYPE_ANYCOMPATIBLENONARRAY_OID,
1341 details: CatalogTypeDetails {
1342 typ: CatalogType::Pseudo,
1343 array_id: None,
1344 pg_metadata: Some(CatalogTypePgMetadata {
1345 typinput_oid: 5092,
1346 typreceive_oid: 0,
1347 }),
1348 },
1349};
1350
1351pub const TYPE_ANYCOMPATIBLERANGE: BuiltinType<NameReference> = BuiltinType {
1352 name: "anycompatiblerange",
1353 schema: PG_CATALOG_SCHEMA,
1354 oid: oid::TYPE_ANYCOMPATIBLERANGE_OID,
1355 details: CatalogTypeDetails {
1356 typ: CatalogType::Pseudo,
1357 array_id: None,
1358 pg_metadata: Some(CatalogTypePgMetadata {
1359 typinput_oid: 5094,
1360 typreceive_oid: 0,
1361 }),
1362 },
1363};
1364
1365pub const TYPE_LIST: BuiltinType<NameReference> = BuiltinType {
1366 name: "list",
1367 schema: MZ_CATALOG_SCHEMA,
1368 oid: mz_pgrepr::oid::TYPE_LIST_OID,
1369 details: CatalogTypeDetails {
1370 typ: CatalogType::Pseudo,
1371 array_id: None,
1372 pg_metadata: None,
1373 },
1374};
1375
1376pub const TYPE_MAP: BuiltinType<NameReference> = BuiltinType {
1377 name: "map",
1378 schema: MZ_CATALOG_SCHEMA,
1379 oid: mz_pgrepr::oid::TYPE_MAP_OID,
1380 details: CatalogTypeDetails {
1381 typ: CatalogType::Pseudo,
1382 array_id: None,
1383 pg_metadata: None,
1384 },
1385};
1386
1387pub const TYPE_ANYCOMPATIBLELIST: BuiltinType<NameReference> = BuiltinType {
1388 name: "anycompatiblelist",
1389 schema: MZ_CATALOG_SCHEMA,
1390 oid: mz_pgrepr::oid::TYPE_ANYCOMPATIBLELIST_OID,
1391 details: CatalogTypeDetails {
1392 typ: CatalogType::Pseudo,
1393 array_id: None,
1394 pg_metadata: None,
1395 },
1396};
1397
1398pub const TYPE_ANYCOMPATIBLEMAP: BuiltinType<NameReference> = BuiltinType {
1399 name: "anycompatiblemap",
1400 schema: MZ_CATALOG_SCHEMA,
1401 oid: mz_pgrepr::oid::TYPE_ANYCOMPATIBLEMAP_OID,
1402 details: CatalogTypeDetails {
1403 typ: CatalogType::Pseudo,
1404 array_id: None,
1405 pg_metadata: None,
1406 },
1407};
1408
1409pub const TYPE_UINT2: BuiltinType<NameReference> = BuiltinType {
1410 name: "uint2",
1411 schema: MZ_CATALOG_SCHEMA,
1412 oid: mz_pgrepr::oid::TYPE_UINT2_OID,
1413 details: CatalogTypeDetails {
1414 typ: CatalogType::UInt16,
1415 array_id: None,
1416 pg_metadata: None,
1417 },
1418};
1419
1420pub const TYPE_UINT2_ARRAY: BuiltinType<NameReference> = BuiltinType {
1421 name: "_uint2",
1422 schema: MZ_CATALOG_SCHEMA,
1423 oid: mz_pgrepr::oid::TYPE_UINT2_ARRAY_OID,
1424 details: CatalogTypeDetails {
1425 typ: CatalogType::Array {
1426 element_reference: TYPE_UINT2.name,
1427 },
1428 array_id: None,
1429 pg_metadata: None,
1430 },
1431};
1432
1433pub const TYPE_UINT4: BuiltinType<NameReference> = BuiltinType {
1434 name: "uint4",
1435 schema: MZ_CATALOG_SCHEMA,
1436 oid: mz_pgrepr::oid::TYPE_UINT4_OID,
1437 details: CatalogTypeDetails {
1438 typ: CatalogType::UInt32,
1439 array_id: None,
1440 pg_metadata: None,
1441 },
1442};
1443
1444pub const TYPE_UINT4_ARRAY: BuiltinType<NameReference> = BuiltinType {
1445 name: "_uint4",
1446 schema: MZ_CATALOG_SCHEMA,
1447 oid: mz_pgrepr::oid::TYPE_UINT4_ARRAY_OID,
1448 details: CatalogTypeDetails {
1449 typ: CatalogType::Array {
1450 element_reference: TYPE_UINT4.name,
1451 },
1452 array_id: None,
1453 pg_metadata: None,
1454 },
1455};
1456
1457pub const TYPE_UINT8: BuiltinType<NameReference> = BuiltinType {
1458 name: "uint8",
1459 schema: MZ_CATALOG_SCHEMA,
1460 oid: mz_pgrepr::oid::TYPE_UINT8_OID,
1461 details: CatalogTypeDetails {
1462 typ: CatalogType::UInt64,
1463 array_id: None,
1464 pg_metadata: None,
1465 },
1466};
1467
1468pub const TYPE_UINT8_ARRAY: BuiltinType<NameReference> = BuiltinType {
1469 name: "_uint8",
1470 schema: MZ_CATALOG_SCHEMA,
1471 oid: mz_pgrepr::oid::TYPE_UINT8_ARRAY_OID,
1472 details: CatalogTypeDetails {
1473 typ: CatalogType::Array {
1474 element_reference: TYPE_UINT8.name,
1475 },
1476 array_id: None,
1477 pg_metadata: None,
1478 },
1479};
1480
1481pub const TYPE_MZ_TIMESTAMP: BuiltinType<NameReference> = BuiltinType {
1482 name: "mz_timestamp",
1483 schema: MZ_CATALOG_SCHEMA,
1484 oid: mz_pgrepr::oid::TYPE_MZ_TIMESTAMP_OID,
1485 details: CatalogTypeDetails {
1486 typ: CatalogType::MzTimestamp,
1487 array_id: None,
1488 pg_metadata: None,
1489 },
1490};
1491
1492pub const TYPE_MZ_TIMESTAMP_ARRAY: BuiltinType<NameReference> = BuiltinType {
1493 name: "_mz_timestamp",
1494 schema: MZ_CATALOG_SCHEMA,
1495 oid: mz_pgrepr::oid::TYPE_MZ_TIMESTAMP_ARRAY_OID,
1496 details: CatalogTypeDetails {
1497 typ: CatalogType::Array {
1498 element_reference: TYPE_MZ_TIMESTAMP.name,
1499 },
1500 array_id: None,
1501 pg_metadata: None,
1502 },
1503};
1504
1505pub const TYPE_INT4_RANGE: BuiltinType<NameReference> = BuiltinType {
1506 name: "int4range",
1507 schema: PG_CATALOG_SCHEMA,
1508 oid: mz_pgrepr::oid::TYPE_INT4RANGE_OID,
1509 details: CatalogTypeDetails {
1510 typ: CatalogType::Range {
1511 element_reference: TYPE_INT4.name,
1512 },
1513 array_id: None,
1514 pg_metadata: Some(CatalogTypePgMetadata {
1515 typinput_oid: 3834,
1516 typreceive_oid: 3836,
1517 }),
1518 },
1519};
1520
1521pub const TYPE_INT4_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1522 name: "_int4range",
1523 schema: PG_CATALOG_SCHEMA,
1524 oid: mz_pgrepr::oid::TYPE_INT4RANGE_ARRAY_OID,
1525 details: CatalogTypeDetails {
1526 typ: CatalogType::Array {
1527 element_reference: TYPE_INT4_RANGE.name,
1528 },
1529 array_id: None,
1530 pg_metadata: Some(CatalogTypePgMetadata {
1531 typinput_oid: 750,
1532 typreceive_oid: 2400,
1533 }),
1534 },
1535};
1536
1537pub const TYPE_INT8_RANGE: BuiltinType<NameReference> = BuiltinType {
1538 name: "int8range",
1539 schema: PG_CATALOG_SCHEMA,
1540 oid: mz_pgrepr::oid::TYPE_INT8RANGE_OID,
1541 details: CatalogTypeDetails {
1542 typ: CatalogType::Range {
1543 element_reference: TYPE_INT8.name,
1544 },
1545 array_id: None,
1546 pg_metadata: Some(CatalogTypePgMetadata {
1547 typinput_oid: 3834,
1548 typreceive_oid: 3836,
1549 }),
1550 },
1551};
1552
1553pub const TYPE_INT8_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1554 name: "_int8range",
1555 schema: PG_CATALOG_SCHEMA,
1556 oid: mz_pgrepr::oid::TYPE_INT8RANGE_ARRAY_OID,
1557 details: CatalogTypeDetails {
1558 typ: CatalogType::Array {
1559 element_reference: TYPE_INT8_RANGE.name,
1560 },
1561 array_id: None,
1562 pg_metadata: Some(CatalogTypePgMetadata {
1563 typinput_oid: 750,
1564 typreceive_oid: 2400,
1565 }),
1566 },
1567};
1568
1569pub const TYPE_DATE_RANGE: BuiltinType<NameReference> = BuiltinType {
1570 name: "daterange",
1571 schema: PG_CATALOG_SCHEMA,
1572 oid: mz_pgrepr::oid::TYPE_DATERANGE_OID,
1573 details: CatalogTypeDetails {
1574 typ: CatalogType::Range {
1575 element_reference: TYPE_DATE.name,
1576 },
1577 array_id: None,
1578 pg_metadata: Some(CatalogTypePgMetadata {
1579 typinput_oid: 3834,
1580 typreceive_oid: 3836,
1581 }),
1582 },
1583};
1584
1585pub const TYPE_DATE_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1586 name: "_daterange",
1587 schema: PG_CATALOG_SCHEMA,
1588 oid: mz_pgrepr::oid::TYPE_DATERANGE_ARRAY_OID,
1589 details: CatalogTypeDetails {
1590 typ: CatalogType::Array {
1591 element_reference: TYPE_DATE_RANGE.name,
1592 },
1593 array_id: None,
1594 pg_metadata: Some(CatalogTypePgMetadata {
1595 typinput_oid: 750,
1596 typreceive_oid: 2400,
1597 }),
1598 },
1599};
1600
1601pub const TYPE_NUM_RANGE: BuiltinType<NameReference> = BuiltinType {
1602 name: "numrange",
1603 schema: PG_CATALOG_SCHEMA,
1604 oid: mz_pgrepr::oid::TYPE_NUMRANGE_OID,
1605 details: CatalogTypeDetails {
1606 typ: CatalogType::Range {
1607 element_reference: TYPE_NUMERIC.name,
1608 },
1609 array_id: None,
1610 pg_metadata: Some(CatalogTypePgMetadata {
1611 typinput_oid: 3834,
1612 typreceive_oid: 3836,
1613 }),
1614 },
1615};
1616
1617pub const TYPE_NUM_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1618 name: "_numrange",
1619 schema: PG_CATALOG_SCHEMA,
1620 oid: mz_pgrepr::oid::TYPE_NUMRANGE_ARRAY_OID,
1621 details: CatalogTypeDetails {
1622 typ: CatalogType::Array {
1623 element_reference: TYPE_NUM_RANGE.name,
1624 },
1625 array_id: None,
1626 pg_metadata: Some(CatalogTypePgMetadata {
1627 typinput_oid: 750,
1628 typreceive_oid: 2400,
1629 }),
1630 },
1631};
1632
1633pub const TYPE_TS_RANGE: BuiltinType<NameReference> = BuiltinType {
1634 name: "tsrange",
1635 schema: PG_CATALOG_SCHEMA,
1636 oid: mz_pgrepr::oid::TYPE_TSRANGE_OID,
1637 details: CatalogTypeDetails {
1638 typ: CatalogType::Range {
1639 element_reference: TYPE_TIMESTAMP.name,
1640 },
1641 array_id: None,
1642 pg_metadata: Some(CatalogTypePgMetadata {
1643 typinput_oid: 3834,
1644 typreceive_oid: 3836,
1645 }),
1646 },
1647};
1648
1649pub const TYPE_TS_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1650 name: "_tsrange",
1651 schema: PG_CATALOG_SCHEMA,
1652 oid: mz_pgrepr::oid::TYPE_TSRANGE_ARRAY_OID,
1653 details: CatalogTypeDetails {
1654 typ: CatalogType::Array {
1655 element_reference: TYPE_TS_RANGE.name,
1656 },
1657 array_id: None,
1658 pg_metadata: Some(CatalogTypePgMetadata {
1659 typinput_oid: 750,
1660 typreceive_oid: 2400,
1661 }),
1662 },
1663};
1664
1665pub const TYPE_TSTZ_RANGE: BuiltinType<NameReference> = BuiltinType {
1666 name: "tstzrange",
1667 schema: PG_CATALOG_SCHEMA,
1668 oid: mz_pgrepr::oid::TYPE_TSTZRANGE_OID,
1669 details: CatalogTypeDetails {
1670 typ: CatalogType::Range {
1671 element_reference: TYPE_TIMESTAMPTZ.name,
1672 },
1673 array_id: None,
1674 pg_metadata: Some(CatalogTypePgMetadata {
1675 typinput_oid: 3834,
1676 typreceive_oid: 3836,
1677 }),
1678 },
1679};
1680
1681pub const TYPE_TSTZ_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1682 name: "_tstzrange",
1683 schema: PG_CATALOG_SCHEMA,
1684 oid: mz_pgrepr::oid::TYPE_TSTZRANGE_ARRAY_OID,
1685 details: CatalogTypeDetails {
1686 typ: CatalogType::Array {
1687 element_reference: TYPE_TSTZ_RANGE.name,
1688 },
1689 array_id: None,
1690 pg_metadata: Some(CatalogTypePgMetadata {
1691 typinput_oid: 750,
1692 typreceive_oid: 2400,
1693 }),
1694 },
1695};
1696
1697pub const TYPE_MZ_ACL_ITEM: BuiltinType<NameReference> = BuiltinType {
1698 name: "mz_aclitem",
1699 schema: MZ_CATALOG_SCHEMA,
1700 oid: mz_pgrepr::oid::TYPE_MZ_ACL_ITEM_OID,
1701 details: CatalogTypeDetails {
1702 typ: CatalogType::MzAclItem,
1703 array_id: None,
1704 pg_metadata: None,
1705 },
1706};
1707
1708pub const TYPE_MZ_ACL_ITEM_ARRAY: BuiltinType<NameReference> = BuiltinType {
1709 name: "_mz_aclitem",
1710 schema: MZ_CATALOG_SCHEMA,
1711 oid: mz_pgrepr::oid::TYPE_MZ_ACL_ITEM_ARRAY_OID,
1712 details: CatalogTypeDetails {
1713 typ: CatalogType::Array {
1714 element_reference: TYPE_MZ_ACL_ITEM.name,
1715 },
1716 array_id: None,
1717 pg_metadata: Some(CatalogTypePgMetadata {
1718 typinput_oid: 750,
1719 typreceive_oid: 2400,
1720 }),
1721 },
1722};
1723
1724pub const TYPE_ACL_ITEM: BuiltinType<NameReference> = BuiltinType {
1725 name: "aclitem",
1726 schema: PG_CATALOG_SCHEMA,
1727 oid: 1033,
1728 details: CatalogTypeDetails {
1729 typ: CatalogType::AclItem,
1730 array_id: None,
1731 pg_metadata: Some(CatalogTypePgMetadata {
1732 typinput_oid: 1031,
1733 typreceive_oid: 0,
1734 }),
1735 },
1736};
1737
1738pub const TYPE_ACL_ITEM_ARRAY: BuiltinType<NameReference> = BuiltinType {
1739 name: "_aclitem",
1740 schema: PG_CATALOG_SCHEMA,
1741 oid: 1034,
1742 details: CatalogTypeDetails {
1743 typ: CatalogType::Array {
1744 element_reference: TYPE_ACL_ITEM.name,
1745 },
1746 array_id: None,
1747 pg_metadata: Some(CatalogTypePgMetadata {
1748 typinput_oid: 750,
1749 typreceive_oid: 2400,
1750 }),
1751 },
1752};
1753
1754pub const TYPE_INTERNAL: BuiltinType<NameReference> = BuiltinType {
1755 name: "internal",
1756 schema: PG_CATALOG_SCHEMA,
1757 oid: 2281,
1758 details: CatalogTypeDetails {
1759 typ: CatalogType::Pseudo,
1760 array_id: None,
1761 pg_metadata: Some(CatalogTypePgMetadata {
1762 typinput_oid: 2304,
1763 typreceive_oid: 0,
1764 }),
1765 },
1766};
1767
1768const PUBLIC_SELECT: MzAclItem = MzAclItem {
1769 grantee: RoleId::Public,
1770 grantor: MZ_SYSTEM_ROLE_ID,
1771 acl_mode: AclMode::SELECT,
1772};
1773
1774const SUPPORT_SELECT: MzAclItem = MzAclItem {
1775 grantee: MZ_SUPPORT_ROLE_ID,
1776 grantor: MZ_SYSTEM_ROLE_ID,
1777 acl_mode: AclMode::SELECT,
1778};
1779
1780const ANALYTICS_SELECT: MzAclItem = MzAclItem {
1781 grantee: MZ_ANALYTICS_ROLE_ID,
1782 grantor: MZ_SYSTEM_ROLE_ID,
1783 acl_mode: AclMode::SELECT,
1784};
1785
1786const MONITOR_SELECT: MzAclItem = MzAclItem {
1787 grantee: MZ_MONITOR_ROLE_ID,
1788 grantor: MZ_SYSTEM_ROLE_ID,
1789 acl_mode: AclMode::SELECT,
1790};
1791
1792const MONITOR_REDACTED_SELECT: MzAclItem = MzAclItem {
1793 grantee: MZ_MONITOR_REDACTED_ROLE_ID,
1794 grantor: MZ_SYSTEM_ROLE_ID,
1795 acl_mode: AclMode::SELECT,
1796};
1797
1798pub static MZ_DATAFLOW_OPERATORS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1799 name: "mz_dataflow_operators_per_worker",
1800 schema: MZ_INTROSPECTION_SCHEMA,
1801 oid: oid::LOG_MZ_DATAFLOW_OPERATORS_PER_WORKER_OID,
1802 variant: LogVariant::Timely(TimelyLog::Operates),
1803 access: vec![PUBLIC_SELECT],
1804});
1805
1806pub static MZ_DATAFLOW_ADDRESSES_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1807 name: "mz_dataflow_addresses_per_worker",
1808 schema: MZ_INTROSPECTION_SCHEMA,
1809 oid: oid::LOG_MZ_DATAFLOW_ADDRESSES_PER_WORKER_OID,
1810 variant: LogVariant::Timely(TimelyLog::Addresses),
1811 access: vec![PUBLIC_SELECT],
1812});
1813
1814pub static MZ_DATAFLOW_CHANNELS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1815 name: "mz_dataflow_channels_per_worker",
1816 schema: MZ_INTROSPECTION_SCHEMA,
1817 oid: oid::LOG_MZ_DATAFLOW_CHANNELS_PER_WORKER_OID,
1818 variant: LogVariant::Timely(TimelyLog::Channels),
1819 access: vec![PUBLIC_SELECT],
1820});
1821
1822pub static MZ_SCHEDULING_ELAPSED_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1823 name: "mz_scheduling_elapsed_raw",
1824 schema: MZ_INTROSPECTION_SCHEMA,
1825 oid: oid::LOG_MZ_SCHEDULING_ELAPSED_RAW_OID,
1826 variant: LogVariant::Timely(TimelyLog::Elapsed),
1827 access: vec![PUBLIC_SELECT],
1828});
1829
1830pub static MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_RAW: LazyLock<BuiltinLog> =
1831 LazyLock::new(|| BuiltinLog {
1832 name: "mz_compute_operator_durations_histogram_raw",
1833 schema: MZ_INTROSPECTION_SCHEMA,
1834 oid: oid::LOG_MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_RAW_OID,
1835 variant: LogVariant::Timely(TimelyLog::Histogram),
1836 access: vec![PUBLIC_SELECT],
1837 });
1838
1839pub static MZ_SCHEDULING_PARKS_HISTOGRAM_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1840 name: "mz_scheduling_parks_histogram_raw",
1841 schema: MZ_INTROSPECTION_SCHEMA,
1842 oid: oid::LOG_MZ_SCHEDULING_PARKS_HISTOGRAM_RAW_OID,
1843 variant: LogVariant::Timely(TimelyLog::Parks),
1844 access: vec![PUBLIC_SELECT],
1845});
1846
1847pub static MZ_ARRANGEMENT_RECORDS_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1848 name: "mz_arrangement_records_raw",
1849 schema: MZ_INTROSPECTION_SCHEMA,
1850 oid: oid::LOG_MZ_ARRANGEMENT_RECORDS_RAW_OID,
1851 variant: LogVariant::Differential(DifferentialLog::ArrangementRecords),
1852 access: vec![PUBLIC_SELECT],
1853});
1854
1855pub static MZ_ARRANGEMENT_BATCHES_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1856 name: "mz_arrangement_batches_raw",
1857 schema: MZ_INTROSPECTION_SCHEMA,
1858 oid: oid::LOG_MZ_ARRANGEMENT_BATCHES_RAW_OID,
1859 variant: LogVariant::Differential(DifferentialLog::ArrangementBatches),
1860 access: vec![PUBLIC_SELECT],
1861});
1862
1863pub static MZ_ARRANGEMENT_SHARING_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1864 name: "mz_arrangement_sharing_raw",
1865 schema: MZ_INTROSPECTION_SCHEMA,
1866 oid: oid::LOG_MZ_ARRANGEMENT_SHARING_RAW_OID,
1867 variant: LogVariant::Differential(DifferentialLog::Sharing),
1868 access: vec![PUBLIC_SELECT],
1869});
1870
1871pub static MZ_ARRANGEMENT_BATCHER_RECORDS_RAW: LazyLock<BuiltinLog> =
1872 LazyLock::new(|| BuiltinLog {
1873 name: "mz_arrangement_batcher_records_raw",
1874 schema: MZ_INTROSPECTION_SCHEMA,
1875 oid: oid::LOG_MZ_ARRANGEMENT_BATCHER_RECORDS_RAW_OID,
1876 variant: LogVariant::Differential(DifferentialLog::BatcherRecords),
1877 access: vec![PUBLIC_SELECT],
1878 });
1879
1880pub static MZ_ARRANGEMENT_BATCHER_SIZE_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1881 name: "mz_arrangement_batcher_size_raw",
1882 schema: MZ_INTROSPECTION_SCHEMA,
1883 oid: oid::LOG_MZ_ARRANGEMENT_BATCHER_SIZE_RAW_OID,
1884 variant: LogVariant::Differential(DifferentialLog::BatcherSize),
1885 access: vec![PUBLIC_SELECT],
1886});
1887
1888pub static MZ_ARRANGEMENT_BATCHER_CAPACITY_RAW: LazyLock<BuiltinLog> =
1889 LazyLock::new(|| BuiltinLog {
1890 name: "mz_arrangement_batcher_capacity_raw",
1891 schema: MZ_INTROSPECTION_SCHEMA,
1892 oid: oid::LOG_MZ_ARRANGEMENT_BATCHER_CAPACITY_RAW_OID,
1893 variant: LogVariant::Differential(DifferentialLog::BatcherCapacity),
1894 access: vec![PUBLIC_SELECT],
1895 });
1896
1897pub static MZ_ARRANGEMENT_BATCHER_ALLOCATIONS_RAW: LazyLock<BuiltinLog> =
1898 LazyLock::new(|| BuiltinLog {
1899 name: "mz_arrangement_batcher_allocations_raw",
1900 schema: MZ_INTROSPECTION_SCHEMA,
1901 oid: oid::LOG_MZ_ARRANGEMENT_BATCHER_ALLOCATIONS_RAW_OID,
1902 variant: LogVariant::Differential(DifferentialLog::BatcherAllocations),
1903 access: vec![PUBLIC_SELECT],
1904 });
1905
1906pub static MZ_COMPUTE_EXPORTS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1907 name: "mz_compute_exports_per_worker",
1908 schema: MZ_INTROSPECTION_SCHEMA,
1909 oid: oid::LOG_MZ_COMPUTE_EXPORTS_PER_WORKER_OID,
1910 variant: LogVariant::Compute(ComputeLog::DataflowCurrent),
1911 access: vec![PUBLIC_SELECT],
1912});
1913
1914pub static MZ_COMPUTE_DATAFLOW_GLOBAL_IDS_PER_WORKER: LazyLock<BuiltinLog> =
1915 LazyLock::new(|| BuiltinLog {
1916 name: "mz_compute_dataflow_global_ids_per_worker",
1917 schema: MZ_INTROSPECTION_SCHEMA,
1918 oid: oid::LOG_MZ_COMPUTE_DATAFLOW_GLOBAL_IDS_PER_WORKER_OID,
1919 variant: LogVariant::Compute(ComputeLog::DataflowGlobal),
1920 access: vec![PUBLIC_SELECT],
1921 });
1922
1923pub static MZ_COMPUTE_FRONTIERS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1924 name: "mz_compute_frontiers_per_worker",
1925 schema: MZ_INTROSPECTION_SCHEMA,
1926 oid: oid::LOG_MZ_COMPUTE_FRONTIERS_PER_WORKER_OID,
1927 variant: LogVariant::Compute(ComputeLog::FrontierCurrent),
1928 access: vec![PUBLIC_SELECT],
1929});
1930
1931pub static MZ_COMPUTE_IMPORT_FRONTIERS_PER_WORKER: LazyLock<BuiltinLog> =
1932 LazyLock::new(|| BuiltinLog {
1933 name: "mz_compute_import_frontiers_per_worker",
1934 schema: MZ_INTROSPECTION_SCHEMA,
1935 oid: oid::LOG_MZ_COMPUTE_IMPORT_FRONTIERS_PER_WORKER_OID,
1936 variant: LogVariant::Compute(ComputeLog::ImportFrontierCurrent),
1937 access: vec![PUBLIC_SELECT],
1938 });
1939
1940pub static MZ_COMPUTE_ERROR_COUNTS_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1941 name: "mz_compute_error_counts_raw",
1942 schema: MZ_INTROSPECTION_SCHEMA,
1943 oid: oid::LOG_MZ_COMPUTE_ERROR_COUNTS_RAW_OID,
1944 variant: LogVariant::Compute(ComputeLog::ErrorCount),
1945 access: vec![PUBLIC_SELECT],
1946});
1947
1948pub static MZ_COMPUTE_HYDRATION_TIMES_PER_WORKER: LazyLock<BuiltinLog> =
1949 LazyLock::new(|| BuiltinLog {
1950 name: "mz_compute_hydration_times_per_worker",
1951 schema: MZ_INTROSPECTION_SCHEMA,
1952 oid: oid::LOG_MZ_COMPUTE_HYDRATION_TIMES_PER_WORKER_OID,
1953 variant: LogVariant::Compute(ComputeLog::HydrationTime),
1954 access: vec![PUBLIC_SELECT],
1955 });
1956
1957pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_PER_WORKER: LazyLock<BuiltinLog> =
1958 LazyLock::new(|| BuiltinLog {
1959 name: "mz_compute_operator_hydration_statuses_per_worker",
1960 schema: MZ_INTROSPECTION_SCHEMA,
1961 oid: oid::LOG_MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_PER_WORKER_OID,
1962 variant: LogVariant::Compute(ComputeLog::OperatorHydrationStatus),
1963 access: vec![PUBLIC_SELECT],
1964 });
1965
1966pub static MZ_ACTIVE_PEEKS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1967 name: "mz_active_peeks_per_worker",
1968 schema: MZ_INTROSPECTION_SCHEMA,
1969 oid: oid::LOG_MZ_ACTIVE_PEEKS_PER_WORKER_OID,
1970 variant: LogVariant::Compute(ComputeLog::PeekCurrent),
1971 access: vec![PUBLIC_SELECT],
1972});
1973
1974pub static MZ_COMPUTE_LIR_MAPPING_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1975 name: "mz_compute_lir_mapping_per_worker",
1976 schema: MZ_INTROSPECTION_SCHEMA,
1977 oid: oid::LOG_MZ_COMPUTE_LIR_MAPPING_PER_WORKER_OID,
1978 variant: LogVariant::Compute(ComputeLog::LirMapping),
1979 access: vec![PUBLIC_SELECT],
1980});
1981
1982pub static MZ_PEEK_DURATIONS_HISTOGRAM_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1983 name: "mz_peek_durations_histogram_raw",
1984 schema: MZ_INTROSPECTION_SCHEMA,
1985 oid: oid::LOG_MZ_PEEK_DURATIONS_HISTOGRAM_RAW_OID,
1986 variant: LogVariant::Compute(ComputeLog::PeekDuration),
1987 access: vec![PUBLIC_SELECT],
1988});
1989
1990pub static MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_RAW: LazyLock<BuiltinLog> =
1991 LazyLock::new(|| BuiltinLog {
1992 name: "mz_dataflow_shutdown_durations_histogram_raw",
1993 schema: MZ_INTROSPECTION_SCHEMA,
1994 oid: oid::LOG_MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_RAW_OID,
1995 variant: LogVariant::Compute(ComputeLog::ShutdownDuration),
1996 access: vec![PUBLIC_SELECT],
1997 });
1998
1999pub static MZ_ARRANGEMENT_HEAP_SIZE_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
2000 name: "mz_arrangement_heap_size_raw",
2001 schema: MZ_INTROSPECTION_SCHEMA,
2002 oid: oid::LOG_MZ_ARRANGEMENT_HEAP_SIZE_RAW_OID,
2003 variant: LogVariant::Compute(ComputeLog::ArrangementHeapSize),
2004 access: vec![PUBLIC_SELECT],
2005});
2006
2007pub static MZ_ARRANGEMENT_HEAP_CAPACITY_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
2008 name: "mz_arrangement_heap_capacity_raw",
2009 schema: MZ_INTROSPECTION_SCHEMA,
2010 oid: oid::LOG_MZ_ARRANGEMENT_HEAP_CAPACITY_RAW_OID,
2011 variant: LogVariant::Compute(ComputeLog::ArrangementHeapCapacity),
2012 access: vec![PUBLIC_SELECT],
2013});
2014
2015pub static MZ_ARRANGEMENT_HEAP_ALLOCATIONS_RAW: LazyLock<BuiltinLog> =
2016 LazyLock::new(|| BuiltinLog {
2017 name: "mz_arrangement_heap_allocations_raw",
2018 schema: MZ_INTROSPECTION_SCHEMA,
2019 oid: oid::LOG_MZ_ARRANGEMENT_HEAP_ALLOCATIONS_RAW_OID,
2020 variant: LogVariant::Compute(ComputeLog::ArrangementHeapAllocations),
2021 access: vec![PUBLIC_SELECT],
2022 });
2023
2024pub static MZ_MESSAGE_BATCH_COUNTS_RECEIVED_RAW: LazyLock<BuiltinLog> =
2025 LazyLock::new(|| BuiltinLog {
2026 name: "mz_message_batch_counts_received_raw",
2027 schema: MZ_INTROSPECTION_SCHEMA,
2028 oid: oid::LOG_MZ_MESSAGE_BATCH_COUNTS_RECEIVED_RAW_OID,
2029 variant: LogVariant::Timely(TimelyLog::BatchesReceived),
2030 access: vec![PUBLIC_SELECT],
2031 });
2032
2033pub static MZ_MESSAGE_BATCH_COUNTS_SENT_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
2034 name: "mz_message_batch_counts_sent_raw",
2035 schema: MZ_INTROSPECTION_SCHEMA,
2036 oid: oid::LOG_MZ_MESSAGE_BATCH_COUNTS_SENT_RAW_OID,
2037 variant: LogVariant::Timely(TimelyLog::BatchesSent),
2038 access: vec![PUBLIC_SELECT],
2039});
2040
2041pub static MZ_MESSAGE_COUNTS_RECEIVED_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
2042 name: "mz_message_counts_received_raw",
2043 schema: MZ_INTROSPECTION_SCHEMA,
2044 oid: oid::LOG_MZ_MESSAGE_COUNTS_RECEIVED_RAW_OID,
2045 variant: LogVariant::Timely(TimelyLog::MessagesReceived),
2046 access: vec![PUBLIC_SELECT],
2047});
2048
2049pub static MZ_MESSAGE_COUNTS_SENT_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
2050 name: "mz_message_counts_sent_raw",
2051 schema: MZ_INTROSPECTION_SCHEMA,
2052 oid: oid::LOG_MZ_MESSAGE_COUNTS_SENT_RAW_OID,
2053 variant: LogVariant::Timely(TimelyLog::MessagesSent),
2054 access: vec![PUBLIC_SELECT],
2055});
2056
2057pub static MZ_DATAFLOW_OPERATOR_REACHABILITY_RAW: LazyLock<BuiltinLog> =
2058 LazyLock::new(|| BuiltinLog {
2059 name: "mz_dataflow_operator_reachability_raw",
2060 schema: MZ_INTROSPECTION_SCHEMA,
2061 oid: oid::LOG_MZ_DATAFLOW_OPERATOR_REACHABILITY_RAW_OID,
2062 variant: LogVariant::Timely(TimelyLog::Reachability),
2063 access: vec![PUBLIC_SELECT],
2064 });
2065
2066pub static MZ_KAFKA_SINKS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2067 name: "mz_kafka_sinks",
2068 schema: MZ_CATALOG_SCHEMA,
2069 oid: oid::TABLE_MZ_KAFKA_SINKS_OID,
2070 desc: RelationDesc::builder()
2071 .with_column("id", SqlScalarType::String.nullable(false))
2072 .with_column("topic", SqlScalarType::String.nullable(false))
2073 .with_key(vec![0])
2074 .finish(),
2075 column_comments: BTreeMap::from_iter([
2076 ("id", "The ID of the sink."),
2077 (
2078 "topic",
2079 "The name of the Kafka topic into which the sink is writing.",
2080 ),
2081 ]),
2082 is_retained_metrics_object: false,
2083 access: vec![PUBLIC_SELECT],
2084});
2085pub static MZ_KAFKA_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2086 name: "mz_kafka_connections",
2087 schema: MZ_CATALOG_SCHEMA,
2088 oid: oid::TABLE_MZ_KAFKA_CONNECTIONS_OID,
2089 desc: RelationDesc::builder()
2090 .with_column("id", SqlScalarType::String.nullable(false))
2091 .with_column(
2092 "brokers",
2093 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
2094 )
2095 .with_column("sink_progress_topic", SqlScalarType::String.nullable(false))
2096 .finish(),
2097 column_comments: BTreeMap::from_iter([
2098 ("id", "The ID of the connection."),
2099 (
2100 "brokers",
2101 "The addresses of the Kafka brokers to connect to.",
2102 ),
2103 (
2104 "sink_progress_topic",
2105 "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.",
2106 ),
2107 ]),
2108 is_retained_metrics_object: false,
2109 access: vec![PUBLIC_SELECT],
2110});
2111pub static MZ_KAFKA_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2112 name: "mz_kafka_sources",
2113 schema: MZ_CATALOG_SCHEMA,
2114 oid: oid::TABLE_MZ_KAFKA_SOURCES_OID,
2115 desc: RelationDesc::builder()
2116 .with_column("id", SqlScalarType::String.nullable(false))
2117 .with_column("group_id_prefix", SqlScalarType::String.nullable(false))
2118 .with_column("topic", SqlScalarType::String.nullable(false))
2119 .finish(),
2120 column_comments: BTreeMap::from_iter([
2121 (
2122 "id",
2123 "The ID of the Kafka source. Corresponds to `mz_catalog.mz_sources.id`.",
2124 ),
2125 (
2126 "group_id_prefix",
2127 "The value of the `GROUP ID PREFIX` connection option.",
2128 ),
2129 (
2130 "topic",
2131 "The name of the Kafka topic the source is reading from.",
2132 ),
2133 ]),
2134 is_retained_metrics_object: false,
2135 access: vec![PUBLIC_SELECT],
2136});
2137pub static MZ_POSTGRES_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2138 name: "mz_postgres_sources",
2139 schema: MZ_INTERNAL_SCHEMA,
2140 oid: oid::TABLE_MZ_POSTGRES_SOURCES_OID,
2141 desc: RelationDesc::builder()
2142 .with_column("id", SqlScalarType::String.nullable(false))
2143 .with_column("replication_slot", SqlScalarType::String.nullable(false))
2144 .with_column("timeline_id", SqlScalarType::UInt64.nullable(true))
2145 .finish(),
2146 column_comments: BTreeMap::from_iter([
2147 (
2148 "id",
2149 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
2150 ),
2151 (
2152 "replication_slot",
2153 "The name of the replication slot in the PostgreSQL database that Materialize will create and stream data from.",
2154 ),
2155 (
2156 "timeline_id",
2157 "The PostgreSQL timeline ID determined on source creation.",
2158 ),
2159 ]),
2160 is_retained_metrics_object: false,
2161 access: vec![PUBLIC_SELECT],
2162});
2163pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2164 name: "mz_postgres_source_tables",
2165 schema: MZ_INTERNAL_SCHEMA,
2166 oid: oid::TABLE_MZ_POSTGRES_SOURCE_TABLES_OID,
2167 desc: RelationDesc::builder()
2168 .with_column("id", SqlScalarType::String.nullable(false))
2169 .with_column("schema_name", SqlScalarType::String.nullable(false))
2170 .with_column("table_name", SqlScalarType::String.nullable(false))
2171 .finish(),
2172 column_comments: BTreeMap::from_iter([
2173 (
2174 "id",
2175 "The ID of the subsource or table. Corresponds to `mz_catalog.mz_sources.id` or `mz_catalog.mz_tables.id`.",
2176 ),
2177 (
2178 "schema_name",
2179 "The schema of the upstream table being ingested.",
2180 ),
2181 (
2182 "table_name",
2183 "The name of the upstream table being ingested.",
2184 ),
2185 ]),
2186 is_retained_metrics_object: true,
2187 access: vec![PUBLIC_SELECT],
2188});
2189pub static MZ_MYSQL_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2190 name: "mz_mysql_source_tables",
2191 schema: MZ_INTERNAL_SCHEMA,
2192 oid: oid::TABLE_MZ_MYSQL_SOURCE_TABLES_OID,
2193 desc: RelationDesc::builder()
2194 .with_column("id", SqlScalarType::String.nullable(false))
2195 .with_column("schema_name", SqlScalarType::String.nullable(false))
2196 .with_column("table_name", SqlScalarType::String.nullable(false))
2197 .finish(),
2198 column_comments: BTreeMap::from_iter([
2199 (
2200 "id",
2201 "The ID of the subsource or table. Corresponds to `mz_catalog.mz_sources.id` or `mz_catalog.mz_tables.id`.",
2202 ),
2203 (
2204 "schema_name",
2205 "The schema (or, database) of the upstream table being ingested.",
2206 ),
2207 (
2208 "table_name",
2209 "The name of the upstream table being ingested.",
2210 ),
2211 ]),
2212 is_retained_metrics_object: true,
2213 access: vec![PUBLIC_SELECT],
2214});
2215pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2216 name: "mz_sql_server_source_tables",
2217 schema: MZ_INTERNAL_SCHEMA,
2218 oid: oid::TABLE_MZ_SQL_SERVER_SOURCE_TABLES_OID,
2219 desc: RelationDesc::builder()
2220 .with_column("id", SqlScalarType::String.nullable(false))
2221 .with_column("schema_name", SqlScalarType::String.nullable(false))
2222 .with_column("table_name", SqlScalarType::String.nullable(false))
2223 .finish(),
2224 column_comments: BTreeMap::from_iter([
2225 (
2226 "id",
2227 "The ID of the subsource or table. Corresponds to `mz_catalog.mz_sources.id` or `mz_catalog.mz_tables.id`.",
2228 ),
2229 (
2230 "schema_name",
2231 "The schema (or, database) of the upstream table being ingested.",
2232 ),
2233 (
2234 "table_name",
2235 "The name of the upstream table being ingested.",
2236 ),
2237 ]),
2238 is_retained_metrics_object: true,
2239 access: vec![PUBLIC_SELECT],
2240});
2241pub static MZ_KAFKA_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2242 name: "mz_kafka_source_tables",
2243 schema: MZ_INTERNAL_SCHEMA,
2244 oid: oid::TABLE_MZ_KAFKA_SOURCE_TABLES_OID,
2245 desc: RelationDesc::builder()
2246 .with_column("id", SqlScalarType::String.nullable(false))
2247 .with_column("topic", SqlScalarType::String.nullable(false))
2248 .with_column("envelope_type", SqlScalarType::String.nullable(true))
2249 .with_column("key_format", SqlScalarType::String.nullable(true))
2250 .with_column("value_format", SqlScalarType::String.nullable(true))
2251 .finish(),
2252 column_comments: BTreeMap::from_iter([
2253 (
2254 "id",
2255 "The ID of the table. Corresponds to `mz_catalog.mz_tables.id`.",
2256 ),
2257 ("topic", "The topic being ingested."),
2258 (
2259 "envelope_type",
2260 "The envelope type: `none`, `upsert`, or `debezium`. `NULL` for other source types.",
2261 ),
2262 (
2263 "key_format",
2264 "The format of the Kafka message key: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`, or `NULL`.",
2265 ),
2266 (
2267 "value_format",
2268 "The format of the Kafka message value: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`. `NULL` for other source types.",
2269 ),
2270 ]),
2271 is_retained_metrics_object: true,
2272 access: vec![PUBLIC_SELECT],
2273});
2274pub static MZ_OBJECT_DEPENDENCIES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2275 name: "mz_object_dependencies",
2276 schema: MZ_INTERNAL_SCHEMA,
2277 oid: oid::TABLE_MZ_OBJECT_DEPENDENCIES_OID,
2278 desc: RelationDesc::builder()
2279 .with_column("object_id", SqlScalarType::String.nullable(false))
2280 .with_column(
2281 "referenced_object_id",
2282 SqlScalarType::String.nullable(false),
2283 )
2284 .finish(),
2285 column_comments: BTreeMap::from_iter([
2286 (
2287 "object_id",
2288 "The ID of the dependent object. Corresponds to `mz_objects.id`.",
2289 ),
2290 (
2291 "referenced_object_id",
2292 "The ID of the referenced object. Corresponds to `mz_objects.id`.",
2293 ),
2294 ]),
2295 is_retained_metrics_object: true,
2296 access: vec![PUBLIC_SELECT],
2297});
2298pub static MZ_COMPUTE_DEPENDENCIES: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
2299 name: "mz_compute_dependencies",
2300 schema: MZ_INTERNAL_SCHEMA,
2301 oid: oid::SOURCE_MZ_COMPUTE_DEPENDENCIES_OID,
2302 data_source: IntrospectionType::ComputeDependencies,
2303 desc: RelationDesc::builder()
2304 .with_column("object_id", SqlScalarType::String.nullable(false))
2305 .with_column("dependency_id", SqlScalarType::String.nullable(false))
2306 .finish(),
2307 column_comments: BTreeMap::from_iter([
2308 (
2309 "object_id",
2310 "The ID of a compute object. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, or `mz_internal.mz_subscriptions`.",
2311 ),
2312 (
2313 "dependency_id",
2314 "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`.",
2315 ),
2316 ]),
2317 is_retained_metrics_object: false,
2318 access: vec![PUBLIC_SELECT],
2319});
2320
2321pub static MZ_DATABASES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2322 name: "mz_databases",
2323 schema: MZ_CATALOG_SCHEMA,
2324 oid: oid::TABLE_MZ_DATABASES_OID,
2325 desc: RelationDesc::builder()
2326 .with_column("id", SqlScalarType::String.nullable(false))
2327 .with_column("oid", SqlScalarType::Oid.nullable(false))
2328 .with_column("name", SqlScalarType::String.nullable(false))
2329 .with_column("owner_id", SqlScalarType::String.nullable(false))
2330 .with_column(
2331 "privileges",
2332 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2333 )
2334 .with_key(vec![0])
2335 .with_key(vec![1])
2336 .finish(),
2337 column_comments: BTreeMap::from_iter([
2338 ("id", "Materialize's unique ID for the database."),
2339 (
2340 "oid",
2341 "A [PostgreSQL-compatible OID][`oid`] for the database.",
2342 ),
2343 ("name", "The name of the database."),
2344 (
2345 "owner_id",
2346 "The role ID of the owner of the database. Corresponds to `mz_roles.id`.",
2347 ),
2348 ("privileges", "The privileges belonging to the database."),
2349 ]),
2350 is_retained_metrics_object: false,
2351 access: vec![PUBLIC_SELECT],
2352});
2353pub static MZ_SCHEMAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2354 name: "mz_schemas",
2355 schema: MZ_CATALOG_SCHEMA,
2356 oid: oid::TABLE_MZ_SCHEMAS_OID,
2357 desc: RelationDesc::builder()
2358 .with_column("id", SqlScalarType::String.nullable(false))
2359 .with_column("oid", SqlScalarType::Oid.nullable(false))
2360 .with_column("database_id", SqlScalarType::String.nullable(true))
2361 .with_column("name", SqlScalarType::String.nullable(false))
2362 .with_column("owner_id", SqlScalarType::String.nullable(false))
2363 .with_column(
2364 "privileges",
2365 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2366 )
2367 .with_key(vec![0])
2368 .with_key(vec![1])
2369 .finish(),
2370 column_comments: BTreeMap::from_iter([
2371 ("id", "Materialize's unique ID for the schema."),
2372 (
2373 "oid",
2374 "A [PostgreSQL-compatible oid][`oid`] for the schema.",
2375 ),
2376 (
2377 "database_id",
2378 "The ID of the database containing the schema. Corresponds to `mz_databases.id`.",
2379 ),
2380 ("name", "The name of the schema."),
2381 (
2382 "owner_id",
2383 "The role ID of the owner of the schema. Corresponds to `mz_roles.id`.",
2384 ),
2385 ("privileges", "The privileges belonging to the schema."),
2386 ]),
2387 is_retained_metrics_object: false,
2388 access: vec![PUBLIC_SELECT],
2389});
2390pub static MZ_COLUMNS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2391 name: "mz_columns",
2392 schema: MZ_CATALOG_SCHEMA,
2393 oid: oid::TABLE_MZ_COLUMNS_OID,
2394 desc: RelationDesc::builder()
2395 .with_column("id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false))
2397 .with_column("position", SqlScalarType::UInt64.nullable(false))
2398 .with_column("nullable", SqlScalarType::Bool.nullable(false))
2399 .with_column("type", SqlScalarType::String.nullable(false))
2400 .with_column("default", SqlScalarType::String.nullable(true))
2401 .with_column("type_oid", SqlScalarType::Oid.nullable(false))
2402 .with_column("type_mod", SqlScalarType::Int32.nullable(false))
2403 .finish(),
2404 column_comments: BTreeMap::from_iter([
2405 (
2406 "id",
2407 "The unique ID of the table, source, or view containing the column.",
2408 ),
2409 ("name", "The name of the column."),
2410 (
2411 "position",
2412 "The 1-indexed position of the column in its containing table, source, or view.",
2413 ),
2414 ("nullable", "Can the column contain a `NULL` value?"),
2415 ("type", "The data type of the column."),
2416 ("default", "The default expression of the column."),
2417 (
2418 "type_oid",
2419 "The OID of the type of the column (references `mz_types`).",
2420 ),
2421 ("type_mod", "The packed type identifier of the column."),
2422 ]),
2423 is_retained_metrics_object: false,
2424 access: vec![PUBLIC_SELECT],
2425});
2426pub static MZ_INDEXES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2427 name: "mz_indexes",
2428 schema: MZ_CATALOG_SCHEMA,
2429 oid: oid::TABLE_MZ_INDEXES_OID,
2430 desc: RelationDesc::builder()
2431 .with_column("id", SqlScalarType::String.nullable(false))
2432 .with_column("oid", SqlScalarType::Oid.nullable(false))
2433 .with_column("name", SqlScalarType::String.nullable(false))
2434 .with_column("on_id", SqlScalarType::String.nullable(false))
2435 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2436 .with_column("owner_id", SqlScalarType::String.nullable(false))
2437 .with_column("create_sql", SqlScalarType::String.nullable(false))
2438 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2439 .with_key(vec![0])
2440 .with_key(vec![1])
2441 .finish(),
2442 column_comments: BTreeMap::from_iter([
2443 ("id", "Materialize's unique ID for the index."),
2444 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the index."),
2445 ("name", "The name of the index."),
2446 (
2447 "on_id",
2448 "The ID of the relation on which the index is built.",
2449 ),
2450 (
2451 "cluster_id",
2452 "The ID of the cluster in which the index is built.",
2453 ),
2454 (
2455 "owner_id",
2456 "The role ID of the owner of the index. Corresponds to `mz_roles.id`.",
2457 ),
2458 ("create_sql", "The `CREATE` SQL statement for the index."),
2459 (
2460 "redacted_create_sql",
2461 "The redacted `CREATE` SQL statement for the index.",
2462 ),
2463 ]),
2464 is_retained_metrics_object: false,
2465 access: vec![PUBLIC_SELECT],
2466});
2467pub static MZ_INDEX_COLUMNS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2468 name: "mz_index_columns",
2469 schema: MZ_CATALOG_SCHEMA,
2470 oid: oid::TABLE_MZ_INDEX_COLUMNS_OID,
2471 desc: RelationDesc::builder()
2472 .with_column("index_id", SqlScalarType::String.nullable(false))
2473 .with_column("index_position", SqlScalarType::UInt64.nullable(false))
2474 .with_column("on_position", SqlScalarType::UInt64.nullable(true))
2475 .with_column("on_expression", SqlScalarType::String.nullable(true))
2476 .with_column("nullable", SqlScalarType::Bool.nullable(false))
2477 .finish(),
2478 column_comments: BTreeMap::from_iter([
2479 (
2480 "index_id",
2481 "The ID of the index which contains this column. Corresponds to `mz_indexes.id`.",
2482 ),
2483 (
2484 "index_position",
2485 "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.)",
2486 ),
2487 (
2488 "on_position",
2489 "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.",
2490 ),
2491 (
2492 "on_expression",
2493 "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.",
2494 ),
2495 (
2496 "nullable",
2497 "Can this column of the index evaluate to `NULL`?",
2498 ),
2499 ]),
2500 is_retained_metrics_object: false,
2501 access: vec![PUBLIC_SELECT],
2502});
2503pub static MZ_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2504 name: "mz_tables",
2505 schema: MZ_CATALOG_SCHEMA,
2506 oid: oid::TABLE_MZ_TABLES_OID,
2507 desc: RelationDesc::builder()
2508 .with_column("id", SqlScalarType::String.nullable(false))
2509 .with_column("oid", SqlScalarType::Oid.nullable(false))
2510 .with_column("schema_id", SqlScalarType::String.nullable(false))
2511 .with_column("name", SqlScalarType::String.nullable(false))
2512 .with_column("owner_id", SqlScalarType::String.nullable(false))
2513 .with_column(
2514 "privileges",
2515 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2516 )
2517 .with_column("create_sql", SqlScalarType::String.nullable(true))
2518 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
2519 .with_column("source_id", SqlScalarType::String.nullable(true))
2520 .with_key(vec![0])
2521 .with_key(vec![1])
2522 .finish(),
2523 column_comments: BTreeMap::from_iter([
2524 ("id", "Materialize's unique ID for the table."),
2525 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the table."),
2526 (
2527 "schema_id",
2528 "The ID of the schema to which the table belongs. Corresponds to `mz_schemas.id`.",
2529 ),
2530 ("name", "The name of the table."),
2531 (
2532 "owner_id",
2533 "The role ID of the owner of the table. Corresponds to `mz_roles.id`.",
2534 ),
2535 ("privileges", "The privileges belonging to the table."),
2536 ("create_sql", "The `CREATE` SQL statement for the table."),
2537 (
2538 "redacted_create_sql",
2539 "The redacted `CREATE` SQL statement for the table.",
2540 ),
2541 (
2542 "source_id",
2543 "The ID of the source associated with the table, if any. Corresponds to `mz_sources.id`.",
2544 ),
2545 ]),
2546 is_retained_metrics_object: true,
2547 access: vec![PUBLIC_SELECT],
2548});
2549pub static MZ_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2550 name: "mz_connections",
2551 schema: MZ_CATALOG_SCHEMA,
2552 oid: oid::TABLE_MZ_CONNECTIONS_OID,
2553 desc: RelationDesc::builder()
2554 .with_column("id", SqlScalarType::String.nullable(false))
2555 .with_column("oid", SqlScalarType::Oid.nullable(false))
2556 .with_column("schema_id", SqlScalarType::String.nullable(false))
2557 .with_column("name", SqlScalarType::String.nullable(false))
2558 .with_column("type", SqlScalarType::String.nullable(false))
2559 .with_column("owner_id", SqlScalarType::String.nullable(false))
2560 .with_column(
2561 "privileges",
2562 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2563 )
2564 .with_column("create_sql", SqlScalarType::String.nullable(false))
2565 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2566 .with_key(vec![0])
2567 .with_key(vec![1])
2568 .finish(),
2569 column_comments: BTreeMap::from_iter([
2570 ("id", "The unique ID of the connection."),
2571 (
2572 "oid",
2573 "A [PostgreSQL-compatible OID][`oid`] for the connection.",
2574 ),
2575 (
2576 "schema_id",
2577 "The ID of the schema to which the connection belongs. Corresponds to `mz_schemas.id`.",
2578 ),
2579 ("name", "The name of the connection."),
2580 (
2581 "type",
2582 "The type of the connection: `confluent-schema-registry`, `kafka`, `postgres`, or `ssh-tunnel`.",
2583 ),
2584 (
2585 "owner_id",
2586 "The role ID of the owner of the connection. Corresponds to `mz_roles.id`.",
2587 ),
2588 ("privileges", "The privileges belonging to the connection."),
2589 (
2590 "create_sql",
2591 "The `CREATE` SQL statement for the connection.",
2592 ),
2593 (
2594 "redacted_create_sql",
2595 "The redacted `CREATE` SQL statement for the connection.",
2596 ),
2597 ]),
2598 is_retained_metrics_object: false,
2599 access: vec![PUBLIC_SELECT],
2600});
2601pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2602 name: "mz_ssh_tunnel_connections",
2603 schema: MZ_CATALOG_SCHEMA,
2604 oid: oid::TABLE_MZ_SSH_TUNNEL_CONNECTIONS_OID,
2605 desc: RelationDesc::builder()
2606 .with_column("id", SqlScalarType::String.nullable(false))
2607 .with_column("public_key_1", SqlScalarType::String.nullable(false))
2608 .with_column("public_key_2", SqlScalarType::String.nullable(false))
2609 .finish(),
2610 column_comments: BTreeMap::from_iter([
2611 ("id", "The ID of the connection."),
2612 (
2613 "public_key_1",
2614 "The first public key associated with the SSH tunnel.",
2615 ),
2616 (
2617 "public_key_2",
2618 "The second public key associated with the SSH tunnel.",
2619 ),
2620 ]),
2621 is_retained_metrics_object: false,
2622 access: vec![PUBLIC_SELECT],
2623});
2624pub static MZ_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2625 name: "mz_sources",
2626 schema: MZ_CATALOG_SCHEMA,
2627 oid: oid::TABLE_MZ_SOURCES_OID,
2628 desc: RelationDesc::builder()
2629 .with_column("id", SqlScalarType::String.nullable(false))
2630 .with_column("oid", SqlScalarType::Oid.nullable(false))
2631 .with_column("schema_id", SqlScalarType::String.nullable(false))
2632 .with_column("name", SqlScalarType::String.nullable(false))
2633 .with_column("type", SqlScalarType::String.nullable(false))
2634 .with_column("connection_id", SqlScalarType::String.nullable(true))
2635 .with_column("size", SqlScalarType::String.nullable(true))
2636 .with_column("envelope_type", SqlScalarType::String.nullable(true))
2637 .with_column("key_format", SqlScalarType::String.nullable(true))
2638 .with_column("value_format", SqlScalarType::String.nullable(true))
2639 .with_column("cluster_id", SqlScalarType::String.nullable(true))
2640 .with_column("owner_id", SqlScalarType::String.nullable(false))
2641 .with_column(
2642 "privileges",
2643 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2644 )
2645 .with_column("create_sql", SqlScalarType::String.nullable(true))
2646 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
2647 .with_key(vec![0])
2648 .with_key(vec![1])
2649 .finish(),
2650 column_comments: BTreeMap::from_iter([
2651 ("id", "Materialize's unique ID for the source."),
2652 (
2653 "oid",
2654 "A [PostgreSQL-compatible OID][`oid`] for the source.",
2655 ),
2656 (
2657 "schema_id",
2658 "The ID of the schema to which the source belongs. Corresponds to `mz_schemas.id`.",
2659 ),
2660 ("name", "The name of the source."),
2661 (
2662 "type",
2663 "The type of the source: `kafka`, `mysql`, `postgres`, `load-generator`, `progress`, or `subsource`.",
2664 ),
2665 (
2666 "connection_id",
2667 "The ID of the connection associated with the source, if any. Corresponds to `mz_connections.id`.",
2668 ),
2669 ("size", "Deprecated The size of the source."),
2670 (
2671 "envelope_type",
2672 "For Kafka sources, the envelope type: `none`, `upsert`, or `debezium`. `NULL` for other source types.",
2673 ),
2674 (
2675 "key_format",
2676 "For Kafka sources, the format of the Kafka message key: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`, or `NULL`.",
2677 ),
2678 (
2679 "value_format",
2680 "For Kafka sources, the format of the Kafka message value: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`. `NULL` for other source types.",
2681 ),
2682 (
2683 "cluster_id",
2684 "The ID of the cluster maintaining the source. Corresponds to `mz_clusters.id`.",
2685 ),
2686 (
2687 "owner_id",
2688 "The role ID of the owner of the source. Corresponds to `mz_roles.id`.",
2689 ),
2690 ("privileges", "The privileges granted on the source."),
2691 ("create_sql", "The `CREATE` SQL statement for the source."),
2692 (
2693 "redacted_create_sql",
2694 "The redacted `CREATE` SQL statement for the source.",
2695 ),
2696 ]),
2697 is_retained_metrics_object: true,
2698 access: vec![PUBLIC_SELECT],
2699});
2700pub static MZ_SINKS: LazyLock<BuiltinTable> = LazyLock::new(|| {
2701 BuiltinTable {
2702 name: "mz_sinks",
2703 schema: MZ_CATALOG_SCHEMA,
2704 oid: oid::TABLE_MZ_SINKS_OID,
2705 desc: RelationDesc::builder()
2706 .with_column("id", SqlScalarType::String.nullable(false))
2707 .with_column("oid", SqlScalarType::Oid.nullable(false))
2708 .with_column("schema_id", SqlScalarType::String.nullable(false))
2709 .with_column("name", SqlScalarType::String.nullable(false))
2710 .with_column("type", SqlScalarType::String.nullable(false))
2711 .with_column("connection_id", SqlScalarType::String.nullable(true))
2712 .with_column("size", SqlScalarType::String.nullable(true))
2713 .with_column("envelope_type", SqlScalarType::String.nullable(true))
2714 .with_column("format", SqlScalarType::String.nullable(false))
2717 .with_column("key_format", SqlScalarType::String.nullable(true))
2718 .with_column("value_format", SqlScalarType::String.nullable(false))
2719 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2720 .with_column("owner_id", SqlScalarType::String.nullable(false))
2721 .with_column("create_sql", SqlScalarType::String.nullable(false))
2722 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2723 .with_key(vec![0])
2724 .with_key(vec![1])
2725 .finish(),
2726 column_comments: BTreeMap::from_iter([
2727 ("id", "Materialize's unique ID for the sink."),
2728 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the sink."),
2729 (
2730 "schema_id",
2731 "The ID of the schema to which the sink belongs. Corresponds to `mz_schemas.id`.",
2732 ),
2733 ("name", "The name of the sink."),
2734 ("type", "The type of the sink: `kafka`."),
2735 (
2736 "connection_id",
2737 "The ID of the connection associated with the sink, if any. Corresponds to `mz_connections.id`.",
2738 ),
2739 ("size", "The size of the sink."),
2740 (
2741 "envelope_type",
2742 "The envelope of the sink: `upsert`, or `debezium`.",
2743 ),
2744 (
2745 "format",
2746 "Deprecated The format of the Kafka messages produced by the sink: `avro`, `json`, `text`, or `bytes`.",
2747 ),
2748 (
2749 "key_format",
2750 "The format of the Kafka message key for messages produced by the sink: `avro`, `json`, `bytes`, `text`, or `NULL`.",
2751 ),
2752 (
2753 "value_format",
2754 "The format of the Kafka message value for messages produced by the sink: `avro`, `json`, `text`, or `bytes`.",
2755 ),
2756 (
2757 "cluster_id",
2758 "The ID of the cluster maintaining the sink. Corresponds to `mz_clusters.id`.",
2759 ),
2760 (
2761 "owner_id",
2762 "The role ID of the owner of the sink. Corresponds to `mz_roles.id`.",
2763 ),
2764 ("create_sql", "The `CREATE` SQL statement for the sink."),
2765 (
2766 "redacted_create_sql",
2767 "The redacted `CREATE` SQL statement for the sink.",
2768 ),
2769 ]),
2770 is_retained_metrics_object: true,
2771 access: vec![PUBLIC_SELECT],
2772 }
2773});
2774pub static MZ_VIEWS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2775 name: "mz_views",
2776 schema: MZ_CATALOG_SCHEMA,
2777 oid: oid::TABLE_MZ_VIEWS_OID,
2778 desc: RelationDesc::builder()
2779 .with_column("id", SqlScalarType::String.nullable(false))
2780 .with_column("oid", SqlScalarType::Oid.nullable(false))
2781 .with_column("schema_id", SqlScalarType::String.nullable(false))
2782 .with_column("name", SqlScalarType::String.nullable(false))
2783 .with_column("definition", SqlScalarType::String.nullable(false))
2784 .with_column("owner_id", SqlScalarType::String.nullable(false))
2785 .with_column(
2786 "privileges",
2787 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2788 )
2789 .with_column("create_sql", SqlScalarType::String.nullable(false))
2790 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2791 .with_key(vec![0])
2792 .with_key(vec![1])
2793 .finish(),
2794 column_comments: BTreeMap::from_iter([
2795 ("id", "Materialize's unique ID for the view."),
2796 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the view."),
2797 (
2798 "schema_id",
2799 "The ID of the schema to which the view belongs. Corresponds to `mz_schemas.id`.",
2800 ),
2801 ("name", "The name of the view."),
2802 ("definition", "The view definition (a `SELECT` query)."),
2803 (
2804 "owner_id",
2805 "The role ID of the owner of the view. Corresponds to `mz_roles.id`.",
2806 ),
2807 ("privileges", "The privileges belonging to the view."),
2808 ("create_sql", "The `CREATE` SQL statement for the view."),
2809 (
2810 "redacted_create_sql",
2811 "The redacted `CREATE` SQL statement for the view.",
2812 ),
2813 ]),
2814 is_retained_metrics_object: false,
2815 access: vec![PUBLIC_SELECT],
2816});
2817pub static MZ_MATERIALIZED_VIEWS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2818 name: "mz_materialized_views",
2819 schema: MZ_CATALOG_SCHEMA,
2820 oid: oid::TABLE_MZ_MATERIALIZED_VIEWS_OID,
2821 desc: RelationDesc::builder()
2822 .with_column("id", SqlScalarType::String.nullable(false))
2823 .with_column("oid", SqlScalarType::Oid.nullable(false))
2824 .with_column("schema_id", SqlScalarType::String.nullable(false))
2825 .with_column("name", SqlScalarType::String.nullable(false))
2826 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2827 .with_column("definition", SqlScalarType::String.nullable(false))
2828 .with_column("owner_id", SqlScalarType::String.nullable(false))
2829 .with_column(
2830 "privileges",
2831 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2832 )
2833 .with_column("create_sql", SqlScalarType::String.nullable(false))
2834 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2835 .with_key(vec![0])
2836 .with_key(vec![1])
2837 .finish(),
2838 column_comments: BTreeMap::from_iter([
2839 ("id", "Materialize's unique ID for the materialized view."),
2840 (
2841 "oid",
2842 "A [PostgreSQL-compatible OID][`oid`] for the materialized view.",
2843 ),
2844 (
2845 "schema_id",
2846 "The ID of the schema to which the materialized view belongs. Corresponds to `mz_schemas.id`.",
2847 ),
2848 ("name", "The name of the materialized view."),
2849 (
2850 "cluster_id",
2851 "The ID of the cluster maintaining the materialized view. Corresponds to `mz_clusters.id`.",
2852 ),
2853 (
2854 "definition",
2855 "The materialized view definition (a `SELECT` query).",
2856 ),
2857 (
2858 "owner_id",
2859 "The role ID of the owner of the materialized view. Corresponds to `mz_roles.id`.",
2860 ),
2861 (
2862 "privileges",
2863 "The privileges belonging to the materialized view.",
2864 ),
2865 (
2866 "create_sql",
2867 "The `CREATE` SQL statement for the materialized view.",
2868 ),
2869 (
2870 "redacted_create_sql",
2871 "The redacted `CREATE` SQL statement for the materialized view.",
2872 ),
2873 ]),
2874 is_retained_metrics_object: false,
2875 access: vec![PUBLIC_SELECT],
2876});
2877pub static MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES: LazyLock<BuiltinTable> = LazyLock::new(|| {
2878 BuiltinTable {
2879 name: "mz_materialized_view_refresh_strategies",
2880 schema: MZ_INTERNAL_SCHEMA,
2881 oid: oid::TABLE_MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES_OID,
2882 desc: RelationDesc::builder()
2883 .with_column(
2884 "materialized_view_id",
2885 SqlScalarType::String.nullable(false),
2886 )
2887 .with_column("type", SqlScalarType::String.nullable(false))
2888 .with_column("interval", SqlScalarType::Interval.nullable(true))
2889 .with_column(
2890 "aligned_to",
2891 SqlScalarType::TimestampTz { precision: None }.nullable(true),
2892 )
2893 .with_column(
2894 "at",
2895 SqlScalarType::TimestampTz { precision: None }.nullable(true),
2896 )
2897 .finish(),
2898 column_comments: BTreeMap::from_iter([
2899 (
2900 "materialized_view_id",
2901 "The ID of the materialized view. Corresponds to `mz_catalog.mz_materialized_views.id`",
2902 ),
2903 (
2904 "type",
2905 "`at`, `every`, or `on-commit`. Default: `on-commit`",
2906 ),
2907 (
2908 "interval",
2909 "The refresh interval of a `REFRESH EVERY` option, or `NULL` if the `type` is not `every`.",
2910 ),
2911 (
2912 "aligned_to",
2913 "The `ALIGNED TO` option of a `REFRESH EVERY` option, or `NULL` if the `type` is not `every`.",
2914 ),
2915 (
2916 "at",
2917 "The time of a `REFRESH AT`, or `NULL` if the `type` is not `at`.",
2918 ),
2919 ]),
2920 is_retained_metrics_object: false,
2921 access: vec![PUBLIC_SELECT],
2922 }
2923});
2924pub static MZ_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2925 name: "mz_types",
2926 schema: MZ_CATALOG_SCHEMA,
2927 oid: oid::TABLE_MZ_TYPES_OID,
2928 desc: RelationDesc::builder()
2929 .with_column("id", SqlScalarType::String.nullable(false))
2930 .with_column("oid", SqlScalarType::Oid.nullable(false))
2931 .with_column("schema_id", SqlScalarType::String.nullable(false))
2932 .with_column("name", SqlScalarType::String.nullable(false))
2933 .with_column("category", SqlScalarType::String.nullable(false))
2934 .with_column("owner_id", SqlScalarType::String.nullable(false))
2935 .with_column(
2936 "privileges",
2937 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2938 )
2939 .with_column("create_sql", SqlScalarType::String.nullable(true))
2940 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
2941 .with_key(vec![0])
2942 .with_key(vec![1])
2943 .finish(),
2944 column_comments: BTreeMap::from_iter([
2945 ("id", "Materialize's unique ID for the type."),
2946 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the type."),
2947 (
2948 "schema_id",
2949 "The ID of the schema to which the type belongs. Corresponds to `mz_schemas.id`.",
2950 ),
2951 ("name", "The name of the type."),
2952 ("category", "The category of the type."),
2953 (
2954 "owner_id",
2955 "The role ID of the owner of the type. Corresponds to `mz_roles.id`.",
2956 ),
2957 ("privileges", "The privileges belonging to the type."),
2958 ("create_sql", "The `CREATE` SQL statement for the type."),
2959 (
2960 "redacted_create_sql",
2961 "The redacted `CREATE` SQL statement for the type.",
2962 ),
2963 ]),
2964 is_retained_metrics_object: false,
2965 access: vec![PUBLIC_SELECT],
2966});
2967pub static MZ_CONTINUAL_TASKS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2968 name: "mz_continual_tasks",
2969 schema: MZ_INTERNAL_SCHEMA,
2970 oid: oid::TABLE_MZ_CONTINUAL_TASKS_OID,
2971 desc: RelationDesc::builder()
2972 .with_column("id", SqlScalarType::String.nullable(false))
2973 .with_column("oid", SqlScalarType::Oid.nullable(false))
2974 .with_column("schema_id", SqlScalarType::String.nullable(false))
2975 .with_column("name", SqlScalarType::String.nullable(false))
2976 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2977 .with_column("definition", SqlScalarType::String.nullable(false))
2978 .with_column("owner_id", SqlScalarType::String.nullable(false))
2979 .with_column(
2980 "privileges",
2981 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2982 )
2983 .with_column("create_sql", SqlScalarType::String.nullable(false))
2984 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2985 .with_key(vec![0])
2986 .with_key(vec![1])
2987 .finish(),
2988 column_comments: BTreeMap::new(),
2989 is_retained_metrics_object: false,
2990 access: vec![PUBLIC_SELECT],
2991});
2992pub static MZ_NETWORK_POLICIES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2993 name: "mz_network_policies",
2994 schema: MZ_INTERNAL_SCHEMA,
2995 oid: oid::TABLE_MZ_NETWORK_POLICIES_OID,
2996 desc: RelationDesc::builder()
2997 .with_column("id", SqlScalarType::String.nullable(false))
2998 .with_column("name", SqlScalarType::String.nullable(false))
2999 .with_column("owner_id", SqlScalarType::String.nullable(false))
3000 .with_column(
3001 "privileges",
3002 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
3003 )
3004 .with_column("oid", SqlScalarType::Oid.nullable(false))
3005 .finish(),
3006 column_comments: BTreeMap::from_iter([
3007 ("id", "The ID of the network policy."),
3008 ("name", "The name of the network policy."),
3009 (
3010 "owner_id",
3011 "The role ID of the owner of the network policy. Corresponds to `mz_catalog.mz_roles.id`.",
3012 ),
3013 (
3014 "privileges",
3015 "The privileges belonging to the network policy.",
3016 ),
3017 (
3018 "oid",
3019 "A [PostgreSQL-compatible OID][`oid`] for the network policy.",
3020 ),
3021 ]),
3022 is_retained_metrics_object: false,
3023 access: vec![PUBLIC_SELECT],
3024});
3025pub static MZ_NETWORK_POLICY_RULES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3026 name: "mz_network_policy_rules",
3027 schema: MZ_INTERNAL_SCHEMA,
3028 oid: oid::TABLE_MZ_NETWORK_POLICY_RULES_OID,
3029 desc: RelationDesc::builder()
3030 .with_column("name", SqlScalarType::String.nullable(false))
3031 .with_column("policy_id", SqlScalarType::String.nullable(false))
3032 .with_column("action", SqlScalarType::String.nullable(false))
3033 .with_column("address", SqlScalarType::String.nullable(false))
3034 .with_column("direction", SqlScalarType::String.nullable(false))
3035 .finish(),
3036 column_comments: BTreeMap::from_iter([
3037 (
3038 "name",
3039 "The name of the network policy rule. Can be combined with `policy_id` to form a unique identifier.",
3040 ),
3041 (
3042 "policy_id",
3043 "The ID the network policy the rule is part of. Corresponds to `mz_network_policy_rules.id`.",
3044 ),
3045 (
3046 "action",
3047 "The action of the rule. `allow` is the only supported action.",
3048 ),
3049 ("address", "The address the rule will take action on."),
3050 (
3051 "direction",
3052 "The direction of traffic the rule applies to. `ingress` is the only supported direction.",
3053 ),
3054 ]),
3055 is_retained_metrics_object: false,
3056 access: vec![PUBLIC_SELECT],
3057});
3058pub static MZ_TYPE_PG_METADATA: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3061 name: "mz_type_pg_metadata",
3062 schema: MZ_INTERNAL_SCHEMA,
3063 oid: oid::TABLE_MZ_TYPE_PG_METADATA_OID,
3064 desc: RelationDesc::builder()
3065 .with_column("id", SqlScalarType::String.nullable(false))
3066 .with_column("typinput", SqlScalarType::Oid.nullable(false))
3067 .with_column("typreceive", SqlScalarType::Oid.nullable(false))
3068 .finish(),
3069 column_comments: BTreeMap::new(),
3070 is_retained_metrics_object: false,
3071 access: vec![PUBLIC_SELECT],
3072});
3073pub static MZ_ARRAY_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3074 name: "mz_array_types",
3075 schema: MZ_CATALOG_SCHEMA,
3076 oid: oid::TABLE_MZ_ARRAY_TYPES_OID,
3077 desc: RelationDesc::builder()
3078 .with_column("id", SqlScalarType::String.nullable(false))
3079 .with_column("element_id", SqlScalarType::String.nullable(false))
3080 .finish(),
3081 column_comments: BTreeMap::from_iter([
3082 ("id", "The ID of the array type."),
3083 ("element_id", "The ID of the array's element type."),
3084 ]),
3085 is_retained_metrics_object: false,
3086 access: vec![PUBLIC_SELECT],
3087});
3088pub static MZ_BASE_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3089 name: "mz_base_types",
3090 schema: MZ_CATALOG_SCHEMA,
3091 oid: oid::TABLE_MZ_BASE_TYPES_OID,
3092 desc: RelationDesc::builder()
3093 .with_column("id", SqlScalarType::String.nullable(false))
3094 .finish(),
3095 column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]),
3096 is_retained_metrics_object: false,
3097 access: vec![PUBLIC_SELECT],
3098});
3099pub static MZ_LIST_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3100 name: "mz_list_types",
3101 schema: MZ_CATALOG_SCHEMA,
3102 oid: oid::TABLE_MZ_LIST_TYPES_OID,
3103 desc: RelationDesc::builder()
3104 .with_column("id", SqlScalarType::String.nullable(false))
3105 .with_column("element_id", SqlScalarType::String.nullable(false))
3106 .with_column(
3107 "element_modifiers",
3108 SqlScalarType::List {
3109 element_type: Box::new(SqlScalarType::Int64),
3110 custom_id: None,
3111 }
3112 .nullable(true),
3113 )
3114 .finish(),
3115 column_comments: BTreeMap::from_iter([
3116 ("id", "The ID of the list type."),
3117 ("element_id", "The IID of the list's element type."),
3118 (
3119 "element_modifiers",
3120 "The element type modifiers, or `NULL` if none.",
3121 ),
3122 ]),
3123 is_retained_metrics_object: false,
3124 access: vec![PUBLIC_SELECT],
3125});
3126pub static MZ_MAP_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3127 name: "mz_map_types",
3128 schema: MZ_CATALOG_SCHEMA,
3129 oid: oid::TABLE_MZ_MAP_TYPES_OID,
3130 desc: RelationDesc::builder()
3131 .with_column("id", SqlScalarType::String.nullable(false))
3132 .with_column("key_id", SqlScalarType::String.nullable(false))
3133 .with_column("value_id", SqlScalarType::String.nullable(false))
3134 .with_column(
3135 "key_modifiers",
3136 SqlScalarType::List {
3137 element_type: Box::new(SqlScalarType::Int64),
3138 custom_id: None,
3139 }
3140 .nullable(true),
3141 )
3142 .with_column(
3143 "value_modifiers",
3144 SqlScalarType::List {
3145 element_type: Box::new(SqlScalarType::Int64),
3146 custom_id: None,
3147 }
3148 .nullable(true),
3149 )
3150 .finish(),
3151 column_comments: BTreeMap::from_iter([
3152 ("id", "The ID of the map type."),
3153 ("key_id", "The ID of the map's key type."),
3154 ("value_id", "The ID of the map's value type."),
3155 (
3156 "key_modifiers",
3157 "The key type modifiers, or `NULL` if none.",
3158 ),
3159 (
3160 "value_modifiers",
3161 "The value type modifiers, or `NULL` if none.",
3162 ),
3163 ]),
3164 is_retained_metrics_object: false,
3165 access: vec![PUBLIC_SELECT],
3166});
3167pub static MZ_ROLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3168 name: "mz_roles",
3169 schema: MZ_CATALOG_SCHEMA,
3170 oid: oid::TABLE_MZ_ROLES_OID,
3171 desc: RelationDesc::builder()
3172 .with_column("id", SqlScalarType::String.nullable(false))
3173 .with_column("oid", SqlScalarType::Oid.nullable(false))
3174 .with_column("name", SqlScalarType::String.nullable(false))
3175 .with_column("inherit", SqlScalarType::Bool.nullable(false))
3176 .with_key(vec![0])
3177 .with_key(vec![1])
3178 .finish(),
3179 column_comments: BTreeMap::from_iter([
3180 ("id", "Materialize's unique ID for the role."),
3181 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the role."),
3182 ("name", "The name of the role."),
3183 (
3184 "inherit",
3185 "Indicates whether the role has inheritance of privileges.",
3186 ),
3187 ]),
3188 is_retained_metrics_object: false,
3189 access: vec![PUBLIC_SELECT],
3190});
3191pub static MZ_ROLE_MEMBERS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3192 name: "mz_role_members",
3193 schema: MZ_CATALOG_SCHEMA,
3194 oid: oid::TABLE_MZ_ROLE_MEMBERS_OID,
3195 desc: RelationDesc::builder()
3196 .with_column("role_id", SqlScalarType::String.nullable(false))
3197 .with_column("member", SqlScalarType::String.nullable(false))
3198 .with_column("grantor", SqlScalarType::String.nullable(false))
3199 .finish(),
3200 column_comments: BTreeMap::from_iter([
3201 (
3202 "role_id",
3203 "The ID of the role the `member` is a member of. Corresponds to `mz_roles.id`.",
3204 ),
3205 (
3206 "member",
3207 "The ID of the role that is a member of `role_id`. Corresponds to `mz_roles.id`.",
3208 ),
3209 (
3210 "grantor",
3211 "The ID of the role that granted membership of `member` to `role_id`. Corresponds to `mz_roles.id`.",
3212 ),
3213 ]),
3214 is_retained_metrics_object: false,
3215 access: vec![PUBLIC_SELECT],
3216});
3217pub static MZ_ROLE_PARAMETERS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3218 name: "mz_role_parameters",
3219 schema: MZ_CATALOG_SCHEMA,
3220 oid: oid::TABLE_MZ_ROLE_PARAMETERS_OID,
3221 desc: RelationDesc::builder()
3222 .with_column("role_id", SqlScalarType::String.nullable(false))
3223 .with_column("parameter_name", SqlScalarType::String.nullable(false))
3224 .with_column("parameter_value", SqlScalarType::String.nullable(false))
3225 .finish(),
3226 column_comments: BTreeMap::from_iter([
3227 (
3228 "role_id",
3229 "The ID of the role whose configuration parameter default is set. Corresponds to `mz_roles.id`.",
3230 ),
3231 (
3232 "parameter_name",
3233 "The configuration parameter name. One of the supported configuration parameters.",
3234 ),
3235 (
3236 "parameter_value",
3237 "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.",
3238 ),
3239 ]),
3240 is_retained_metrics_object: false,
3241 access: vec![PUBLIC_SELECT],
3242});
3243pub static MZ_PSEUDO_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3244 name: "mz_pseudo_types",
3245 schema: MZ_CATALOG_SCHEMA,
3246 oid: oid::TABLE_MZ_PSEUDO_TYPES_OID,
3247 desc: RelationDesc::builder()
3248 .with_column("id", SqlScalarType::String.nullable(false))
3249 .finish(),
3250 column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]),
3251 is_retained_metrics_object: false,
3252 access: vec![PUBLIC_SELECT],
3253});
3254pub static MZ_FUNCTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| {
3255 BuiltinTable {
3256 name: "mz_functions",
3257 schema: MZ_CATALOG_SCHEMA,
3258 oid: oid::TABLE_MZ_FUNCTIONS_OID,
3259 desc: RelationDesc::builder()
3260 .with_column("id", SqlScalarType::String.nullable(false)) .with_column("oid", SqlScalarType::Oid.nullable(false))
3262 .with_column("schema_id", SqlScalarType::String.nullable(false))
3263 .with_column("name", SqlScalarType::String.nullable(false))
3264 .with_column(
3265 "argument_type_ids",
3266 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
3267 )
3268 .with_column(
3269 "variadic_argument_type_id",
3270 SqlScalarType::String.nullable(true),
3271 )
3272 .with_column("return_type_id", SqlScalarType::String.nullable(true))
3273 .with_column("returns_set", SqlScalarType::Bool.nullable(false))
3274 .with_column("owner_id", SqlScalarType::String.nullable(false))
3275 .finish(),
3276 column_comments: BTreeMap::from_iter([
3277 ("id", "Materialize's unique ID for the function."),
3278 (
3279 "oid",
3280 "A [PostgreSQL-compatible OID][`oid`] for the function.",
3281 ),
3282 (
3283 "schema_id",
3284 "The ID of the schema to which the function belongs. Corresponds to `mz_schemas.id`.",
3285 ),
3286 ("name", "The name of the function."),
3287 (
3288 "argument_type_ids",
3289 "The ID of each argument's type. Each entry refers to `mz_types.id`.",
3290 ),
3291 (
3292 "variadic_argument_type_id",
3293 "The ID of the variadic argument's type, or `NULL` if the function does not have a variadic argument. Refers to `mz_types.id`.",
3294 ),
3295 (
3296 "return_type_id",
3297 "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`].",
3298 ),
3299 (
3300 "returns_set",
3301 "Whether the function returns a set, i.e. the function is a table function.",
3302 ),
3303 (
3304 "owner_id",
3305 "The role ID of the owner of the function. Corresponds to `mz_roles.id`.",
3306 ),
3307 ]),
3308 is_retained_metrics_object: false,
3309 access: vec![PUBLIC_SELECT],
3310 }
3311});
3312pub static MZ_OPERATORS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3313 name: "mz_operators",
3314 schema: MZ_CATALOG_SCHEMA,
3315 oid: oid::TABLE_MZ_OPERATORS_OID,
3316 desc: RelationDesc::builder()
3317 .with_column("oid", SqlScalarType::Oid.nullable(false))
3318 .with_column("name", SqlScalarType::String.nullable(false))
3319 .with_column(
3320 "argument_type_ids",
3321 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
3322 )
3323 .with_column("return_type_id", SqlScalarType::String.nullable(true))
3324 .finish(),
3325 column_comments: BTreeMap::new(),
3326 is_retained_metrics_object: false,
3327 access: vec![PUBLIC_SELECT],
3328});
3329pub static MZ_AGGREGATES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3330 name: "mz_aggregates",
3331 schema: MZ_INTERNAL_SCHEMA,
3332 oid: oid::TABLE_MZ_AGGREGATES_OID,
3333 desc: RelationDesc::builder()
3334 .with_column("oid", SqlScalarType::Oid.nullable(false))
3335 .with_column("agg_kind", SqlScalarType::String.nullable(false))
3336 .with_column("agg_num_direct_args", SqlScalarType::Int16.nullable(false))
3337 .finish(),
3338 column_comments: BTreeMap::new(),
3339 is_retained_metrics_object: false,
3340 access: vec![PUBLIC_SELECT],
3341});
3342
3343pub static MZ_CLUSTERS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3344 name: "mz_clusters",
3345 schema: MZ_CATALOG_SCHEMA,
3346 oid: oid::TABLE_MZ_CLUSTERS_OID,
3347 desc: RelationDesc::builder()
3348 .with_column("id", SqlScalarType::String.nullable(false))
3349 .with_column("name", SqlScalarType::String.nullable(false))
3350 .with_column("owner_id", SqlScalarType::String.nullable(false))
3351 .with_column(
3352 "privileges",
3353 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
3354 )
3355 .with_column("managed", SqlScalarType::Bool.nullable(false))
3356 .with_column("size", SqlScalarType::String.nullable(true))
3357 .with_column("replication_factor", SqlScalarType::UInt32.nullable(true))
3358 .with_column("disk", SqlScalarType::Bool.nullable(true))
3359 .with_column(
3360 "availability_zones",
3361 SqlScalarType::List {
3362 element_type: Box::new(SqlScalarType::String),
3363 custom_id: None,
3364 }
3365 .nullable(true),
3366 )
3367 .with_column(
3368 "introspection_debugging",
3369 SqlScalarType::Bool.nullable(true),
3370 )
3371 .with_column(
3372 "introspection_interval",
3373 SqlScalarType::Interval.nullable(true),
3374 )
3375 .with_key(vec![0])
3376 .finish(),
3377 column_comments: BTreeMap::from_iter([
3378 ("id", "Materialize's unique ID for the cluster."),
3379 ("name", "The name of the cluster."),
3380 (
3381 "owner_id",
3382 "The role ID of the owner of the cluster. Corresponds to `mz_roles.id`.",
3383 ),
3384 ("privileges", "The privileges belonging to the cluster."),
3385 (
3386 "managed",
3387 "Whether the cluster is a managed cluster with automatically managed replicas.",
3388 ),
3389 (
3390 "size",
3391 "If the cluster is managed, the desired size of the cluster's replicas. `NULL` for unmanaged clusters.",
3392 ),
3393 (
3394 "replication_factor",
3395 "If the cluster is managed, the desired number of replicas of the cluster. `NULL` for unmanaged clusters.",
3396 ),
3397 (
3398 "disk",
3399 "Unstable If the cluster is managed, `true` if the replicas have the `DISK` option . `NULL` for unmanaged clusters.",
3400 ),
3401 (
3402 "availability_zones",
3403 "Unstable If the cluster is managed, the list of availability zones specified in `AVAILABILITY ZONES`. `NULL` for unmanaged clusters.",
3404 ),
3405 (
3406 "introspection_debugging",
3407 "Whether introspection of the gathering of the introspection data is enabled.",
3408 ),
3409 (
3410 "introspection_interval",
3411 "The interval at which to collect introspection data.",
3412 ),
3413 ]),
3414 is_retained_metrics_object: false,
3415 access: vec![PUBLIC_SELECT],
3416});
3417
3418pub static MZ_CLUSTER_WORKLOAD_CLASSES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3419 name: "mz_cluster_workload_classes",
3420 schema: MZ_INTERNAL_SCHEMA,
3421 oid: oid::TABLE_MZ_CLUSTER_WORKLOAD_CLASSES_OID,
3422 desc: RelationDesc::builder()
3423 .with_column("id", SqlScalarType::String.nullable(false))
3424 .with_column("workload_class", SqlScalarType::String.nullable(true))
3425 .with_key(vec![0])
3426 .finish(),
3427 column_comments: BTreeMap::new(),
3428 is_retained_metrics_object: false,
3429 access: vec![PUBLIC_SELECT],
3430});
3431
3432pub const MZ_CLUSTER_WORKLOAD_CLASSES_IND: BuiltinIndex = BuiltinIndex {
3433 name: "mz_cluster_workload_classes_ind",
3434 schema: MZ_INTERNAL_SCHEMA,
3435 oid: oid::INDEX_MZ_CLUSTER_WORKLOAD_CLASSES_IND_OID,
3436 sql: "IN CLUSTER mz_catalog_server
3437ON mz_internal.mz_cluster_workload_classes (id)",
3438 is_retained_metrics_object: false,
3439};
3440
3441pub static MZ_CLUSTER_SCHEDULES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3442 name: "mz_cluster_schedules",
3443 schema: MZ_INTERNAL_SCHEMA,
3444 oid: oid::TABLE_MZ_CLUSTER_SCHEDULES_OID,
3445 desc: RelationDesc::builder()
3446 .with_column("cluster_id", SqlScalarType::String.nullable(false))
3447 .with_column("type", SqlScalarType::String.nullable(false))
3448 .with_column(
3449 "refresh_hydration_time_estimate",
3450 SqlScalarType::Interval.nullable(true),
3451 )
3452 .finish(),
3453 column_comments: BTreeMap::from_iter([
3454 (
3455 "cluster_id",
3456 "The ID of the cluster. Corresponds to `mz_clusters.id`.",
3457 ),
3458 ("type", "`on-refresh`, or `manual`. Default: `manual`"),
3459 (
3460 "refresh_hydration_time_estimate",
3461 "The interval given in the `HYDRATION TIME ESTIMATE` option.",
3462 ),
3463 ]),
3464 is_retained_metrics_object: false,
3465 access: vec![PUBLIC_SELECT],
3466});
3467
3468pub static MZ_SECRETS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3469 name: "mz_secrets",
3470 schema: MZ_CATALOG_SCHEMA,
3471 oid: oid::TABLE_MZ_SECRETS_OID,
3472 desc: RelationDesc::builder()
3473 .with_column("id", SqlScalarType::String.nullable(false))
3474 .with_column("oid", SqlScalarType::Oid.nullable(false))
3475 .with_column("schema_id", SqlScalarType::String.nullable(false))
3476 .with_column("name", SqlScalarType::String.nullable(false))
3477 .with_column("owner_id", SqlScalarType::String.nullable(false))
3478 .with_column(
3479 "privileges",
3480 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
3481 )
3482 .finish(),
3483 column_comments: BTreeMap::from_iter([
3484 ("id", "The unique ID of the secret."),
3485 (
3486 "oid",
3487 "A [PostgreSQL-compatible oid][`oid`] for the secret.",
3488 ),
3489 (
3490 "schema_id",
3491 "The ID of the schema to which the secret belongs. Corresponds to `mz_schemas.id`.",
3492 ),
3493 ("name", "The name of the secret."),
3494 (
3495 "owner_id",
3496 "The role ID of the owner of the secret. Corresponds to `mz_roles.id`.",
3497 ),
3498 ("privileges", "The privileges belonging to the secret."),
3499 ]),
3500 is_retained_metrics_object: false,
3501 access: vec![PUBLIC_SELECT],
3502});
3503
3504pub static MZ_CLUSTER_REPLICAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3505 name: "mz_cluster_replicas",
3506 schema: MZ_CATALOG_SCHEMA,
3507 oid: oid::TABLE_MZ_CLUSTER_REPLICAS_OID,
3508 desc: RelationDesc::builder()
3509 .with_column("id", SqlScalarType::String.nullable(false))
3510 .with_column("name", SqlScalarType::String.nullable(false))
3511 .with_column("cluster_id", SqlScalarType::String.nullable(false))
3512 .with_column("size", SqlScalarType::String.nullable(true))
3513 .with_column("availability_zone", SqlScalarType::String.nullable(true))
3516 .with_column("owner_id", SqlScalarType::String.nullable(false))
3517 .with_column("disk", SqlScalarType::Bool.nullable(true))
3518 .finish(),
3519 column_comments: BTreeMap::from_iter([
3520 ("id", "Materialize's unique ID for the cluster replica."),
3521 ("name", "The name of the cluster replica."),
3522 (
3523 "cluster_id",
3524 "The ID of the cluster to which the replica belongs. Corresponds to `mz_clusters.id`.",
3525 ),
3526 (
3527 "size",
3528 "The cluster replica's size, selected during creation.",
3529 ),
3530 (
3531 "availability_zone",
3532 "The availability zone in which the cluster is running.",
3533 ),
3534 (
3535 "owner_id",
3536 "The role ID of the owner of the cluster replica. Corresponds to `mz_roles.id`.",
3537 ),
3538 ("disk", "If the replica has a local disk."),
3539 ]),
3540 is_retained_metrics_object: true,
3541 access: vec![PUBLIC_SELECT],
3542});
3543
3544pub static MZ_INTERNAL_CLUSTER_REPLICAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3545 name: "mz_internal_cluster_replicas",
3546 schema: MZ_INTERNAL_SCHEMA,
3547 oid: oid::TABLE_MZ_INTERNAL_CLUSTER_REPLICAS_OID,
3548 desc: RelationDesc::builder()
3549 .with_column("id", SqlScalarType::String.nullable(false))
3550 .finish(),
3551 column_comments: BTreeMap::from_iter([(
3552 "id",
3553 "The ID of a cluster replica. Corresponds to `mz_cluster_replicas.id`.",
3554 )]),
3555 is_retained_metrics_object: false,
3556 access: vec![PUBLIC_SELECT],
3557});
3558
3559pub static MZ_PENDING_CLUSTER_REPLICAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3560 name: "mz_pending_cluster_replicas",
3561 schema: MZ_INTERNAL_SCHEMA,
3562 oid: oid::TABLE_MZ_PENDING_CLUSTER_REPLICAS_OID,
3563 desc: RelationDesc::builder()
3564 .with_column("id", SqlScalarType::String.nullable(false))
3565 .finish(),
3566 column_comments: BTreeMap::from_iter([(
3567 "id",
3568 "The ID of a cluster replica. Corresponds to `mz_cluster_replicas.id`.",
3569 )]),
3570 is_retained_metrics_object: false,
3571 access: vec![PUBLIC_SELECT],
3572});
3573
3574pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| {
3575 BuiltinSource {
3576 name: "mz_cluster_replica_status_history",
3577 schema: MZ_INTERNAL_SCHEMA,
3578 oid: oid::SOURCE_MZ_CLUSTER_REPLICA_STATUS_HISTORY_OID,
3579 data_source: IntrospectionType::ReplicaStatusHistory,
3580 desc: REPLICA_STATUS_HISTORY_DESC.clone(),
3581 column_comments: BTreeMap::from_iter([
3582 ("replica_id", "The ID of a cluster replica."),
3583 ("process_id", "The ID of a process within the replica."),
3584 (
3585 "status",
3586 "The status of the cluster replica: `online` or `offline`.",
3587 ),
3588 (
3589 "reason",
3590 "If the cluster replica is in an `offline` state, the reason (if available). For example, `oom-killed`.",
3591 ),
3592 (
3593 "occurred_at",
3594 "Wall-clock timestamp at which the event occurred.",
3595 ),
3596 ]),
3597 is_retained_metrics_object: false,
3598 access: vec![PUBLIC_SELECT],
3599 }
3600});
3601
3602pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY_CT: LazyLock<BuiltinContinualTask> = LazyLock::new(
3603 || {
3604 BuiltinContinualTask {
3605 name: "mz_cluster_replica_status_history_ct",
3606 schema: MZ_INTERNAL_SCHEMA,
3607 oid: oid::CT_MZ_CLUSTER_REPLICA_STATUS_HISTORY_OID,
3608 desc: REPLICA_STATUS_HISTORY_DESC.clone(),
3609 sql: "
3610IN CLUSTER mz_catalog_server
3611ON INPUT mz_internal.mz_cluster_replica_status_history AS (
3612 DELETE FROM mz_internal.mz_cluster_replica_status_history_ct WHERE occurred_at + '30d' < mz_now();
3613 INSERT INTO mz_internal.mz_cluster_replica_status_history_ct SELECT * FROM mz_internal.mz_cluster_replica_status_history;
3614)",
3615 access: vec![PUBLIC_SELECT],
3616 }
3617 },
3618);
3619
3620pub static MZ_CLUSTER_REPLICA_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
3621 name: "mz_cluster_replica_statuses",
3622 schema: MZ_INTERNAL_SCHEMA,
3623 oid: oid::VIEW_MZ_CLUSTER_REPLICA_STATUSES_OID,
3624 desc: RelationDesc::builder()
3625 .with_column("replica_id", SqlScalarType::String.nullable(false))
3626 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
3627 .with_column("status", SqlScalarType::String.nullable(false))
3628 .with_column("reason", SqlScalarType::String.nullable(true))
3629 .with_column(
3630 "updated_at",
3631 SqlScalarType::TimestampTz { precision: None }.nullable(false),
3632 )
3633 .with_key(vec![0, 1])
3634 .finish(),
3635 column_comments: BTreeMap::from_iter([
3636 (
3637 "replica_id",
3638 "Materialize's unique ID for the cluster replica.",
3639 ),
3640 (
3641 "process_id",
3642 "The ID of the process within the cluster replica.",
3643 ),
3644 (
3645 "status",
3646 "The status of the cluster replica: `online` or `offline`.",
3647 ),
3648 (
3649 "reason",
3650 "If the cluster replica is in a `offline` state, the reason (if available). For example, `oom-killed`.",
3651 ),
3652 (
3653 "updated_at",
3654 "The time at which the status was last updated.",
3655 ),
3656 ]),
3657 sql: "
3658SELECT
3659 DISTINCT ON (replica_id, process_id)
3660 replica_id,
3661 process_id,
3662 status,
3663 reason,
3664 occurred_at as updated_at
3665FROM mz_internal.mz_cluster_replica_status_history
3666JOIN mz_cluster_replicas r ON r.id = replica_id
3667ORDER BY replica_id, process_id, occurred_at DESC",
3668 access: vec![PUBLIC_SELECT],
3669});
3670
3671pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3672 name: "mz_cluster_replica_sizes",
3673 schema: MZ_CATALOG_SCHEMA,
3674 oid: oid::TABLE_MZ_CLUSTER_REPLICA_SIZES_OID,
3675 desc: RelationDesc::builder()
3676 .with_column("size", SqlScalarType::String.nullable(false))
3677 .with_column("processes", SqlScalarType::UInt64.nullable(false))
3678 .with_column("workers", SqlScalarType::UInt64.nullable(false))
3679 .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(false))
3680 .with_column("memory_bytes", SqlScalarType::UInt64.nullable(false))
3681 .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true))
3682 .with_column(
3683 "credits_per_hour",
3684 SqlScalarType::Numeric { max_scale: None }.nullable(false),
3685 )
3686 .finish(),
3687 column_comments: BTreeMap::from_iter([
3688 ("size", "The human-readable replica size."),
3689 ("processes", "The number of processes in the replica."),
3690 (
3691 "workers",
3692 "The number of Timely Dataflow workers per process.",
3693 ),
3694 (
3695 "cpu_nano_cores",
3696 "The CPU allocation per process, in billionths of a vCPU core.",
3697 ),
3698 (
3699 "memory_bytes",
3700 "The RAM allocation per process, in billionths of a vCPU core.",
3701 ),
3702 ("disk_bytes", "The disk allocation per process."),
3703 (
3704 "credits_per_hour",
3705 "The number of compute credits consumed per hour.",
3706 ),
3707 ]),
3708 is_retained_metrics_object: true,
3709 access: vec![PUBLIC_SELECT],
3710});
3711
3712pub static MZ_AUDIT_EVENTS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3713 name: "mz_audit_events",
3714 schema: MZ_CATALOG_SCHEMA,
3715 oid: oid::TABLE_MZ_AUDIT_EVENTS_OID,
3716 desc: RelationDesc::builder()
3717 .with_column("id", SqlScalarType::UInt64.nullable(false))
3718 .with_column("event_type", SqlScalarType::String.nullable(false))
3719 .with_column("object_type", SqlScalarType::String.nullable(false))
3720 .with_column("details", SqlScalarType::Jsonb.nullable(false))
3721 .with_column("user", SqlScalarType::String.nullable(true))
3722 .with_column(
3723 "occurred_at",
3724 SqlScalarType::TimestampTz { precision: None }.nullable(false),
3725 )
3726 .with_key(vec![0])
3727 .finish(),
3728 column_comments: BTreeMap::from_iter([
3729 (
3730 "id",
3731 "Materialize's unique, monotonically increasing ID for the event.",
3732 ),
3733 (
3734 "event_type",
3735 "The type of the event: `create`, `drop`, or `alter`.",
3736 ),
3737 (
3738 "object_type",
3739 "The type of the affected object: `cluster`, `cluster-replica`, `connection`, `database`, `function`, `index`, `materialized-view`, `role`, `schema`, `secret`, `sink`, `source`, `table`, `type`, or `view`.",
3740 ),
3741 (
3742 "details",
3743 "Additional details about the event. The shape of the details varies based on `event_type` and `object_type`.",
3744 ),
3745 (
3746 "user",
3747 "The user who triggered the event, or `NULL` if triggered by the system.",
3748 ),
3749 (
3750 "occurred_at",
3751 "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.",
3752 ),
3753 ]),
3754 is_retained_metrics_object: false,
3755 access: vec![PUBLIC_SELECT],
3756});
3757
3758pub static MZ_SOURCE_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
3759 name: "mz_source_status_history",
3760 schema: MZ_INTERNAL_SCHEMA,
3761 oid: oid::SOURCE_MZ_SOURCE_STATUS_HISTORY_OID,
3762 data_source: IntrospectionType::SourceStatusHistory,
3763 desc: MZ_SOURCE_STATUS_HISTORY_DESC.clone(),
3764 column_comments: BTreeMap::from_iter([
3765 (
3766 "occurred_at",
3767 "Wall-clock timestamp of the source status change.",
3768 ),
3769 (
3770 "source_id",
3771 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
3772 ),
3773 (
3774 "status",
3775 "The status of the source: one of `created`, `starting`, `running`, `paused`, `stalled`, `failed`, or `dropped`.",
3776 ),
3777 (
3778 "error",
3779 "If the source is in an error state, the error message.",
3780 ),
3781 (
3782 "details",
3783 "Additional metadata provided by the source. In case of error, may contain a `hint` field with helpful suggestions.",
3784 ),
3785 (
3786 "replica_id",
3787 "The ID of the replica that an instance of a source is running on.",
3788 ),
3789 ]),
3790 is_retained_metrics_object: false,
3791 access: vec![PUBLIC_SELECT],
3792});
3793
3794pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(
3795 || BuiltinSource {
3796 name: "mz_aws_privatelink_connection_status_history",
3797 schema: MZ_INTERNAL_SCHEMA,
3798 oid: oid::SOURCE_MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_OID,
3799 data_source: IntrospectionType::PrivatelinkConnectionStatusHistory,
3800 desc: MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_DESC.clone(),
3801 column_comments: BTreeMap::from_iter([
3802 ("occurred_at", "Wall-clock timestamp of the status change."),
3803 (
3804 "connection_id",
3805 "The unique identifier of the AWS PrivateLink connection. Corresponds to `mz_catalog.mz_connections.id`.",
3806 ),
3807 (
3808 "status",
3809 "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`.",
3810 ),
3811 ]),
3812 is_retained_metrics_object: false,
3813 access: vec![PUBLIC_SELECT],
3814 },
3815);
3816
3817pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUSES: LazyLock<BuiltinView> =
3818 LazyLock::new(|| BuiltinView {
3819 name: "mz_aws_privatelink_connection_statuses",
3820 schema: MZ_INTERNAL_SCHEMA,
3821 oid: oid::VIEW_MZ_AWS_PRIVATELINK_CONNECTION_STATUSES_OID,
3822 desc: RelationDesc::builder()
3823 .with_column("id", SqlScalarType::String.nullable(false))
3824 .with_column("name", SqlScalarType::String.nullable(false))
3825 .with_column(
3826 "last_status_change_at",
3827 SqlScalarType::TimestampTz { precision: None }.nullable(true),
3828 )
3829 .with_column("status", SqlScalarType::String.nullable(true))
3830 .with_key(vec![0])
3831 .finish(),
3832 column_comments: BTreeMap::from_iter([
3833 (
3834 "id",
3835 "The ID of the connection. Corresponds to `mz_catalog.mz_connections.id`.",
3836 ),
3837 ("name", "The name of the connection."),
3838 (
3839 "last_status_change_at",
3840 "Wall-clock timestamp of the connection status change.",
3841 ),
3842 ("status", ""),
3843 ]),
3844 sql: "
3845 WITH statuses_w_last_status AS (
3846 SELECT
3847 connection_id,
3848 occurred_at,
3849 status,
3850 lag(status) OVER (PARTITION BY connection_id ORDER BY occurred_at) AS last_status
3851 FROM mz_internal.mz_aws_privatelink_connection_status_history
3852 ),
3853 latest_events AS (
3854 -- Only take the most recent transition for each ID
3855 SELECT DISTINCT ON(connection_id) connection_id, occurred_at, status
3856 FROM statuses_w_last_status
3857 -- Only keep first status transitions
3858 WHERE status <> last_status OR last_status IS NULL
3859 ORDER BY connection_id, occurred_at DESC
3860 )
3861 SELECT
3862 conns.id,
3863 name,
3864 occurred_at as last_status_change_at,
3865 status
3866 FROM latest_events
3867 JOIN mz_catalog.mz_connections AS conns
3868 ON conns.id = latest_events.connection_id",
3869 access: vec![PUBLIC_SELECT],
3870 });
3871
3872pub static MZ_STATEMENT_EXECUTION_HISTORY: LazyLock<BuiltinSource> =
3873 LazyLock::new(|| BuiltinSource {
3874 name: "mz_statement_execution_history",
3875 schema: MZ_INTERNAL_SCHEMA,
3876 oid: oid::SOURCE_MZ_STATEMENT_EXECUTION_HISTORY_OID,
3877 data_source: IntrospectionType::StatementExecutionHistory,
3878 desc: MZ_STATEMENT_EXECUTION_HISTORY_DESC.clone(),
3879 column_comments: BTreeMap::new(),
3880 is_retained_metrics_object: false,
3881 access: vec![MONITOR_SELECT],
3882 });
3883
3884pub static MZ_STATEMENT_EXECUTION_HISTORY_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| {
3885 BuiltinView {
3886 name: "mz_statement_execution_history_redacted",
3887 schema: MZ_INTERNAL_SCHEMA,
3888 oid: oid::VIEW_MZ_STATEMENT_EXECUTION_HISTORY_REDACTED_OID,
3889 desc: RelationDesc::builder()
3891 .with_column("id", SqlScalarType::Uuid.nullable(false))
3892 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
3893 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
3894 .with_column("cluster_id", SqlScalarType::String.nullable(true))
3895 .with_column("application_name", SqlScalarType::String.nullable(false))
3896 .with_column("cluster_name", SqlScalarType::String.nullable(true))
3897 .with_column("database_name", SqlScalarType::String.nullable(false))
3898 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
3899 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
3900 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
3901 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
3902 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
3903 .with_column("mz_version", SqlScalarType::String.nullable(false))
3904 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
3905 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
3906 .with_column("finished_status", SqlScalarType::String.nullable(true))
3907 .with_column("result_size", SqlScalarType::Int64.nullable(true))
3908 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
3909 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
3910 .finish(),
3911 column_comments: BTreeMap::new(),
3912 sql: "
3913SELECT id, prepared_statement_id, sample_rate, cluster_id, application_name,
3914cluster_name, database_name, search_path, transaction_isolation, execution_timestamp, transaction_id,
3915transient_index_id, mz_version, began_at, finished_at, finished_status,
3916result_size, rows_returned, execution_strategy
3917FROM mz_internal.mz_statement_execution_history",
3918 access: vec![SUPPORT_SELECT, ANALYTICS_SELECT, MONITOR_REDACTED_SELECT, MONITOR_SELECT],
3919}
3920});
3921
3922pub static MZ_PREPARED_STATEMENT_HISTORY: LazyLock<BuiltinSource> =
3923 LazyLock::new(|| BuiltinSource {
3924 name: "mz_prepared_statement_history",
3925 schema: MZ_INTERNAL_SCHEMA,
3926 oid: oid::SOURCE_MZ_PREPARED_STATEMENT_HISTORY_OID,
3927 data_source: IntrospectionType::PreparedStatementHistory,
3928 desc: MZ_PREPARED_STATEMENT_HISTORY_DESC.clone(),
3929 column_comments: BTreeMap::new(),
3930 is_retained_metrics_object: false,
3931 access: vec![
3932 SUPPORT_SELECT,
3933 ANALYTICS_SELECT,
3934 MONITOR_REDACTED_SELECT,
3935 MONITOR_SELECT,
3936 ],
3937 });
3938
3939pub static MZ_SQL_TEXT: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
3940 name: "mz_sql_text",
3941 schema: MZ_INTERNAL_SCHEMA,
3942 oid: oid::SOURCE_MZ_SQL_TEXT_OID,
3943 desc: MZ_SQL_TEXT_DESC.clone(),
3944 data_source: IntrospectionType::SqlText,
3945 column_comments: BTreeMap::new(),
3946 is_retained_metrics_object: false,
3947 access: vec![MONITOR_SELECT],
3948});
3949
3950pub static MZ_SQL_TEXT_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
3951 name: "mz_sql_text_redacted",
3952 schema: MZ_INTERNAL_SCHEMA,
3953 oid: oid::VIEW_MZ_SQL_TEXT_REDACTED_OID,
3954 desc: RelationDesc::builder()
3955 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
3956 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
3957 .finish(),
3958 column_comments: BTreeMap::new(),
3959 sql: "SELECT sql_hash, redacted_sql FROM mz_internal.mz_sql_text",
3960 access: vec![
3961 MONITOR_SELECT,
3962 MONITOR_REDACTED_SELECT,
3963 SUPPORT_SELECT,
3964 ANALYTICS_SELECT,
3965 ],
3966});
3967
3968pub static MZ_RECENT_SQL_TEXT: LazyLock<BuiltinView> = LazyLock::new(|| {
3969 BuiltinView {
3970 name: "mz_recent_sql_text",
3971 schema: MZ_INTERNAL_SCHEMA,
3972 oid: oid::VIEW_MZ_RECENT_SQL_TEXT_OID,
3973 desc: RelationDesc::builder()
3978 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
3979 .with_column("sql", SqlScalarType::String.nullable(false))
3980 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
3981 .with_key(vec![0, 1, 2])
3982 .finish(),
3983 column_comments: BTreeMap::new(),
3984 sql: "SELECT DISTINCT sql_hash, sql, redacted_sql FROM mz_internal.mz_sql_text WHERE prepared_day + INTERVAL '4 days' >= mz_now()",
3985 access: vec![MONITOR_SELECT],
3986 }
3987});
3988
3989pub static MZ_RECENT_SQL_TEXT_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
3990 name: "mz_recent_sql_text_redacted",
3991 schema: MZ_INTERNAL_SCHEMA,
3992 oid: oid::VIEW_MZ_RECENT_SQL_TEXT_REDACTED_OID,
3993 desc: RelationDesc::builder()
3994 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
3995 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
3996 .finish(),
3997 column_comments: BTreeMap::new(),
3998 sql: "SELECT sql_hash, redacted_sql FROM mz_internal.mz_recent_sql_text",
3999 access: vec![
4000 MONITOR_SELECT,
4001 MONITOR_REDACTED_SELECT,
4002 SUPPORT_SELECT,
4003 ANALYTICS_SELECT,
4004 ],
4005});
4006
4007pub static MZ_RECENT_SQL_TEXT_IND: LazyLock<BuiltinIndex> = LazyLock::new(|| BuiltinIndex {
4008 name: "mz_recent_sql_text_ind",
4009 schema: MZ_INTERNAL_SCHEMA,
4010 oid: oid::INDEX_MZ_RECENT_SQL_TEXT_IND_OID,
4011 sql: "IN CLUSTER mz_catalog_server ON mz_internal.mz_recent_sql_text (sql_hash)",
4012 is_retained_metrics_object: false,
4013});
4014
4015pub static MZ_SESSION_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
4016 name: "mz_session_history",
4017 schema: MZ_INTERNAL_SCHEMA,
4018 oid: oid::SOURCE_MZ_SESSION_HISTORY_OID,
4019 data_source: IntrospectionType::SessionHistory,
4020 desc: MZ_SESSION_HISTORY_DESC.clone(),
4021 column_comments: BTreeMap::new(),
4022 is_retained_metrics_object: false,
4023 access: vec![PUBLIC_SELECT],
4024});
4025
4026pub static MZ_ACTIVITY_LOG_THINNED: LazyLock<BuiltinView> = LazyLock::new(|| {
4027 BuiltinView {
4028 name: "mz_activity_log_thinned",
4029 schema: MZ_INTERNAL_SCHEMA,
4030 oid: oid::VIEW_MZ_ACTIVITY_LOG_THINNED_OID,
4031 desc: RelationDesc::builder()
4032 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4033 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4034 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4035 .with_column("application_name", SqlScalarType::String.nullable(false))
4036 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4037 .with_column("database_name", SqlScalarType::String.nullable(false))
4038 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
4039 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
4040 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4041 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4042 .with_column("params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false))
4043 .with_column("mz_version", SqlScalarType::String.nullable(false))
4044 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4045 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
4046 .with_column("finished_status", SqlScalarType::String.nullable(true))
4047 .with_column("error_message", SqlScalarType::String.nullable(true))
4048 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4049 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4050 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4051 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4052 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4053 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4054 .with_column("prepared_statement_name", SqlScalarType::String.nullable(false))
4055 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4056 .with_column("prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4057 .with_column("statement_type", SqlScalarType::String.nullable(true))
4058 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4059 .with_column("connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4060 .with_column("initial_application_name", SqlScalarType::String.nullable(false))
4061 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4062 .finish(),
4063 column_comments: BTreeMap::new(),
4064 sql: "
4065SELECT mseh.id AS execution_id, sample_rate, cluster_id, application_name, cluster_name, database_name, search_path,
4066transaction_isolation, execution_timestamp, transient_index_id, params, mz_version, began_at, finished_at, finished_status,
4067error_message, result_size, rows_returned, execution_strategy, transaction_id,
4068mpsh.id AS prepared_statement_id, sql_hash, mpsh.name AS prepared_statement_name,
4069mpsh.session_id, prepared_at, statement_type, throttled_count,
4070connected_at, initial_application_name, authenticated_user
4071FROM mz_internal.mz_statement_execution_history mseh,
4072 mz_internal.mz_prepared_statement_history mpsh,
4073 mz_internal.mz_session_history msh
4074WHERE mseh.prepared_statement_id = mpsh.id
4075AND mpsh.session_id = msh.session_id",
4076 access: vec![MONITOR_SELECT],
4077 }
4078});
4079
4080pub static MZ_RECENT_ACTIVITY_LOG_THINNED: LazyLock<BuiltinView> = LazyLock::new(|| {
4081 BuiltinView {
4082 name: "mz_recent_activity_log_thinned",
4083 schema: MZ_INTERNAL_SCHEMA,
4084 oid: oid::VIEW_MZ_RECENT_ACTIVITY_LOG_THINNED_OID,
4085 desc: RelationDesc::builder()
4086 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4087 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4088 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4089 .with_column("application_name", SqlScalarType::String.nullable(false))
4090 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4091 .with_column("database_name", SqlScalarType::String.nullable(false))
4092 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
4093 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
4094 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4095 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4096 .with_column("params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false))
4097 .with_column("mz_version", SqlScalarType::String.nullable(false))
4098 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4099 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
4100 .with_column("finished_status", SqlScalarType::String.nullable(true))
4101 .with_column("error_message", SqlScalarType::String.nullable(true))
4102 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4103 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4104 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4105 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4106 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4107 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4108 .with_column("prepared_statement_name", SqlScalarType::String.nullable(false))
4109 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4110 .with_column("prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4111 .with_column("statement_type", SqlScalarType::String.nullable(true))
4112 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4113 .with_column("connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4114 .with_column("initial_application_name", SqlScalarType::String.nullable(false))
4115 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4116 .finish(),
4117 column_comments: BTreeMap::new(),
4118 sql:
4121 "SELECT * FROM mz_internal.mz_activity_log_thinned WHERE prepared_at + INTERVAL '1 day' > mz_now()
4122AND began_at + INTERVAL '1 day' > mz_now() AND connected_at + INTERVAL '2 days' > mz_now()",
4123 access: vec![MONITOR_SELECT],
4124 }
4125});
4126
4127pub static MZ_RECENT_ACTIVITY_LOG: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4128 name: "mz_recent_activity_log",
4129 schema: MZ_INTERNAL_SCHEMA,
4130 oid: oid::VIEW_MZ_RECENT_ACTIVITY_LOG_OID,
4131 desc: RelationDesc::builder()
4132 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4133 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4134 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4135 .with_column("application_name", SqlScalarType::String.nullable(false))
4136 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4137 .with_column("database_name", SqlScalarType::String.nullable(false))
4138 .with_column(
4139 "search_path",
4140 SqlScalarType::List {
4141 element_type: Box::new(SqlScalarType::String),
4142 custom_id: None,
4143 }
4144 .nullable(false),
4145 )
4146 .with_column(
4147 "transaction_isolation",
4148 SqlScalarType::String.nullable(false),
4149 )
4150 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4151 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4152 .with_column(
4153 "params",
4154 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
4155 )
4156 .with_column("mz_version", SqlScalarType::String.nullable(false))
4157 .with_column(
4158 "began_at",
4159 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4160 )
4161 .with_column(
4162 "finished_at",
4163 SqlScalarType::TimestampTz { precision: None }.nullable(true),
4164 )
4165 .with_column("finished_status", SqlScalarType::String.nullable(true))
4166 .with_column("error_message", SqlScalarType::String.nullable(true))
4167 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4168 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4169 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4170 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4171 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4172 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4173 .with_column(
4174 "prepared_statement_name",
4175 SqlScalarType::String.nullable(false),
4176 )
4177 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4178 .with_column(
4179 "prepared_at",
4180 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4181 )
4182 .with_column("statement_type", SqlScalarType::String.nullable(true))
4183 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4184 .with_column(
4185 "connected_at",
4186 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4187 )
4188 .with_column(
4189 "initial_application_name",
4190 SqlScalarType::String.nullable(false),
4191 )
4192 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4193 .with_column("sql", SqlScalarType::String.nullable(false))
4194 .finish(),
4195 column_comments: BTreeMap::from_iter([
4196 (
4197 "execution_id",
4198 "An ID that is unique for each executed statement.",
4199 ),
4200 (
4201 "sample_rate",
4202 "The actual rate at which the statement was sampled.",
4203 ),
4204 (
4205 "cluster_id",
4206 "The ID of the cluster the statement execution was directed to. Corresponds to mz_clusters.id.",
4207 ),
4208 (
4209 "application_name",
4210 "The value of the `application_name` configuration parameter at execution time.",
4211 ),
4212 (
4213 "cluster_name",
4214 "The name of the cluster with ID `cluster_id` at execution time.",
4215 ),
4216 (
4217 "database_name",
4218 "The value of the `database` configuration parameter at execution time.",
4219 ),
4220 (
4221 "search_path",
4222 "The value of the `search_path` configuration parameter at execution time.",
4223 ),
4224 (
4225 "transaction_isolation",
4226 "The value of the `transaction_isolation` configuration parameter at execution time.",
4227 ),
4228 (
4229 "execution_timestamp",
4230 "The logical timestamp at which execution was scheduled.",
4231 ),
4232 (
4233 "transient_index_id",
4234 "The internal index of the compute dataflow created for the query, if any.",
4235 ),
4236 (
4237 "params",
4238 "The parameters with which the statement was executed.",
4239 ),
4240 (
4241 "mz_version",
4242 "The version of Materialize that was running when the statement was executed.",
4243 ),
4244 (
4245 "began_at",
4246 "The wall-clock time at which the statement began executing.",
4247 ),
4248 (
4249 "finished_at",
4250 "The wall-clock time at which the statement finished executing.",
4251 ),
4252 (
4253 "finished_status",
4254 "The final status of the statement (e.g., `success`, `canceled`, `error`, or `aborted`). `aborted` means that Materialize exited before the statement finished executing.",
4255 ),
4256 (
4257 "error_message",
4258 "The error message, if the statement failed.",
4259 ),
4260 (
4261 "result_size",
4262 "The size in bytes of the result, for statements that return rows.",
4263 ),
4264 (
4265 "rows_returned",
4266 "The number of rows returned, for statements that return rows.",
4267 ),
4268 (
4269 "execution_strategy",
4270 "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.",
4271 ),
4272 (
4273 "transaction_id",
4274 "The ID of the transaction that the statement was part of. Note that transaction IDs are only unique per session.",
4275 ),
4276 (
4277 "prepared_statement_id",
4278 "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`).",
4279 ),
4280 (
4281 "sql_hash",
4282 "An opaque value uniquely identifying the text of the query.",
4283 ),
4284 (
4285 "prepared_statement_name",
4286 "The name given by the client library to the prepared statement.",
4287 ),
4288 (
4289 "session_id",
4290 "An ID that is unique for each session. Corresponds to mz_sessions.id.",
4291 ),
4292 (
4293 "prepared_at",
4294 "The time at which the statement was prepared.",
4295 ),
4296 (
4297 "statement_type",
4298 "The type of the statement, e.g. `select` for a `SELECT` query, or `NULL` if the statement was empty.",
4299 ),
4300 (
4301 "throttled_count",
4302 "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.",
4303 ),
4304 (
4305 "connected_at",
4306 "The time at which the session was established.",
4307 ),
4308 (
4309 "initial_application_name",
4310 "The initial value of `application_name` at the beginning of the session.",
4311 ),
4312 (
4313 "authenticated_user",
4314 "The name of the user for which the session was established.",
4315 ),
4316 ("sql", "The SQL text of the statement."),
4317 ]),
4318 sql: "SELECT mralt.*, mrst.sql
4319FROM mz_internal.mz_recent_activity_log_thinned mralt,
4320 mz_internal.mz_recent_sql_text mrst
4321WHERE mralt.sql_hash = mrst.sql_hash",
4322 access: vec![MONITOR_SELECT],
4323});
4324
4325pub static MZ_RECENT_ACTIVITY_LOG_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| {
4326 BuiltinView {
4327 name: "mz_recent_activity_log_redacted",
4328 schema: MZ_INTERNAL_SCHEMA,
4329 oid: oid::VIEW_MZ_RECENT_ACTIVITY_LOG_REDACTED_OID,
4330 desc: RelationDesc::builder()
4332 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4333 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4334 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4335 .with_column("application_name", SqlScalarType::String.nullable(false))
4336 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4337 .with_column("database_name", SqlScalarType::String.nullable(false))
4338 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
4339 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
4340 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4341 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4342 .with_column("params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false))
4343 .with_column("mz_version", SqlScalarType::String.nullable(false))
4344 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4345 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
4346 .with_column("finished_status", SqlScalarType::String.nullable(true))
4347 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4348 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4349 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4350 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4351 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4352 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4353 .with_column("prepared_statement_name", SqlScalarType::String.nullable(false))
4354 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4355 .with_column("prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4356 .with_column("statement_type", SqlScalarType::String.nullable(true))
4357 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4358 .with_column("initial_application_name", SqlScalarType::String.nullable(false))
4359 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4360 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
4361 .finish(),
4362 column_comments: BTreeMap::new(),
4363 sql: "SELECT mralt.execution_id, mralt.sample_rate, mralt.cluster_id, mralt.application_name,
4364 mralt.cluster_name, mralt.database_name, mralt.search_path, mralt.transaction_isolation, mralt.execution_timestamp,
4365 mralt.transient_index_id, mralt.params, mralt.mz_version, mralt.began_at, mralt.finished_at,
4366 mralt.finished_status, mralt.result_size, mralt.rows_returned, mralt.execution_strategy, mralt.transaction_id,
4367 mralt.prepared_statement_id, mralt.sql_hash, mralt.prepared_statement_name, mralt.session_id,
4368 mralt.prepared_at, mralt.statement_type, mralt.throttled_count,
4369 mralt.initial_application_name, mralt.authenticated_user,
4370 mrst.redacted_sql
4371FROM mz_internal.mz_recent_activity_log_thinned mralt,
4372 mz_internal.mz_recent_sql_text mrst
4373WHERE mralt.sql_hash = mrst.sql_hash",
4374 access: vec![MONITOR_SELECT, MONITOR_REDACTED_SELECT, SUPPORT_SELECT, ANALYTICS_SELECT],
4375}
4376});
4377
4378pub static MZ_STATEMENT_LIFECYCLE_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| {
4379 BuiltinSource {
4380 name: "mz_statement_lifecycle_history",
4381 schema: MZ_INTERNAL_SCHEMA,
4382 oid: oid::SOURCE_MZ_STATEMENT_LIFECYCLE_HISTORY_OID,
4383 desc: RelationDesc::builder()
4384 .with_column("statement_id", SqlScalarType::Uuid.nullable(false))
4385 .with_column("event_type", SqlScalarType::String.nullable(false))
4386 .with_column(
4387 "occurred_at",
4388 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4389 )
4390 .finish(),
4391 data_source: IntrospectionType::StatementLifecycleHistory,
4392 column_comments: BTreeMap::from_iter([
4393 (
4394 "statement_id",
4395 "The ID of the execution event. Corresponds to `mz_recent_activity_log.execution_id`",
4396 ),
4397 (
4398 "event_type",
4399 "The type of lifecycle event, e.g. `'execution-began'`, `'storage-dependencies-finished'`, `'compute-dependencies-finished'`, or `'execution-finished'`",
4400 ),
4401 ("occurred_at", "The time at which the event took place."),
4402 ]),
4403 is_retained_metrics_object: false,
4404 access: vec![
4408 SUPPORT_SELECT,
4409 ANALYTICS_SELECT,
4410 MONITOR_REDACTED_SELECT,
4411 MONITOR_SELECT,
4412 ],
4413 }
4414});
4415
4416pub static MZ_SOURCE_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4417 name: "mz_source_statuses",
4418 schema: MZ_INTERNAL_SCHEMA,
4419 oid: oid::VIEW_MZ_SOURCE_STATUSES_OID,
4420 desc: RelationDesc::builder()
4421 .with_column("id", SqlScalarType::String.nullable(false))
4422 .with_column("name", SqlScalarType::String.nullable(false))
4423 .with_column("type", SqlScalarType::String.nullable(false))
4424 .with_column(
4425 "last_status_change_at",
4426 SqlScalarType::TimestampTz { precision: None }.nullable(true),
4427 )
4428 .with_column("status", SqlScalarType::String.nullable(false))
4429 .with_column("error", SqlScalarType::String.nullable(true))
4430 .with_column("details", SqlScalarType::Jsonb.nullable(true))
4431 .finish(),
4432 column_comments: BTreeMap::from_iter([
4433 (
4434 "id",
4435 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
4436 ),
4437 ("name", "The name of the source."),
4438 ("type", "The type of the source."),
4439 (
4440 "last_status_change_at",
4441 "Wall-clock timestamp of the source status change.",
4442 ),
4443 (
4444 "status",
4445 "The status of the source: one of `created`, `starting`, `running`, `paused`, `stalled`, `failed`, or `dropped`.",
4446 ),
4447 (
4448 "error",
4449 "If the source is in an error state, the error message.",
4450 ),
4451 (
4452 "details",
4453 "Additional metadata provided by the source. In case of error, may contain a `hint` field with helpful suggestions.",
4454 ),
4455 ]),
4456 sql: "
4457 WITH
4458 -- The status history contains per-replica events and source-global events.
4459 -- For the latter, replica_id is NULL. We turn these into '<source>', so that
4460 -- we can treat them uniformly below.
4461 uniform_status_history AS
4462 (
4463 SELECT
4464 s.source_id,
4465 COALESCE(s.replica_id, '<source>') as replica_id,
4466 s.occurred_at,
4467 s.status,
4468 s.error,
4469 s.details
4470 FROM mz_internal.mz_source_status_history s
4471 ),
4472 -- For getting the latest events, we first determine the latest per-replica
4473 -- events here and then apply precedence rules below.
4474 latest_per_replica_events AS
4475 (
4476 SELECT DISTINCT ON (source_id, replica_id)
4477 occurred_at, source_id, replica_id, status, error, details
4478 FROM uniform_status_history
4479 ORDER BY source_id, replica_id, occurred_at DESC
4480 ),
4481 -- We have a precedence list that determines the overall status in case
4482 -- there is differing per-replica (including source-global) statuses. If
4483 -- there is no 'dropped' status, and any replica reports 'running', the
4484 -- overall status is 'running' even if there might be some replica that has
4485 -- errors or is paused.
4486 latest_events AS
4487 (
4488 SELECT DISTINCT ON (source_id)
4489 source_id,
4490 occurred_at,
4491 status,
4492 error,
4493 details
4494 FROM latest_per_replica_events
4495 ORDER BY source_id, CASE status
4496 WHEN 'dropped' THEN 1
4497 WHEN 'running' THEN 2
4498 WHEN 'stalled' THEN 3
4499 WHEN 'starting' THEN 4
4500 WHEN 'paused' THEN 5
4501 WHEN 'ceased' THEN 6
4502 ELSE 7 -- For any other status values
4503 END
4504 ),
4505 -- Determine which sources are subsources and which are parent sources
4506 subsources AS
4507 (
4508 SELECT subsources.id AS self, sources.id AS parent
4509 FROM
4510 mz_catalog.mz_sources AS subsources
4511 JOIN
4512 mz_internal.mz_object_dependencies AS deps
4513 ON subsources.id = deps.object_id
4514 JOIN mz_catalog.mz_sources AS sources ON sources.id = deps.referenced_object_id
4515 ),
4516 -- Determine which sources are source tables
4517 tables AS
4518 (
4519 SELECT tables.id AS self, tables.source_id AS parent, tables.name
4520 FROM mz_catalog.mz_tables AS tables
4521 WHERE tables.source_id IS NOT NULL
4522 ),
4523 -- Determine which collection's ID to use for the status
4524 id_of_status_to_use AS
4525 (
4526 SELECT
4527 self_events.source_id,
4528 -- If self not errored, but parent is, use parent; else self
4529 CASE
4530 WHEN
4531 self_events.status <> 'ceased' AND
4532 parent_events.status = 'stalled'
4533 THEN parent_events.source_id
4534 -- TODO: Remove this once subsources eagerly propogate their status
4535 -- Subsources move from starting to running lazily once they see
4536 -- a record flow through, even though they are online and healthy.
4537 -- This has been repeatedly brought up as confusing by users.
4538 -- So now, if the parent source is running, and the subsource is
4539 -- starting, we override its status to running to relfect its healthy
4540 -- status.
4541 WHEN
4542 self_events.status = 'starting' AND
4543 parent_events.status = 'running'
4544 THEN parent_events.source_id
4545 ELSE self_events.source_id
4546 END AS id_to_use
4547 FROM
4548 latest_events AS self_events
4549 LEFT JOIN subsources ON self_events.source_id = subsources.self
4550 LEFT JOIN tables ON self_events.source_id = tables.self
4551 LEFT JOIN
4552 latest_events AS parent_events
4553 ON parent_events.source_id = COALESCE(subsources.parent, tables.parent)
4554 ),
4555 -- Swap out events for the ID of the event we plan to use instead
4556 latest_events_to_use AS
4557 (
4558 SELECT occurred_at, s.source_id, status, error, details
4559 FROM
4560 id_of_status_to_use AS s
4561 JOIN latest_events AS e ON e.source_id = s.id_to_use
4562 ),
4563 combined AS (
4564 SELECT
4565 mz_sources.id,
4566 mz_sources.name,
4567 mz_sources.type,
4568 occurred_at,
4569 status,
4570 error,
4571 details
4572 FROM
4573 mz_catalog.mz_sources
4574 LEFT JOIN latest_events_to_use AS e ON mz_sources.id = e.source_id
4575 UNION ALL
4576 SELECT
4577 tables.self AS id,
4578 tables.name,
4579 'table' AS type,
4580 occurred_at,
4581 status,
4582 error,
4583 details
4584 FROM
4585 tables
4586 LEFT JOIN latest_events_to_use AS e ON tables.self = e.source_id
4587 )
4588SELECT
4589 id,
4590 name,
4591 type,
4592 occurred_at AS last_status_change_at,
4593 -- TODO(parkmycar): Report status of webhook source once database-issues#5986 is closed.
4594 CASE
4595 WHEN
4596 type = 'webhook' OR
4597 type = 'progress'
4598 THEN 'running'
4599 ELSE COALESCE(status, 'created')
4600 END AS status,
4601 error,
4602 details
4603FROM combined
4604WHERE id NOT LIKE 's%';",
4605 access: vec![PUBLIC_SELECT],
4606});
4607
4608pub static MZ_SINK_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
4609 name: "mz_sink_status_history",
4610 schema: MZ_INTERNAL_SCHEMA,
4611 oid: oid::SOURCE_MZ_SINK_STATUS_HISTORY_OID,
4612 data_source: IntrospectionType::SinkStatusHistory,
4613 desc: MZ_SINK_STATUS_HISTORY_DESC.clone(),
4614 column_comments: BTreeMap::from_iter([
4615 (
4616 "occurred_at",
4617 "Wall-clock timestamp of the sink status change.",
4618 ),
4619 (
4620 "sink_id",
4621 "The ID of the sink. Corresponds to `mz_catalog.mz_sinks.id`.",
4622 ),
4623 (
4624 "status",
4625 "The status of the sink: one of `created`, `starting`, `running`, `stalled`, `failed`, or `dropped`.",
4626 ),
4627 (
4628 "error",
4629 "If the sink is in an error state, the error message.",
4630 ),
4631 (
4632 "details",
4633 "Additional metadata provided by the sink. In case of error, may contain a `hint` field with helpful suggestions.",
4634 ),
4635 (
4636 "replica_id",
4637 "The ID of the replica that an instance of a sink is running on.",
4638 ),
4639 ]),
4640 is_retained_metrics_object: false,
4641 access: vec![PUBLIC_SELECT],
4642});
4643
4644pub static MZ_SINK_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4645 name: "mz_sink_statuses",
4646 schema: MZ_INTERNAL_SCHEMA,
4647 oid: oid::VIEW_MZ_SINK_STATUSES_OID,
4648 desc: RelationDesc::builder()
4649 .with_column("id", SqlScalarType::String.nullable(false))
4650 .with_column("name", SqlScalarType::String.nullable(false))
4651 .with_column("type", SqlScalarType::String.nullable(false))
4652 .with_column(
4653 "last_status_change_at",
4654 SqlScalarType::TimestampTz { precision: None }.nullable(true),
4655 )
4656 .with_column("status", SqlScalarType::String.nullable(false))
4657 .with_column("error", SqlScalarType::String.nullable(true))
4658 .with_column("details", SqlScalarType::Jsonb.nullable(true))
4659 .finish(),
4660 column_comments: BTreeMap::from_iter([
4661 (
4662 "id",
4663 "The ID of the sink. Corresponds to `mz_catalog.mz_sinks.id`.",
4664 ),
4665 ("name", "The name of the sink."),
4666 ("type", "The type of the sink."),
4667 (
4668 "last_status_change_at",
4669 "Wall-clock timestamp of the sink status change.",
4670 ),
4671 (
4672 "status",
4673 "The status of the sink: one of `created`, `starting`, `running`, `stalled`, `failed`, or `dropped`.",
4674 ),
4675 (
4676 "error",
4677 "If the sink is in an error state, the error message.",
4678 ),
4679 (
4680 "details",
4681 "Additional metadata provided by the sink. In case of error, may contain a `hint` field with helpful suggestions.",
4682 ),
4683 ]),
4684 sql: "
4685WITH
4686-- The status history contains per-replica events and sink-global events.
4687-- For the latter, replica_id is NULL. We turn these into '<sink>', so that
4688-- we can treat them uniformly below.
4689uniform_status_history AS
4690(
4691 SELECT
4692 s.sink_id,
4693 COALESCE(s.replica_id, '<sink>') as replica_id,
4694 s.occurred_at,
4695 s.status,
4696 s.error,
4697 s.details
4698 FROM mz_internal.mz_sink_status_history s
4699),
4700-- For getting the latest events, we first determine the latest per-replica
4701-- events here and then apply precedence rules below.
4702latest_per_replica_events AS
4703(
4704 SELECT DISTINCT ON (sink_id, replica_id)
4705 occurred_at, sink_id, replica_id, status, error, details
4706 FROM uniform_status_history
4707 ORDER BY sink_id, replica_id, occurred_at DESC
4708),
4709-- We have a precedence list that determines the overall status in case
4710-- there is differing per-replica (including sink-global) statuses. If
4711-- there is no 'dropped' status, and any replica reports 'running', the
4712-- overall status is 'running' even if there might be some replica that has
4713-- errors or is paused.
4714latest_events AS
4715(
4716 SELECT DISTINCT ON (sink_id)
4717 sink_id,
4718 occurred_at,
4719 status,
4720 error,
4721 details
4722 FROM latest_per_replica_events
4723 ORDER BY sink_id, CASE status
4724 WHEN 'dropped' THEN 1
4725 WHEN 'running' THEN 2
4726 WHEN 'stalled' THEN 3
4727 WHEN 'starting' THEN 4
4728 WHEN 'paused' THEN 5
4729 WHEN 'ceased' THEN 6
4730 ELSE 7 -- For any other status values
4731 END
4732)
4733SELECT
4734 mz_sinks.id,
4735 name,
4736 mz_sinks.type,
4737 occurred_at as last_status_change_at,
4738 coalesce(status, 'created') as status,
4739 error,
4740 details
4741FROM mz_catalog.mz_sinks
4742LEFT JOIN latest_events ON mz_sinks.id = latest_events.sink_id
4743WHERE
4744 -- This is a convenient way to filter out system sinks, like the status_history table itself.
4745 mz_sinks.id NOT LIKE 's%'",
4746 access: vec![PUBLIC_SELECT],
4747});
4748
4749pub static MZ_STORAGE_USAGE_BY_SHARD_DESCRIPTION: LazyLock<SystemObjectDescription> =
4750 LazyLock::new(|| SystemObjectDescription {
4751 schema_name: MZ_STORAGE_USAGE_BY_SHARD.schema.to_string(),
4752 object_type: CatalogItemType::Table,
4753 object_name: MZ_STORAGE_USAGE_BY_SHARD.name.to_string(),
4754 });
4755
4756pub static MZ_STORAGE_USAGE_BY_SHARD: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
4757 name: "mz_storage_usage_by_shard",
4758 schema: MZ_INTERNAL_SCHEMA,
4759 oid: oid::TABLE_MZ_STORAGE_USAGE_BY_SHARD_OID,
4760 desc: RelationDesc::builder()
4761 .with_column("id", SqlScalarType::UInt64.nullable(false))
4762 .with_column("shard_id", SqlScalarType::String.nullable(true))
4763 .with_column("size_bytes", SqlScalarType::UInt64.nullable(false))
4764 .with_column(
4765 "collection_timestamp",
4766 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4767 )
4768 .finish(),
4769 column_comments: BTreeMap::new(),
4770 is_retained_metrics_object: false,
4771 access: vec![PUBLIC_SELECT],
4772});
4773
4774pub static MZ_EGRESS_IPS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
4775 name: "mz_egress_ips",
4776 schema: MZ_CATALOG_SCHEMA,
4777 oid: oid::TABLE_MZ_EGRESS_IPS_OID,
4778 desc: RelationDesc::builder()
4779 .with_column("egress_ip", SqlScalarType::String.nullable(false))
4780 .with_column("prefix_length", SqlScalarType::Int32.nullable(false))
4781 .with_column("cidr", SqlScalarType::String.nullable(false))
4782 .finish(),
4783 column_comments: BTreeMap::from_iter([
4784 ("egress_ip", "The start of the range of IP addresses."),
4785 (
4786 "prefix_length",
4787 "The number of leading bits in the CIDR netmask.",
4788 ),
4789 ("cidr", "The CIDR representation."),
4790 ]),
4791 is_retained_metrics_object: false,
4792 access: vec![PUBLIC_SELECT],
4793});
4794
4795pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock<BuiltinTable> =
4796 LazyLock::new(|| BuiltinTable {
4797 name: "mz_aws_privatelink_connections",
4798 schema: MZ_CATALOG_SCHEMA,
4799 oid: oid::TABLE_MZ_AWS_PRIVATELINK_CONNECTIONS_OID,
4800 desc: RelationDesc::builder()
4801 .with_column("id", SqlScalarType::String.nullable(false))
4802 .with_column("principal", SqlScalarType::String.nullable(false))
4803 .finish(),
4804 column_comments: BTreeMap::from_iter([
4805 ("id", "The ID of the connection."),
4806 (
4807 "principal",
4808 "The AWS Principal that Materialize will use to connect to the VPC endpoint.",
4809 ),
4810 ]),
4811 is_retained_metrics_object: false,
4812 access: vec![PUBLIC_SELECT],
4813 });
4814
4815pub static MZ_AWS_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
4816 name: "mz_aws_connections",
4817 schema: MZ_INTERNAL_SCHEMA,
4818 oid: oid::TABLE_MZ_AWS_CONNECTIONS_OID,
4819 desc: RelationDesc::builder()
4820 .with_column("id", SqlScalarType::String.nullable(false))
4821 .with_column("endpoint", SqlScalarType::String.nullable(true))
4822 .with_column("region", SqlScalarType::String.nullable(true))
4823 .with_column("access_key_id", SqlScalarType::String.nullable(true))
4824 .with_column(
4825 "access_key_id_secret_id",
4826 SqlScalarType::String.nullable(true),
4827 )
4828 .with_column(
4829 "secret_access_key_secret_id",
4830 SqlScalarType::String.nullable(true),
4831 )
4832 .with_column("session_token", SqlScalarType::String.nullable(true))
4833 .with_column(
4834 "session_token_secret_id",
4835 SqlScalarType::String.nullable(true),
4836 )
4837 .with_column("assume_role_arn", SqlScalarType::String.nullable(true))
4838 .with_column(
4839 "assume_role_session_name",
4840 SqlScalarType::String.nullable(true),
4841 )
4842 .with_column("principal", SqlScalarType::String.nullable(true))
4843 .with_column("external_id", SqlScalarType::String.nullable(true))
4844 .with_column("example_trust_policy", SqlScalarType::Jsonb.nullable(true))
4845 .finish(),
4846 column_comments: BTreeMap::from_iter([
4847 ("id", "The ID of the connection."),
4848 ("endpoint", "The value of the `ENDPOINT` option, if set."),
4849 ("region", "The value of the `REGION` option, if set."),
4850 (
4851 "access_key_id",
4852 "The value of the `ACCESS KEY ID` option, if provided in line.",
4853 ),
4854 (
4855 "access_key_id_secret_id",
4856 "The ID of the secret referenced by the `ACCESS KEY ID` option, if provided via a secret.",
4857 ),
4858 (
4859 "secret_access_key_secret_id",
4860 "The ID of the secret referenced by the `SECRET ACCESS KEY` option, if set.",
4861 ),
4862 (
4863 "session_token",
4864 "The value of the `SESSION TOKEN` option, if provided in line.",
4865 ),
4866 (
4867 "session_token_secret_id",
4868 "The ID of the secret referenced by the `SESSION TOKEN` option, if provided via a secret.",
4869 ),
4870 (
4871 "assume_role_arn",
4872 "The value of the `ASSUME ROLE ARN` option, if set.",
4873 ),
4874 (
4875 "assume_role_session_name",
4876 "The value of the `ASSUME ROLE SESSION NAME` option, if set.",
4877 ),
4878 (
4879 "principal",
4880 "The ARN of the AWS principal Materialize will use when assuming the provided role, if the connection is configured to use role assumption.",
4881 ),
4882 (
4883 "external_id",
4884 "The external ID Materialize will use when assuming the provided role, if the connection is configured to use role assumption.",
4885 ),
4886 (
4887 "example_trust_policy",
4888 "An example of an IAM role trust policy that allows this connection's principal and external ID to assume the role.",
4889 ),
4890 ]),
4891 is_retained_metrics_object: false,
4892 access: vec![PUBLIC_SELECT],
4893});
4894
4895pub static MZ_CLUSTER_REPLICA_METRICS_HISTORY: LazyLock<BuiltinSource> =
4896 LazyLock::new(|| BuiltinSource {
4897 name: "mz_cluster_replica_metrics_history",
4898 schema: MZ_INTERNAL_SCHEMA,
4899 oid: oid::SOURCE_MZ_CLUSTER_REPLICA_METRICS_HISTORY_OID,
4900 data_source: IntrospectionType::ReplicaMetricsHistory,
4901 desc: REPLICA_METRICS_HISTORY_DESC.clone(),
4902 column_comments: BTreeMap::from_iter([
4903 ("replica_id", "The ID of a cluster replica."),
4904 ("process_id", "The ID of a process within the replica."),
4905 (
4906 "cpu_nano_cores",
4907 "Approximate CPU usage in billionths of a vCPU core.",
4908 ),
4909 ("memory_bytes", "Approximate memory usage in bytes."),
4910 ("disk_bytes", "Approximate disk usage in bytes."),
4911 (
4912 "occurred_at",
4913 "Wall-clock timestamp at which the event occurred.",
4914 ),
4915 ]),
4916 is_retained_metrics_object: false,
4917 access: vec![PUBLIC_SELECT],
4918 });
4919
4920pub static MZ_CLUSTER_REPLICA_METRICS_HISTORY_CT: LazyLock<BuiltinContinualTask> = LazyLock::new(
4921 || {
4922 BuiltinContinualTask {
4923 name: "mz_cluster_replica_metrics_history_ct",
4924 schema: MZ_INTERNAL_SCHEMA,
4925 oid: oid::CT_MZ_CLUSTER_REPLICA_METRICS_HISTORY_OID,
4926 desc: REPLICA_METRICS_HISTORY_DESC.clone(),
4927 sql: "
4928IN CLUSTER mz_catalog_server
4929ON INPUT mz_internal.mz_cluster_replica_metrics_history AS (
4930 DELETE FROM mz_internal.mz_cluster_replica_metrics_history_ct WHERE occurred_at + '30d' < mz_now();
4931 INSERT INTO mz_internal.mz_cluster_replica_metrics_history_ct SELECT * FROM mz_internal.mz_cluster_replica_metrics_history;
4932)",
4933 access: vec![PUBLIC_SELECT],
4934 }
4935 },
4936);
4937
4938pub static MZ_CLUSTER_REPLICA_METRICS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4939 name: "mz_cluster_replica_metrics",
4940 schema: MZ_INTERNAL_SCHEMA,
4941 oid: oid::VIEW_MZ_CLUSTER_REPLICA_METRICS_OID,
4942 desc: RelationDesc::builder()
4943 .with_column("replica_id", SqlScalarType::String.nullable(false))
4944 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
4945 .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(true))
4946 .with_column("memory_bytes", SqlScalarType::UInt64.nullable(true))
4947 .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true))
4948 .with_key(vec![0, 1])
4949 .finish(),
4950 column_comments: BTreeMap::from_iter([
4951 ("replica_id", "The ID of a cluster replica."),
4952 ("process_id", "The ID of a process within the replica."),
4953 (
4954 "cpu_nano_cores",
4955 "Approximate CPU usage, in billionths of a vCPU core.",
4956 ),
4957 ("memory_bytes", "Approximate RAM usage, in bytes."),
4958 ("disk_bytes", "Approximate disk usage in bytes."),
4959 ]),
4960 sql: "
4961SELECT
4962 DISTINCT ON (replica_id, process_id)
4963 replica_id,
4964 process_id,
4965 cpu_nano_cores,
4966 memory_bytes,
4967 disk_bytes
4968FROM mz_internal.mz_cluster_replica_metrics_history
4969JOIN mz_cluster_replicas r ON r.id = replica_id
4970ORDER BY replica_id, process_id, occurred_at DESC",
4971 access: vec![PUBLIC_SELECT],
4972});
4973
4974pub static MZ_CLUSTER_REPLICA_FRONTIERS: LazyLock<BuiltinSource> =
4975 LazyLock::new(|| BuiltinSource {
4976 name: "mz_cluster_replica_frontiers",
4977 schema: MZ_CATALOG_SCHEMA,
4978 oid: oid::SOURCE_MZ_CLUSTER_REPLICA_FRONTIERS_OID,
4979 data_source: IntrospectionType::ReplicaFrontiers,
4980 desc: RelationDesc::builder()
4981 .with_column("object_id", SqlScalarType::String.nullable(false))
4982 .with_column("replica_id", SqlScalarType::String.nullable(false))
4983 .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true))
4984 .finish(),
4985 column_comments: BTreeMap::from_iter([
4986 (
4987 "object_id",
4988 "The ID of the source, sink, index, materialized view, or subscription.",
4989 ),
4990 ("replica_id", "The ID of a cluster replica."),
4991 (
4992 "write_frontier",
4993 "The next timestamp at which the output may change.",
4994 ),
4995 ]),
4996 is_retained_metrics_object: false,
4997 access: vec![PUBLIC_SELECT],
4998 });
4999
5000pub static MZ_CLUSTER_REPLICA_FRONTIERS_IND: LazyLock<BuiltinIndex> =
5001 LazyLock::new(|| BuiltinIndex {
5002 name: "mz_cluster_replica_frontiers_ind",
5003 schema: MZ_CATALOG_SCHEMA,
5004 oid: oid::INDEX_MZ_CLUSTER_REPLICA_FRONTIERS_IND_OID,
5005 sql: "IN CLUSTER mz_catalog_server ON mz_catalog.mz_cluster_replica_frontiers (object_id)",
5006 is_retained_metrics_object: false,
5007 });
5008
5009pub static MZ_FRONTIERS: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5010 name: "mz_frontiers",
5011 schema: MZ_INTERNAL_SCHEMA,
5012 oid: oid::SOURCE_MZ_FRONTIERS_OID,
5013 data_source: IntrospectionType::Frontiers,
5014 desc: RelationDesc::builder()
5015 .with_column("object_id", SqlScalarType::String.nullable(false))
5016 .with_column("read_frontier", SqlScalarType::MzTimestamp.nullable(true))
5017 .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true))
5018 .finish(),
5019 column_comments: BTreeMap::from_iter([
5020 (
5021 "object_id",
5022 "The ID of the source, sink, table, index, materialized view, or subscription.",
5023 ),
5024 (
5025 "read_frontier",
5026 "The earliest timestamp at which the output is still readable.",
5027 ),
5028 (
5029 "write_frontier",
5030 "The next timestamp at which the output may change.",
5031 ),
5032 ]),
5033 is_retained_metrics_object: false,
5034 access: vec![PUBLIC_SELECT],
5035});
5036
5037pub static MZ_GLOBAL_FRONTIERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5039 name: "mz_global_frontiers",
5040 schema: MZ_INTERNAL_SCHEMA,
5041 oid: oid::VIEW_MZ_GLOBAL_FRONTIERS_OID,
5042 desc: RelationDesc::builder()
5043 .with_column("object_id", SqlScalarType::String.nullable(false))
5044 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
5045 .finish(),
5046 column_comments: BTreeMap::new(),
5047 sql: "
5048SELECT object_id, write_frontier AS time
5049FROM mz_internal.mz_frontiers
5050WHERE write_frontier IS NOT NULL",
5051 access: vec![PUBLIC_SELECT],
5052});
5053
5054pub static MZ_WALLCLOCK_LAG_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5055 name: "mz_wallclock_lag_history",
5056 schema: MZ_INTERNAL_SCHEMA,
5057 oid: oid::SOURCE_MZ_WALLCLOCK_LAG_HISTORY_OID,
5058 desc: WALLCLOCK_LAG_HISTORY_DESC.clone(),
5059 data_source: IntrospectionType::WallclockLagHistory,
5060 column_comments: BTreeMap::from_iter([
5061 (
5062 "object_id",
5063 "The ID of the table, source, materialized view, index, or sink. Corresponds to `mz_objects.id`.",
5064 ),
5065 (
5066 "replica_id",
5067 "The ID of a replica computing the object, or `NULL` for persistent objects. Corresponds to `mz_cluster_replicas.id`.",
5068 ),
5069 (
5070 "lag",
5071 "The amount of time the object's write frontier lags behind wallclock time.",
5072 ),
5073 (
5074 "occurred_at",
5075 "Wall-clock timestamp at which the event occurred.",
5076 ),
5077 ]),
5078 is_retained_metrics_object: false,
5079 access: vec![PUBLIC_SELECT],
5080});
5081
5082pub static MZ_WALLCLOCK_LAG_HISTORY_CT: LazyLock<BuiltinContinualTask> = LazyLock::new(|| {
5083 BuiltinContinualTask {
5084 name: "mz_wallclock_lag_history_ct",
5085 schema: MZ_INTERNAL_SCHEMA,
5086 oid: oid::CT_MZ_WALLCLOCK_LAG_HISTORY_OID,
5087 desc: WALLCLOCK_LAG_HISTORY_DESC.clone(),
5088 sql: "
5089IN CLUSTER mz_catalog_server
5090ON INPUT mz_internal.mz_wallclock_lag_history AS (
5091 DELETE FROM mz_internal.mz_wallclock_lag_history_ct WHERE occurred_at + '30d' < mz_now();
5092 INSERT INTO mz_internal.mz_wallclock_lag_history_ct SELECT * FROM mz_internal.mz_wallclock_lag_history;
5093)",
5094 access: vec![PUBLIC_SELECT],
5095 }
5096});
5097
5098pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5099 name: "mz_wallclock_global_lag_history",
5100 schema: MZ_INTERNAL_SCHEMA,
5101 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_HISTORY_OID,
5102 desc: RelationDesc::builder()
5103 .with_column("object_id", SqlScalarType::String.nullable(false))
5104 .with_column("lag", SqlScalarType::Interval.nullable(true))
5105 .with_column(
5106 "occurred_at",
5107 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5108 )
5109 .with_key(vec![0, 2])
5110 .finish(),
5111 column_comments: BTreeMap::new(),
5112 sql: "
5113WITH times_binned AS (
5114 SELECT
5115 object_id,
5116 lag,
5117 date_trunc('minute', occurred_at) AS occurred_at
5118 FROM mz_internal.mz_wallclock_lag_history
5119)
5120SELECT
5121 object_id,
5122 min(lag) AS lag,
5123 occurred_at
5124FROM times_binned
5125GROUP BY object_id, occurred_at
5126OPTIONS (AGGREGATE INPUT GROUP SIZE = 1)",
5127 access: vec![PUBLIC_SELECT],
5128});
5129
5130pub static MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY: LazyLock<BuiltinView> =
5131 LazyLock::new(|| BuiltinView {
5132 name: "mz_wallclock_global_lag_recent_history",
5133 schema: MZ_INTERNAL_SCHEMA,
5134 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_OID,
5135 desc: RelationDesc::builder()
5136 .with_column("object_id", SqlScalarType::String.nullable(false))
5137 .with_column("lag", SqlScalarType::Interval.nullable(true))
5138 .with_column(
5139 "occurred_at",
5140 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5141 )
5142 .with_key(vec![0, 2])
5143 .finish(),
5144 column_comments: BTreeMap::new(),
5145 sql: "
5146SELECT object_id, lag, occurred_at
5147FROM mz_internal.mz_wallclock_global_lag_history
5148WHERE occurred_at + '1 day' > mz_now()",
5149 access: vec![PUBLIC_SELECT],
5150 });
5151
5152pub static MZ_WALLCLOCK_GLOBAL_LAG: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5153 name: "mz_wallclock_global_lag",
5154 schema: MZ_INTERNAL_SCHEMA,
5155 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_OID,
5156 desc: RelationDesc::builder()
5157 .with_column("object_id", SqlScalarType::String.nullable(false))
5158 .with_column("lag", SqlScalarType::Interval.nullable(true))
5159 .with_key(vec![0])
5160 .finish(),
5161 column_comments: BTreeMap::from_iter([
5162 (
5163 "object_id",
5164 "The ID of the table, source, materialized view, index, or sink. Corresponds to `mz_objects.id`.",
5165 ),
5166 (
5167 "lag",
5168 "The amount of time the object's write frontier lags behind wallclock time.",
5169 ),
5170 ]),
5171 sql: "
5172SELECT DISTINCT ON (object_id) object_id, lag
5173FROM mz_internal.mz_wallclock_global_lag_recent_history
5174WHERE occurred_at + '5 minutes' > mz_now()
5175ORDER BY object_id, occurred_at DESC",
5176 access: vec![PUBLIC_SELECT],
5177});
5178
5179pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW: LazyLock<BuiltinSource> =
5180 LazyLock::new(|| BuiltinSource {
5181 name: "mz_wallclock_global_lag_histogram_raw",
5182 schema: MZ_INTERNAL_SCHEMA,
5183 oid: oid::SOURCE_MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW_OID,
5184 desc: WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW_DESC.clone(),
5185 column_comments: BTreeMap::new(),
5186 data_source: IntrospectionType::WallclockLagHistogram,
5187 is_retained_metrics_object: false,
5188 access: vec![PUBLIC_SELECT],
5189 });
5190
5191pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM: LazyLock<BuiltinView> =
5192 LazyLock::new(|| BuiltinView {
5193 name: "mz_wallclock_global_lag_histogram",
5194 schema: MZ_INTERNAL_SCHEMA,
5195 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_OID,
5196 desc: RelationDesc::builder()
5197 .with_column(
5198 "period_start",
5199 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5200 )
5201 .with_column(
5202 "period_end",
5203 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5204 )
5205 .with_column("object_id", SqlScalarType::String.nullable(false))
5206 .with_column("lag_seconds", SqlScalarType::UInt64.nullable(true))
5207 .with_column("labels", SqlScalarType::Jsonb.nullable(false))
5208 .with_column("count", SqlScalarType::Int64.nullable(false))
5209 .with_key(vec![0, 1, 2, 3, 4])
5210 .finish(),
5211 column_comments: BTreeMap::new(),
5212 sql: "
5213SELECT *, count(*) AS count
5214FROM mz_internal.mz_wallclock_global_lag_histogram_raw
5215GROUP BY period_start, period_end, object_id, lag_seconds, labels",
5216 access: vec![PUBLIC_SELECT],
5217 });
5218
5219pub static MZ_MATERIALIZED_VIEW_REFRESHES: LazyLock<BuiltinSource> = LazyLock::new(|| {
5220 BuiltinSource {
5221 name: "mz_materialized_view_refreshes",
5222 schema: MZ_INTERNAL_SCHEMA,
5223 oid: oid::SOURCE_MZ_MATERIALIZED_VIEW_REFRESHES_OID,
5224 data_source: IntrospectionType::ComputeMaterializedViewRefreshes,
5225 desc: RelationDesc::builder()
5226 .with_column(
5227 "materialized_view_id",
5228 SqlScalarType::String.nullable(false),
5229 )
5230 .with_column(
5231 "last_completed_refresh",
5232 SqlScalarType::MzTimestamp.nullable(true),
5233 )
5234 .with_column("next_refresh", SqlScalarType::MzTimestamp.nullable(true))
5235 .finish(),
5236 column_comments: BTreeMap::from_iter([
5237 (
5238 "materialized_view_id",
5239 "The ID of the materialized view. Corresponds to `mz_catalog.mz_materialized_views.id`",
5240 ),
5241 (
5242 "last_completed_refresh",
5243 "The time of the last successfully completed refresh. `NULL` if the materialized view hasn't completed any refreshes yet.",
5244 ),
5245 (
5246 "next_refresh",
5247 "The time of the next scheduled refresh. `NULL` if the materialized view has no future scheduled refreshes.",
5248 ),
5249 ]),
5250 is_retained_metrics_object: false,
5251 access: vec![PUBLIC_SELECT],
5252 }
5253});
5254
5255pub static MZ_SUBSCRIPTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5256 name: "mz_subscriptions",
5257 schema: MZ_INTERNAL_SCHEMA,
5258 oid: oid::TABLE_MZ_SUBSCRIPTIONS_OID,
5259 desc: RelationDesc::builder()
5260 .with_column("id", SqlScalarType::String.nullable(false))
5261 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
5262 .with_column("cluster_id", SqlScalarType::String.nullable(false))
5263 .with_column(
5264 "created_at",
5265 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5266 )
5267 .with_column(
5268 "referenced_object_ids",
5269 SqlScalarType::List {
5270 element_type: Box::new(SqlScalarType::String),
5271 custom_id: None,
5272 }
5273 .nullable(false),
5274 )
5275 .finish(),
5276 column_comments: BTreeMap::from_iter([
5277 ("id", "The ID of the subscription."),
5278 (
5279 "session_id",
5280 "The ID of the session that runs the subscription. Corresponds to `mz_sessions.id`.",
5281 ),
5282 (
5283 "cluster_id",
5284 "The ID of the cluster on which the subscription is running. Corresponds to `mz_clusters.id`.",
5285 ),
5286 (
5287 "created_at",
5288 "The time at which the subscription was created.",
5289 ),
5290 (
5291 "referenced_object_ids",
5292 "The IDs of objects referenced by the subscription. Corresponds to `mz_objects.id`",
5293 ),
5294 ]),
5295 is_retained_metrics_object: false,
5296 access: vec![PUBLIC_SELECT],
5297});
5298
5299pub static MZ_SESSIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5300 name: "mz_sessions",
5301 schema: MZ_INTERNAL_SCHEMA,
5302 oid: oid::TABLE_MZ_SESSIONS_OID,
5303 desc: RelationDesc::builder()
5304 .with_column("id", SqlScalarType::Uuid.nullable(false))
5305 .with_column("connection_id", SqlScalarType::UInt32.nullable(false))
5306 .with_column("role_id", SqlScalarType::String.nullable(false))
5307 .with_column("client_ip", SqlScalarType::String.nullable(true))
5308 .with_column(
5309 "connected_at",
5310 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5311 )
5312 .finish(),
5313 column_comments: BTreeMap::from_iter([
5314 ("id", "The globally unique ID of the session."),
5315 (
5316 "connection_id",
5317 "The connection ID of the session. Unique only for active sessions and can be recycled. Corresponds to `pg_backend_pid()`.",
5318 ),
5319 (
5320 "role_id",
5321 "The role ID of the role that the session is logged in as. Corresponds to `mz_catalog.mz_roles`.",
5322 ),
5323 (
5324 "client_ip",
5325 "The IP address of the client that initiated the session.",
5326 ),
5327 (
5328 "connected_at",
5329 "The time at which the session connected to the system.",
5330 ),
5331 ]),
5332 is_retained_metrics_object: false,
5333 access: vec![PUBLIC_SELECT],
5334});
5335
5336pub static MZ_DEFAULT_PRIVILEGES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5337 name: "mz_default_privileges",
5338 schema: MZ_CATALOG_SCHEMA,
5339 oid: oid::TABLE_MZ_DEFAULT_PRIVILEGES_OID,
5340 desc: RelationDesc::builder()
5341 .with_column("role_id", SqlScalarType::String.nullable(false))
5342 .with_column("database_id", SqlScalarType::String.nullable(true))
5343 .with_column("schema_id", SqlScalarType::String.nullable(true))
5344 .with_column("object_type", SqlScalarType::String.nullable(false))
5345 .with_column("grantee", SqlScalarType::String.nullable(false))
5346 .with_column("privileges", SqlScalarType::String.nullable(false))
5347 .finish(),
5348 column_comments: BTreeMap::from_iter([
5349 (
5350 "role_id",
5351 "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.",
5352 ),
5353 (
5354 "database_id",
5355 "Privileges described in this row will be granted only on objects in the database identified by `database_id` if non-null.",
5356 ),
5357 (
5358 "schema_id",
5359 "Privileges described in this row will be granted only on objects in the schema identified by `schema_id` if non-null.",
5360 ),
5361 (
5362 "object_type",
5363 "Privileges described in this row will be granted only on objects of type `object_type`.",
5364 ),
5365 (
5366 "grantee",
5367 "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.",
5368 ),
5369 ("privileges", "The set of privileges that will be granted."),
5370 ]),
5371 is_retained_metrics_object: false,
5372 access: vec![PUBLIC_SELECT],
5373});
5374
5375pub static MZ_SYSTEM_PRIVILEGES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5376 name: "mz_system_privileges",
5377 schema: MZ_CATALOG_SCHEMA,
5378 oid: oid::TABLE_MZ_SYSTEM_PRIVILEGES_OID,
5379 desc: RelationDesc::builder()
5380 .with_column("privileges", SqlScalarType::MzAclItem.nullable(false))
5381 .finish(),
5382 column_comments: BTreeMap::from_iter([(
5383 "privileges",
5384 "The privileges belonging to the system.",
5385 )]),
5386 is_retained_metrics_object: false,
5387 access: vec![PUBLIC_SELECT],
5388});
5389
5390pub static MZ_COMMENTS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5391 name: "mz_comments",
5392 schema: MZ_INTERNAL_SCHEMA,
5393 oid: oid::TABLE_MZ_COMMENTS_OID,
5394 desc: RelationDesc::builder()
5395 .with_column("id", SqlScalarType::String.nullable(false))
5396 .with_column("object_type", SqlScalarType::String.nullable(false))
5397 .with_column("object_sub_id", SqlScalarType::Int32.nullable(true))
5398 .with_column("comment", SqlScalarType::String.nullable(false))
5399 .finish(),
5400 column_comments: BTreeMap::from_iter([
5401 (
5402 "id",
5403 "The ID of the object. Corresponds to `mz_objects.id`.",
5404 ),
5405 (
5406 "object_type",
5407 "The type of object the comment is associated with.",
5408 ),
5409 (
5410 "object_sub_id",
5411 "For a comment on a column of a relation, the column number. `NULL` for other object types.",
5412 ),
5413 ("comment", "The comment itself."),
5414 ]),
5415 is_retained_metrics_object: false,
5416 access: vec![PUBLIC_SELECT],
5417});
5418
5419pub static MZ_SOURCE_REFERENCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5420 name: "mz_source_references",
5421 schema: MZ_INTERNAL_SCHEMA,
5422 oid: oid::TABLE_MZ_SOURCE_REFERENCES_OID,
5423 desc: RelationDesc::builder()
5424 .with_column("source_id", SqlScalarType::String.nullable(false))
5425 .with_column("namespace", SqlScalarType::String.nullable(true))
5426 .with_column("name", SqlScalarType::String.nullable(false))
5427 .with_column(
5428 "updated_at",
5429 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5430 )
5431 .with_column(
5432 "columns",
5433 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
5434 )
5435 .finish(),
5436 column_comments: BTreeMap::new(),
5437 is_retained_metrics_object: false,
5438 access: vec![PUBLIC_SELECT],
5439});
5440
5441pub static MZ_WEBHOOKS_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5442 name: "mz_webhook_sources",
5443 schema: MZ_INTERNAL_SCHEMA,
5444 oid: oid::TABLE_MZ_WEBHOOK_SOURCES_OID,
5445 desc: RelationDesc::builder()
5446 .with_column("id", SqlScalarType::String.nullable(false))
5447 .with_column("name", SqlScalarType::String.nullable(false))
5448 .with_column("url", SqlScalarType::String.nullable(false))
5449 .finish(),
5450 column_comments: BTreeMap::from_iter([
5451 (
5452 "id",
5453 "The ID of the webhook source. Corresponds to `mz_sources.id`.",
5454 ),
5455 ("name", "The name of the webhook source."),
5456 (
5457 "url",
5458 "The URL which can be used to send events to the source.",
5459 ),
5460 ]),
5461 is_retained_metrics_object: false,
5462 access: vec![PUBLIC_SELECT],
5463});
5464
5465pub static MZ_HISTORY_RETENTION_STRATEGIES: LazyLock<BuiltinTable> = LazyLock::new(|| {
5466 BuiltinTable {
5467 name: "mz_history_retention_strategies",
5468 schema: MZ_INTERNAL_SCHEMA,
5469 oid: oid::TABLE_MZ_HISTORY_RETENTION_STRATEGIES_OID,
5470 desc: RelationDesc::builder()
5471 .with_column("id", SqlScalarType::String.nullable(false))
5472 .with_column("strategy", SqlScalarType::String.nullable(false))
5473 .with_column("value", SqlScalarType::Jsonb.nullable(false))
5474 .finish(),
5475 column_comments: BTreeMap::from_iter([
5476 ("id", "The ID of the object."),
5477 (
5478 "strategy",
5479 "The strategy. `FOR` is the only strategy, and means the object's compaction window is the duration of the `value` field.",
5480 ),
5481 (
5482 "value",
5483 "The value of the strategy. For `FOR`, is a number of milliseconds.",
5484 ),
5485 ]),
5486 is_retained_metrics_object: false,
5487 access: vec![PUBLIC_SELECT],
5488 }
5489});
5490
5491pub static MZ_LICENSE_KEYS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5492 name: "mz_license_keys",
5493 schema: MZ_INTERNAL_SCHEMA,
5494 oid: oid::TABLE_MZ_LICENSE_KEYS_OID,
5495 desc: RelationDesc::builder()
5496 .with_column("id", SqlScalarType::String.nullable(false))
5497 .with_column("organization", SqlScalarType::String.nullable(false))
5498 .with_column("environment_id", SqlScalarType::String.nullable(false))
5499 .with_column(
5500 "expiration",
5501 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5502 )
5503 .with_column(
5504 "not_before",
5505 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5506 )
5507 .finish(),
5508 column_comments: BTreeMap::from_iter([
5509 ("id", "The identifier of the license key."),
5510 (
5511 "organization",
5512 "The name of the organization that this license key was issued to.",
5513 ),
5514 (
5515 "environment_id",
5516 "The environment ID that this license key was issued for.",
5517 ),
5518 (
5519 "expiration",
5520 "The date and time when this license key expires.",
5521 ),
5522 (
5523 "not_before",
5524 "The start of the validity period for this license key.",
5525 ),
5526 ]),
5527 is_retained_metrics_object: false,
5528 access: vec![PUBLIC_SELECT],
5529});
5530
5531pub static MZ_SOURCE_STATISTICS_RAW: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5534 name: "mz_source_statistics_raw",
5535 schema: MZ_INTERNAL_SCHEMA,
5536 oid: oid::SOURCE_MZ_SOURCE_STATISTICS_RAW_OID,
5537 data_source: IntrospectionType::StorageSourceStatistics,
5538 desc: MZ_SOURCE_STATISTICS_RAW_DESC.clone(),
5539 column_comments: BTreeMap::new(),
5540 is_retained_metrics_object: true,
5541 access: vec![PUBLIC_SELECT],
5542});
5543pub static MZ_SINK_STATISTICS_RAW: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5544 name: "mz_sink_statistics_raw",
5545 schema: MZ_INTERNAL_SCHEMA,
5546 oid: oid::SOURCE_MZ_SINK_STATISTICS_RAW_OID,
5547 data_source: IntrospectionType::StorageSinkStatistics,
5548 desc: MZ_SINK_STATISTICS_RAW_DESC.clone(),
5549 column_comments: BTreeMap::new(),
5550 is_retained_metrics_object: true,
5551 access: vec![PUBLIC_SELECT],
5552});
5553
5554pub static MZ_STORAGE_SHARDS: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5555 name: "mz_storage_shards",
5556 schema: MZ_INTERNAL_SCHEMA,
5557 oid: oid::SOURCE_MZ_STORAGE_SHARDS_OID,
5558 data_source: IntrospectionType::ShardMapping,
5559 desc: RelationDesc::builder()
5560 .with_column("object_id", SqlScalarType::String.nullable(false))
5561 .with_column("shard_id", SqlScalarType::String.nullable(false))
5562 .finish(),
5563 column_comments: BTreeMap::new(),
5564 is_retained_metrics_object: false,
5565 access: vec![PUBLIC_SELECT],
5566});
5567
5568pub static MZ_STORAGE_USAGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5569 name: "mz_storage_usage",
5570 schema: MZ_CATALOG_SCHEMA,
5571 oid: oid::VIEW_MZ_STORAGE_USAGE_OID,
5572 desc: RelationDesc::builder()
5573 .with_column("object_id", SqlScalarType::String.nullable(false))
5574 .with_column("size_bytes", SqlScalarType::UInt64.nullable(false))
5575 .with_column(
5576 "collection_timestamp",
5577 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5578 )
5579 .with_key(vec![0, 2])
5580 .finish(),
5581 column_comments: BTreeMap::from_iter([
5582 (
5583 "object_id",
5584 "The ID of the table, source, or materialized view.",
5585 ),
5586 (
5587 "size_bytes",
5588 "The number of storage bytes used by the object.",
5589 ),
5590 (
5591 "collection_timestamp",
5592 "The time at which storage usage of the object was assessed.",
5593 ),
5594 ]),
5595 sql: "
5596SELECT
5597 object_id,
5598 sum(size_bytes)::uint8 AS size_bytes,
5599 collection_timestamp
5600FROM
5601 mz_internal.mz_storage_shards
5602 JOIN mz_internal.mz_storage_usage_by_shard USING (shard_id)
5603GROUP BY object_id, collection_timestamp",
5604 access: vec![PUBLIC_SELECT],
5605});
5606
5607pub static MZ_RECENT_STORAGE_USAGE: LazyLock<BuiltinView> = LazyLock::new(|| {
5608 BuiltinView {
5609 name: "mz_recent_storage_usage",
5610 schema: MZ_CATALOG_SCHEMA,
5611 oid: oid::VIEW_MZ_RECENT_STORAGE_USAGE_OID,
5612 desc: RelationDesc::builder()
5613 .with_column("object_id", SqlScalarType::String.nullable(false))
5614 .with_column("size_bytes", SqlScalarType::UInt64.nullable(true))
5615 .with_key(vec![0])
5616 .finish(),
5617 column_comments: BTreeMap::from_iter([
5618 ("object_id", "The ID of the table, source, or materialized view."),
5619 ("size_bytes", "The number of storage bytes used by the object in the most recent assessment."),
5620 ]),
5621 sql: "
5622WITH
5623
5624recent_storage_usage_by_shard AS (
5625 SELECT shard_id, size_bytes, collection_timestamp
5626 FROM mz_internal.mz_storage_usage_by_shard
5627 -- Restricting to the last 6 hours makes it feasible to index the view.
5628 WHERE collection_timestamp + '6 hours' >= mz_now()
5629),
5630
5631most_recent_collection_timestamp_by_shard AS (
5632 SELECT shard_id, max(collection_timestamp) AS collection_timestamp
5633 FROM recent_storage_usage_by_shard
5634 GROUP BY shard_id
5635)
5636
5637SELECT
5638 object_id,
5639 sum(size_bytes)::uint8 AS size_bytes
5640FROM
5641 mz_internal.mz_storage_shards
5642 LEFT JOIN most_recent_collection_timestamp_by_shard
5643 ON mz_storage_shards.shard_id = most_recent_collection_timestamp_by_shard.shard_id
5644 LEFT JOIN recent_storage_usage_by_shard
5645 ON mz_storage_shards.shard_id = recent_storage_usage_by_shard.shard_id
5646 AND most_recent_collection_timestamp_by_shard.collection_timestamp = recent_storage_usage_by_shard.collection_timestamp
5647GROUP BY object_id",
5648 access: vec![PUBLIC_SELECT],
5649}
5650});
5651
5652pub static MZ_RECENT_STORAGE_USAGE_IND: LazyLock<BuiltinIndex> = LazyLock::new(|| BuiltinIndex {
5653 name: "mz_recent_storage_usage_ind",
5654 schema: MZ_CATALOG_SCHEMA,
5655 oid: oid::INDEX_MZ_RECENT_STORAGE_USAGE_IND_OID,
5656 sql: "IN CLUSTER mz_catalog_server ON mz_catalog.mz_recent_storage_usage (object_id)",
5657 is_retained_metrics_object: false,
5658});
5659
5660pub static MZ_RELATIONS: LazyLock<BuiltinView> = LazyLock::new(|| {
5661 BuiltinView {
5662 name: "mz_relations",
5663 schema: MZ_CATALOG_SCHEMA,
5664 oid: oid::VIEW_MZ_RELATIONS_OID,
5665 desc: RelationDesc::builder()
5666 .with_column("id", SqlScalarType::String.nullable(false))
5667 .with_column("oid", SqlScalarType::Oid.nullable(false))
5668 .with_column("schema_id", SqlScalarType::String.nullable(false))
5669 .with_column("name", SqlScalarType::String.nullable(false))
5670 .with_column("type", SqlScalarType::String.nullable(false))
5671 .with_column("owner_id", SqlScalarType::String.nullable(false))
5672 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5673 .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false))
5674 .finish(),
5675 column_comments: BTreeMap::from_iter([
5676 ("id", "Materialize's unique ID for the relation."),
5677 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the relation."),
5678 ("schema_id", "The ID of the schema to which the relation belongs. Corresponds to `mz_schemas.id`."),
5679 ("name", "The name of the relation."),
5680 ("type", "The type of the relation: either `table`, `source`, `view`, or `materialized view`."),
5681 ("owner_id", "The role ID of the owner of the relation. Corresponds to `mz_roles.id`."),
5682 ("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."),
5683 ("privileges", "The privileges belonging to the relation."),
5684 ]),
5685 sql: "
5686 SELECT id, oid, schema_id, name, 'table' AS type, owner_id, NULL::text AS cluster_id, privileges FROM mz_catalog.mz_tables
5687UNION ALL SELECT id, oid, schema_id, name, 'source', owner_id, cluster_id, privileges FROM mz_catalog.mz_sources
5688UNION ALL SELECT id, oid, schema_id, name, 'view', owner_id, NULL::text, privileges FROM mz_catalog.mz_views
5689UNION ALL SELECT id, oid, schema_id, name, 'materialized-view', owner_id, cluster_id, privileges FROM mz_catalog.mz_materialized_views
5690UNION ALL SELECT id, oid, schema_id, name, 'continual-task', owner_id, cluster_id, privileges FROM mz_internal.mz_continual_tasks",
5691 access: vec![PUBLIC_SELECT],
5692 }
5693});
5694
5695pub static MZ_OBJECTS_ID_NAMESPACE_TYPES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5696 name: "mz_objects_id_namespace_types",
5697 schema: MZ_INTERNAL_SCHEMA,
5698 oid: oid::VIEW_MZ_OBJECTS_ID_NAMESPACE_TYPES_OID,
5699 desc: RelationDesc::builder()
5700 .with_column("object_type", SqlScalarType::String.nullable(false))
5701 .with_key(vec![0])
5702 .finish(),
5703 column_comments: BTreeMap::new(),
5704 sql: r#"SELECT *
5705 FROM (
5706 VALUES
5707 ('table'),
5708 ('view'),
5709 ('materialized-view'),
5710 ('source'),
5711 ('sink'),
5712 ('index'),
5713 ('connection'),
5714 ('type'),
5715 ('function'),
5716 ('secret')
5717 )
5718 AS _ (object_type)"#,
5719 access: vec![PUBLIC_SELECT],
5720});
5721
5722pub static MZ_OBJECT_OID_ALIAS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5723 name: "mz_object_oid_alias",
5724 schema: MZ_INTERNAL_SCHEMA,
5725 oid: oid::VIEW_MZ_OBJECT_OID_ALIAS_OID,
5726 desc: RelationDesc::builder()
5727 .with_column("object_type", SqlScalarType::String.nullable(false))
5728 .with_column("oid_alias", SqlScalarType::String.nullable(false))
5729 .with_key(vec![0])
5730 .finish(),
5731 column_comments: BTreeMap::new(),
5732 sql: "SELECT object_type, oid_alias
5733 FROM (
5734 VALUES
5735 (
5736 'table'::pg_catalog.text,
5737 'regclass'::pg_catalog.text
5738 ),
5739 ('source', 'regclass'),
5740 ('view', 'regclass'),
5741 ('materialized-view', 'regclass'),
5742 ('index', 'regclass'),
5743 ('type', 'regtype'),
5744 ('function', 'regproc')
5745 )
5746 AS _ (object_type, oid_alias);",
5747 access: vec![PUBLIC_SELECT],
5748});
5749
5750pub static MZ_OBJECTS: LazyLock<BuiltinView> = LazyLock::new(|| {
5751 BuiltinView {
5752 name: "mz_objects",
5753 schema: MZ_CATALOG_SCHEMA,
5754 oid: oid::VIEW_MZ_OBJECTS_OID,
5755 desc: RelationDesc::builder()
5756 .with_column("id", SqlScalarType::String.nullable(false))
5757 .with_column("oid", SqlScalarType::Oid.nullable(false))
5758 .with_column("schema_id", SqlScalarType::String.nullable(false))
5759 .with_column("name", SqlScalarType::String.nullable(false))
5760 .with_column("type", SqlScalarType::String.nullable(false))
5761 .with_column("owner_id", SqlScalarType::String.nullable(false))
5762 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5763 .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(true))
5764 .finish(),
5765 column_comments: BTreeMap::from_iter([
5766 ("id", "Materialize's unique ID for the object."),
5767 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the object."),
5768 ("schema_id", "The ID of the schema to which the object belongs. Corresponds to `mz_schemas.id`."),
5769 ("name", "The name of the object."),
5770 ("type", "The type of the object: one of `table`, `source`, `view`, `materialized-view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`."),
5771 ("owner_id", "The role ID of the owner of the object. Corresponds to `mz_roles.id`."),
5772 ("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."),
5773 ("privileges", "The privileges belonging to the object."),
5774 ]),
5775 sql:
5776 "SELECT id, oid, schema_id, name, type, owner_id, cluster_id, privileges FROM mz_catalog.mz_relations
5777UNION ALL
5778 SELECT id, oid, schema_id, name, 'sink', owner_id, cluster_id, NULL::mz_catalog.mz_aclitem[] FROM mz_catalog.mz_sinks
5779UNION ALL
5780 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[]
5781 FROM mz_catalog.mz_indexes
5782 JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
5783UNION ALL
5784 SELECT id, oid, schema_id, name, 'connection', owner_id, NULL::text, privileges FROM mz_catalog.mz_connections
5785UNION ALL
5786 SELECT id, oid, schema_id, name, 'type', owner_id, NULL::text, privileges FROM mz_catalog.mz_types
5787UNION ALL
5788 SELECT id, oid, schema_id, name, 'function', owner_id, NULL::text, NULL::mz_catalog.mz_aclitem[] FROM mz_catalog.mz_functions
5789UNION ALL
5790 SELECT id, oid, schema_id, name, 'secret', owner_id, NULL::text, privileges FROM mz_catalog.mz_secrets",
5791 access: vec![PUBLIC_SELECT],
5792 }
5793});
5794
5795pub static MZ_OBJECT_FULLY_QUALIFIED_NAMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5796 name: "mz_object_fully_qualified_names",
5797 schema: MZ_INTERNAL_SCHEMA,
5798 oid: oid::VIEW_MZ_OBJECT_FULLY_QUALIFIED_NAMES_OID,
5799 desc: RelationDesc::builder()
5800 .with_column("id", SqlScalarType::String.nullable(false))
5801 .with_column("name", SqlScalarType::String.nullable(false))
5802 .with_column("object_type", SqlScalarType::String.nullable(false))
5803 .with_column("schema_id", SqlScalarType::String.nullable(false))
5804 .with_column("schema_name", SqlScalarType::String.nullable(false))
5805 .with_column("database_id", SqlScalarType::String.nullable(true))
5806 .with_column("database_name", SqlScalarType::String.nullable(true))
5807 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5808 .finish(),
5809 column_comments: BTreeMap::from_iter([
5810 ("id", "Materialize's unique ID for the object."),
5811 ("name", "The name of the object."),
5812 (
5813 "object_type",
5814 "The type of the object: one of `table`, `source`, `view`, `materialized view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`.",
5815 ),
5816 (
5817 "schema_id",
5818 "The ID of the schema to which the object belongs. Corresponds to `mz_schemas.id`.",
5819 ),
5820 (
5821 "schema_name",
5822 "The name of the schema to which the object belongs. Corresponds to `mz_schemas.name`.",
5823 ),
5824 (
5825 "database_id",
5826 "The ID of the database to which the object belongs. Corresponds to `mz_databases.id`.",
5827 ),
5828 (
5829 "database_name",
5830 "The name of the database to which the object belongs. Corresponds to `mz_databases.name`.",
5831 ),
5832 (
5833 "cluster_id",
5834 "The ID of the cluster maintaining the source, materialized view, index, or sink. Corresponds to `mz_clusters.id`. `NULL` for other object types.",
5835 ),
5836 ]),
5837 sql: "
5838 SELECT o.id,
5839 o.name,
5840 o.type as object_type,
5841 sc.id as schema_id,
5842 sc.name as schema_name,
5843 db.id as database_id,
5844 db.name as database_name,
5845 o.cluster_id
5846 FROM mz_catalog.mz_objects o
5847 INNER JOIN mz_catalog.mz_schemas sc ON sc.id = o.schema_id
5848 -- LEFT JOIN accounts for objects in the ambient database.
5849 LEFT JOIN mz_catalog.mz_databases db ON db.id = sc.database_id",
5850 access: vec![PUBLIC_SELECT],
5851});
5852
5853pub static MZ_OBJECT_LIFETIMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5855 name: "mz_object_lifetimes",
5856 schema: MZ_INTERNAL_SCHEMA,
5857 oid: oid::VIEW_MZ_OBJECT_LIFETIMES_OID,
5858 desc: RelationDesc::builder()
5859 .with_column("id", SqlScalarType::String.nullable(true))
5860 .with_column("previous_id", SqlScalarType::String.nullable(true))
5861 .with_column("object_type", SqlScalarType::String.nullable(false))
5862 .with_column("event_type", SqlScalarType::String.nullable(false))
5863 .with_column(
5864 "occurred_at",
5865 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5866 )
5867 .finish(),
5868 column_comments: BTreeMap::from_iter([
5869 ("id", "Materialize's unique ID for the object."),
5870 ("previous_id", "The object's previous ID, if one exists."),
5871 (
5872 "object_type",
5873 "The type of the object: one of `table`, `source`, `view`, `materialized view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`.",
5874 ),
5875 (
5876 "event_type",
5877 "The lifetime event, either `create` or `drop`.",
5878 ),
5879 (
5880 "occurred_at",
5881 "Wall-clock timestamp of when the event occurred.",
5882 ),
5883 ]),
5884 sql: "
5885 SELECT
5886 CASE
5887 WHEN a.object_type = 'cluster-replica' THEN a.details ->> 'replica_id'
5888 ELSE a.details ->> 'id'
5889 END id,
5890 a.details ->> 'previous_id' as previous_id,
5891 a.object_type,
5892 a.event_type,
5893 a.occurred_at
5894 FROM mz_catalog.mz_audit_events a
5895 WHERE a.event_type = 'create' OR a.event_type = 'drop'",
5896 access: vec![PUBLIC_SELECT],
5897});
5898
5899pub static MZ_OBJECT_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5900 name: "mz_object_history",
5901 schema: MZ_INTERNAL_SCHEMA,
5902 oid: oid::VIEW_MZ_OBJECT_HISTORY_OID,
5903 desc: RelationDesc::builder()
5904 .with_column("id", SqlScalarType::String.nullable(true))
5905 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5906 .with_column("object_type", SqlScalarType::String.nullable(false))
5907 .with_column(
5908 "created_at",
5909 SqlScalarType::TimestampTz { precision: None }.nullable(true),
5910 )
5911 .with_column(
5912 "dropped_at",
5913 SqlScalarType::TimestampTz { precision: None }.nullable(true),
5914 )
5915 .finish(),
5916 column_comments: BTreeMap::from_iter([
5917 ("id", "Materialize's unique ID for the object."),
5918 (
5919 "cluster_id",
5920 "The object's cluster ID. `NULL` if the object has no associated cluster.",
5921 ),
5922 (
5923 "object_type",
5924 "The type of the object: one of `table`, `source`, `view`, `materialized view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`.",
5925 ),
5926 (
5927 "created_at",
5928 "Wall-clock timestamp of when the object was created. `NULL` for built in system objects.",
5929 ),
5930 (
5931 "dropped_at",
5932 "Wall-clock timestamp of when the object was dropped. `NULL` for built in system objects or if the object hasn't been dropped.",
5933 ),
5934 ]),
5935 sql: r#"
5936 WITH
5937 creates AS
5938 (
5939 SELECT
5940 details ->> 'id' AS id,
5941 -- We need to backfill cluster_id since older object create events don't include the cluster ID in the audit log
5942 COALESCE(details ->> 'cluster_id', objects.cluster_id) AS cluster_id,
5943 object_type,
5944 occurred_at
5945 FROM
5946 mz_catalog.mz_audit_events AS events
5947 LEFT JOIN mz_catalog.mz_objects AS objects ON details ->> 'id' = objects.id
5948 WHERE event_type = 'create' AND object_type IN ( SELECT object_type FROM mz_internal.mz_objects_id_namespace_types )
5949 ),
5950 drops AS
5951 (
5952 SELECT details ->> 'id' AS id, occurred_at
5953 FROM mz_catalog.mz_audit_events
5954 WHERE event_type = 'drop' AND object_type IN ( SELECT object_type FROM mz_internal.mz_objects_id_namespace_types )
5955 ),
5956 user_object_history AS
5957 (
5958 SELECT
5959 creates.id,
5960 creates.cluster_id,
5961 creates.object_type,
5962 creates.occurred_at AS created_at,
5963 drops.occurred_at AS dropped_at
5964 FROM creates LEFT JOIN drops ON creates.id = drops.id
5965 WHERE creates.id LIKE 'u%'
5966 ),
5967 -- We need to union built in objects since they aren't in the audit log
5968 built_in_objects AS
5969 (
5970 -- Functions that accept different arguments have different oids but the same id. We deduplicate in this case.
5971 SELECT DISTINCT ON (objects.id)
5972 objects.id,
5973 objects.cluster_id,
5974 objects.type AS object_type,
5975 NULL::timestamptz AS created_at,
5976 NULL::timestamptz AS dropped_at
5977 FROM mz_catalog.mz_objects AS objects
5978 WHERE objects.id LIKE 's%'
5979 )
5980 SELECT * FROM user_object_history UNION ALL (SELECT * FROM built_in_objects)"#,
5981 access: vec![PUBLIC_SELECT],
5982});
5983
5984pub static MZ_DATAFLOWS_PER_WORKER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5985 name: "mz_dataflows_per_worker",
5986 schema: MZ_INTROSPECTION_SCHEMA,
5987 oid: oid::VIEW_MZ_DATAFLOWS_PER_WORKER_OID,
5988 desc: RelationDesc::builder()
5989 .with_column("id", SqlScalarType::UInt64.nullable(true))
5990 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
5991 .with_column("name", SqlScalarType::String.nullable(false))
5992 .finish(),
5993 column_comments: BTreeMap::new(),
5994 sql: "SELECT
5995 addrs.address[1] AS id,
5996 ops.worker_id,
5997 ops.name
5998FROM
5999 mz_introspection.mz_dataflow_addresses_per_worker addrs,
6000 mz_introspection.mz_dataflow_operators_per_worker ops
6001WHERE
6002 addrs.id = ops.id AND
6003 addrs.worker_id = ops.worker_id AND
6004 mz_catalog.list_length(addrs.address) = 1",
6005 access: vec![PUBLIC_SELECT],
6006});
6007
6008pub static MZ_DATAFLOWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6009 name: "mz_dataflows",
6010 schema: MZ_INTROSPECTION_SCHEMA,
6011 oid: oid::VIEW_MZ_DATAFLOWS_OID,
6012 desc: RelationDesc::builder()
6013 .with_column("id", SqlScalarType::UInt64.nullable(true))
6014 .with_column("name", SqlScalarType::String.nullable(false))
6015 .finish(),
6016 column_comments: BTreeMap::from_iter([
6017 ("id", "The ID of the dataflow."),
6018 ("name", "The internal name of the dataflow."),
6019 ]),
6020 sql: "
6021SELECT id, name
6022FROM mz_introspection.mz_dataflows_per_worker
6023WHERE worker_id = 0",
6024 access: vec![PUBLIC_SELECT],
6025});
6026
6027pub static MZ_DATAFLOW_ADDRESSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6028 name: "mz_dataflow_addresses",
6029 schema: MZ_INTROSPECTION_SCHEMA,
6030 oid: oid::VIEW_MZ_DATAFLOW_ADDRESSES_OID,
6031 desc: RelationDesc::builder()
6032 .with_column("id", SqlScalarType::UInt64.nullable(false))
6033 .with_column(
6034 "address",
6035 SqlScalarType::List {
6036 element_type: Box::new(SqlScalarType::UInt64),
6037 custom_id: None,
6038 }
6039 .nullable(false),
6040 )
6041 .finish(),
6042 column_comments: BTreeMap::from_iter([
6043 (
6044 "id",
6045 "The ID of the channel or operator. Corresponds to `mz_dataflow_channels.id` or `mz_dataflow_operators.id`.",
6046 ),
6047 (
6048 "address",
6049 "A list of scope-local indexes indicating the path from the root to this channel or operator.",
6050 ),
6051 ]),
6052 sql: "
6053SELECT id, address
6054FROM mz_introspection.mz_dataflow_addresses_per_worker
6055WHERE worker_id = 0",
6056 access: vec![PUBLIC_SELECT],
6057});
6058
6059pub static MZ_DATAFLOW_CHANNELS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6060 name: "mz_dataflow_channels",
6061 schema: MZ_INTROSPECTION_SCHEMA,
6062 oid: oid::VIEW_MZ_DATAFLOW_CHANNELS_OID,
6063 desc: RelationDesc::builder()
6064 .with_column("id", SqlScalarType::UInt64.nullable(false))
6065 .with_column("from_index", SqlScalarType::UInt64.nullable(false))
6066 .with_column("from_port", SqlScalarType::UInt64.nullable(false))
6067 .with_column("to_index", SqlScalarType::UInt64.nullable(false))
6068 .with_column("to_port", SqlScalarType::UInt64.nullable(false))
6069 .with_column("type", SqlScalarType::String.nullable(false))
6070 .finish(),
6071 column_comments: BTreeMap::from_iter([
6072 ("id", "The ID of the channel."),
6073 (
6074 "from_index",
6075 "The scope-local index of the source operator. Corresponds to `mz_dataflow_addresses.address`.",
6076 ),
6077 ("from_port", "The source operator's output port."),
6078 (
6079 "to_index",
6080 "The scope-local index of the target operator. Corresponds to `mz_dataflow_addresses.address`.",
6081 ),
6082 ("to_port", "The target operator's input port."),
6083 ("type", "The container type of the channel."),
6084 ]),
6085 sql: "
6086SELECT id, from_index, from_port, to_index, to_port, type
6087FROM mz_introspection.mz_dataflow_channels_per_worker
6088WHERE worker_id = 0",
6089 access: vec![PUBLIC_SELECT],
6090});
6091
6092pub static MZ_DATAFLOW_OPERATORS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6093 name: "mz_dataflow_operators",
6094 schema: MZ_INTROSPECTION_SCHEMA,
6095 oid: oid::VIEW_MZ_DATAFLOW_OPERATORS_OID,
6096 desc: RelationDesc::builder()
6097 .with_column("id", SqlScalarType::UInt64.nullable(false))
6098 .with_column("name", SqlScalarType::String.nullable(false))
6099 .finish(),
6100 column_comments: BTreeMap::from_iter([
6101 ("id", "The ID of the operator."),
6102 ("name", "The internal name of the operator."),
6103 ]),
6104 sql: "
6105SELECT id, name
6106FROM mz_introspection.mz_dataflow_operators_per_worker
6107WHERE worker_id = 0",
6108 access: vec![PUBLIC_SELECT],
6109});
6110
6111pub static MZ_DATAFLOW_GLOBAL_IDS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6112 name: "mz_dataflow_global_ids",
6113 schema: MZ_INTROSPECTION_SCHEMA,
6114 oid: oid::VIEW_MZ_DATAFLOW_GLOBAL_IDS_OID,
6115 desc: RelationDesc::builder()
6116 .with_column("id", SqlScalarType::UInt64.nullable(false))
6117 .with_column("global_id", SqlScalarType::String.nullable(false))
6118 .finish(),
6119 column_comments: BTreeMap::from_iter([
6120 ("id", "The dataflow ID."),
6121 ("global_id", "A global ID associated with that dataflow."),
6122 ]),
6123 sql: "
6124SELECT id, global_id
6125FROM mz_introspection.mz_compute_dataflow_global_ids_per_worker
6126WHERE worker_id = 0",
6127 access: vec![PUBLIC_SELECT],
6128});
6129
6130pub static MZ_MAPPABLE_OBJECTS: LazyLock<BuiltinView> = LazyLock::new(|| {
6131 BuiltinView {
6132 name: "mz_mappable_objects",
6133 schema: MZ_INTROSPECTION_SCHEMA,
6134 oid: oid::VIEW_MZ_MAPPABLE_OBJECTS_OID,
6135 desc: RelationDesc::builder()
6136 .with_column("name", SqlScalarType::String.nullable(false))
6137 .with_column("global_id", SqlScalarType::String.nullable(false))
6138 .finish(),
6139 column_comments: BTreeMap::from_iter([
6140 ("name", "The name of the object."),
6141 ("global_id", "The global ID of the object."),
6142 ]),
6143 sql: "
6144SELECT quote_ident(md.name) || '.' || quote_ident(ms.name) || '.' || quote_ident(mo.name) AS name, mgi.global_id AS global_id
6145FROM mz_catalog.mz_objects mo
6146 JOIN mz_introspection.mz_compute_exports mce ON (mo.id = mce.export_id)
6147 JOIN mz_catalog.mz_schemas ms ON (mo.schema_id = ms.id)
6148 JOIN mz_catalog.mz_databases md ON (ms.database_id = md.id)
6149 JOIN mz_introspection.mz_dataflow_global_ids mgi ON (mce.dataflow_id = mgi.id);",
6150 access: vec![PUBLIC_SELECT],
6151}
6152});
6153
6154pub static MZ_LIR_MAPPING: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6155 name: "mz_lir_mapping",
6156 schema: MZ_INTROSPECTION_SCHEMA,
6157 oid: oid::VIEW_MZ_LIR_MAPPING_OID,
6158 desc: RelationDesc::builder()
6159 .with_column("global_id", SqlScalarType::String.nullable(false))
6160 .with_column("lir_id", SqlScalarType::UInt64.nullable(false))
6161 .with_column("operator", SqlScalarType::String.nullable(false))
6162 .with_column("parent_lir_id", SqlScalarType::UInt64.nullable(true))
6163 .with_column("nesting", SqlScalarType::UInt16.nullable(false))
6164 .with_column("operator_id_start", SqlScalarType::UInt64.nullable(false))
6165 .with_column("operator_id_end", SqlScalarType::UInt64.nullable(false))
6166 .finish(),
6167 column_comments: BTreeMap::from_iter([
6168 ("global_id", "The global ID."),
6169 ("lir_id", "The LIR node ID."),
6170 (
6171 "operator",
6172 "The LIR operator, in the format `OperatorName INPUTS [OPTIONS]`.",
6173 ),
6174 (
6175 "parent_lir_id",
6176 "The parent of this LIR node. May be `NULL`.",
6177 ),
6178 ("nesting", "The nesting level of this LIR node."),
6179 (
6180 "operator_id_start",
6181 "The first dataflow operator ID implementing this LIR operator (inclusive).",
6182 ),
6183 (
6184 "operator_id_end",
6185 "The first dataflow operator ID after this LIR operator (exclusive).",
6186 ),
6187 ]),
6188 sql: "
6189SELECT global_id, lir_id, operator, parent_lir_id, nesting, operator_id_start, operator_id_end
6190FROM mz_introspection.mz_compute_lir_mapping_per_worker
6191WHERE worker_id = 0",
6192 access: vec![PUBLIC_SELECT],
6193});
6194
6195pub static MZ_DATAFLOW_OPERATOR_DATAFLOWS_PER_WORKER: LazyLock<BuiltinView> =
6196 LazyLock::new(|| BuiltinView {
6197 name: "mz_dataflow_operator_dataflows_per_worker",
6198 schema: MZ_INTROSPECTION_SCHEMA,
6199 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_DATAFLOWS_PER_WORKER_OID,
6200 desc: RelationDesc::builder()
6201 .with_column("id", SqlScalarType::UInt64.nullable(false))
6202 .with_column("name", SqlScalarType::String.nullable(false))
6203 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6204 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6205 .with_column("dataflow_name", SqlScalarType::String.nullable(false))
6206 .finish(),
6207 column_comments: BTreeMap::new(),
6208 sql: "SELECT
6209 ops.id,
6210 ops.name,
6211 ops.worker_id,
6212 dfs.id as dataflow_id,
6213 dfs.name as dataflow_name
6214FROM
6215 mz_introspection.mz_dataflow_operators_per_worker ops,
6216 mz_introspection.mz_dataflow_addresses_per_worker addrs,
6217 mz_introspection.mz_dataflows_per_worker dfs
6218WHERE
6219 ops.id = addrs.id AND
6220 ops.worker_id = addrs.worker_id AND
6221 dfs.id = addrs.address[1] AND
6222 dfs.worker_id = addrs.worker_id",
6223 access: vec![PUBLIC_SELECT],
6224 });
6225
6226pub static MZ_DATAFLOW_OPERATOR_DATAFLOWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6227 name: "mz_dataflow_operator_dataflows",
6228 schema: MZ_INTROSPECTION_SCHEMA,
6229 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_DATAFLOWS_OID,
6230 desc: RelationDesc::builder()
6231 .with_column("id", SqlScalarType::UInt64.nullable(false))
6232 .with_column("name", SqlScalarType::String.nullable(false))
6233 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6234 .with_column("dataflow_name", SqlScalarType::String.nullable(false))
6235 .finish(),
6236 column_comments: BTreeMap::from_iter([
6237 (
6238 "id",
6239 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
6240 ),
6241 ("name", "The internal name of the operator."),
6242 (
6243 "dataflow_id",
6244 "The ID of the dataflow hosting the operator. Corresponds to `mz_dataflows.id`.",
6245 ),
6246 (
6247 "dataflow_name",
6248 "The internal name of the dataflow hosting the operator.",
6249 ),
6250 ]),
6251 sql: "
6252SELECT id, name, dataflow_id, dataflow_name
6253FROM mz_introspection.mz_dataflow_operator_dataflows_per_worker
6254WHERE worker_id = 0",
6255 access: vec![PUBLIC_SELECT],
6256});
6257
6258pub static MZ_OBJECT_TRANSITIVE_DEPENDENCIES: LazyLock<BuiltinView> = LazyLock::new(|| {
6259 BuiltinView {
6260 name: "mz_object_transitive_dependencies",
6261 schema: MZ_INTERNAL_SCHEMA,
6262 oid: oid::VIEW_MZ_OBJECT_TRANSITIVE_DEPENDENCIES_OID,
6263 desc: RelationDesc::builder()
6264 .with_column("object_id", SqlScalarType::String.nullable(false))
6265 .with_column(
6266 "referenced_object_id",
6267 SqlScalarType::String.nullable(false),
6268 )
6269 .with_key(vec![0, 1])
6270 .finish(),
6271 column_comments: BTreeMap::from_iter([
6272 (
6273 "object_id",
6274 "The ID of the dependent object. Corresponds to `mz_objects.id`.",
6275 ),
6276 (
6277 "referenced_object_id",
6278 "The ID of the (possibly transitively) referenced object. Corresponds to `mz_objects.id`.",
6279 ),
6280 ]),
6281 sql: "
6282WITH MUTUALLY RECURSIVE
6283 reach(object_id text, referenced_object_id text) AS (
6284 SELECT object_id, referenced_object_id FROM mz_internal.mz_object_dependencies
6285 UNION
6286 SELECT x, z FROM reach r1(x, y) JOIN reach r2(y, z) USING(y)
6287 )
6288SELECT object_id, referenced_object_id FROM reach;",
6289 access: vec![PUBLIC_SELECT],
6290 }
6291});
6292
6293pub static MZ_COMPUTE_EXPORTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6294 name: "mz_compute_exports",
6295 schema: MZ_INTROSPECTION_SCHEMA,
6296 oid: oid::VIEW_MZ_COMPUTE_EXPORTS_OID,
6297 desc: RelationDesc::builder()
6298 .with_column("export_id", SqlScalarType::String.nullable(false))
6299 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6300 .finish(),
6301 column_comments: BTreeMap::from_iter([
6302 (
6303 "export_id",
6304 "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`.",
6305 ),
6306 (
6307 "dataflow_id",
6308 "The ID of the dataflow. Corresponds to `mz_dataflows.id`.",
6309 ),
6310 ]),
6311 sql: "
6312SELECT export_id, dataflow_id
6313FROM mz_introspection.mz_compute_exports_per_worker
6314WHERE worker_id = 0",
6315 access: vec![PUBLIC_SELECT],
6316});
6317
6318pub static MZ_COMPUTE_FRONTIERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6319 name: "mz_compute_frontiers",
6320 schema: MZ_INTROSPECTION_SCHEMA,
6321 oid: oid::VIEW_MZ_COMPUTE_FRONTIERS_OID,
6322 desc: RelationDesc::builder()
6323 .with_column("export_id", SqlScalarType::String.nullable(false))
6324 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
6325 .with_key(vec![0])
6326 .finish(),
6327 column_comments: BTreeMap::from_iter([
6328 (
6329 "export_id",
6330 "The ID of the dataflow export. Corresponds to `mz_compute_exports.export_id`.",
6331 ),
6332 (
6333 "time",
6334 "The next timestamp at which the dataflow output may change.",
6335 ),
6336 ]),
6337 sql: "SELECT
6338 export_id, pg_catalog.min(time) AS time
6339FROM mz_introspection.mz_compute_frontiers_per_worker
6340GROUP BY export_id",
6341 access: vec![PUBLIC_SELECT],
6342});
6343
6344pub static MZ_DATAFLOW_CHANNEL_OPERATORS_PER_WORKER: LazyLock<BuiltinView> =
6345 LazyLock::new(|| BuiltinView {
6346 name: "mz_dataflow_channel_operators_per_worker",
6347 schema: MZ_INTROSPECTION_SCHEMA,
6348 oid: oid::VIEW_MZ_DATAFLOW_CHANNEL_OPERATORS_PER_WORKER_OID,
6349 desc: RelationDesc::builder()
6350 .with_column("id", SqlScalarType::UInt64.nullable(false))
6351 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6352 .with_column("from_operator_id", SqlScalarType::UInt64.nullable(true))
6353 .with_column(
6354 "from_operator_address",
6355 SqlScalarType::List {
6356 element_type: Box::new(SqlScalarType::UInt64),
6357 custom_id: None,
6358 }
6359 .nullable(true),
6360 )
6361 .with_column("to_operator_id", SqlScalarType::UInt64.nullable(true))
6362 .with_column(
6363 "to_operator_address",
6364 SqlScalarType::List {
6365 element_type: Box::new(SqlScalarType::UInt64),
6366 custom_id: None,
6367 }
6368 .nullable(true),
6369 )
6370 .with_column("type", SqlScalarType::String.nullable(false))
6371 .finish(),
6372 column_comments: BTreeMap::new(),
6373 sql: "
6374WITH
6375channel_addresses(id, worker_id, address, from_index, to_index, type) AS (
6376 SELECT id, worker_id, address, from_index, to_index, type
6377 FROM mz_introspection.mz_dataflow_channels_per_worker mdc
6378 INNER JOIN mz_introspection.mz_dataflow_addresses_per_worker mda
6379 USING (id, worker_id)
6380),
6381channel_operator_addresses(id, worker_id, from_address, to_address, type) AS (
6382 SELECT id, worker_id,
6383 address || from_index AS from_address,
6384 address || to_index AS to_address,
6385 type
6386 FROM channel_addresses
6387),
6388operator_addresses(id, worker_id, address) AS (
6389 SELECT id, worker_id, address
6390 FROM mz_introspection.mz_dataflow_addresses_per_worker mda
6391 INNER JOIN mz_introspection.mz_dataflow_operators_per_worker mdo
6392 USING (id, worker_id)
6393)
6394SELECT coa.id,
6395 coa.worker_id,
6396 from_ops.id AS from_operator_id,
6397 coa.from_address AS from_operator_address,
6398 to_ops.id AS to_operator_id,
6399 coa.to_address AS to_operator_address,
6400 coa.type
6401FROM channel_operator_addresses coa
6402 LEFT OUTER JOIN operator_addresses from_ops
6403 ON coa.from_address = from_ops.address AND
6404 coa.worker_id = from_ops.worker_id
6405 LEFT OUTER JOIN operator_addresses to_ops
6406 ON coa.to_address = to_ops.address AND
6407 coa.worker_id = to_ops.worker_id
6408",
6409 access: vec![PUBLIC_SELECT],
6410 });
6411
6412pub static MZ_DATAFLOW_CHANNEL_OPERATORS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6413 name: "mz_dataflow_channel_operators",
6414 schema: MZ_INTROSPECTION_SCHEMA,
6415 oid: oid::VIEW_MZ_DATAFLOW_CHANNEL_OPERATORS_OID,
6416 desc: RelationDesc::builder()
6417 .with_column("id", SqlScalarType::UInt64.nullable(false))
6418 .with_column("from_operator_id", SqlScalarType::UInt64.nullable(true))
6419 .with_column(
6420 "from_operator_address",
6421 SqlScalarType::List {
6422 element_type: Box::new(SqlScalarType::UInt64),
6423 custom_id: None,
6424 }
6425 .nullable(true),
6426 )
6427 .with_column("to_operator_id", SqlScalarType::UInt64.nullable(true))
6428 .with_column(
6429 "to_operator_address",
6430 SqlScalarType::List {
6431 element_type: Box::new(SqlScalarType::UInt64),
6432 custom_id: None,
6433 }
6434 .nullable(true),
6435 )
6436 .with_column("type", SqlScalarType::String.nullable(false))
6437 .finish(),
6438 column_comments: BTreeMap::from_iter([
6439 (
6440 "id",
6441 "The ID of the channel. Corresponds to `mz_dataflow_channels.id`.",
6442 ),
6443 (
6444 "from_operator_id",
6445 "The ID of the source of the channel. Corresponds to `mz_dataflow_operators.id`.",
6446 ),
6447 (
6448 "from_operator_address",
6449 "The address of the source of the channel. Corresponds to `mz_dataflow_addresses.address`.",
6450 ),
6451 (
6452 "to_operator_id",
6453 "The ID of the target of the channel. Corresponds to `mz_dataflow_operators.id`.",
6454 ),
6455 (
6456 "to_operator_address",
6457 "The address of the target of the channel. Corresponds to `mz_dataflow_addresses.address`.",
6458 ),
6459 ("type", "The container type of the channel."),
6460 ]),
6461 sql: "
6462SELECT id, from_operator_id, from_operator_address, to_operator_id, to_operator_address, type
6463FROM mz_introspection.mz_dataflow_channel_operators_per_worker
6464WHERE worker_id = 0",
6465 access: vec![PUBLIC_SELECT],
6466});
6467
6468pub static MZ_COMPUTE_IMPORT_FRONTIERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6469 name: "mz_compute_import_frontiers",
6470 schema: MZ_INTROSPECTION_SCHEMA,
6471 oid: oid::VIEW_MZ_COMPUTE_IMPORT_FRONTIERS_OID,
6472 desc: RelationDesc::builder()
6473 .with_column("export_id", SqlScalarType::String.nullable(false))
6474 .with_column("import_id", SqlScalarType::String.nullable(false))
6475 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
6476 .with_key(vec![0, 1])
6477 .finish(),
6478 column_comments: BTreeMap::from_iter([
6479 (
6480 "export_id",
6481 "The ID of the dataflow export. Corresponds to `mz_compute_exports.export_id`.",
6482 ),
6483 (
6484 "import_id",
6485 "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`.",
6486 ),
6487 (
6488 "time",
6489 "The next timestamp at which the dataflow input may change.",
6490 ),
6491 ]),
6492 sql: "SELECT
6493 export_id, import_id, pg_catalog.min(time) AS time
6494FROM mz_introspection.mz_compute_import_frontiers_per_worker
6495GROUP BY export_id, import_id",
6496 access: vec![PUBLIC_SELECT],
6497});
6498
6499pub static MZ_RECORDS_PER_DATAFLOW_OPERATOR_PER_WORKER: LazyLock<BuiltinView> =
6500 LazyLock::new(|| BuiltinView {
6501 name: "mz_records_per_dataflow_operator_per_worker",
6502 schema: MZ_INTROSPECTION_SCHEMA,
6503 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_OPERATOR_PER_WORKER_OID,
6504 desc: RelationDesc::builder()
6505 .with_column("id", SqlScalarType::UInt64.nullable(false))
6506 .with_column("name", SqlScalarType::String.nullable(false))
6507 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6508 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6509 .with_column("records", SqlScalarType::Int64.nullable(true))
6510 .with_column("batches", SqlScalarType::Int64.nullable(true))
6511 .with_column("size", SqlScalarType::Int64.nullable(true))
6512 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6513 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6514 .finish(),
6515 column_comments: BTreeMap::new(),
6516 sql: "
6517SELECT
6518 dod.id,
6519 dod.name,
6520 dod.worker_id,
6521 dod.dataflow_id,
6522 ar_size.records AS records,
6523 ar_size.batches AS batches,
6524 ar_size.size AS size,
6525 ar_size.capacity AS capacity,
6526 ar_size.allocations AS allocations
6527FROM
6528 mz_introspection.mz_dataflow_operator_dataflows_per_worker dod
6529 LEFT OUTER JOIN mz_introspection.mz_arrangement_sizes_per_worker ar_size ON
6530 dod.id = ar_size.operator_id AND
6531 dod.worker_id = ar_size.worker_id",
6532 access: vec![PUBLIC_SELECT],
6533 });
6534
6535pub static MZ_RECORDS_PER_DATAFLOW_OPERATOR: LazyLock<BuiltinView> =
6536 LazyLock::new(|| BuiltinView {
6537 name: "mz_records_per_dataflow_operator",
6538 schema: MZ_INTROSPECTION_SCHEMA,
6539 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_OPERATOR_OID,
6540 desc: RelationDesc::builder()
6541 .with_column("id", SqlScalarType::UInt64.nullable(false))
6542 .with_column("name", SqlScalarType::String.nullable(false))
6543 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6544 .with_column("records", SqlScalarType::Int64.nullable(true))
6545 .with_column("batches", SqlScalarType::Int64.nullable(true))
6546 .with_column("size", SqlScalarType::Int64.nullable(true))
6547 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6548 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6549 .with_key(vec![0, 1, 2])
6550 .finish(),
6551 column_comments: BTreeMap::from_iter([
6552 (
6553 "id",
6554 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
6555 ),
6556 ("name", "The internal name of the operator."),
6557 (
6558 "dataflow_id",
6559 "The ID of the dataflow. Corresponds to `mz_dataflows.id`.",
6560 ),
6561 ("records", "The number of records in the operator."),
6562 ("batches", "The number of batches in the dataflow."),
6563 ("size", "The utilized size in bytes of the arrangement."),
6564 (
6565 "capacity",
6566 "The capacity in bytes of the arrangement. Can be larger than the size.",
6567 ),
6568 (
6569 "allocations",
6570 "The number of separate memory allocations backing the arrangement.",
6571 ),
6572 ]),
6573 sql: "
6574SELECT
6575 id,
6576 name,
6577 dataflow_id,
6578 SUM(records)::int8 AS records,
6579 SUM(batches)::int8 AS batches,
6580 SUM(size)::int8 AS size,
6581 SUM(capacity)::int8 AS capacity,
6582 SUM(allocations)::int8 AS allocations
6583FROM mz_introspection.mz_records_per_dataflow_operator_per_worker
6584GROUP BY id, name, dataflow_id",
6585 access: vec![PUBLIC_SELECT],
6586 });
6587
6588pub static MZ_RECORDS_PER_DATAFLOW_PER_WORKER: LazyLock<BuiltinView> =
6589 LazyLock::new(|| BuiltinView {
6590 name: "mz_records_per_dataflow_per_worker",
6591 schema: MZ_INTROSPECTION_SCHEMA,
6592 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_PER_WORKER_OID,
6593 desc: RelationDesc::builder()
6594 .with_column("id", SqlScalarType::UInt64.nullable(false))
6595 .with_column("name", SqlScalarType::String.nullable(false))
6596 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6597 .with_column("records", SqlScalarType::Int64.nullable(true))
6598 .with_column("batches", SqlScalarType::Int64.nullable(true))
6599 .with_column("size", SqlScalarType::Int64.nullable(true))
6600 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6601 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6602 .with_key(vec![0, 1, 2])
6603 .finish(),
6604 column_comments: BTreeMap::new(),
6605 sql: "
6606SELECT
6607 rdo.dataflow_id as id,
6608 dfs.name,
6609 rdo.worker_id,
6610 SUM(rdo.records)::int8 as records,
6611 SUM(rdo.batches)::int8 as batches,
6612 SUM(rdo.size)::int8 as size,
6613 SUM(rdo.capacity)::int8 as capacity,
6614 SUM(rdo.allocations)::int8 as allocations
6615FROM
6616 mz_introspection.mz_records_per_dataflow_operator_per_worker rdo,
6617 mz_introspection.mz_dataflows_per_worker dfs
6618WHERE
6619 rdo.dataflow_id = dfs.id AND
6620 rdo.worker_id = dfs.worker_id
6621GROUP BY
6622 rdo.dataflow_id,
6623 dfs.name,
6624 rdo.worker_id",
6625 access: vec![PUBLIC_SELECT],
6626 });
6627
6628pub static MZ_RECORDS_PER_DATAFLOW: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6629 name: "mz_records_per_dataflow",
6630 schema: MZ_INTROSPECTION_SCHEMA,
6631 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_OID,
6632 desc: RelationDesc::builder()
6633 .with_column("id", SqlScalarType::UInt64.nullable(false))
6634 .with_column("name", SqlScalarType::String.nullable(false))
6635 .with_column("records", SqlScalarType::Int64.nullable(true))
6636 .with_column("batches", SqlScalarType::Int64.nullable(true))
6637 .with_column("size", SqlScalarType::Int64.nullable(true))
6638 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6639 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6640 .with_key(vec![0, 1])
6641 .finish(),
6642 column_comments: BTreeMap::from_iter([
6643 (
6644 "id",
6645 "The ID of the dataflow. Corresponds to `mz_dataflows.id`.",
6646 ),
6647 ("name", "The internal name of the dataflow."),
6648 ("records", "The number of records in the dataflow."),
6649 ("batches", "The number of batches in the dataflow."),
6650 ("size", "The utilized size in bytes of the arrangements."),
6651 (
6652 "capacity",
6653 "The capacity in bytes of the arrangements. Can be larger than the size.",
6654 ),
6655 (
6656 "allocations",
6657 "The number of separate memory allocations backing the arrangements.",
6658 ),
6659 ]),
6660 sql: "
6661SELECT
6662 id,
6663 name,
6664 SUM(records)::int8 as records,
6665 SUM(batches)::int8 as batches,
6666 SUM(size)::int8 as size,
6667 SUM(capacity)::int8 as capacity,
6668 SUM(allocations)::int8 as allocations
6669FROM
6670 mz_introspection.mz_records_per_dataflow_per_worker
6671GROUP BY
6672 id,
6673 name",
6674 access: vec![PUBLIC_SELECT],
6675});
6676
6677pub static PG_NAMESPACE_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6683 name: "pg_namespace_all_databases",
6684 schema: MZ_INTERNAL_SCHEMA,
6685 oid: oid::VIEW_PG_NAMESPACE_ALL_DATABASES_OID,
6686 desc: RelationDesc::builder()
6687 .with_column("oid", SqlScalarType::Oid.nullable(false))
6688 .with_column("nspname", SqlScalarType::String.nullable(false))
6689 .with_column("nspowner", SqlScalarType::Oid.nullable(false))
6690 .with_column(
6691 "nspacl",
6692 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
6693 )
6694 .with_column("database_name", SqlScalarType::String.nullable(true))
6695 .finish(),
6696 column_comments: BTreeMap::new(),
6697 sql: "
6698SELECT
6699 s.oid AS oid,
6700 s.name AS nspname,
6701 role_owner.oid AS nspowner,
6702 NULL::pg_catalog.text[] AS nspacl,
6703 d.name as database_name
6704FROM mz_catalog.mz_schemas s
6705LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
6706JOIN mz_catalog.mz_roles role_owner ON role_owner.id = s.owner_id",
6707 access: vec![PUBLIC_SELECT],
6708});
6709
6710pub const PG_NAMESPACE_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
6711 name: "pg_namespace_all_databases_ind",
6712 schema: MZ_INTERNAL_SCHEMA,
6713 oid: oid::INDEX_PG_NAMESPACE_ALL_DATABASES_IND_OID,
6714 sql: "IN CLUSTER mz_catalog_server
6715ON mz_internal.pg_namespace_all_databases (nspname)",
6716 is_retained_metrics_object: false,
6717};
6718
6719pub static PG_NAMESPACE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6720 name: "pg_namespace",
6721 schema: PG_CATALOG_SCHEMA,
6722 oid: oid::VIEW_PG_NAMESPACE_OID,
6723 desc: RelationDesc::builder()
6724 .with_column("oid", SqlScalarType::Oid.nullable(false))
6725 .with_column("nspname", SqlScalarType::String.nullable(false))
6726 .with_column("nspowner", SqlScalarType::Oid.nullable(false))
6727 .with_column(
6728 "nspacl",
6729 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
6730 )
6731 .finish(),
6732 column_comments: BTreeMap::new(),
6733 sql: "
6734SELECT
6735 oid, nspname, nspowner, nspacl
6736FROM mz_internal.pg_namespace_all_databases
6737WHERE database_name IS NULL OR database_name = pg_catalog.current_database();",
6738 access: vec![PUBLIC_SELECT],
6739});
6740
6741pub static PG_CLASS_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
6747 BuiltinView {
6748 name: "pg_class_all_databases",
6749 schema: MZ_INTERNAL_SCHEMA,
6750 oid: oid::VIEW_PG_CLASS_ALL_DATABASES_OID,
6751 desc: RelationDesc::builder()
6752 .with_column("oid", SqlScalarType::Oid.nullable(false))
6753 .with_column("relname", SqlScalarType::String.nullable(false))
6754 .with_column("relnamespace", SqlScalarType::Oid.nullable(false))
6755 .with_column("reloftype", SqlScalarType::Oid.nullable(false))
6756 .with_column("relowner", SqlScalarType::Oid.nullable(false))
6757 .with_column("relam", SqlScalarType::Oid.nullable(false))
6758 .with_column("reltablespace", SqlScalarType::Oid.nullable(false))
6759 .with_column("reltuples", SqlScalarType::Float32.nullable(false))
6760 .with_column("reltoastrelid", SqlScalarType::Oid.nullable(false))
6761 .with_column("relhasindex", SqlScalarType::Bool.nullable(false))
6762 .with_column("relpersistence", SqlScalarType::PgLegacyChar.nullable(false))
6763 .with_column("relkind", SqlScalarType::String.nullable(true))
6764 .with_column("relnatts", SqlScalarType::Int16.nullable(false))
6765 .with_column("relchecks", SqlScalarType::Int16.nullable(false))
6766 .with_column("relhasrules", SqlScalarType::Bool.nullable(false))
6767 .with_column("relhastriggers", SqlScalarType::Bool.nullable(false))
6768 .with_column("relhassubclass", SqlScalarType::Bool.nullable(false))
6769 .with_column("relrowsecurity", SqlScalarType::Bool.nullable(false))
6770 .with_column("relforcerowsecurity", SqlScalarType::Bool.nullable(false))
6771 .with_column("relreplident", SqlScalarType::PgLegacyChar.nullable(false))
6772 .with_column("relispartition", SqlScalarType::Bool.nullable(false))
6773 .with_column("relhasoids", SqlScalarType::Bool.nullable(false))
6774 .with_column("reloptions", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true))
6775 .with_column("database_name", SqlScalarType::String.nullable(true))
6776 .finish(),
6777 column_comments: BTreeMap::new(),
6778 sql: "
6779SELECT
6780 class_objects.oid,
6781 class_objects.name AS relname,
6782 mz_schemas.oid AS relnamespace,
6783 -- MZ doesn't support typed tables so reloftype is filled with 0
6784 0::pg_catalog.oid AS reloftype,
6785 role_owner.oid AS relowner,
6786 0::pg_catalog.oid AS relam,
6787 -- MZ doesn't have tablespaces so reltablespace is filled in with 0 implying the default tablespace
6788 0::pg_catalog.oid AS reltablespace,
6789 -- MZ doesn't support (estimated) row counts currently.
6790 -- Postgres defines a value of -1 as unknown.
6791 -1::float4 as reltuples,
6792 -- MZ doesn't use TOAST tables so reltoastrelid is filled with 0
6793 0::pg_catalog.oid AS reltoastrelid,
6794 EXISTS (SELECT id, oid, name, on_id, cluster_id FROM mz_catalog.mz_indexes where mz_indexes.on_id = class_objects.id) AS relhasindex,
6795 -- MZ doesn't have unlogged tables and because of (https://github.com/MaterializeInc/database-issues/issues/2689)
6796 -- temporary objects don't show up here, so relpersistence is filled with 'p' for permanent.
6797 -- TODO(jkosh44): update this column when issue is resolved.
6798 'p'::pg_catalog.\"char\" AS relpersistence,
6799 CASE
6800 WHEN class_objects.type = 'table' THEN 'r'
6801 WHEN class_objects.type = 'source' THEN 'r'
6802 WHEN class_objects.type = 'index' THEN 'i'
6803 WHEN class_objects.type = 'view' THEN 'v'
6804 WHEN class_objects.type = 'materialized-view' THEN 'm'
6805 END relkind,
6806 COALESCE(
6807 (
6808 SELECT count(*)::pg_catalog.int2
6809 FROM mz_catalog.mz_columns
6810 WHERE mz_columns.id = class_objects.id
6811 ),
6812 0::pg_catalog.int2
6813 ) AS relnatts,
6814 -- MZ doesn't support CHECK constraints so relchecks is filled with 0
6815 0::pg_catalog.int2 AS relchecks,
6816 -- MZ doesn't support creating rules so relhasrules is filled with false
6817 false AS relhasrules,
6818 -- MZ doesn't support creating triggers so relhastriggers is filled with false
6819 false AS relhastriggers,
6820 -- MZ doesn't support table inheritance or partitions so relhassubclass is filled with false
6821 false AS relhassubclass,
6822 -- MZ doesn't have row level security so relrowsecurity and relforcerowsecurity is filled with false
6823 false AS relrowsecurity,
6824 false AS relforcerowsecurity,
6825 -- MZ doesn't support replication so relreplident is filled with 'd' for default
6826 'd'::pg_catalog.\"char\" AS relreplident,
6827 -- MZ doesn't support table partitioning so relispartition is filled with false
6828 false AS relispartition,
6829 -- PG removed relhasoids in v12 so it's filled with false
6830 false AS relhasoids,
6831 -- MZ doesn't support options for relations
6832 NULL::pg_catalog.text[] as reloptions,
6833 d.name as database_name
6834FROM (
6835 -- pg_class catalogs relations and indexes
6836 SELECT id, oid, schema_id, name, type, owner_id FROM mz_catalog.mz_relations
6837 UNION ALL
6838 SELECT mz_indexes.id, mz_indexes.oid, mz_relations.schema_id, mz_indexes.name, 'index' AS type, mz_indexes.owner_id
6839 FROM mz_catalog.mz_indexes
6840 JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
6841) AS class_objects
6842JOIN mz_catalog.mz_schemas ON mz_schemas.id = class_objects.schema_id
6843LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
6844JOIN mz_catalog.mz_roles role_owner ON role_owner.id = class_objects.owner_id",
6845 access: vec![PUBLIC_SELECT],
6846 }
6847});
6848
6849pub const PG_CLASS_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
6850 name: "pg_class_all_databases_ind",
6851 schema: MZ_INTERNAL_SCHEMA,
6852 oid: oid::INDEX_PG_CLASS_ALL_DATABASES_IND_OID,
6853 sql: "IN CLUSTER mz_catalog_server
6854ON mz_internal.pg_class_all_databases (relname)",
6855 is_retained_metrics_object: false,
6856};
6857
6858pub static PG_CLASS: LazyLock<BuiltinView> = LazyLock::new(|| {
6859 BuiltinView {
6860 name: "pg_class",
6861 schema: PG_CATALOG_SCHEMA,
6862 oid: oid::VIEW_PG_CLASS_OID,
6863 desc: RelationDesc::builder()
6864 .with_column("oid", SqlScalarType::Oid.nullable(false))
6865 .with_column("relname", SqlScalarType::String.nullable(false))
6866 .with_column("relnamespace", SqlScalarType::Oid.nullable(false))
6867 .with_column("reloftype", SqlScalarType::Oid.nullable(false))
6868 .with_column("relowner", SqlScalarType::Oid.nullable(false))
6869 .with_column("relam", SqlScalarType::Oid.nullable(false))
6870 .with_column("reltablespace", SqlScalarType::Oid.nullable(false))
6871 .with_column("reltuples", SqlScalarType::Float32.nullable(false))
6872 .with_column("reltoastrelid", SqlScalarType::Oid.nullable(false))
6873 .with_column("relhasindex", SqlScalarType::Bool.nullable(false))
6874 .with_column("relpersistence", SqlScalarType::PgLegacyChar.nullable(false))
6875 .with_column("relkind", SqlScalarType::String.nullable(true))
6876 .with_column("relnatts", SqlScalarType::Int16.nullable(false))
6877 .with_column("relchecks", SqlScalarType::Int16.nullable(false))
6878 .with_column("relhasrules", SqlScalarType::Bool.nullable(false))
6879 .with_column("relhastriggers", SqlScalarType::Bool.nullable(false))
6880 .with_column("relhassubclass", SqlScalarType::Bool.nullable(false))
6881 .with_column("relrowsecurity", SqlScalarType::Bool.nullable(false))
6882 .with_column("relforcerowsecurity", SqlScalarType::Bool.nullable(false))
6883 .with_column("relreplident", SqlScalarType::PgLegacyChar.nullable(false))
6884 .with_column("relispartition", SqlScalarType::Bool.nullable(false))
6885 .with_column("relhasoids", SqlScalarType::Bool.nullable(false))
6886 .with_column(
6887 "reloptions",
6888 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
6889 )
6890 .finish(),
6891 column_comments: BTreeMap::new(),
6892 sql: "
6893SELECT
6894 oid, relname, relnamespace, reloftype, relowner, relam, reltablespace, reltuples, reltoastrelid,
6895 relhasindex, relpersistence, relkind, relnatts, relchecks, relhasrules, relhastriggers, relhassubclass,
6896 relrowsecurity, relforcerowsecurity, relreplident, relispartition, relhasoids, reloptions
6897FROM mz_internal.pg_class_all_databases
6898WHERE database_name IS NULL OR database_name = pg_catalog.current_database();
6899",
6900 access: vec![PUBLIC_SELECT],
6901}
6902});
6903
6904pub static PG_DEPEND: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6905 name: "pg_depend",
6906 schema: PG_CATALOG_SCHEMA,
6907 oid: oid::VIEW_PG_DEPEND_OID,
6908 desc: RelationDesc::builder()
6909 .with_column("classid", SqlScalarType::Oid.nullable(true))
6910 .with_column("objid", SqlScalarType::Oid.nullable(false))
6911 .with_column("objsubid", SqlScalarType::Int32.nullable(false))
6912 .with_column("refclassid", SqlScalarType::Oid.nullable(true))
6913 .with_column("refobjid", SqlScalarType::Oid.nullable(false))
6914 .with_column("refobjsubid", SqlScalarType::Int32.nullable(false))
6915 .with_column("deptype", SqlScalarType::PgLegacyChar.nullable(false))
6916 .finish(),
6917 column_comments: BTreeMap::new(),
6918 sql: "
6919WITH class_objects AS (
6920 SELECT
6921 CASE
6922 WHEN type = 'table' THEN 'pg_tables'::pg_catalog.regclass::pg_catalog.oid
6923 WHEN type = 'source' THEN 'pg_tables'::pg_catalog.regclass::pg_catalog.oid
6924 WHEN type = 'view' THEN 'pg_views'::pg_catalog.regclass::pg_catalog.oid
6925 WHEN type = 'materialized-view' THEN 'pg_matviews'::pg_catalog.regclass::pg_catalog.oid
6926 END classid,
6927 id,
6928 oid,
6929 schema_id
6930 FROM mz_catalog.mz_relations
6931 UNION ALL
6932 SELECT
6933 'pg_index'::pg_catalog.regclass::pg_catalog.oid AS classid,
6934 i.id,
6935 i.oid,
6936 r.schema_id
6937 FROM mz_catalog.mz_indexes i
6938 JOIN mz_catalog.mz_relations r ON i.on_id = r.id
6939),
6940
6941current_objects AS (
6942 SELECT class_objects.*
6943 FROM class_objects
6944 JOIN mz_catalog.mz_schemas ON mz_schemas.id = class_objects.schema_id
6945 LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
6946 -- This filter is tricky, as it filters out not just objects outside the
6947 -- database, but *dependencies* on objects outside this database. It's not
6948 -- clear that this is the right choice, but because PostgreSQL doesn't
6949 -- support cross-database references, it's not clear that the other choice
6950 -- is better.
6951 WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()
6952)
6953
6954SELECT
6955 objects.classid::pg_catalog.oid,
6956 objects.oid::pg_catalog.oid AS objid,
6957 0::pg_catalog.int4 AS objsubid,
6958 dependents.classid::pg_catalog.oid AS refclassid,
6959 dependents.oid::pg_catalog.oid AS refobjid,
6960 0::pg_catalog.int4 AS refobjsubid,
6961 'n'::pg_catalog.char AS deptype
6962FROM mz_internal.mz_object_dependencies
6963JOIN current_objects objects ON object_id = objects.id
6964JOIN current_objects dependents ON referenced_object_id = dependents.id",
6965 access: vec![PUBLIC_SELECT],
6966});
6967
6968pub static PG_DATABASE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6969 name: "pg_database",
6970 schema: PG_CATALOG_SCHEMA,
6971 oid: oid::VIEW_PG_DATABASE_OID,
6972 desc: RelationDesc::builder()
6973 .with_column("oid", SqlScalarType::Oid.nullable(false))
6974 .with_column("datname", SqlScalarType::String.nullable(false))
6975 .with_column("datdba", SqlScalarType::Oid.nullable(false))
6976 .with_column("encoding", SqlScalarType::Int32.nullable(false))
6977 .with_column("datistemplate", SqlScalarType::Bool.nullable(false))
6978 .with_column("datallowconn", SqlScalarType::Bool.nullable(false))
6979 .with_column("datcollate", SqlScalarType::String.nullable(false))
6980 .with_column("datctype", SqlScalarType::String.nullable(false))
6981 .with_column(
6982 "datacl",
6983 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
6984 )
6985 .with_key(vec![0])
6986 .finish(),
6987 column_comments: BTreeMap::new(),
6988 sql: "SELECT
6989 d.oid as oid,
6990 d.name as datname,
6991 role_owner.oid as datdba,
6992 6 as encoding,
6993 -- Materialize doesn't support database cloning.
6994 FALSE AS datistemplate,
6995 TRUE AS datallowconn,
6996 'C' as datcollate,
6997 'C' as datctype,
6998 NULL::pg_catalog.text[] as datacl
6999FROM mz_catalog.mz_databases d
7000JOIN mz_catalog.mz_roles role_owner ON role_owner.id = d.owner_id",
7001 access: vec![PUBLIC_SELECT],
7002});
7003
7004pub static PG_INDEX: LazyLock<BuiltinView> = LazyLock::new(|| {
7005 BuiltinView {
7006 name: "pg_index",
7007 schema: PG_CATALOG_SCHEMA,
7008 oid: oid::VIEW_PG_INDEX_OID,
7009 desc: RelationDesc::builder()
7010 .with_column("indexrelid", SqlScalarType::Oid.nullable(false))
7011 .with_column("indrelid", SqlScalarType::Oid.nullable(false))
7012 .with_column("indnatts", SqlScalarType::Int16.nullable(false))
7013 .with_column("indisunique", SqlScalarType::Bool.nullable(false))
7014 .with_column("indisprimary", SqlScalarType::Bool.nullable(false))
7015 .with_column("indimmediate", SqlScalarType::Bool.nullable(false))
7016 .with_column("indisclustered", SqlScalarType::Bool.nullable(false))
7017 .with_column("indisvalid", SqlScalarType::Bool.nullable(false))
7018 .with_column("indisreplident", SqlScalarType::Bool.nullable(false))
7019 .with_column("indkey", SqlScalarType::Int2Vector.nullable(false))
7020 .with_column("indoption", SqlScalarType::Int2Vector.nullable(false))
7021 .with_column("indexprs", SqlScalarType::String.nullable(true))
7022 .with_column("indpred", SqlScalarType::String.nullable(true))
7023 .with_key(vec![0, 1])
7024 .finish(),
7025 column_comments: BTreeMap::new(),
7026 sql: "SELECT
7027 mz_indexes.oid AS indexrelid,
7028 mz_relations.oid AS indrelid,
7029 COALESCE(
7030 (
7031 SELECT count(*)::pg_catalog.int2
7032 FROM mz_catalog.mz_columns
7033 JOIN mz_catalog.mz_relations mri ON mz_columns.id = mri.id
7034 WHERE mri.oid = mz_catalog.mz_relations.oid
7035 ),
7036 0::pg_catalog.int2
7037 ) AS indnatts,
7038 -- MZ doesn't support creating unique indexes so indisunique is filled with false
7039 false::pg_catalog.bool AS indisunique,
7040 false::pg_catalog.bool AS indisprimary,
7041 -- MZ doesn't support unique indexes so indimmediate is filled with false
7042 false::pg_catalog.bool AS indimmediate,
7043 -- MZ doesn't support CLUSTER so indisclustered is filled with false
7044 false::pg_catalog.bool AS indisclustered,
7045 -- MZ never creates invalid indexes so indisvalid is filled with true
7046 true::pg_catalog.bool AS indisvalid,
7047 -- MZ doesn't support replication so indisreplident is filled with false
7048 false::pg_catalog.bool AS indisreplident,
7049 -- Return zero if the index attribute is not a simple column reference, column position otherwise
7050 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,
7051 -- MZ doesn't have per-column flags, so returning a 0 for each column in the index
7052 pg_catalog.string_agg('0', ' ')::pg_catalog.int2vector AS indoption,
7053 -- Index expressions are returned in MZ format
7054 CASE pg_catalog.string_agg(mz_index_columns.on_expression, ' ' ORDER BY mz_index_columns.index_position::int8)
7055 WHEN NULL THEN NULL
7056 ELSE '{' || pg_catalog.string_agg(mz_index_columns.on_expression, '}, {' ORDER BY mz_index_columns.index_position::int8) || '}'
7057 END AS indexprs,
7058 -- MZ doesn't support indexes with predicates
7059 NULL::pg_catalog.text AS indpred
7060FROM mz_catalog.mz_indexes
7061JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
7062JOIN mz_catalog.mz_index_columns ON mz_index_columns.index_id = mz_indexes.id
7063JOIN mz_catalog.mz_schemas ON mz_schemas.id = mz_relations.schema_id
7064LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
7065WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()
7066GROUP BY mz_indexes.oid, mz_relations.oid",
7067 access: vec![PUBLIC_SELECT],
7068 }
7069});
7070
7071pub static PG_INDEXES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7072 name: "pg_indexes",
7073 schema: PG_CATALOG_SCHEMA,
7074 oid: oid::VIEW_PG_INDEXES_OID,
7075 desc: RelationDesc::builder()
7076 .with_column("table_catalog", SqlScalarType::String.nullable(false))
7077 .with_column("schemaname", SqlScalarType::String.nullable(false))
7078 .with_column("tablename", SqlScalarType::String.nullable(false))
7079 .with_column("indexname", SqlScalarType::String.nullable(false))
7080 .with_column("tablespace", SqlScalarType::String.nullable(true))
7081 .with_column("indexdef", SqlScalarType::String.nullable(true))
7082 .finish(),
7083 column_comments: BTreeMap::new(),
7084 sql: "SELECT
7085 current_database() as table_catalog,
7086 s.name AS schemaname,
7087 r.name AS tablename,
7088 i.name AS indexname,
7089 NULL::text AS tablespace,
7090 -- TODO(jkosh44) Fill in with actual index definition.
7091 NULL::text AS indexdef
7092FROM mz_catalog.mz_indexes i
7093JOIN mz_catalog.mz_relations r ON i.on_id = r.id
7094JOIN mz_catalog.mz_schemas s ON s.id = r.schema_id
7095LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
7096WHERE s.database_id IS NULL OR d.name = current_database()",
7097 access: vec![PUBLIC_SELECT],
7098});
7099
7100pub static PG_DESCRIPTION_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
7106 BuiltinView {
7107 name: "pg_description_all_databases",
7108 schema: MZ_INTERNAL_SCHEMA,
7109 oid: oid::VIEW_PG_DESCRIPTION_ALL_DATABASES_OID,
7110 desc: RelationDesc::builder()
7111 .with_column("objoid", SqlScalarType::Oid.nullable(false))
7112 .with_column("classoid", SqlScalarType::Oid.nullable(true))
7113 .with_column("objsubid", SqlScalarType::Int32.nullable(false))
7114 .with_column("description", SqlScalarType::String.nullable(false))
7115 .with_column("oid_database_name", SqlScalarType::String.nullable(true))
7116 .with_column("class_database_name", SqlScalarType::String.nullable(true))
7117 .finish(),
7118 column_comments: BTreeMap::new(),
7119 sql: "
7120(
7121 -- Gather all of the class oid's for objects that can have comments.
7122 WITH pg_classoids AS (
7123 SELECT oid, database_name as oid_database_name,
7124 (SELECT oid FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_class') AS classoid,
7125 (SELECT database_name FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_class') AS class_database_name
7126 FROM mz_internal.pg_class_all_databases
7127 UNION ALL
7128 SELECT oid, database_name as oid_database_name,
7129 (SELECT oid FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_type') AS classoid,
7130 (SELECT database_name FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_type') AS class_database_name
7131 FROM mz_internal.pg_type_all_databases
7132 UNION ALL
7133 SELECT oid, database_name as oid_database_name,
7134 (SELECT oid FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_namespace') AS classoid,
7135 (SELECT database_name FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_namespace') AS class_database_name
7136 FROM mz_internal.pg_namespace_all_databases
7137 ),
7138
7139 -- Gather all of the MZ ids for objects that can have comments.
7140 mz_objects AS (
7141 SELECT id, oid, type FROM mz_catalog.mz_objects
7142 UNION ALL
7143 SELECT id, oid, 'schema' AS type FROM mz_catalog.mz_schemas
7144 )
7145 SELECT
7146 pg_classoids.oid AS objoid,
7147 pg_classoids.classoid as classoid,
7148 COALESCE(cmt.object_sub_id, 0) AS objsubid,
7149 cmt.comment AS description,
7150 -- Columns added because of the peeling. (Note that there are 2 of these here.)
7151 oid_database_name,
7152 class_database_name
7153 FROM
7154 pg_classoids
7155 JOIN
7156 mz_objects ON pg_classoids.oid = mz_objects.oid
7157 JOIN
7158 mz_internal.mz_comments AS cmt ON mz_objects.id = cmt.id AND lower(mz_objects.type) = lower(cmt.object_type)
7159)",
7160 access: vec![PUBLIC_SELECT],
7161 }
7162});
7163
7164pub const PG_DESCRIPTION_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7165 name: "pg_description_all_databases_ind",
7166 schema: MZ_INTERNAL_SCHEMA,
7167 oid: oid::INDEX_PG_DESCRIPTION_ALL_DATABASES_IND_OID,
7168 sql: "IN CLUSTER mz_catalog_server
7169ON mz_internal.pg_description_all_databases (objoid, classoid, objsubid, description, oid_database_name, class_database_name)",
7170 is_retained_metrics_object: false,
7171};
7172
7173pub static PG_DESCRIPTION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7177 name: "pg_description",
7178 schema: PG_CATALOG_SCHEMA,
7179 oid: oid::VIEW_PG_DESCRIPTION_OID,
7180 desc: RelationDesc::builder()
7181 .with_column("objoid", SqlScalarType::Oid.nullable(false))
7182 .with_column("classoid", SqlScalarType::Oid.nullable(true))
7183 .with_column("objsubid", SqlScalarType::Int32.nullable(false))
7184 .with_column("description", SqlScalarType::String.nullable(false))
7185 .finish(),
7186 column_comments: BTreeMap::new(),
7187 sql: "
7188SELECT
7189 objoid,
7190 classoid,
7191 objsubid,
7192 description
7193FROM
7194 mz_internal.pg_description_all_databases
7195WHERE
7196 (oid_database_name IS NULL OR oid_database_name = pg_catalog.current_database()) AND
7197 (class_database_name IS NULL OR class_database_name = pg_catalog.current_database());",
7198 access: vec![PUBLIC_SELECT],
7199});
7200
7201pub static PG_TYPE_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
7207 BuiltinView {
7208 name: "pg_type_all_databases",
7209 schema: MZ_INTERNAL_SCHEMA,
7210 oid: oid::VIEW_PG_TYPE_ALL_DATABASES_OID,
7211 desc: RelationDesc::builder()
7212 .with_column("oid", SqlScalarType::Oid.nullable(false))
7213 .with_column("typname", SqlScalarType::String.nullable(false))
7214 .with_column("typnamespace", SqlScalarType::Oid.nullable(false))
7215 .with_column("typowner", SqlScalarType::Oid.nullable(false))
7216 .with_column("typlen", SqlScalarType::Int16.nullable(true))
7217 .with_column("typtype", SqlScalarType::PgLegacyChar.nullable(false))
7218 .with_column("typcategory", SqlScalarType::PgLegacyChar.nullable(true))
7219 .with_column("typdelim", SqlScalarType::PgLegacyChar.nullable(false))
7220 .with_column("typrelid", SqlScalarType::Oid.nullable(false))
7221 .with_column("typelem", SqlScalarType::Oid.nullable(false))
7222 .with_column("typarray", SqlScalarType::Oid.nullable(false))
7223 .with_column("typinput", SqlScalarType::RegProc.nullable(true))
7224 .with_column("typreceive", SqlScalarType::Oid.nullable(false))
7225 .with_column("typnotnull", SqlScalarType::Bool.nullable(false))
7226 .with_column("typbasetype", SqlScalarType::Oid.nullable(false))
7227 .with_column("typtypmod", SqlScalarType::Int32.nullable(false))
7228 .with_column("typcollation", SqlScalarType::Oid.nullable(false))
7229 .with_column("typdefault", SqlScalarType::String.nullable(true))
7230 .with_column("database_name", SqlScalarType::String.nullable(true))
7231 .finish(),
7232 column_comments: BTreeMap::new(),
7233 sql: "
7234SELECT
7235 mz_types.oid,
7236 mz_types.name AS typname,
7237 mz_schemas.oid AS typnamespace,
7238 role_owner.oid AS typowner,
7239 NULL::pg_catalog.int2 AS typlen,
7240 -- 'a' is used internally to denote an array type, but in postgres they show up
7241 -- as 'b'.
7242 (CASE mztype WHEN 'a' THEN 'b' ELSE mztype END)::pg_catalog.char AS typtype,
7243 (CASE category
7244 WHEN 'array' THEN 'A'
7245 WHEN 'bit-string' THEN 'V'
7246 WHEN 'boolean' THEN 'B'
7247 WHEN 'composite' THEN 'C'
7248 WHEN 'date-time' THEN 'D'
7249 WHEN 'enum' THEN 'E'
7250 WHEN 'geometric' THEN 'G'
7251 WHEN 'list' THEN 'U' -- List types are user-defined from PostgreSQL's perspective.
7252 WHEN 'network-address' THEN 'I'
7253 WHEN 'numeric' THEN 'N'
7254 WHEN 'pseudo' THEN 'P'
7255 WHEN 'string' THEN 'S'
7256 WHEN 'timespan' THEN 'T'
7257 WHEN 'user-defined' THEN 'U'
7258 WHEN 'unknown' THEN 'X'
7259 END)::pg_catalog.char AS typcategory,
7260 -- In pg only the 'box' type is not ','.
7261 ','::pg_catalog.char AS typdelim,
7262 0::pg_catalog.oid AS typrelid,
7263 coalesce(
7264 (
7265 SELECT t.oid
7266 FROM mz_catalog.mz_array_types a
7267 JOIN mz_catalog.mz_types t ON a.element_id = t.id
7268 WHERE a.id = mz_types.id
7269 ),
7270 0
7271 ) AS typelem,
7272 coalesce(
7273 (
7274 SELECT
7275 t.oid
7276 FROM
7277 mz_catalog.mz_array_types AS a
7278 JOIN mz_catalog.mz_types AS t ON a.id = t.id
7279 WHERE
7280 a.element_id = mz_types.id
7281 ),
7282 0
7283 )
7284 AS typarray,
7285 mz_internal.mz_type_pg_metadata.typinput::pg_catalog.regproc AS typinput,
7286 COALESCE(mz_internal.mz_type_pg_metadata.typreceive, 0) AS typreceive,
7287 false::pg_catalog.bool AS typnotnull,
7288 0::pg_catalog.oid AS typbasetype,
7289 -1::pg_catalog.int4 AS typtypmod,
7290 -- MZ doesn't support COLLATE so typcollation is filled with 0
7291 0::pg_catalog.oid AS typcollation,
7292 NULL::pg_catalog.text AS typdefault,
7293 d.name as database_name
7294FROM
7295 mz_catalog.mz_types
7296 LEFT JOIN mz_internal.mz_type_pg_metadata ON mz_catalog.mz_types.id = mz_internal.mz_type_pg_metadata.id
7297 JOIN mz_catalog.mz_schemas ON mz_schemas.id = mz_types.schema_id
7298 JOIN (
7299 -- 'a' is not a supported typtype, but we use it to denote an array. It is
7300 -- converted to the correct value above.
7301 SELECT id, 'a' AS mztype FROM mz_catalog.mz_array_types
7302 UNION ALL SELECT id, 'b' FROM mz_catalog.mz_base_types
7303 UNION ALL SELECT id, 'l' FROM mz_catalog.mz_list_types
7304 UNION ALL SELECT id, 'm' FROM mz_catalog.mz_map_types
7305 UNION ALL SELECT id, 'p' FROM mz_catalog.mz_pseudo_types
7306 )
7307 AS t ON mz_types.id = t.id
7308 LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
7309 JOIN mz_catalog.mz_roles role_owner ON role_owner.id = mz_types.owner_id",
7310 access: vec![PUBLIC_SELECT],
7311 }
7312});
7313
7314pub const PG_TYPE_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7315 name: "pg_type_all_databases_ind",
7316 schema: MZ_INTERNAL_SCHEMA,
7317 oid: oid::INDEX_PG_TYPE_ALL_DATABASES_IND_OID,
7318 sql: "IN CLUSTER mz_catalog_server
7319ON mz_internal.pg_type_all_databases (oid)",
7320 is_retained_metrics_object: false,
7321};
7322
7323pub static PG_TYPE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7324 name: "pg_type",
7325 schema: PG_CATALOG_SCHEMA,
7326 oid: oid::VIEW_PG_TYPE_OID,
7327 desc: RelationDesc::builder()
7328 .with_column("oid", SqlScalarType::Oid.nullable(false))
7329 .with_column("typname", SqlScalarType::String.nullable(false))
7330 .with_column("typnamespace", SqlScalarType::Oid.nullable(false))
7331 .with_column("typowner", SqlScalarType::Oid.nullable(false))
7332 .with_column("typlen", SqlScalarType::Int16.nullable(true))
7333 .with_column("typtype", SqlScalarType::PgLegacyChar.nullable(false))
7334 .with_column("typcategory", SqlScalarType::PgLegacyChar.nullable(true))
7335 .with_column("typdelim", SqlScalarType::PgLegacyChar.nullable(false))
7336 .with_column("typrelid", SqlScalarType::Oid.nullable(false))
7337 .with_column("typelem", SqlScalarType::Oid.nullable(false))
7338 .with_column("typarray", SqlScalarType::Oid.nullable(false))
7339 .with_column("typinput", SqlScalarType::RegProc.nullable(true))
7340 .with_column("typreceive", SqlScalarType::Oid.nullable(false))
7341 .with_column("typnotnull", SqlScalarType::Bool.nullable(false))
7342 .with_column("typbasetype", SqlScalarType::Oid.nullable(false))
7343 .with_column("typtypmod", SqlScalarType::Int32.nullable(false))
7344 .with_column("typcollation", SqlScalarType::Oid.nullable(false))
7345 .with_column("typdefault", SqlScalarType::String.nullable(true))
7346 .finish(),
7347 column_comments: BTreeMap::new(),
7348 sql: "SELECT
7349 oid, typname, typnamespace, typowner, typlen, typtype, typcategory, typdelim, typrelid, typelem,
7350 typarray, typinput, typreceive, typnotnull, typbasetype, typtypmod, typcollation, typdefault
7351FROM mz_internal.pg_type_all_databases
7352WHERE database_name IS NULL OR database_name = pg_catalog.current_database();",
7353 access: vec![PUBLIC_SELECT],
7354});
7355
7356pub static PG_ATTRIBUTE_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
7362 BuiltinView {
7363 name: "pg_attribute_all_databases",
7364 schema: MZ_INTERNAL_SCHEMA,
7365 oid: oid::VIEW_PG_ATTRIBUTE_ALL_DATABASES_OID,
7366 desc: RelationDesc::builder()
7367 .with_column("attrelid", SqlScalarType::Oid.nullable(false))
7368 .with_column("attname", SqlScalarType::String.nullable(false))
7369 .with_column("atttypid", SqlScalarType::Oid.nullable(false))
7370 .with_column("attlen", SqlScalarType::Int16.nullable(true))
7371 .with_column("attnum", SqlScalarType::Int16.nullable(false))
7372 .with_column("atttypmod", SqlScalarType::Int32.nullable(false))
7373 .with_column("attnotnull", SqlScalarType::Bool.nullable(false))
7374 .with_column("atthasdef", SqlScalarType::Bool.nullable(false))
7375 .with_column("attidentity", SqlScalarType::PgLegacyChar.nullable(false))
7376 .with_column("attgenerated", SqlScalarType::PgLegacyChar.nullable(false))
7377 .with_column("attisdropped", SqlScalarType::Bool.nullable(false))
7378 .with_column("attcollation", SqlScalarType::Oid.nullable(false))
7379 .with_column("database_name", SqlScalarType::String.nullable(true))
7380 .with_column("pg_type_database_name", SqlScalarType::String.nullable(true))
7381 .finish(),
7382 column_comments: BTreeMap::new(),
7383 sql: "
7384SELECT
7385 class_objects.oid as attrelid,
7386 mz_columns.name as attname,
7387 mz_columns.type_oid AS atttypid,
7388 pg_type_all_databases.typlen AS attlen,
7389 position::int8::int2 as attnum,
7390 mz_columns.type_mod as atttypmod,
7391 NOT nullable as attnotnull,
7392 mz_columns.default IS NOT NULL as atthasdef,
7393 ''::pg_catalog.\"char\" as attidentity,
7394 -- MZ doesn't support generated columns so attgenerated is filled with ''
7395 ''::pg_catalog.\"char\" as attgenerated,
7396 FALSE as attisdropped,
7397 -- MZ doesn't support COLLATE so attcollation is filled with 0
7398 0::pg_catalog.oid as attcollation,
7399 -- Columns added because of the peeling. (Note that there are 2 of these here.)
7400 d.name as database_name,
7401 pg_type_all_databases.database_name as pg_type_database_name
7402FROM (
7403 -- pg_attribute catalogs columns on relations and indexes
7404 SELECT id, oid, schema_id, name, type FROM mz_catalog.mz_relations
7405 UNION ALL
7406 SELECT mz_indexes.id, mz_indexes.oid, mz_relations.schema_id, mz_indexes.name, 'index' AS type
7407 FROM mz_catalog.mz_indexes
7408 JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
7409) AS class_objects
7410JOIN mz_catalog.mz_columns ON class_objects.id = mz_columns.id
7411JOIN mz_internal.pg_type_all_databases ON pg_type_all_databases.oid = mz_columns.type_oid
7412JOIN mz_catalog.mz_schemas ON mz_schemas.id = class_objects.schema_id
7413LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id",
7414 access: vec![PUBLIC_SELECT],
7417 }
7418});
7419
7420pub const PG_ATTRIBUTE_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7421 name: "pg_attribute_all_databases_ind",
7422 schema: MZ_INTERNAL_SCHEMA,
7423 oid: oid::INDEX_PG_ATTRIBUTE_ALL_DATABASES_IND_OID,
7424 sql: "IN CLUSTER mz_catalog_server
7425ON mz_internal.pg_attribute_all_databases (
7426 attrelid, attname, atttypid, attlen, attnum, atttypmod, attnotnull, atthasdef, attidentity,
7427 attgenerated, attisdropped, attcollation, database_name, pg_type_database_name
7428)",
7429 is_retained_metrics_object: false,
7430};
7431
7432pub static PG_ATTRIBUTE: LazyLock<BuiltinView> = LazyLock::new(|| {
7433 BuiltinView {
7434 name: "pg_attribute",
7435 schema: PG_CATALOG_SCHEMA,
7436 oid: oid::VIEW_PG_ATTRIBUTE_OID,
7437 desc: RelationDesc::builder()
7438 .with_column("attrelid", SqlScalarType::Oid.nullable(false))
7439 .with_column("attname", SqlScalarType::String.nullable(false))
7440 .with_column("atttypid", SqlScalarType::Oid.nullable(false))
7441 .with_column("attlen", SqlScalarType::Int16.nullable(true))
7442 .with_column("attnum", SqlScalarType::Int16.nullable(false))
7443 .with_column("atttypmod", SqlScalarType::Int32.nullable(false))
7444 .with_column("attnotnull", SqlScalarType::Bool.nullable(false))
7445 .with_column("atthasdef", SqlScalarType::Bool.nullable(false))
7446 .with_column("attidentity", SqlScalarType::PgLegacyChar.nullable(false))
7447 .with_column("attgenerated", SqlScalarType::PgLegacyChar.nullable(false))
7448 .with_column("attisdropped", SqlScalarType::Bool.nullable(false))
7449 .with_column("attcollation", SqlScalarType::Oid.nullable(false))
7450 .finish(),
7451 column_comments: BTreeMap::new(),
7452 sql: "
7453SELECT
7454 attrelid, attname, atttypid, attlen, attnum, atttypmod, attnotnull, atthasdef, attidentity,
7455 attgenerated, attisdropped, attcollation
7456FROM mz_internal.pg_attribute_all_databases
7457WHERE
7458 (database_name IS NULL OR database_name = pg_catalog.current_database()) AND
7459 (pg_type_database_name IS NULL OR pg_type_database_name = pg_catalog.current_database());",
7460 access: vec![PUBLIC_SELECT],
7463 }
7464});
7465
7466pub static PG_PROC: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7467 name: "pg_proc",
7468 schema: PG_CATALOG_SCHEMA,
7469 oid: oid::VIEW_PG_PROC_OID,
7470 desc: RelationDesc::builder()
7471 .with_column("oid", SqlScalarType::Oid.nullable(false))
7472 .with_column("proname", SqlScalarType::String.nullable(false))
7473 .with_column("pronamespace", SqlScalarType::Oid.nullable(false))
7474 .with_column("proowner", SqlScalarType::Oid.nullable(false))
7475 .with_column("proargdefaults", SqlScalarType::String.nullable(true))
7476 .with_column("prorettype", SqlScalarType::Oid.nullable(false))
7477 .finish(),
7478 column_comments: BTreeMap::new(),
7479 sql: "SELECT
7480 mz_functions.oid,
7481 mz_functions.name AS proname,
7482 mz_schemas.oid AS pronamespace,
7483 role_owner.oid AS proowner,
7484 NULL::pg_catalog.text AS proargdefaults,
7485 ret_type.oid AS prorettype
7486FROM mz_catalog.mz_functions
7487JOIN mz_catalog.mz_schemas ON mz_functions.schema_id = mz_schemas.id
7488LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
7489JOIN mz_catalog.mz_types AS ret_type ON mz_functions.return_type_id = ret_type.id
7490JOIN mz_catalog.mz_roles role_owner ON role_owner.id = mz_functions.owner_id
7491WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()",
7492 access: vec![PUBLIC_SELECT],
7493});
7494
7495pub static PG_OPERATOR: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7496 name: "pg_operator",
7497 schema: PG_CATALOG_SCHEMA,
7498 oid: oid::VIEW_PG_OPERATOR_OID,
7499 desc: RelationDesc::builder()
7500 .with_column("oid", SqlScalarType::Oid.nullable(false))
7501 .with_column("oprname", SqlScalarType::String.nullable(false))
7502 .with_column("oprresult", SqlScalarType::Oid.nullable(false))
7503 .with_column("oprleft", SqlScalarType::Oid.nullable(false))
7504 .with_column("oprright", SqlScalarType::Oid.nullable(false))
7505 .with_key(vec![0, 1, 2, 3, 4])
7506 .finish(),
7507 column_comments: BTreeMap::new(),
7508 sql: "SELECT
7509 mz_operators.oid,
7510 mz_operators.name AS oprname,
7511 ret_type.oid AS oprresult,
7512 left_type.oid as oprleft,
7513 right_type.oid as oprright
7514FROM mz_catalog.mz_operators
7515JOIN mz_catalog.mz_types AS ret_type ON mz_operators.return_type_id = ret_type.id
7516JOIN mz_catalog.mz_types AS left_type ON mz_operators.argument_type_ids[1] = left_type.id
7517JOIN mz_catalog.mz_types AS right_type ON mz_operators.argument_type_ids[2] = right_type.id
7518WHERE array_length(mz_operators.argument_type_ids, 1) = 2
7519UNION SELECT
7520 mz_operators.oid,
7521 mz_operators.name AS oprname,
7522 ret_type.oid AS oprresult,
7523 0 as oprleft,
7524 right_type.oid as oprright
7525FROM mz_catalog.mz_operators
7526JOIN mz_catalog.mz_types AS ret_type ON mz_operators.return_type_id = ret_type.id
7527JOIN mz_catalog.mz_types AS right_type ON mz_operators.argument_type_ids[1] = right_type.id
7528WHERE array_length(mz_operators.argument_type_ids, 1) = 1",
7529 access: vec![PUBLIC_SELECT],
7530});
7531
7532pub static PG_RANGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7533 name: "pg_range",
7534 schema: PG_CATALOG_SCHEMA,
7535 oid: oid::VIEW_PG_RANGE_OID,
7536 desc: RelationDesc::builder()
7537 .with_column("rngtypid", SqlScalarType::Oid.nullable(false))
7538 .with_column("rngsubtype", SqlScalarType::Oid.nullable(false))
7539 .with_key(vec![])
7540 .finish(),
7541 column_comments: BTreeMap::new(),
7542 sql: "SELECT
7543 NULL::pg_catalog.oid AS rngtypid,
7544 NULL::pg_catalog.oid AS rngsubtype
7545WHERE false",
7546 access: vec![PUBLIC_SELECT],
7547});
7548
7549pub static PG_ENUM: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7550 name: "pg_enum",
7551 schema: PG_CATALOG_SCHEMA,
7552 oid: oid::VIEW_PG_ENUM_OID,
7553 desc: RelationDesc::builder()
7554 .with_column("oid", SqlScalarType::Oid.nullable(false))
7555 .with_column("enumtypid", SqlScalarType::Oid.nullable(false))
7556 .with_column("enumsortorder", SqlScalarType::Float32.nullable(false))
7557 .with_column("enumlabel", SqlScalarType::String.nullable(false))
7558 .with_key(vec![])
7559 .finish(),
7560 column_comments: BTreeMap::new(),
7561 sql: "SELECT
7562 NULL::pg_catalog.oid AS oid,
7563 NULL::pg_catalog.oid AS enumtypid,
7564 NULL::pg_catalog.float4 AS enumsortorder,
7565 NULL::pg_catalog.text AS enumlabel
7566WHERE false",
7567 access: vec![PUBLIC_SELECT],
7568});
7569
7570pub static PG_ATTRDEF_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7574 name: "pg_attrdef_all_databases",
7575 schema: MZ_INTERNAL_SCHEMA,
7576 oid: oid::VIEW_PG_ATTRDEF_ALL_DATABASES_OID,
7577 desc: RelationDesc::builder()
7578 .with_column("oid", SqlScalarType::Oid.nullable(true))
7579 .with_column("adrelid", SqlScalarType::Oid.nullable(false))
7580 .with_column("adnum", SqlScalarType::Int64.nullable(false))
7581 .with_column("adbin", SqlScalarType::String.nullable(false))
7582 .with_column("adsrc", SqlScalarType::String.nullable(false))
7583 .finish(),
7584 column_comments: BTreeMap::new(),
7585 sql: "
7586SELECT
7587 NULL::pg_catalog.oid AS oid,
7588 mz_objects.oid AS adrelid,
7589 mz_columns.position::int8 AS adnum,
7590 mz_columns.default AS adbin,
7591 mz_columns.default AS adsrc
7592FROM mz_catalog.mz_columns
7593 JOIN mz_catalog.mz_objects ON mz_columns.id = mz_objects.id
7594WHERE default IS NOT NULL",
7595 access: vec![PUBLIC_SELECT],
7596});
7597
7598pub const PG_ATTRDEF_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7599 name: "pg_attrdef_all_databases_ind",
7600 schema: MZ_INTERNAL_SCHEMA,
7601 oid: oid::INDEX_PG_ATTRDEF_ALL_DATABASES_IND_OID,
7602 sql: "IN CLUSTER mz_catalog_server
7603ON mz_internal.pg_attrdef_all_databases (oid, adrelid, adnum, adbin, adsrc)",
7604 is_retained_metrics_object: false,
7605};
7606
7607pub static PG_ATTRDEF: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7608 name: "pg_attrdef",
7609 schema: PG_CATALOG_SCHEMA,
7610 oid: oid::VIEW_PG_ATTRDEF_OID,
7611 desc: RelationDesc::builder()
7612 .with_column("oid", SqlScalarType::Oid.nullable(true))
7613 .with_column("adrelid", SqlScalarType::Oid.nullable(false))
7614 .with_column("adnum", SqlScalarType::Int64.nullable(false))
7615 .with_column("adbin", SqlScalarType::String.nullable(false))
7616 .with_column("adsrc", SqlScalarType::String.nullable(false))
7617 .finish(),
7618 column_comments: BTreeMap::new(),
7619 sql: "
7620SELECT
7621 pg_attrdef_all_databases.oid as oid,
7622 adrelid,
7623 adnum,
7624 adbin,
7625 adsrc
7626FROM mz_internal.pg_attrdef_all_databases
7627 JOIN mz_catalog.mz_databases d ON (d.id IS NULL OR d.name = pg_catalog.current_database());",
7628 access: vec![PUBLIC_SELECT],
7629});
7630
7631pub static PG_SETTINGS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7632 name: "pg_settings",
7633 schema: PG_CATALOG_SCHEMA,
7634 oid: oid::VIEW_PG_SETTINGS_OID,
7635 desc: RelationDesc::builder()
7636 .with_column("name", SqlScalarType::String.nullable(false))
7637 .with_column("setting", SqlScalarType::String.nullable(false))
7638 .with_key(vec![])
7639 .finish(),
7640 column_comments: BTreeMap::new(),
7641 sql: "SELECT
7642 name, setting
7643FROM (VALUES
7644 ('max_index_keys'::pg_catalog.text, '1000'::pg_catalog.text)
7645) AS _ (name, setting)",
7646 access: vec![PUBLIC_SELECT],
7647});
7648
7649pub static PG_AUTH_MEMBERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7650 name: "pg_auth_members",
7651 schema: PG_CATALOG_SCHEMA,
7652 oid: oid::VIEW_PG_AUTH_MEMBERS_OID,
7653 desc: RelationDesc::builder()
7654 .with_column("roleid", SqlScalarType::Oid.nullable(false))
7655 .with_column("member", SqlScalarType::Oid.nullable(false))
7656 .with_column("grantor", SqlScalarType::Oid.nullable(false))
7657 .with_column("admin_option", SqlScalarType::Bool.nullable(false))
7658 .finish(),
7659 column_comments: BTreeMap::new(),
7660 sql: "SELECT
7661 role.oid AS roleid,
7662 member.oid AS member,
7663 grantor.oid AS grantor,
7664 -- Materialize hasn't implemented admin_option.
7665 false as admin_option
7666FROM mz_catalog.mz_role_members membership
7667JOIN mz_catalog.mz_roles role ON membership.role_id = role.id
7668JOIN mz_catalog.mz_roles member ON membership.member = member.id
7669JOIN mz_catalog.mz_roles grantor ON membership.grantor = grantor.id",
7670 access: vec![PUBLIC_SELECT],
7671});
7672
7673pub static PG_EVENT_TRIGGER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7674 name: "pg_event_trigger",
7675 schema: PG_CATALOG_SCHEMA,
7676 oid: oid::VIEW_PG_EVENT_TRIGGER_OID,
7677 desc: RelationDesc::builder()
7678 .with_column("oid", SqlScalarType::Oid.nullable(false))
7679 .with_column("evtname", SqlScalarType::String.nullable(false))
7680 .with_column("evtevent", SqlScalarType::String.nullable(false))
7681 .with_column("evtowner", SqlScalarType::Oid.nullable(false))
7682 .with_column("evtfoid", SqlScalarType::Oid.nullable(false))
7683 .with_column("evtenabled", SqlScalarType::PgLegacyChar.nullable(false))
7684 .with_column(
7685 "evttags",
7686 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
7687 )
7688 .with_key(vec![])
7689 .finish(),
7690 column_comments: BTreeMap::new(),
7691 sql: "SELECT
7692 NULL::pg_catalog.oid AS oid,
7693 NULL::pg_catalog.text AS evtname,
7694 NULL::pg_catalog.text AS evtevent,
7695 NULL::pg_catalog.oid AS evtowner,
7696 NULL::pg_catalog.oid AS evtfoid,
7697 NULL::pg_catalog.char AS evtenabled,
7698 NULL::pg_catalog.text[] AS evttags
7699 WHERE false",
7700 access: vec![PUBLIC_SELECT],
7701});
7702
7703pub static PG_LANGUAGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7704 name: "pg_language",
7705 schema: PG_CATALOG_SCHEMA,
7706 oid: oid::VIEW_PG_LANGUAGE_OID,
7707 desc: RelationDesc::builder()
7708 .with_column("oid", SqlScalarType::Oid.nullable(false))
7709 .with_column("lanname", SqlScalarType::String.nullable(false))
7710 .with_column("lanowner", SqlScalarType::Oid.nullable(false))
7711 .with_column("lanispl", SqlScalarType::Bool.nullable(false))
7712 .with_column("lanpltrusted", SqlScalarType::Bool.nullable(false))
7713 .with_column("lanplcallfoid", SqlScalarType::Oid.nullable(false))
7714 .with_column("laninline", SqlScalarType::Oid.nullable(false))
7715 .with_column("lanvalidator", SqlScalarType::Oid.nullable(false))
7716 .with_column(
7717 "lanacl",
7718 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
7719 )
7720 .with_key(vec![])
7721 .finish(),
7722 column_comments: BTreeMap::new(),
7723 sql: "SELECT
7724 NULL::pg_catalog.oid AS oid,
7725 NULL::pg_catalog.text AS lanname,
7726 NULL::pg_catalog.oid AS lanowner,
7727 NULL::pg_catalog.bool AS lanispl,
7728 NULL::pg_catalog.bool AS lanpltrusted,
7729 NULL::pg_catalog.oid AS lanplcallfoid,
7730 NULL::pg_catalog.oid AS laninline,
7731 NULL::pg_catalog.oid AS lanvalidator,
7732 NULL::pg_catalog.text[] AS lanacl
7733 WHERE false",
7734 access: vec![PUBLIC_SELECT],
7735});
7736
7737pub static PG_SHDESCRIPTION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7738 name: "pg_shdescription",
7739 schema: PG_CATALOG_SCHEMA,
7740 oid: oid::VIEW_PG_SHDESCRIPTION_OID,
7741 desc: RelationDesc::builder()
7742 .with_column("objoid", SqlScalarType::Oid.nullable(false))
7743 .with_column("classoid", SqlScalarType::Oid.nullable(false))
7744 .with_column("description", SqlScalarType::String.nullable(false))
7745 .with_key(vec![])
7746 .finish(),
7747 column_comments: BTreeMap::new(),
7748 sql: "SELECT
7749 NULL::pg_catalog.oid AS objoid,
7750 NULL::pg_catalog.oid AS classoid,
7751 NULL::pg_catalog.text AS description
7752 WHERE false",
7753 access: vec![PUBLIC_SELECT],
7754});
7755
7756pub static PG_TIMEZONE_ABBREVS: LazyLock<BuiltinView> = LazyLock::new(|| {
7757 BuiltinView {
7758 name: "pg_timezone_abbrevs",
7759 schema: PG_CATALOG_SCHEMA,
7760 oid: oid::VIEW_PG_TIMEZONE_ABBREVS_OID,
7761 desc: RelationDesc::builder()
7762 .with_column("abbrev", SqlScalarType::String.nullable(false))
7763 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
7764 .with_column("is_dst", SqlScalarType::Bool.nullable(true))
7765 .with_key(vec![0])
7766 .finish(),
7767 column_comments: BTreeMap::new(),
7768 sql: "SELECT
7769 abbreviation AS abbrev,
7770 COALESCE(utc_offset, timezone_offset(timezone_name, now()).base_utc_offset + timezone_offset(timezone_name, now()).dst_offset)
7771 AS utc_offset,
7772 COALESCE(dst, timezone_offset(timezone_name, now()).dst_offset <> INTERVAL '0')
7773 AS is_dst
7774FROM mz_catalog.mz_timezone_abbreviations",
7775 access: vec![PUBLIC_SELECT],
7776 }
7777});
7778
7779pub static PG_TIMEZONE_NAMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7780 name: "pg_timezone_names",
7781 schema: PG_CATALOG_SCHEMA,
7782 oid: oid::VIEW_PG_TIMEZONE_NAMES_OID,
7783 desc: RelationDesc::builder()
7784 .with_column("name", SqlScalarType::String.nullable(false))
7785 .with_column("abbrev", SqlScalarType::String.nullable(true))
7786 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
7787 .with_column("is_dst", SqlScalarType::Bool.nullable(true))
7788 .with_key(vec![0])
7789 .finish(),
7790 column_comments: BTreeMap::new(),
7791 sql: "SELECT
7792 name,
7793 timezone_offset(name, now()).abbrev AS abbrev,
7794 timezone_offset(name, now()).base_utc_offset + timezone_offset(name, now()).dst_offset
7795 AS utc_offset,
7796 timezone_offset(name, now()).dst_offset <> INTERVAL '0'
7797 AS is_dst
7798FROM mz_catalog.mz_timezone_names",
7799 access: vec![PUBLIC_SELECT],
7800});
7801
7802pub static MZ_TIMEZONE_ABBREVIATIONS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7803 name: "mz_timezone_abbreviations",
7804 schema: MZ_CATALOG_SCHEMA,
7805 oid: oid::VIEW_MZ_TIMEZONE_ABBREVIATIONS_OID,
7806 desc: RelationDesc::builder()
7807 .with_column("abbreviation", SqlScalarType::String.nullable(false))
7808 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
7809 .with_column("dst", SqlScalarType::Bool.nullable(true))
7810 .with_column("timezone_name", SqlScalarType::String.nullable(true))
7811 .with_key(vec![0])
7812 .finish(),
7813 column_comments: BTreeMap::from_iter([
7814 ("abbreviation", "The timezone abbreviation."),
7815 (
7816 "utc_offset",
7817 "The UTC offset of the timezone or `NULL` if fixed.",
7818 ),
7819 (
7820 "dst",
7821 "Whether the timezone is in daylight savings or `NULL` if fixed.",
7822 ),
7823 (
7824 "timezone_name",
7825 "The full name of the non-fixed timezone or `NULL` if not fixed.",
7826 ),
7827 ]),
7828 sql: format!(
7829 "SELECT * FROM ({}) _ (abbreviation, utc_offset, dst, timezone_name)",
7830 mz_pgtz::abbrev::MZ_CATALOG_TIMEZONE_ABBREVIATIONS_SQL,
7831 )
7832 .leak(),
7833 access: vec![PUBLIC_SELECT],
7834});
7835
7836pub static MZ_TIMEZONE_NAMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7837 name: "mz_timezone_names",
7838 schema: MZ_CATALOG_SCHEMA,
7839 oid: oid::VIEW_MZ_TIMEZONE_NAMES_OID,
7840 desc: RelationDesc::builder()
7841 .with_column("name", SqlScalarType::String.nullable(false))
7842 .with_key(vec![0])
7843 .finish(),
7844 column_comments: BTreeMap::from_iter([("name", "The timezone name.")]),
7845 sql: format!(
7846 "SELECT * FROM ({}) _ (name)",
7847 mz_pgtz::timezone::MZ_CATALOG_TIMEZONE_NAMES_SQL,
7848 )
7849 .leak(),
7850 access: vec![PUBLIC_SELECT],
7851});
7852
7853pub static MZ_PEEK_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
7854 LazyLock::new(|| BuiltinView {
7855 name: "mz_peek_durations_histogram_per_worker",
7856 schema: MZ_INTROSPECTION_SCHEMA,
7857 oid: oid::VIEW_MZ_PEEK_DURATIONS_HISTOGRAM_PER_WORKER_OID,
7858 desc: RelationDesc::builder()
7859 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
7860 .with_column("type", SqlScalarType::String.nullable(false))
7861 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7862 .with_column("count", SqlScalarType::Int64.nullable(false))
7863 .with_key(vec![0, 1, 2])
7864 .finish(),
7865 column_comments: BTreeMap::new(),
7866 sql: "SELECT
7867 worker_id, type, duration_ns, pg_catalog.count(*) AS count
7868FROM
7869 mz_introspection.mz_peek_durations_histogram_raw
7870GROUP BY
7871 worker_id, type, duration_ns",
7872 access: vec![PUBLIC_SELECT],
7873 });
7874
7875pub static MZ_PEEK_DURATIONS_HISTOGRAM: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7876 name: "mz_peek_durations_histogram",
7877 schema: MZ_INTROSPECTION_SCHEMA,
7878 oid: oid::VIEW_MZ_PEEK_DURATIONS_HISTOGRAM_OID,
7879 desc: RelationDesc::builder()
7880 .with_column("type", SqlScalarType::String.nullable(false))
7881 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7882 .with_column(
7883 "count",
7884 SqlScalarType::Numeric {
7885 max_scale: Some(NumericMaxScale::ZERO),
7886 }
7887 .nullable(false),
7888 )
7889 .with_key(vec![0, 1])
7890 .finish(),
7891 column_comments: BTreeMap::from_iter([
7892 ("type", "The peek variant: `index` or `persist`."),
7893 (
7894 "duration_ns",
7895 "The upper bound of the bucket in nanoseconds.",
7896 ),
7897 (
7898 "count",
7899 "The (noncumulative) count of peeks in this bucket.",
7900 ),
7901 ]),
7902 sql: "
7903SELECT
7904 type, duration_ns,
7905 pg_catalog.sum(count) AS count
7906FROM mz_introspection.mz_peek_durations_histogram_per_worker
7907GROUP BY type, duration_ns",
7908 access: vec![PUBLIC_SELECT],
7909});
7910
7911pub static MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
7912 LazyLock::new(|| BuiltinView {
7913 name: "mz_dataflow_shutdown_durations_histogram_per_worker",
7914 schema: MZ_INTROSPECTION_SCHEMA,
7915 oid: oid::VIEW_MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_PER_WORKER_OID,
7916 desc: RelationDesc::builder()
7917 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
7918 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7919 .with_column("count", SqlScalarType::Int64.nullable(false))
7920 .with_key(vec![0, 1])
7921 .finish(),
7922 column_comments: BTreeMap::new(),
7923 sql: "SELECT
7924 worker_id, duration_ns, pg_catalog.count(*) AS count
7925FROM
7926 mz_introspection.mz_dataflow_shutdown_durations_histogram_raw
7927GROUP BY
7928 worker_id, duration_ns",
7929 access: vec![PUBLIC_SELECT],
7930 });
7931
7932pub static MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM: LazyLock<BuiltinView> =
7933 LazyLock::new(|| BuiltinView {
7934 name: "mz_dataflow_shutdown_durations_histogram",
7935 schema: MZ_INTROSPECTION_SCHEMA,
7936 oid: oid::VIEW_MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_OID,
7937 desc: RelationDesc::builder()
7938 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7939 .with_column(
7940 "count",
7941 SqlScalarType::Numeric {
7942 max_scale: Some(NumericMaxScale::ZERO),
7943 }
7944 .nullable(false),
7945 )
7946 .with_key(vec![0])
7947 .finish(),
7948 column_comments: BTreeMap::from_iter([
7949 (
7950 "duration_ns",
7951 "The upper bound of the bucket in nanoseconds.",
7952 ),
7953 (
7954 "count",
7955 "The (noncumulative) count of dataflows in this bucket.",
7956 ),
7957 ]),
7958 sql: "
7959SELECT
7960 duration_ns,
7961 pg_catalog.sum(count) AS count
7962FROM mz_introspection.mz_dataflow_shutdown_durations_histogram_per_worker
7963GROUP BY duration_ns",
7964 access: vec![PUBLIC_SELECT],
7965 });
7966
7967pub static MZ_SCHEDULING_ELAPSED_PER_WORKER: LazyLock<BuiltinView> =
7968 LazyLock::new(|| BuiltinView {
7969 name: "mz_scheduling_elapsed_per_worker",
7970 schema: MZ_INTROSPECTION_SCHEMA,
7971 oid: oid::VIEW_MZ_SCHEDULING_ELAPSED_PER_WORKER_OID,
7972 desc: RelationDesc::builder()
7973 .with_column("id", SqlScalarType::UInt64.nullable(false))
7974 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
7975 .with_column("elapsed_ns", SqlScalarType::Int64.nullable(false))
7976 .with_key(vec![0, 1])
7977 .finish(),
7978 column_comments: BTreeMap::new(),
7979 sql: "SELECT
7980 id, worker_id, pg_catalog.count(*) AS elapsed_ns
7981FROM
7982 mz_introspection.mz_scheduling_elapsed_raw
7983GROUP BY
7984 id, worker_id",
7985 access: vec![PUBLIC_SELECT],
7986 });
7987
7988pub static MZ_SCHEDULING_ELAPSED: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7989 name: "mz_scheduling_elapsed",
7990 schema: MZ_INTROSPECTION_SCHEMA,
7991 oid: oid::VIEW_MZ_SCHEDULING_ELAPSED_OID,
7992 desc: RelationDesc::builder()
7993 .with_column("id", SqlScalarType::UInt64.nullable(false))
7994 .with_column(
7995 "elapsed_ns",
7996 SqlScalarType::Numeric {
7997 max_scale: Some(NumericMaxScale::ZERO),
7998 }
7999 .nullable(false),
8000 )
8001 .with_key(vec![0])
8002 .finish(),
8003 column_comments: BTreeMap::from_iter([
8004 (
8005 "id",
8006 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
8007 ),
8008 (
8009 "elapsed_ns",
8010 "The total elapsed time spent in the operator in nanoseconds.",
8011 ),
8012 ]),
8013 sql: "
8014SELECT
8015 id,
8016 pg_catalog.sum(elapsed_ns) AS elapsed_ns
8017FROM mz_introspection.mz_scheduling_elapsed_per_worker
8018GROUP BY id",
8019 access: vec![PUBLIC_SELECT],
8020});
8021
8022pub static MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
8023 LazyLock::new(|| BuiltinView {
8024 name: "mz_compute_operator_durations_histogram_per_worker",
8025 schema: MZ_INTROSPECTION_SCHEMA,
8026 oid: oid::VIEW_MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_PER_WORKER_OID,
8027 desc: RelationDesc::builder()
8028 .with_column("id", SqlScalarType::UInt64.nullable(false))
8029 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8030 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
8031 .with_column("count", SqlScalarType::Int64.nullable(false))
8032 .with_key(vec![0, 1, 2])
8033 .finish(),
8034 column_comments: BTreeMap::new(),
8035 sql: "SELECT
8036 id, worker_id, duration_ns, pg_catalog.count(*) AS count
8037FROM
8038 mz_introspection.mz_compute_operator_durations_histogram_raw
8039GROUP BY
8040 id, worker_id, duration_ns",
8041 access: vec![PUBLIC_SELECT],
8042 });
8043
8044pub static MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM: LazyLock<BuiltinView> =
8045 LazyLock::new(|| BuiltinView {
8046 name: "mz_compute_operator_durations_histogram",
8047 schema: MZ_INTROSPECTION_SCHEMA,
8048 oid: oid::VIEW_MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_OID,
8049 desc: RelationDesc::builder()
8050 .with_column("id", SqlScalarType::UInt64.nullable(false))
8051 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
8052 .with_column(
8053 "count",
8054 SqlScalarType::Numeric {
8055 max_scale: Some(NumericMaxScale::ZERO),
8056 }
8057 .nullable(false),
8058 )
8059 .with_key(vec![0, 1])
8060 .finish(),
8061 column_comments: BTreeMap::from_iter([
8062 (
8063 "id",
8064 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
8065 ),
8066 (
8067 "duration_ns",
8068 "The upper bound of the duration bucket in nanoseconds.",
8069 ),
8070 (
8071 "count",
8072 "The (noncumulative) count of invocations in the bucket.",
8073 ),
8074 ]),
8075 sql: "
8076SELECT
8077 id,
8078 duration_ns,
8079 pg_catalog.sum(count) AS count
8080FROM mz_introspection.mz_compute_operator_durations_histogram_per_worker
8081GROUP BY id, duration_ns",
8082 access: vec![PUBLIC_SELECT],
8083 });
8084
8085pub static MZ_SCHEDULING_PARKS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
8086 LazyLock::new(|| BuiltinView {
8087 name: "mz_scheduling_parks_histogram_per_worker",
8088 schema: MZ_INTROSPECTION_SCHEMA,
8089 oid: oid::VIEW_MZ_SCHEDULING_PARKS_HISTOGRAM_PER_WORKER_OID,
8090 desc: RelationDesc::builder()
8091 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8092 .with_column("slept_for_ns", SqlScalarType::UInt64.nullable(false))
8093 .with_column("requested_ns", SqlScalarType::UInt64.nullable(false))
8094 .with_column("count", SqlScalarType::Int64.nullable(false))
8095 .with_key(vec![0, 1, 2])
8096 .finish(),
8097 column_comments: BTreeMap::new(),
8098 sql: "SELECT
8099 worker_id, slept_for_ns, requested_ns, pg_catalog.count(*) AS count
8100FROM
8101 mz_introspection.mz_scheduling_parks_histogram_raw
8102GROUP BY
8103 worker_id, slept_for_ns, requested_ns",
8104 access: vec![PUBLIC_SELECT],
8105 });
8106
8107pub static MZ_SCHEDULING_PARKS_HISTOGRAM: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8108 name: "mz_scheduling_parks_histogram",
8109 schema: MZ_INTROSPECTION_SCHEMA,
8110 oid: oid::VIEW_MZ_SCHEDULING_PARKS_HISTOGRAM_OID,
8111 desc: RelationDesc::builder()
8112 .with_column("slept_for_ns", SqlScalarType::UInt64.nullable(false))
8113 .with_column("requested_ns", SqlScalarType::UInt64.nullable(false))
8114 .with_column(
8115 "count",
8116 SqlScalarType::Numeric {
8117 max_scale: Some(NumericMaxScale::ZERO),
8118 }
8119 .nullable(false),
8120 )
8121 .with_key(vec![0, 1])
8122 .finish(),
8123 column_comments: BTreeMap::from_iter([
8124 (
8125 "slept_for_ns",
8126 "The actual length of the park event in nanoseconds.",
8127 ),
8128 (
8129 "requested_ns",
8130 "The requested length of the park event in nanoseconds.",
8131 ),
8132 (
8133 "count",
8134 "The (noncumulative) count of park events in this bucket.",
8135 ),
8136 ]),
8137 sql: "
8138SELECT
8139 slept_for_ns,
8140 requested_ns,
8141 pg_catalog.sum(count) AS count
8142FROM mz_introspection.mz_scheduling_parks_histogram_per_worker
8143GROUP BY slept_for_ns, requested_ns",
8144 access: vec![PUBLIC_SELECT],
8145});
8146
8147pub static MZ_COMPUTE_ERROR_COUNTS_PER_WORKER: LazyLock<BuiltinView> =
8148 LazyLock::new(|| BuiltinView {
8149 name: "mz_compute_error_counts_per_worker",
8150 schema: MZ_INTROSPECTION_SCHEMA,
8151 oid: oid::VIEW_MZ_COMPUTE_ERROR_COUNTS_PER_WORKER_OID,
8152 desc: RelationDesc::builder()
8153 .with_column("export_id", SqlScalarType::String.nullable(false))
8154 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8155 .with_column("count", SqlScalarType::Int64.nullable(false))
8156 .with_key(vec![0, 1, 2])
8157 .finish(),
8158 column_comments: BTreeMap::new(),
8159 sql: "
8160WITH MUTUALLY RECURSIVE
8161 -- Indexes that reuse existing indexes rather than maintaining separate dataflows.
8162 -- For these we don't log error counts separately, so we need to forward the error counts from
8163 -- their dependencies instead.
8164 index_reuses(reuse_id text, index_id text) AS (
8165 SELECT d.object_id, d.dependency_id
8166 FROM mz_internal.mz_compute_dependencies d
8167 JOIN mz_introspection.mz_compute_exports e ON (e.export_id = d.object_id)
8168 WHERE NOT EXISTS (
8169 SELECT 1 FROM mz_introspection.mz_dataflows
8170 WHERE id = e.dataflow_id
8171 )
8172 ),
8173 -- Error counts that were directly logged on compute exports.
8174 direct_errors(export_id text, worker_id uint8, count int8) AS (
8175 SELECT export_id, worker_id, count
8176 FROM mz_introspection.mz_compute_error_counts_raw
8177 ),
8178 -- Error counts propagated to index reused.
8179 all_errors(export_id text, worker_id uint8, count int8) AS (
8180 SELECT * FROM direct_errors
8181 UNION
8182 SELECT r.reuse_id, e.worker_id, e.count
8183 FROM all_errors e
8184 JOIN index_reuses r ON (r.index_id = e.export_id)
8185 )
8186SELECT * FROM all_errors",
8187 access: vec![PUBLIC_SELECT],
8188 });
8189
8190pub static MZ_COMPUTE_ERROR_COUNTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8191 name: "mz_compute_error_counts",
8192 schema: MZ_INTROSPECTION_SCHEMA,
8193 oid: oid::VIEW_MZ_COMPUTE_ERROR_COUNTS_OID,
8194 desc: RelationDesc::builder()
8195 .with_column("export_id", SqlScalarType::String.nullable(false))
8196 .with_column(
8197 "count",
8198 SqlScalarType::Numeric {
8199 max_scale: Some(NumericMaxScale::ZERO),
8200 }
8201 .nullable(false),
8202 )
8203 .with_key(vec![0])
8204 .finish(),
8205 column_comments: BTreeMap::from_iter([
8206 (
8207 "export_id",
8208 "The ID of the dataflow export. Corresponds to `mz_compute_exports.export_id`.",
8209 ),
8210 (
8211 "count",
8212 "The count of errors present in this dataflow export.",
8213 ),
8214 ]),
8215 sql: "
8216SELECT
8217 export_id,
8218 pg_catalog.sum(count) AS count
8219FROM mz_introspection.mz_compute_error_counts_per_worker
8220GROUP BY export_id
8221HAVING pg_catalog.sum(count) != 0",
8222 access: vec![PUBLIC_SELECT],
8223});
8224
8225pub static MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED: LazyLock<BuiltinSource> =
8226 LazyLock::new(|| BuiltinSource {
8227 name: "mz_compute_error_counts_raw_unified",
8231 schema: MZ_INTERNAL_SCHEMA,
8232 oid: oid::SOURCE_MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED_OID,
8233 desc: RelationDesc::builder()
8234 .with_column("replica_id", SqlScalarType::String.nullable(false))
8235 .with_column("object_id", SqlScalarType::String.nullable(false))
8236 .with_column(
8237 "count",
8238 SqlScalarType::Numeric { max_scale: None }.nullable(false),
8239 )
8240 .finish(),
8241 data_source: IntrospectionType::ComputeErrorCounts,
8242 column_comments: BTreeMap::new(),
8243 is_retained_metrics_object: false,
8244 access: vec![PUBLIC_SELECT],
8245 });
8246
8247pub static MZ_COMPUTE_HYDRATION_TIMES: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
8248 name: "mz_compute_hydration_times",
8249 schema: MZ_INTERNAL_SCHEMA,
8250 oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_TIMES_OID,
8251 desc: RelationDesc::builder()
8252 .with_column("replica_id", SqlScalarType::String.nullable(false))
8253 .with_column("object_id", SqlScalarType::String.nullable(false))
8254 .with_column("time_ns", SqlScalarType::UInt64.nullable(true))
8255 .finish(),
8256 data_source: IntrospectionType::ComputeHydrationTimes,
8257 column_comments: BTreeMap::new(),
8258 is_retained_metrics_object: true,
8259 access: vec![PUBLIC_SELECT],
8260});
8261
8262pub static MZ_COMPUTE_HYDRATION_TIMES_IND: LazyLock<BuiltinIndex> =
8263 LazyLock::new(|| BuiltinIndex {
8264 name: "mz_compute_hydration_times_ind",
8265 schema: MZ_INTERNAL_SCHEMA,
8266 oid: oid::INDEX_MZ_COMPUTE_HYDRATION_TIMES_IND_OID,
8267 sql: "IN CLUSTER mz_catalog_server
8268 ON mz_internal.mz_compute_hydration_times (replica_id)",
8269 is_retained_metrics_object: true,
8270 });
8271
8272pub static MZ_COMPUTE_HYDRATION_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8273 name: "mz_compute_hydration_statuses",
8274 schema: MZ_INTERNAL_SCHEMA,
8275 oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_STATUSES_OID,
8276 desc: RelationDesc::builder()
8277 .with_column("object_id", SqlScalarType::String.nullable(false))
8278 .with_column("replica_id", SqlScalarType::String.nullable(false))
8279 .with_column("hydrated", SqlScalarType::Bool.nullable(false))
8280 .with_column("hydration_time", SqlScalarType::Interval.nullable(true))
8281 .finish(),
8282 column_comments: BTreeMap::from_iter([
8283 (
8284 "object_id",
8285 "The ID of a compute object. Corresponds to `mz_catalog.mz_indexes.id` or `mz_catalog.mz_materialized_views.id`",
8286 ),
8287 ("replica_id", "The ID of a cluster replica."),
8288 (
8289 "hydrated",
8290 "Whether the compute object is hydrated on the replica.",
8291 ),
8292 (
8293 "hydration_time",
8294 "The amount of time it took for the replica to hydrate the compute object.",
8295 ),
8296 ]),
8297 sql: "
8298WITH
8299 dataflows AS (
8300 SELECT
8301 object_id,
8302 replica_id,
8303 time_ns IS NOT NULL AS hydrated,
8304 ((time_ns / 1000) || 'microseconds')::interval AS hydration_time
8305 FROM mz_internal.mz_compute_hydration_times
8306 ),
8307 -- MVs that have advanced to the empty frontier don't have a dataflow installed anymore and
8308 -- therefore don't show up in `mz_compute_hydration_times`. We still want to show them here to
8309 -- avoid surprises for people joining `mz_materialized_views` against this relation (like the
8310 -- blue-green readiness query does), so we include them as 'hydrated'.
8311 complete_mvs AS (
8312 SELECT
8313 mv.id,
8314 f.replica_id,
8315 true AS hydrated,
8316 NULL::interval AS hydration_time
8317 FROM mz_materialized_views mv
8318 JOIN mz_catalog.mz_cluster_replica_frontiers f ON f.object_id = mv.id
8319 WHERE f.write_frontier IS NULL
8320 ),
8321 -- Ditto CTs
8322 complete_cts AS (
8323 SELECT
8324 ct.id,
8325 f.replica_id,
8326 true AS hydrated,
8327 NULL::interval AS hydration_time
8328 FROM mz_internal.mz_continual_tasks ct
8329 JOIN mz_catalog.mz_cluster_replica_frontiers f ON f.object_id = ct.id
8330 WHERE f.write_frontier IS NULL
8331 )
8332SELECT * FROM dataflows
8333UNION ALL
8334SELECT * FROM complete_mvs
8335UNION ALL
8336SELECT * FROM complete_cts",
8337 access: vec![PUBLIC_SELECT],
8338});
8339
8340pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES: LazyLock<BuiltinSource> = LazyLock::new(|| {
8341 BuiltinSource {
8342 name: "mz_compute_operator_hydration_statuses",
8343 schema: MZ_INTERNAL_SCHEMA,
8344 oid: oid::SOURCE_MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_OID,
8345 desc: RelationDesc::builder()
8346 .with_column("replica_id", SqlScalarType::String.nullable(false))
8347 .with_column("object_id", SqlScalarType::String.nullable(false))
8348 .with_column(
8349 "physical_plan_node_id",
8350 SqlScalarType::UInt64.nullable(false),
8351 )
8352 .with_column("hydrated", SqlScalarType::Bool.nullable(false))
8353 .with_key(vec![0, 1, 2])
8354 .finish(),
8355 data_source: IntrospectionType::ComputeOperatorHydrationStatus,
8356 column_comments: BTreeMap::from_iter([
8357 ("replica_id", "The ID of a cluster replica."),
8358 (
8359 "object_id",
8360 "The ID of a compute object. Corresponds to `mz_catalog.mz_indexes.id` or `mz_catalog.mz_materialized_views.id`.",
8361 ),
8362 (
8363 "physical_plan_node_id",
8364 "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)`.",
8365 ),
8366 ("hydrated", "Whether the node is hydrated on the replica."),
8367 ]),
8368 is_retained_metrics_object: false,
8369 access: vec![PUBLIC_SELECT],
8370 }
8371});
8372
8373pub static MZ_MESSAGE_COUNTS_PER_WORKER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8374 name: "mz_message_counts_per_worker",
8375 schema: MZ_INTROSPECTION_SCHEMA,
8376 oid: oid::VIEW_MZ_MESSAGE_COUNTS_PER_WORKER_OID,
8377 desc: RelationDesc::builder()
8378 .with_column("channel_id", SqlScalarType::UInt64.nullable(false))
8379 .with_column("from_worker_id", SqlScalarType::UInt64.nullable(false))
8380 .with_column("to_worker_id", SqlScalarType::UInt64.nullable(false))
8381 .with_column("sent", SqlScalarType::Int64.nullable(false))
8382 .with_column("received", SqlScalarType::Int64.nullable(false))
8383 .with_column("batch_sent", SqlScalarType::Int64.nullable(false))
8384 .with_column("batch_received", SqlScalarType::Int64.nullable(false))
8385 .with_key(vec![0, 1, 2])
8386 .finish(),
8387 column_comments: BTreeMap::new(),
8388 sql: "
8389WITH batch_sent_cte AS (
8390 SELECT
8391 channel_id,
8392 from_worker_id,
8393 to_worker_id,
8394 pg_catalog.count(*) AS sent
8395 FROM
8396 mz_introspection.mz_message_batch_counts_sent_raw
8397 GROUP BY
8398 channel_id, from_worker_id, to_worker_id
8399),
8400batch_received_cte AS (
8401 SELECT
8402 channel_id,
8403 from_worker_id,
8404 to_worker_id,
8405 pg_catalog.count(*) AS received
8406 FROM
8407 mz_introspection.mz_message_batch_counts_received_raw
8408 GROUP BY
8409 channel_id, from_worker_id, to_worker_id
8410),
8411sent_cte AS (
8412 SELECT
8413 channel_id,
8414 from_worker_id,
8415 to_worker_id,
8416 pg_catalog.count(*) AS sent
8417 FROM
8418 mz_introspection.mz_message_counts_sent_raw
8419 GROUP BY
8420 channel_id, from_worker_id, to_worker_id
8421),
8422received_cte AS (
8423 SELECT
8424 channel_id,
8425 from_worker_id,
8426 to_worker_id,
8427 pg_catalog.count(*) AS received
8428 FROM
8429 mz_introspection.mz_message_counts_received_raw
8430 GROUP BY
8431 channel_id, from_worker_id, to_worker_id
8432)
8433SELECT
8434 sent_cte.channel_id,
8435 sent_cte.from_worker_id,
8436 sent_cte.to_worker_id,
8437 sent_cte.sent,
8438 received_cte.received,
8439 batch_sent_cte.sent AS batch_sent,
8440 batch_received_cte.received AS batch_received
8441FROM sent_cte
8442JOIN received_cte USING (channel_id, from_worker_id, to_worker_id)
8443JOIN batch_sent_cte USING (channel_id, from_worker_id, to_worker_id)
8444JOIN batch_received_cte USING (channel_id, from_worker_id, to_worker_id)",
8445 access: vec![PUBLIC_SELECT],
8446});
8447
8448pub static MZ_MESSAGE_COUNTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8449 name: "mz_message_counts",
8450 schema: MZ_INTROSPECTION_SCHEMA,
8451 oid: oid::VIEW_MZ_MESSAGE_COUNTS_OID,
8452 desc: RelationDesc::builder()
8453 .with_column("channel_id", SqlScalarType::UInt64.nullable(false))
8454 .with_column(
8455 "sent",
8456 SqlScalarType::Numeric {
8457 max_scale: Some(NumericMaxScale::ZERO),
8458 }
8459 .nullable(false),
8460 )
8461 .with_column(
8462 "received",
8463 SqlScalarType::Numeric {
8464 max_scale: Some(NumericMaxScale::ZERO),
8465 }
8466 .nullable(false),
8467 )
8468 .with_column(
8469 "batch_sent",
8470 SqlScalarType::Numeric {
8471 max_scale: Some(NumericMaxScale::ZERO),
8472 }
8473 .nullable(false),
8474 )
8475 .with_column(
8476 "batch_received",
8477 SqlScalarType::Numeric {
8478 max_scale: Some(NumericMaxScale::ZERO),
8479 }
8480 .nullable(false),
8481 )
8482 .with_key(vec![0])
8483 .finish(),
8484 column_comments: BTreeMap::from_iter([
8485 (
8486 "channel_id",
8487 "The ID of the channel. Corresponds to `mz_dataflow_channels.id`.",
8488 ),
8489 ("sent", "The number of messages sent."),
8490 ("received", "The number of messages received."),
8491 ("batch_sent", "The number of batches sent."),
8492 ("batch_received", "The number of batches received."),
8493 ]),
8494 sql: "
8495SELECT
8496 channel_id,
8497 pg_catalog.sum(sent) AS sent,
8498 pg_catalog.sum(received) AS received,
8499 pg_catalog.sum(batch_sent) AS batch_sent,
8500 pg_catalog.sum(batch_received) AS batch_received
8501FROM mz_introspection.mz_message_counts_per_worker
8502GROUP BY channel_id",
8503 access: vec![PUBLIC_SELECT],
8504});
8505
8506pub static MZ_ACTIVE_PEEKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8507 name: "mz_active_peeks",
8508 schema: MZ_INTROSPECTION_SCHEMA,
8509 oid: oid::VIEW_MZ_ACTIVE_PEEKS_OID,
8510 desc: RelationDesc::builder()
8511 .with_column("id", SqlScalarType::Uuid.nullable(false))
8512 .with_column("object_id", SqlScalarType::String.nullable(false))
8513 .with_column("type", SqlScalarType::String.nullable(false))
8514 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
8515 .finish(),
8516 column_comments: BTreeMap::from_iter([
8517 ("id", "The ID of the peek request."),
8518 (
8519 "object_id",
8520 "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`.",
8521 ),
8522 (
8523 "type",
8524 "The type of the corresponding peek: `index` if targeting an index or temporary dataflow; `persist` for a source, materialized view, or table.",
8525 ),
8526 ("time", "The timestamp the peek has requested."),
8527 ]),
8528 sql: "
8529SELECT id, object_id, type, time
8530FROM mz_introspection.mz_active_peeks_per_worker
8531WHERE worker_id = 0",
8532 access: vec![PUBLIC_SELECT],
8533});
8534
8535pub static MZ_DATAFLOW_OPERATOR_REACHABILITY_PER_WORKER: LazyLock<BuiltinView> =
8536 LazyLock::new(|| BuiltinView {
8537 name: "mz_dataflow_operator_reachability_per_worker",
8538 schema: MZ_INTROSPECTION_SCHEMA,
8539 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_REACHABILITY_PER_WORKER_OID,
8540 desc: RelationDesc::builder()
8541 .with_column("id", SqlScalarType::UInt64.nullable(false))
8542 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8543 .with_column("port", SqlScalarType::UInt64.nullable(false))
8544 .with_column("update_type", SqlScalarType::String.nullable(false))
8545 .with_column("time", SqlScalarType::MzTimestamp.nullable(true))
8546 .with_column("count", SqlScalarType::Int64.nullable(false))
8547 .with_key(vec![0, 1, 2, 3, 4])
8548 .finish(),
8549 column_comments: BTreeMap::new(),
8550 sql: "SELECT
8551 addr2.id,
8552 reachability.worker_id,
8553 port,
8554 update_type,
8555 time,
8556 pg_catalog.count(*) as count
8557FROM
8558 mz_introspection.mz_dataflow_operator_reachability_raw reachability,
8559 mz_introspection.mz_dataflow_addresses_per_worker addr1,
8560 mz_introspection.mz_dataflow_addresses_per_worker addr2
8561WHERE
8562 addr2.address =
8563 CASE
8564 WHEN source = 0 THEN addr1.address
8565 ELSE addr1.address || reachability.source
8566 END
8567 AND addr1.id = reachability.id
8568 AND addr1.worker_id = reachability.worker_id
8569 AND addr2.worker_id = reachability.worker_id
8570GROUP BY addr2.id, reachability.worker_id, port, update_type, time",
8571 access: vec![PUBLIC_SELECT],
8572 });
8573
8574pub static MZ_DATAFLOW_OPERATOR_REACHABILITY: LazyLock<BuiltinView> =
8575 LazyLock::new(|| BuiltinView {
8576 name: "mz_dataflow_operator_reachability",
8577 schema: MZ_INTROSPECTION_SCHEMA,
8578 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_REACHABILITY_OID,
8579 desc: RelationDesc::builder()
8580 .with_column("id", SqlScalarType::UInt64.nullable(false))
8581 .with_column("port", SqlScalarType::UInt64.nullable(false))
8582 .with_column("update_type", SqlScalarType::String.nullable(false))
8583 .with_column("time", SqlScalarType::MzTimestamp.nullable(true))
8584 .with_column(
8585 "count",
8586 SqlScalarType::Numeric {
8587 max_scale: Some(NumericMaxScale::ZERO),
8588 }
8589 .nullable(false),
8590 )
8591 .with_key(vec![0, 1, 2, 3])
8592 .finish(),
8593 column_comments: BTreeMap::new(),
8594 sql: "
8595SELECT
8596 id,
8597 port,
8598 update_type,
8599 time,
8600 pg_catalog.sum(count) as count
8601FROM mz_introspection.mz_dataflow_operator_reachability_per_worker
8602GROUP BY id, port, update_type, time",
8603 access: vec![PUBLIC_SELECT],
8604 });
8605
8606pub static MZ_ARRANGEMENT_SIZES_PER_WORKER: LazyLock<BuiltinView> = LazyLock::new(|| {
8607 BuiltinView {
8608 name: "mz_arrangement_sizes_per_worker",
8609 schema: MZ_INTROSPECTION_SCHEMA,
8610 oid: oid::VIEW_MZ_ARRANGEMENT_SIZES_PER_WORKER_OID,
8611 desc: RelationDesc::builder()
8612 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8613 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8614 .with_column("records", SqlScalarType::Int64.nullable(true))
8615 .with_column("batches", SqlScalarType::Int64.nullable(true))
8616 .with_column("size", SqlScalarType::Int64.nullable(true))
8617 .with_column("capacity", SqlScalarType::Int64.nullable(true))
8618 .with_column("allocations", SqlScalarType::Int64.nullable(true))
8619 .finish(),
8620 column_comments: BTreeMap::new(),
8621 sql: "
8622WITH operators_per_worker_cte AS (
8623 SELECT
8624 id AS operator_id,
8625 worker_id
8626 FROM
8627 mz_introspection.mz_dataflow_operators_per_worker
8628),
8629batches_cte AS (
8630 SELECT
8631 operator_id,
8632 worker_id,
8633 COUNT(*) AS batches
8634 FROM
8635 mz_introspection.mz_arrangement_batches_raw
8636 GROUP BY
8637 operator_id, worker_id
8638),
8639records_cte AS (
8640 SELECT
8641 operator_id,
8642 worker_id,
8643 COUNT(*) AS records
8644 FROM
8645 mz_introspection.mz_arrangement_records_raw
8646 GROUP BY
8647 operator_id, worker_id
8648),
8649heap_size_cte AS (
8650 SELECT
8651 operator_id,
8652 worker_id,
8653 COUNT(*) AS size
8654 FROM
8655 mz_introspection.mz_arrangement_heap_size_raw
8656 GROUP BY
8657 operator_id, worker_id
8658),
8659heap_capacity_cte AS (
8660 SELECT
8661 operator_id,
8662 worker_id,
8663 COUNT(*) AS capacity
8664 FROM
8665 mz_introspection.mz_arrangement_heap_capacity_raw
8666 GROUP BY
8667 operator_id, worker_id
8668),
8669heap_allocations_cte AS (
8670 SELECT
8671 operator_id,
8672 worker_id,
8673 COUNT(*) AS allocations
8674 FROM
8675 mz_introspection.mz_arrangement_heap_allocations_raw
8676 GROUP BY
8677 operator_id, worker_id
8678),
8679batcher_records_cte AS (
8680 SELECT
8681 operator_id,
8682 worker_id,
8683 COUNT(*) AS records
8684 FROM
8685 mz_introspection.mz_arrangement_batcher_records_raw
8686 GROUP BY
8687 operator_id, worker_id
8688),
8689batcher_size_cte AS (
8690 SELECT
8691 operator_id,
8692 worker_id,
8693 COUNT(*) AS size
8694 FROM
8695 mz_introspection.mz_arrangement_batcher_size_raw
8696 GROUP BY
8697 operator_id, worker_id
8698),
8699batcher_capacity_cte AS (
8700 SELECT
8701 operator_id,
8702 worker_id,
8703 COUNT(*) AS capacity
8704 FROM
8705 mz_introspection.mz_arrangement_batcher_capacity_raw
8706 GROUP BY
8707 operator_id, worker_id
8708),
8709batcher_allocations_cte AS (
8710 SELECT
8711 operator_id,
8712 worker_id,
8713 COUNT(*) AS allocations
8714 FROM
8715 mz_introspection.mz_arrangement_batcher_allocations_raw
8716 GROUP BY
8717 operator_id, worker_id
8718),
8719combined AS (
8720 SELECT
8721 opw.operator_id,
8722 opw.worker_id,
8723 CASE
8724 WHEN records_cte.records IS NULL AND batcher_records_cte.records IS NULL THEN NULL
8725 ELSE COALESCE(records_cte.records, 0) + COALESCE(batcher_records_cte.records, 0)
8726 END AS records,
8727 batches_cte.batches AS batches,
8728 CASE
8729 WHEN heap_size_cte.size IS NULL AND batcher_size_cte.size IS NULL THEN NULL
8730 ELSE COALESCE(heap_size_cte.size, 0) + COALESCE(batcher_size_cte.size, 0)
8731 END AS size,
8732 CASE
8733 WHEN heap_capacity_cte.capacity IS NULL AND batcher_capacity_cte.capacity IS NULL THEN NULL
8734 ELSE COALESCE(heap_capacity_cte.capacity, 0) + COALESCE(batcher_capacity_cte.capacity, 0)
8735 END AS capacity,
8736 CASE
8737 WHEN heap_allocations_cte.allocations IS NULL AND batcher_allocations_cte.allocations IS NULL THEN NULL
8738 ELSE COALESCE(heap_allocations_cte.allocations, 0) + COALESCE(batcher_allocations_cte.allocations, 0)
8739 END AS allocations
8740 FROM
8741 operators_per_worker_cte opw
8742 LEFT OUTER JOIN batches_cte USING (operator_id, worker_id)
8743 LEFT OUTER JOIN records_cte USING (operator_id, worker_id)
8744 LEFT OUTER JOIN heap_size_cte USING (operator_id, worker_id)
8745 LEFT OUTER JOIN heap_capacity_cte USING (operator_id, worker_id)
8746 LEFT OUTER JOIN heap_allocations_cte USING (operator_id, worker_id)
8747 LEFT OUTER JOIN batcher_records_cte USING (operator_id, worker_id)
8748 LEFT OUTER JOIN batcher_size_cte USING (operator_id, worker_id)
8749 LEFT OUTER JOIN batcher_capacity_cte USING (operator_id, worker_id)
8750 LEFT OUTER JOIN batcher_allocations_cte USING (operator_id, worker_id)
8751)
8752SELECT
8753 operator_id, worker_id, records, batches, size, capacity, allocations
8754FROM combined
8755WHERE
8756 records IS NOT NULL
8757 OR batches IS NOT NULL
8758 OR size IS NOT NULL
8759 OR capacity IS NOT NULL
8760 OR allocations IS NOT NULL
8761",
8762 access: vec![PUBLIC_SELECT],
8763 }
8764});
8765
8766pub static MZ_ARRANGEMENT_SIZES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8767 name: "mz_arrangement_sizes",
8768 schema: MZ_INTROSPECTION_SCHEMA,
8769 oid: oid::VIEW_MZ_ARRANGEMENT_SIZES_OID,
8770 desc: RelationDesc::builder()
8771 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8772 .with_column("records", SqlScalarType::Int64.nullable(true))
8773 .with_column("batches", SqlScalarType::Int64.nullable(true))
8774 .with_column("size", SqlScalarType::Int64.nullable(true))
8775 .with_column("capacity", SqlScalarType::Int64.nullable(true))
8776 .with_column("allocations", SqlScalarType::Int64.nullable(true))
8777 .with_key(vec![0])
8778 .finish(),
8779 column_comments: BTreeMap::from_iter([
8780 (
8781 "operator_id",
8782 "The ID of the operator that created the arrangement. Corresponds to `mz_dataflow_operators.id`.",
8783 ),
8784 ("records", "The number of records in the arrangement."),
8785 ("batches", "The number of batches in the arrangement."),
8786 ("size", "The utilized size in bytes of the arrangement."),
8787 (
8788 "capacity",
8789 "The capacity in bytes of the arrangement. Can be larger than the size.",
8790 ),
8791 (
8792 "allocations",
8793 "The number of separate memory allocations backing the arrangement.",
8794 ),
8795 ]),
8796 sql: "
8797SELECT
8798 operator_id,
8799 SUM(records)::int8 AS records,
8800 SUM(batches)::int8 AS batches,
8801 SUM(size)::int8 AS size,
8802 SUM(capacity)::int8 AS capacity,
8803 SUM(allocations)::int8 AS allocations
8804FROM mz_introspection.mz_arrangement_sizes_per_worker
8805GROUP BY operator_id",
8806 access: vec![PUBLIC_SELECT],
8807});
8808
8809pub static MZ_ARRANGEMENT_SHARING_PER_WORKER: LazyLock<BuiltinView> =
8810 LazyLock::new(|| BuiltinView {
8811 name: "mz_arrangement_sharing_per_worker",
8812 schema: MZ_INTROSPECTION_SCHEMA,
8813 oid: oid::VIEW_MZ_ARRANGEMENT_SHARING_PER_WORKER_OID,
8814 desc: RelationDesc::builder()
8815 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8816 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8817 .with_column("count", SqlScalarType::Int64.nullable(false))
8818 .with_key(vec![0, 1])
8819 .finish(),
8820 column_comments: BTreeMap::new(),
8821 sql: "
8822SELECT
8823 operator_id,
8824 worker_id,
8825 pg_catalog.count(*) AS count
8826FROM mz_introspection.mz_arrangement_sharing_raw
8827GROUP BY operator_id, worker_id",
8828 access: vec![PUBLIC_SELECT],
8829 });
8830
8831pub static MZ_ARRANGEMENT_SHARING: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8832 name: "mz_arrangement_sharing",
8833 schema: MZ_INTROSPECTION_SCHEMA,
8834 oid: oid::VIEW_MZ_ARRANGEMENT_SHARING_OID,
8835 desc: RelationDesc::builder()
8836 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8837 .with_column("count", SqlScalarType::Int64.nullable(false))
8838 .finish(),
8839 column_comments: BTreeMap::from_iter([
8840 (
8841 "operator_id",
8842 "The ID of the operator that created the arrangement. Corresponds to `mz_dataflow_operators.id`.",
8843 ),
8844 (
8845 "count",
8846 "The number of operators that share the arrangement.",
8847 ),
8848 ]),
8849 sql: "
8850SELECT operator_id, count
8851FROM mz_introspection.mz_arrangement_sharing_per_worker
8852WHERE worker_id = 0",
8853 access: vec![PUBLIC_SELECT],
8854});
8855
8856pub static MZ_CLUSTER_REPLICA_UTILIZATION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8857 name: "mz_cluster_replica_utilization",
8858 schema: MZ_INTERNAL_SCHEMA,
8859 oid: oid::VIEW_MZ_CLUSTER_REPLICA_UTILIZATION_OID,
8860 desc: RelationDesc::builder()
8861 .with_column("replica_id", SqlScalarType::String.nullable(false))
8862 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
8863 .with_column("cpu_percent", SqlScalarType::Float64.nullable(true))
8864 .with_column("memory_percent", SqlScalarType::Float64.nullable(true))
8865 .with_column("disk_percent", SqlScalarType::Float64.nullable(true))
8866 .finish(),
8867 column_comments: BTreeMap::from_iter([
8868 ("replica_id", "The ID of a cluster replica."),
8869 ("process_id", "The ID of a process within the replica."),
8870 (
8871 "cpu_percent",
8872 "Approximate CPU usage in percent of the total allocation.",
8873 ),
8874 (
8875 "memory_percent",
8876 "Approximate RAM usage in percent of the total allocation.",
8877 ),
8878 (
8879 "disk_percent",
8880 "Approximate disk usage in percent of the total allocation.",
8881 ),
8882 ]),
8883 sql: "
8884SELECT
8885 r.id AS replica_id,
8886 m.process_id,
8887 m.cpu_nano_cores::float8 / NULLIF(s.cpu_nano_cores, 0) * 100 AS cpu_percent,
8888 m.memory_bytes::float8 / NULLIF(s.memory_bytes, 0) * 100 AS memory_percent,
8889 m.disk_bytes::float8 / NULLIF(s.disk_bytes, 0) * 100 AS disk_percent
8890FROM
8891 mz_catalog.mz_cluster_replicas AS r
8892 JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size
8893 JOIN mz_internal.mz_cluster_replica_metrics AS m ON m.replica_id = r.id",
8894 access: vec![PUBLIC_SELECT],
8895});
8896
8897pub static MZ_CLUSTER_REPLICA_UTILIZATION_HISTORY: LazyLock<BuiltinView> =
8898 LazyLock::new(|| BuiltinView {
8899 name: "mz_cluster_replica_utilization_history",
8900 schema: MZ_INTERNAL_SCHEMA,
8901 oid: oid::VIEW_MZ_CLUSTER_REPLICA_UTILIZATION_HISTORY_OID,
8902 desc: RelationDesc::builder()
8903 .with_column("replica_id", SqlScalarType::String.nullable(false))
8904 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
8905 .with_column("cpu_percent", SqlScalarType::Float64.nullable(true))
8906 .with_column("memory_percent", SqlScalarType::Float64.nullable(true))
8907 .with_column("disk_percent", SqlScalarType::Float64.nullable(true))
8908 .with_column(
8909 "occurred_at",
8910 SqlScalarType::TimestampTz { precision: None }.nullable(false),
8911 )
8912 .finish(),
8913 column_comments: BTreeMap::from_iter([
8914 ("replica_id", "The ID of a cluster replica."),
8915 ("process_id", "The ID of a process within the replica."),
8916 (
8917 "cpu_percent",
8918 "Approximate CPU usage in percent of the total allocation.",
8919 ),
8920 (
8921 "memory_percent",
8922 "Approximate RAM usage in percent of the total allocation.",
8923 ),
8924 (
8925 "disk_percent",
8926 "Approximate disk usage in percent of the total allocation.",
8927 ),
8928 (
8929 "occurred_at",
8930 "Wall-clock timestamp at which the event occurred.",
8931 ),
8932 ]),
8933 sql: "
8934SELECT
8935 r.id AS replica_id,
8936 m.process_id,
8937 m.cpu_nano_cores::float8 / NULLIF(s.cpu_nano_cores, 0) * 100 AS cpu_percent,
8938 m.memory_bytes::float8 / NULLIF(s.memory_bytes, 0) * 100 AS memory_percent,
8939 m.disk_bytes::float8 / NULLIF(s.disk_bytes, 0) * 100 AS disk_percent,
8940 m.occurred_at
8941FROM
8942 mz_catalog.mz_cluster_replicas AS r
8943 JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size
8944 JOIN mz_internal.mz_cluster_replica_metrics_history AS m ON m.replica_id = r.id",
8945 access: vec![PUBLIC_SELECT],
8946 });
8947
8948pub static MZ_DATAFLOW_OPERATOR_PARENTS_PER_WORKER: LazyLock<BuiltinView> =
8949 LazyLock::new(|| BuiltinView {
8950 name: "mz_dataflow_operator_parents_per_worker",
8951 schema: MZ_INTROSPECTION_SCHEMA,
8952 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_PARENTS_PER_WORKER_OID,
8953 desc: RelationDesc::builder()
8954 .with_column("id", SqlScalarType::UInt64.nullable(false))
8955 .with_column("parent_id", SqlScalarType::UInt64.nullable(false))
8956 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8957 .finish(),
8958 column_comments: BTreeMap::new(),
8959 sql: "
8960WITH operator_addrs AS(
8961 SELECT
8962 id, address, worker_id
8963 FROM mz_introspection.mz_dataflow_addresses_per_worker
8964 INNER JOIN mz_introspection.mz_dataflow_operators_per_worker
8965 USING (id, worker_id)
8966),
8967parent_addrs AS (
8968 SELECT
8969 id,
8970 address[1:list_length(address) - 1] AS parent_address,
8971 worker_id
8972 FROM operator_addrs
8973)
8974SELECT pa.id, oa.id AS parent_id, pa.worker_id
8975FROM parent_addrs AS pa
8976 INNER JOIN operator_addrs AS oa
8977 ON pa.parent_address = oa.address
8978 AND pa.worker_id = oa.worker_id",
8979 access: vec![PUBLIC_SELECT],
8980 });
8981
8982pub static MZ_DATAFLOW_OPERATOR_PARENTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8983 name: "mz_dataflow_operator_parents",
8984 schema: MZ_INTROSPECTION_SCHEMA,
8985 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_PARENTS_OID,
8986 desc: RelationDesc::builder()
8987 .with_column("id", SqlScalarType::UInt64.nullable(false))
8988 .with_column("parent_id", SqlScalarType::UInt64.nullable(false))
8989 .finish(),
8990 column_comments: BTreeMap::from_iter([
8991 (
8992 "id",
8993 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
8994 ),
8995 (
8996 "parent_id",
8997 "The ID of the operator's parent operator. Corresponds to `mz_dataflow_operators.id`.",
8998 ),
8999 ]),
9000 sql: "
9001SELECT id, parent_id
9002FROM mz_introspection.mz_dataflow_operator_parents_per_worker
9003WHERE worker_id = 0",
9004 access: vec![PUBLIC_SELECT],
9005});
9006
9007pub static MZ_DATAFLOW_ARRANGEMENT_SIZES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9008 name: "mz_dataflow_arrangement_sizes",
9009 schema: MZ_INTROSPECTION_SCHEMA,
9010 oid: oid::VIEW_MZ_DATAFLOW_ARRANGEMENT_SIZES_OID,
9011 desc: RelationDesc::builder()
9012 .with_column("id", SqlScalarType::UInt64.nullable(false))
9013 .with_column("name", SqlScalarType::String.nullable(false))
9014 .with_column("records", SqlScalarType::Int64.nullable(true))
9015 .with_column("batches", SqlScalarType::Int64.nullable(true))
9016 .with_column("size", SqlScalarType::Int64.nullable(true))
9017 .with_column("capacity", SqlScalarType::Int64.nullable(true))
9018 .with_column("allocations", SqlScalarType::Int64.nullable(true))
9019 .with_key(vec![0, 1])
9020 .finish(),
9021 column_comments: BTreeMap::from_iter([
9022 (
9023 "id",
9024 "The ID of the [dataflow]. Corresponds to `mz_dataflows.id`.",
9025 ),
9026 ("name", "The name of the [dataflow]."),
9027 (
9028 "records",
9029 "The number of records in all arrangements in the dataflow.",
9030 ),
9031 (
9032 "batches",
9033 "The number of batches in all arrangements in the dataflow.",
9034 ),
9035 ("size", "The utilized size in bytes of the arrangements."),
9036 (
9037 "capacity",
9038 "The capacity in bytes of the arrangements. Can be larger than the size.",
9039 ),
9040 (
9041 "allocations",
9042 "The number of separate memory allocations backing the arrangements.",
9043 ),
9044 ]),
9045 sql: "
9046SELECT
9047 mdod.dataflow_id AS id,
9048 mdod.dataflow_name AS name,
9049 SUM(mas.records)::int8 AS records,
9050 SUM(mas.batches)::int8 AS batches,
9051 SUM(mas.size)::int8 AS size,
9052 SUM(mas.capacity)::int8 AS capacity,
9053 SUM(mas.allocations)::int8 AS allocations
9054FROM mz_introspection.mz_dataflow_operator_dataflows AS mdod
9055LEFT JOIN mz_introspection.mz_arrangement_sizes AS mas
9056 ON mdod.id = mas.operator_id
9057GROUP BY mdod.dataflow_id, mdod.dataflow_name",
9058 access: vec![PUBLIC_SELECT],
9059});
9060
9061pub static MZ_EXPECTED_GROUP_SIZE_ADVICE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9062 name: "mz_expected_group_size_advice",
9063 schema: MZ_INTROSPECTION_SCHEMA,
9064 oid: oid::VIEW_MZ_EXPECTED_GROUP_SIZE_ADVICE_OID,
9065 desc: RelationDesc::builder()
9066 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
9067 .with_column("dataflow_name", SqlScalarType::String.nullable(false))
9068 .with_column("region_id", SqlScalarType::UInt64.nullable(false))
9069 .with_column("region_name", SqlScalarType::String.nullable(false))
9070 .with_column("levels", SqlScalarType::Int64.nullable(false))
9071 .with_column("to_cut", SqlScalarType::Int64.nullable(false))
9072 .with_column(
9073 "savings",
9074 SqlScalarType::Numeric {
9075 max_scale: Some(NumericMaxScale::ZERO),
9076 }
9077 .nullable(true),
9078 )
9079 .with_column("hint", SqlScalarType::Float64.nullable(false))
9080 .finish(),
9081 column_comments: BTreeMap::from_iter([
9082 (
9083 "dataflow_id",
9084 "The ID of the [dataflow]. Corresponds to `mz_dataflows.id`.",
9085 ),
9086 (
9087 "dataflow_name",
9088 "The internal name of the dataflow hosting the min/max aggregation or Top K.",
9089 ),
9090 (
9091 "region_id",
9092 "The ID of the root operator scope. Corresponds to `mz_dataflow_operators.id`.",
9093 ),
9094 (
9095 "region_name",
9096 "The internal name of the root operator scope for the min/max aggregation or Top K.",
9097 ),
9098 (
9099 "levels",
9100 "The number of levels in the hierarchical scheme implemented by the region.",
9101 ),
9102 (
9103 "to_cut",
9104 "The number of levels that can be eliminated (cut) from the region's hierarchy.",
9105 ),
9106 (
9107 "savings",
9108 "A conservative estimate of the amount of memory in bytes to be saved by applying the hint.",
9109 ),
9110 (
9111 "hint",
9112 "The hint value that will eliminate `to_cut` levels from the region's hierarchy.",
9113 ),
9114 ]),
9115 sql: "
9116 -- The mz_expected_group_size_advice view provides tuning suggestions for the GROUP SIZE
9117 -- query hints. This tuning hint is effective for min/max/top-k patterns, where a stack
9118 -- of arrangements must be built. For each dataflow and region corresponding to one
9119 -- such pattern, we look for how many levels can be eliminated without hitting a level
9120 -- that actually substantially filters the input. The advice is constructed so that
9121 -- setting the hint for the affected region will eliminate these redundant levels of
9122 -- the hierarchical rendering.
9123 --
9124 -- A number of helper CTEs are used for the view definition. The first one, operators,
9125 -- looks for operator names that comprise arrangements of inputs to each level of a
9126 -- min/max/top-k hierarchy.
9127 WITH operators AS (
9128 SELECT
9129 dod.dataflow_id,
9130 dor.id AS region_id,
9131 dod.id,
9132 ars.records,
9133 ars.size
9134 FROM
9135 mz_introspection.mz_dataflow_operator_dataflows dod
9136 JOIN mz_introspection.mz_dataflow_addresses doa
9137 ON dod.id = doa.id
9138 JOIN mz_introspection.mz_dataflow_addresses dra
9139 ON dra.address = doa.address[:list_length(doa.address) - 1]
9140 JOIN mz_introspection.mz_dataflow_operators dor
9141 ON dor.id = dra.id
9142 JOIN mz_introspection.mz_arrangement_sizes ars
9143 ON ars.operator_id = dod.id
9144 WHERE
9145 dod.name = 'Arranged TopK input'
9146 OR dod.name = 'Arranged MinsMaxesHierarchical input'
9147 OR dod.name = 'Arrange ReduceMinsMaxes'
9148 ),
9149 -- The second CTE, levels, simply computes the heights of the min/max/top-k hierarchies
9150 -- identified in operators above.
9151 levels AS (
9152 SELECT o.dataflow_id, o.region_id, COUNT(*) AS levels
9153 FROM operators o
9154 GROUP BY o.dataflow_id, o.region_id
9155 ),
9156 -- The third CTE, pivot, determines for each min/max/top-k hierarchy, the first input
9157 -- operator. This operator is crucially important, as it records the number of records
9158 -- that was given as input to the gadget as a whole.
9159 pivot AS (
9160 SELECT
9161 o1.dataflow_id,
9162 o1.region_id,
9163 o1.id,
9164 o1.records
9165 FROM operators o1
9166 WHERE
9167 o1.id = (
9168 SELECT MIN(o2.id)
9169 FROM operators o2
9170 WHERE
9171 o2.dataflow_id = o1.dataflow_id
9172 AND o2.region_id = o1.region_id
9173 OPTIONS (AGGREGATE INPUT GROUP SIZE = 8)
9174 )
9175 ),
9176 -- The fourth CTE, candidates, will look for operators where the number of records
9177 -- maintained is not significantly different from the number at the pivot (excluding
9178 -- the pivot itself). These are the candidates for being cut from the dataflow region
9179 -- by adjusting the hint. The query includes a constant, heuristically tuned on TPC-H
9180 -- load generator data, to give some room for small deviations in number of records.
9181 -- The intuition for allowing for this deviation is that we are looking for a strongly
9182 -- reducing point in the hierarchy. To see why one such operator ought to exist in an
9183 -- untuned hierarchy, consider that at each level, we use hashing to distribute rows
9184 -- among groups where the min/max/top-k computation is (partially) applied. If the
9185 -- hierarchy has too many levels, the first-level (pivot) groups will be such that many
9186 -- groups might be empty or contain only one row. Each subsequent level will have a number
9187 -- of groups that is reduced exponentially. So at some point, we will find the level where
9188 -- we actually start having a few rows per group. That's where we will see the row counts
9189 -- significantly drop off.
9190 candidates AS (
9191 SELECT
9192 o.dataflow_id,
9193 o.region_id,
9194 o.id,
9195 o.records,
9196 o.size
9197 FROM
9198 operators o
9199 JOIN pivot p
9200 ON o.dataflow_id = p.dataflow_id
9201 AND o.region_id = p.region_id
9202 AND o.id <> p.id
9203 WHERE o.records >= p.records * (1 - 0.15)
9204 ),
9205 -- The fifth CTE, cuts, computes for each relevant dataflow region, the number of
9206 -- candidate levels that should be cut. We only return here dataflow regions where at
9207 -- least one level must be cut. Note that once we hit a point where the hierarchy starts
9208 -- to have a filtering effect, i.e., after the last candidate, it is dangerous to suggest
9209 -- cutting the height of the hierarchy further. This is because we will have way less
9210 -- groups in the next level, so there should be even further reduction happening or there
9211 -- is some substantial skew in the data. But if the latter is the case, then we should not
9212 -- tune the GROUP SIZE hints down anyway to avoid hurting latency upon updates directed
9213 -- at these unusually large groups. In addition to selecting the levels to cut, we also
9214 -- compute a conservative estimate of the memory savings in bytes that will result from
9215 -- cutting these levels from the hierarchy. The estimate is based on the sizes of the
9216 -- input arrangements for each level to be cut. These arrangements should dominate the
9217 -- size of each level that can be cut, since the reduction gadget internal to the level
9218 -- does not remove much data at these levels.
9219 cuts AS (
9220 SELECT c.dataflow_id, c.region_id, COUNT(*) AS to_cut, SUM(c.size) AS savings
9221 FROM candidates c
9222 GROUP BY c.dataflow_id, c.region_id
9223 HAVING COUNT(*) > 0
9224 )
9225 -- Finally, we compute the hint suggestion for each dataflow region based on the number of
9226 -- levels and the number of candidates to be cut. The hint is computed taking into account
9227 -- the fan-in used in rendering for the hash partitioning and reduction of the groups,
9228 -- currently equal to 16.
9229 SELECT
9230 dod.dataflow_id,
9231 dod.dataflow_name,
9232 dod.id AS region_id,
9233 dod.name AS region_name,
9234 l.levels,
9235 c.to_cut,
9236 c.savings,
9237 pow(16, l.levels - c.to_cut) - 1 AS hint
9238 FROM cuts c
9239 JOIN levels l
9240 ON c.dataflow_id = l.dataflow_id AND c.region_id = l.region_id
9241 JOIN mz_introspection.mz_dataflow_operator_dataflows dod
9242 ON dod.dataflow_id = c.dataflow_id AND dod.id = c.region_id",
9243 access: vec![PUBLIC_SELECT],
9244});
9245
9246pub static MZ_INDEX_ADVICE: LazyLock<BuiltinView> = LazyLock::new(|| {
9247 BuiltinView {
9248 name: "mz_index_advice",
9249 schema: MZ_INTERNAL_SCHEMA,
9250 oid: oid::VIEW_MZ_INDEX_ADVICE_OID,
9251 desc: RelationDesc::builder()
9252 .with_column("object_id", SqlScalarType::String.nullable(true))
9253 .with_column("hint", SqlScalarType::String.nullable(false))
9254 .with_column("details", SqlScalarType::String.nullable(false))
9255 .with_column("referenced_object_ids", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(true))
9256 .finish(),
9257 column_comments: BTreeMap::from_iter([
9258 ("object_id", "The ID of the object. Corresponds to mz_objects.id."),
9259 ("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."),
9260 ("details", "Additional details on why the `hint` was proposed based on the dependencies of the object."),
9261 ("referenced_object_ids", "The IDs of objects referenced by `details`. Corresponds to mz_objects.id."),
9262 ]),
9263 sql: "
9264-- To avoid confusion with sources and sinks in the materialize sense,
9265-- the following uses the terms leafs (instead of sinks) and roots (instead of sources)
9266-- when referring to the object dependency graph.
9267--
9268-- The basic idea is to walk up the dependency graph to propagate the transitive dependencies
9269-- of maintained objected upwards. The leaves of the dependency graph are maintained objects
9270-- that are not depended on by other maintained objects and have a justification why they must
9271-- be maintained (e.g. a materialized view that is depended on by a sink).
9272-- Starting from these leaves, the dependencies are propagated upwards towards the roots according
9273-- to the object dependencies. Whenever there is a node that is being depended on by multiple
9274-- downstream objects, that node is marked to be converted into a maintained object and this
9275-- node is then propagated further up. Once completed, the list of objects that are marked as
9276-- maintained is checked against all objects to generate appropriate recommendations.
9277--
9278-- Note that the recommendations only incorporate dependencies between objects.
9279-- This can lead to bad recommendations, e.g. filters can no longer be pushed into (or close to)
9280-- a sink if an index is added in between the sink and the filter. For very selective filters,
9281-- this can lead to redundant work: the index is computing stuff only to discarded by the selective
9282-- filter later on. But these kind of aspects cannot be understood by merely looking at the
9283-- dependencies.
9284WITH MUTUALLY RECURSIVE
9285 -- for all objects, understand if they have an index on them and on which cluster they are running
9286 -- this avoids having different cases for views with an index and materialized views later on
9287 objects(id text, type text, cluster_id text, indexes text list) AS (
9288 -- views and materialized views without an index
9289 SELECT
9290 o.id,
9291 o.type,
9292 o.cluster_id,
9293 '{}'::text list AS indexes
9294 FROM mz_catalog.mz_objects o
9295 WHERE o.id LIKE 'u%' AND o.type IN ('materialized-view', 'view') AND NOT EXISTS (
9296 SELECT FROM mz_internal.mz_object_dependencies d
9297 JOIN mz_catalog.mz_objects AS i
9298 ON (i.id = d.object_id AND i.type = 'index')
9299 WHERE (o.id = d.referenced_object_id)
9300 )
9301
9302 UNION ALL
9303
9304 -- views and materialized views with an index
9305 SELECT
9306 o.id,
9307 o.type,
9308 -- o.cluster_id is always NULL for views, so use the cluster of the index instead
9309 COALESCE(o.cluster_id, i.cluster_id) AS cluster_id,
9310 list_agg(i.id) AS indexes
9311 FROM mz_catalog.mz_objects o
9312 JOIN mz_internal.mz_object_dependencies AS d
9313 ON (o.id = d.referenced_object_id)
9314 JOIN mz_catalog.mz_objects AS i
9315 ON (i.id = d.object_id AND i.type = 'index')
9316 WHERE o.id LIKE 'u%' AND o.type IN ('materialized-view', 'view', 'source')
9317 GROUP BY o.id, o.type, o.cluster_id, i.cluster_id
9318 ),
9319
9320 -- maintained objects that are at the leafs of the dependency graph with respect to a specific cluster
9321 maintained_leafs(id text, justification text) AS (
9322 -- materialized views that are connected to a sink
9323 SELECT
9324 m.id,
9325 s.id AS justification
9326 FROM objects AS m
9327 JOIN mz_internal.mz_object_dependencies AS d
9328 ON (m.id = d.referenced_object_id)
9329 JOIN mz_catalog.mz_objects AS s
9330 ON (s.id = d.object_id AND s.type = 'sink')
9331 WHERE m.type = 'materialized-view'
9332
9333 UNION ALL
9334
9335 -- (materialized) views with an index that are not transitively depend on by maintained objects on the same cluster
9336 SELECT
9337 v.id,
9338 unnest(v.indexes) AS justification
9339 FROM objects AS v
9340 WHERE v.type IN ('view', 'materialized-view', 'source') AND NOT EXISTS (
9341 SELECT FROM mz_internal.mz_object_transitive_dependencies AS d
9342 INNER JOIN mz_catalog.mz_objects AS child
9343 ON (d.object_id = child.id)
9344 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]
9345 )
9346 ),
9347
9348 -- this is just a helper cte to union multiple lists as part of an aggregation, which is not directly possible in SQL
9349 agg_maintained_children(id text, maintained_children text list) AS (
9350 SELECT
9351 parent_id AS id,
9352 list_agg(maintained_child) AS maintained_leafs
9353 FROM (
9354 SELECT DISTINCT
9355 d.referenced_object_id AS parent_id,
9356 -- it's not possible to union lists in an aggregation, so we have to unnest the list first
9357 unnest(child.maintained_children) AS maintained_child
9358 FROM propagate_dependencies AS child
9359 INNER JOIN mz_internal.mz_object_dependencies AS d
9360 ON (child.id = d.object_id)
9361 )
9362 GROUP BY parent_id
9363 ),
9364
9365 -- propagate dependencies of maintained objects from the leafs to the roots of the dependency graph and
9366 -- record a justification when an object should be maintained, e.g. when it is depended on by more than one maintained object
9367 -- 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
9368 propagate_dependencies(id text, maintained_children text list, justification text list) AS (
9369 -- base case: start with the leafs
9370 SELECT DISTINCT
9371 id,
9372 LIST[id] AS maintained_children,
9373 list_agg(justification) AS justification
9374 FROM maintained_leafs
9375 GROUP BY id
9376
9377 UNION
9378
9379 -- recursive case: if there is a child with the same dependencies as the parent,
9380 -- the parent is only reused by a single child
9381 SELECT
9382 parent.id,
9383 child.maintained_children,
9384 NULL::text list AS justification
9385 FROM agg_maintained_children AS parent
9386 INNER JOIN mz_internal.mz_object_dependencies AS d
9387 ON (parent.id = d.referenced_object_id)
9388 INNER JOIN propagate_dependencies AS child
9389 ON (d.object_id = child.id)
9390 WHERE parent.maintained_children = child.maintained_children
9391
9392 UNION
9393
9394 -- recursive case: if there is NO child with the same dependencies as the parent,
9395 -- different children are reusing the parent so maintaining the object is justified by itself
9396 SELECT DISTINCT
9397 parent.id,
9398 LIST[parent.id] AS maintained_children,
9399 parent.maintained_children AS justification
9400 FROM agg_maintained_children AS parent
9401 WHERE NOT EXISTS (
9402 SELECT FROM mz_internal.mz_object_dependencies AS d
9403 INNER JOIN propagate_dependencies AS child
9404 ON (d.object_id = child.id AND d.referenced_object_id = parent.id)
9405 WHERE parent.maintained_children = child.maintained_children
9406 )
9407 ),
9408
9409 objects_with_justification(id text, type text, cluster_id text, maintained_children text list, justification text list, indexes text list) AS (
9410 SELECT
9411 p.id,
9412 o.type,
9413 o.cluster_id,
9414 p.maintained_children,
9415 p.justification,
9416 o.indexes
9417 FROM propagate_dependencies p
9418 JOIN objects AS o
9419 ON (p.id = o.id)
9420 ),
9421
9422 hints(id text, hint text, details text, justification text list) AS (
9423 -- materialized views that are not required
9424 SELECT
9425 id,
9426 'convert to a view' AS hint,
9427 'no dependencies from sinks nor from objects on different clusters' AS details,
9428 justification
9429 FROM objects_with_justification
9430 WHERE type = 'materialized-view' AND justification IS NULL
9431
9432 UNION ALL
9433
9434 -- materialized views that are required because a sink or a maintained object from a different cluster depends on them
9435 SELECT
9436 id,
9437 'keep' AS hint,
9438 'dependencies from sinks or objects on different clusters: ' AS details,
9439 justification
9440 FROM objects_with_justification AS m
9441 WHERE type = 'materialized-view' AND justification IS NOT NULL AND EXISTS (
9442 SELECT FROM unnest(justification) AS dependency
9443 JOIN mz_catalog.mz_objects s ON (s.type = 'sink' AND s.id = dependency)
9444
9445 UNION ALL
9446
9447 SELECT FROM unnest(justification) AS dependency
9448 JOIN mz_catalog.mz_objects AS d ON (d.id = dependency)
9449 WHERE d.cluster_id != m.cluster_id
9450 )
9451
9452 UNION ALL
9453
9454 -- 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
9455 SELECT
9456 id,
9457 'convert to a view with an index' AS hint,
9458 'no dependencies from sinks nor from objects on different clusters, but maintained dependencies on the same cluster: ' AS details,
9459 justification
9460 FROM objects_with_justification AS m
9461 WHERE type = 'materialized-view' AND justification IS NOT NULL AND NOT EXISTS (
9462 SELECT FROM unnest(justification) AS dependency
9463 JOIN mz_catalog.mz_objects s ON (s.type = 'sink' AND s.id = dependency)
9464
9465 UNION ALL
9466
9467 SELECT FROM unnest(justification) AS dependency
9468 JOIN mz_catalog.mz_objects AS d ON (d.id = dependency)
9469 WHERE d.cluster_id != m.cluster_id
9470 )
9471
9472 UNION ALL
9473
9474 -- views that have indexes on different clusters should be a materialized view
9475 SELECT
9476 o.id,
9477 'convert to materialized view' AS hint,
9478 'dependencies on multiple clusters: ' AS details,
9479 o.justification
9480 FROM objects_with_justification o,
9481 LATERAL unnest(o.justification) j
9482 LEFT JOIN mz_catalog.mz_objects AS m
9483 ON (m.id = j AND m.type IN ('index', 'materialized-view'))
9484 WHERE o.type = 'view' AND o.justification IS NOT NULL
9485 GROUP BY o.id, o.justification
9486 HAVING count(DISTINCT m.cluster_id) >= 2
9487
9488 UNION ALL
9489
9490 -- views without an index that should be maintained
9491 SELECT
9492 id,
9493 'add index' AS hint,
9494 'multiple downstream dependencies: ' AS details,
9495 justification
9496 FROM objects_with_justification
9497 WHERE type = 'view' AND justification IS NOT NULL AND indexes = '{}'::text list
9498
9499 UNION ALL
9500
9501 -- index inside the dependency graph (not a leaf)
9502 SELECT
9503 unnest(indexes) AS id,
9504 'drop unless queried directly' AS hint,
9505 'fewer than two downstream dependencies: ' AS details,
9506 maintained_children AS justification
9507 FROM objects_with_justification
9508 WHERE type = 'view' AND NOT indexes = '{}'::text list AND justification IS NULL
9509
9510 UNION ALL
9511
9512 -- index on a leaf of the dependency graph
9513 SELECT
9514 unnest(indexes) AS id,
9515 'drop unless queried directly' AS hint,
9516 'associated object does not have any dependencies (maintained or not maintained)' AS details,
9517 NULL::text list AS justification
9518 FROM objects_with_justification
9519 -- indexes can only be part of justification for leaf nodes
9520 WHERE type IN ('view', 'materialized-view') AND NOT indexes = '{}'::text list AND justification @> indexes
9521
9522 UNION ALL
9523
9524 -- index on a source
9525 SELECT
9526 unnest(indexes) AS id,
9527 'drop unless queried directly' AS hint,
9528 'sources do not transform data and can expose data directly' AS details,
9529 NULL::text list AS justification
9530 FROM objects_with_justification
9531 -- indexes can only be part of justification for leaf nodes
9532 WHERE type = 'source' AND NOT indexes = '{}'::text list
9533
9534 UNION ALL
9535
9536 -- indexes on views inside the dependency graph
9537 SELECT
9538 unnest(indexes) AS id,
9539 'keep' AS hint,
9540 'multiple downstream dependencies: ' AS details,
9541 justification
9542 FROM objects_with_justification
9543 -- indexes can only be part of justification for leaf nodes
9544 WHERE type = 'view' AND justification IS NOT NULL AND NOT indexes = '{}'::text list AND NOT justification @> indexes
9545 ),
9546
9547 hints_resolved_ids(id text, hint text, details text, justification text list) AS (
9548 SELECT
9549 h.id,
9550 h.hint,
9551 h.details || list_agg(o.name)::text AS details,
9552 h.justification
9553 FROM hints AS h,
9554 LATERAL unnest(h.justification) j
9555 JOIN mz_catalog.mz_objects AS o
9556 ON (o.id = j)
9557 GROUP BY h.id, h.hint, h.details, h.justification
9558
9559 UNION ALL
9560
9561 SELECT
9562 id,
9563 hint,
9564 details,
9565 justification
9566 FROM hints
9567 WHERE justification IS NULL
9568 )
9569
9570SELECT
9571 h.id AS object_id,
9572 h.hint AS hint,
9573 h.details,
9574 h.justification AS referenced_object_ids
9575FROM hints_resolved_ids AS h",
9576 access: vec![PUBLIC_SELECT],
9577 }
9578});
9579
9580pub static PG_CONSTRAINT: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9583 name: "pg_constraint",
9584 schema: PG_CATALOG_SCHEMA,
9585 oid: oid::VIEW_PG_CONSTRAINT_OID,
9586 desc: RelationDesc::builder()
9587 .with_column("oid", SqlScalarType::Oid.nullable(false))
9588 .with_column("conname", SqlScalarType::String.nullable(false))
9589 .with_column("connamespace", SqlScalarType::Oid.nullable(false))
9590 .with_column("contype", SqlScalarType::PgLegacyChar.nullable(false))
9591 .with_column("condeferrable", SqlScalarType::Bool.nullable(false))
9592 .with_column("condeferred", SqlScalarType::Bool.nullable(false))
9593 .with_column("convalidated", SqlScalarType::Bool.nullable(false))
9594 .with_column("conrelid", SqlScalarType::Oid.nullable(false))
9595 .with_column("contypid", SqlScalarType::Oid.nullable(false))
9596 .with_column("conindid", SqlScalarType::Oid.nullable(false))
9597 .with_column("conparentid", SqlScalarType::Oid.nullable(false))
9598 .with_column("confrelid", SqlScalarType::Oid.nullable(false))
9599 .with_column("confupdtype", SqlScalarType::PgLegacyChar.nullable(false))
9600 .with_column("confdeltype", SqlScalarType::PgLegacyChar.nullable(false))
9601 .with_column("confmatchtype", SqlScalarType::PgLegacyChar.nullable(false))
9602 .with_column("conislocal", SqlScalarType::Bool.nullable(false))
9603 .with_column("coninhcount", SqlScalarType::Int32.nullable(false))
9604 .with_column("connoinherit", SqlScalarType::Bool.nullable(false))
9605 .with_column(
9606 "conkey",
9607 SqlScalarType::Array(Box::new(SqlScalarType::Int16)).nullable(false),
9608 )
9609 .with_column(
9610 "confkey",
9611 SqlScalarType::Array(Box::new(SqlScalarType::Int16)).nullable(false),
9612 )
9613 .with_column(
9614 "conpfeqop",
9615 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9616 )
9617 .with_column(
9618 "conppeqop",
9619 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9620 )
9621 .with_column(
9622 "conffeqop",
9623 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9624 )
9625 .with_column(
9626 "conexclop",
9627 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9628 )
9629 .with_column("conbin", SqlScalarType::String.nullable(false))
9630 .with_key(vec![])
9631 .finish(),
9632 column_comments: BTreeMap::new(),
9633 sql: "SELECT
9634 NULL::pg_catalog.oid as oid,
9635 NULL::pg_catalog.text as conname,
9636 NULL::pg_catalog.oid as connamespace,
9637 NULL::pg_catalog.\"char\" as contype,
9638 NULL::pg_catalog.bool as condeferrable,
9639 NULL::pg_catalog.bool as condeferred,
9640 NULL::pg_catalog.bool as convalidated,
9641 NULL::pg_catalog.oid as conrelid,
9642 NULL::pg_catalog.oid as contypid,
9643 NULL::pg_catalog.oid as conindid,
9644 NULL::pg_catalog.oid as conparentid,
9645 NULL::pg_catalog.oid as confrelid,
9646 NULL::pg_catalog.\"char\" as confupdtype,
9647 NULL::pg_catalog.\"char\" as confdeltype,
9648 NULL::pg_catalog.\"char\" as confmatchtype,
9649 NULL::pg_catalog.bool as conislocal,
9650 NULL::pg_catalog.int4 as coninhcount,
9651 NULL::pg_catalog.bool as connoinherit,
9652 NULL::pg_catalog.int2[] as conkey,
9653 NULL::pg_catalog.int2[] as confkey,
9654 NULL::pg_catalog.oid[] as conpfeqop,
9655 NULL::pg_catalog.oid[] as conppeqop,
9656 NULL::pg_catalog.oid[] as conffeqop,
9657 NULL::pg_catalog.oid[] as conexclop,
9658 NULL::pg_catalog.text as conbin
9659WHERE false",
9660 access: vec![PUBLIC_SELECT],
9661});
9662
9663pub static PG_TABLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9664 name: "pg_tables",
9665 schema: PG_CATALOG_SCHEMA,
9666 oid: oid::VIEW_PG_TABLES_OID,
9667 desc: RelationDesc::builder()
9668 .with_column("schemaname", SqlScalarType::String.nullable(true))
9669 .with_column("tablename", SqlScalarType::String.nullable(false))
9670 .with_column("tableowner", SqlScalarType::String.nullable(false))
9671 .finish(),
9672 column_comments: BTreeMap::new(),
9673 sql: "
9674SELECT n.nspname AS schemaname,
9675 c.relname AS tablename,
9676 pg_catalog.pg_get_userbyid(c.relowner) AS tableowner
9677FROM pg_catalog.pg_class c
9678LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
9679WHERE c.relkind IN ('r', 'p')",
9680 access: vec![PUBLIC_SELECT],
9681});
9682
9683pub static PG_TABLESPACE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9684 name: "pg_tablespace",
9685 schema: PG_CATALOG_SCHEMA,
9686 oid: oid::VIEW_PG_TABLESPACE_OID,
9687 desc: RelationDesc::builder()
9688 .with_column("oid", SqlScalarType::Oid.nullable(false))
9689 .with_column("spcname", SqlScalarType::String.nullable(false))
9690 .with_column("spcowner", SqlScalarType::Oid.nullable(true))
9691 .with_column(
9692 "spcacl",
9693 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9694 )
9695 .with_column(
9696 "spcoptions",
9697 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9698 )
9699 .with_key(vec![])
9700 .finish(),
9701 column_comments: BTreeMap::new(),
9702 sql: "
9703 SELECT oid, spcname, spcowner, spcacl, spcoptions
9704 FROM (
9705 VALUES (
9706 --These are the same defaults CockroachDB uses.
9707 0::pg_catalog.oid,
9708 'pg_default'::pg_catalog.text,
9709 NULL::pg_catalog.oid,
9710 NULL::pg_catalog.text[],
9711 NULL::pg_catalog.text[]
9712 )
9713 ) AS _ (oid, spcname, spcowner, spcacl, spcoptions)
9714",
9715 access: vec![PUBLIC_SELECT],
9716});
9717
9718pub static PG_ACCESS_METHODS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9719 name: "pg_am",
9720 schema: PG_CATALOG_SCHEMA,
9721 oid: oid::VIEW_PG_AM_OID,
9722 desc: RelationDesc::builder()
9723 .with_column("oid", SqlScalarType::Oid.nullable(false))
9724 .with_column("amname", SqlScalarType::String.nullable(false))
9725 .with_column("amhandler", SqlScalarType::RegProc.nullable(false))
9726 .with_column("amtype", SqlScalarType::PgLegacyChar.nullable(false))
9727 .with_key(vec![])
9728 .finish(),
9729 column_comments: BTreeMap::new(),
9730 sql: "
9731SELECT NULL::pg_catalog.oid AS oid,
9732 NULL::pg_catalog.text AS amname,
9733 NULL::pg_catalog.regproc AS amhandler,
9734 NULL::pg_catalog.\"char\" AS amtype
9735WHERE false",
9736 access: vec![PUBLIC_SELECT],
9737});
9738
9739pub static PG_ROLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9740 name: "pg_roles",
9741 schema: PG_CATALOG_SCHEMA,
9742 oid: oid::VIEW_PG_ROLES_OID,
9743 desc: RelationDesc::builder()
9744 .with_column("rolname", SqlScalarType::String.nullable(false))
9745 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
9746 .with_column("rolinherit", SqlScalarType::Bool.nullable(false))
9747 .with_column("rolcreaterole", SqlScalarType::Bool.nullable(true))
9748 .with_column("rolcreatedb", SqlScalarType::Bool.nullable(true))
9749 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(false))
9750 .with_column("rolreplication", SqlScalarType::Bool.nullable(false))
9751 .with_column("rolconnlimit", SqlScalarType::Int32.nullable(false))
9752 .with_column("rolpassword", SqlScalarType::String.nullable(false))
9753 .with_column(
9754 "rolvaliduntil",
9755 SqlScalarType::TimestampTz { precision: None }.nullable(true),
9756 )
9757 .with_column("rolbypassrls", SqlScalarType::Bool.nullable(false))
9758 .with_column(
9759 "rolconfig",
9760 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9761 )
9762 .with_column("oid", SqlScalarType::Oid.nullable(false))
9763 .finish(),
9764 column_comments: BTreeMap::new(),
9765 sql: "SELECT
9766 rolname,
9767 rolsuper,
9768 rolinherit,
9769 rolcreaterole,
9770 rolcreatedb,
9771 rolcanlogin,
9772 rolreplication,
9773 rolconnlimit,
9774 rolpassword,
9775 rolvaliduntil,
9776 rolbypassrls,
9777 (
9778 SELECT array_agg(parameter_name || '=' || parameter_value)
9779 FROM mz_catalog.mz_role_parameters rp
9780 JOIN mz_catalog.mz_roles r ON r.id = rp.role_id
9781 WHERE ai.oid = r.oid
9782 ) AS rolconfig,
9783 oid
9784FROM pg_catalog.pg_authid ai",
9785 access: vec![PUBLIC_SELECT],
9786});
9787
9788pub static PG_USER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9789 name: "pg_user",
9790 schema: PG_CATALOG_SCHEMA,
9791 oid: oid::VIEW_PG_USER_OID,
9792 desc: RelationDesc::builder()
9793 .with_column("usename", SqlScalarType::String.nullable(false))
9794 .with_column("usesysid", SqlScalarType::Oid.nullable(false))
9795 .with_column("usecreatedb", SqlScalarType::Bool.nullable(true))
9796 .with_column("usesuper", SqlScalarType::Bool.nullable(true))
9797 .with_column("userepl", SqlScalarType::Bool.nullable(false))
9798 .with_column("usebypassrls", SqlScalarType::Bool.nullable(false))
9799 .with_column("passwd", SqlScalarType::String.nullable(false))
9800 .with_column(
9801 "valuntil",
9802 SqlScalarType::TimestampTz { precision: None }.nullable(true),
9803 )
9804 .with_column(
9805 "useconfig",
9806 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9807 )
9808 .finish(),
9809 column_comments: BTreeMap::new(),
9810 sql: "
9811SELECT
9812 rolname as usename,
9813 ai.oid as usesysid,
9814 rolcreatedb AS usecreatedb,
9815 rolsuper AS usesuper,
9816 rolreplication AS userepl,
9817 rolbypassrls AS usebypassrls,
9818 rolpassword as passwd,
9819 rolvaliduntil as valuntil,
9820 (
9821 SELECT array_agg(parameter_name || '=' || parameter_value)
9822 FROM mz_catalog.mz_role_parameters rp
9823 JOIN mz_catalog.mz_roles r ON r.id = rp.role_id
9824 WHERE ai.oid = r.oid
9825 ) AS useconfig
9826FROM pg_catalog.pg_authid ai
9827WHERE rolcanlogin",
9828 access: vec![PUBLIC_SELECT],
9829});
9830
9831pub static PG_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9832 name: "pg_views",
9833 schema: PG_CATALOG_SCHEMA,
9834 oid: oid::VIEW_PG_VIEWS_OID,
9835 desc: RelationDesc::builder()
9836 .with_column("schemaname", SqlScalarType::String.nullable(true))
9837 .with_column("viewname", SqlScalarType::String.nullable(false))
9838 .with_column("viewowner", SqlScalarType::Oid.nullable(false))
9839 .with_column("definition", SqlScalarType::String.nullable(false))
9840 .finish(),
9841 column_comments: BTreeMap::new(),
9842 sql: "SELECT
9843 s.name AS schemaname,
9844 v.name AS viewname,
9845 role_owner.oid AS viewowner,
9846 v.definition AS definition
9847FROM mz_catalog.mz_views v
9848LEFT JOIN mz_catalog.mz_schemas s ON s.id = v.schema_id
9849LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
9850JOIN mz_catalog.mz_roles role_owner ON role_owner.id = v.owner_id
9851WHERE s.database_id IS NULL OR d.name = current_database()",
9852 access: vec![PUBLIC_SELECT],
9853});
9854
9855pub static PG_MATVIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9856 name: "pg_matviews",
9857 schema: PG_CATALOG_SCHEMA,
9858 oid: oid::VIEW_PG_MATVIEWS_OID,
9859 desc: RelationDesc::builder()
9860 .with_column("schemaname", SqlScalarType::String.nullable(true))
9861 .with_column("matviewname", SqlScalarType::String.nullable(false))
9862 .with_column("matviewowner", SqlScalarType::Oid.nullable(false))
9863 .with_column("definition", SqlScalarType::String.nullable(false))
9864 .finish(),
9865 column_comments: BTreeMap::new(),
9866 sql: "SELECT
9867 s.name AS schemaname,
9868 m.name AS matviewname,
9869 role_owner.oid AS matviewowner,
9870 m.definition AS definition
9871FROM mz_catalog.mz_materialized_views m
9872LEFT JOIN mz_catalog.mz_schemas s ON s.id = m.schema_id
9873LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
9874JOIN mz_catalog.mz_roles role_owner ON role_owner.id = m.owner_id
9875WHERE s.database_id IS NULL OR d.name = current_database()",
9876 access: vec![PUBLIC_SELECT],
9877});
9878
9879pub static INFORMATION_SCHEMA_APPLICABLE_ROLES: LazyLock<BuiltinView> =
9880 LazyLock::new(|| BuiltinView {
9881 name: "applicable_roles",
9882 schema: INFORMATION_SCHEMA,
9883 oid: oid::VIEW_APPLICABLE_ROLES_OID,
9884 desc: RelationDesc::builder()
9885 .with_column("grantee", SqlScalarType::String.nullable(false))
9886 .with_column("role_name", SqlScalarType::String.nullable(false))
9887 .with_column("is_grantable", SqlScalarType::String.nullable(false))
9888 .finish(),
9889 column_comments: BTreeMap::new(),
9890 sql: "
9891SELECT
9892 member.name AS grantee,
9893 role.name AS role_name,
9894 -- ADMIN OPTION isn't implemented.
9895 'NO' AS is_grantable
9896FROM mz_catalog.mz_role_members membership
9897JOIN mz_catalog.mz_roles role ON membership.role_id = role.id
9898JOIN mz_catalog.mz_roles member ON membership.member = member.id
9899WHERE mz_catalog.mz_is_superuser() OR pg_has_role(current_role, member.oid, 'USAGE')",
9900 access: vec![PUBLIC_SELECT],
9901 });
9902
9903pub static INFORMATION_SCHEMA_COLUMNS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9904 name: "columns",
9905 schema: INFORMATION_SCHEMA,
9906 oid: oid::VIEW_COLUMNS_OID,
9907 desc: RelationDesc::builder()
9908 .with_column("table_catalog", SqlScalarType::String.nullable(false))
9909 .with_column("table_schema", SqlScalarType::String.nullable(false))
9910 .with_column("table_name", SqlScalarType::String.nullable(false))
9911 .with_column("column_name", SqlScalarType::String.nullable(false))
9912 .with_column("ordinal_position", SqlScalarType::Int64.nullable(false))
9913 .with_column("column_default", SqlScalarType::String.nullable(true))
9914 .with_column("is_nullable", SqlScalarType::String.nullable(false))
9915 .with_column("data_type", SqlScalarType::String.nullable(false))
9916 .with_column(
9917 "character_maximum_length",
9918 SqlScalarType::Int32.nullable(true),
9919 )
9920 .with_column("numeric_precision", SqlScalarType::Int32.nullable(true))
9921 .with_column("numeric_scale", SqlScalarType::Int32.nullable(true))
9922 .finish(),
9923 column_comments: BTreeMap::new(),
9924 sql: "
9925SELECT
9926 current_database() as table_catalog,
9927 s.name AS table_schema,
9928 o.name AS table_name,
9929 c.name AS column_name,
9930 c.position::int8 AS ordinal_position,
9931 c.default AS column_default,
9932 CASE WHEN c.nullable THEN 'YES' ELSE 'NO' END AS is_nullable,
9933 c.type AS data_type,
9934 NULL::pg_catalog.int4 AS character_maximum_length,
9935 NULL::pg_catalog.int4 AS numeric_precision,
9936 NULL::pg_catalog.int4 AS numeric_scale
9937FROM mz_catalog.mz_columns c
9938JOIN mz_catalog.mz_objects o ON o.id = c.id
9939JOIN mz_catalog.mz_schemas s ON s.id = o.schema_id
9940LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
9941WHERE s.database_id IS NULL OR d.name = current_database()",
9942 access: vec![PUBLIC_SELECT],
9943});
9944
9945pub static INFORMATION_SCHEMA_ENABLED_ROLES: LazyLock<BuiltinView> =
9946 LazyLock::new(|| BuiltinView {
9947 name: "enabled_roles",
9948 schema: INFORMATION_SCHEMA,
9949 oid: oid::VIEW_ENABLED_ROLES_OID,
9950 desc: RelationDesc::builder()
9951 .with_column("role_name", SqlScalarType::String.nullable(false))
9952 .finish(),
9953 column_comments: BTreeMap::new(),
9954 sql: "
9955SELECT name AS role_name
9956FROM mz_catalog.mz_roles
9957WHERE mz_catalog.mz_is_superuser() OR pg_has_role(current_role, oid, 'USAGE')",
9958 access: vec![PUBLIC_SELECT],
9959 });
9960
9961pub static INFORMATION_SCHEMA_ROLE_TABLE_GRANTS: LazyLock<BuiltinView> = LazyLock::new(|| {
9962 BuiltinView {
9963 name: "role_table_grants",
9964 schema: INFORMATION_SCHEMA,
9965 oid: oid::VIEW_ROLE_TABLE_GRANTS_OID,
9966 desc: RelationDesc::builder()
9967 .with_column("grantor", SqlScalarType::String.nullable(false))
9968 .with_column("grantee", SqlScalarType::String.nullable(true))
9969 .with_column("table_catalog", SqlScalarType::String.nullable(true))
9970 .with_column("table_schema", SqlScalarType::String.nullable(false))
9971 .with_column("table_name", SqlScalarType::String.nullable(false))
9972 .with_column("privilege_type", SqlScalarType::String.nullable(true))
9973 .with_column("is_grantable", SqlScalarType::String.nullable(false))
9974 .with_column("with_hierarchy", SqlScalarType::String.nullable(false))
9975 .finish(),
9976 column_comments: BTreeMap::new(),
9977 sql: "
9978SELECT grantor, grantee, table_catalog, table_schema, table_name, privilege_type, is_grantable, with_hierarchy
9979FROM information_schema.table_privileges
9980WHERE
9981 grantor IN (SELECT role_name FROM information_schema.enabled_roles)
9982 OR grantee IN (SELECT role_name FROM information_schema.enabled_roles)",
9983 access: vec![PUBLIC_SELECT],
9984 }
9985});
9986
9987pub static INFORMATION_SCHEMA_KEY_COLUMN_USAGE: LazyLock<BuiltinView> =
9988 LazyLock::new(|| BuiltinView {
9989 name: "key_column_usage",
9990 schema: INFORMATION_SCHEMA,
9991 oid: oid::VIEW_KEY_COLUMN_USAGE_OID,
9992 desc: RelationDesc::builder()
9993 .with_column("constraint_catalog", SqlScalarType::String.nullable(false))
9994 .with_column("constraint_schema", SqlScalarType::String.nullable(false))
9995 .with_column("constraint_name", SqlScalarType::String.nullable(false))
9996 .with_column("table_catalog", SqlScalarType::String.nullable(false))
9997 .with_column("table_schema", SqlScalarType::String.nullable(false))
9998 .with_column("table_name", SqlScalarType::String.nullable(false))
9999 .with_column("column_name", SqlScalarType::String.nullable(false))
10000 .with_column("ordinal_position", SqlScalarType::Int32.nullable(false))
10001 .with_column(
10002 "position_in_unique_constraint",
10003 SqlScalarType::Int32.nullable(false),
10004 )
10005 .with_key(vec![])
10006 .finish(),
10007 column_comments: BTreeMap::new(),
10008 sql: "SELECT
10009 NULL::text AS constraint_catalog,
10010 NULL::text AS constraint_schema,
10011 NULL::text AS constraint_name,
10012 NULL::text AS table_catalog,
10013 NULL::text AS table_schema,
10014 NULL::text AS table_name,
10015 NULL::text AS column_name,
10016 NULL::integer AS ordinal_position,
10017 NULL::integer AS position_in_unique_constraint
10018WHERE false",
10019 access: vec![PUBLIC_SELECT],
10020 });
10021
10022pub static INFORMATION_SCHEMA_REFERENTIAL_CONSTRAINTS: LazyLock<BuiltinView> =
10023 LazyLock::new(|| BuiltinView {
10024 name: "referential_constraints",
10025 schema: INFORMATION_SCHEMA,
10026 oid: oid::VIEW_REFERENTIAL_CONSTRAINTS_OID,
10027 desc: RelationDesc::builder()
10028 .with_column("constraint_catalog", SqlScalarType::String.nullable(false))
10029 .with_column("constraint_schema", SqlScalarType::String.nullable(false))
10030 .with_column("constraint_name", SqlScalarType::String.nullable(false))
10031 .with_column(
10032 "unique_constraint_catalog",
10033 SqlScalarType::String.nullable(false),
10034 )
10035 .with_column(
10036 "unique_constraint_schema",
10037 SqlScalarType::String.nullable(false),
10038 )
10039 .with_column(
10040 "unique_constraint_name",
10041 SqlScalarType::String.nullable(false),
10042 )
10043 .with_column("match_option", SqlScalarType::String.nullable(false))
10044 .with_column("update_rule", SqlScalarType::String.nullable(false))
10045 .with_column("delete_rule", SqlScalarType::String.nullable(false))
10046 .with_key(vec![])
10047 .finish(),
10048 column_comments: BTreeMap::new(),
10049 sql: "SELECT
10050 NULL::text AS constraint_catalog,
10051 NULL::text AS constraint_schema,
10052 NULL::text AS constraint_name,
10053 NULL::text AS unique_constraint_catalog,
10054 NULL::text AS unique_constraint_schema,
10055 NULL::text AS unique_constraint_name,
10056 NULL::text AS match_option,
10057 NULL::text AS update_rule,
10058 NULL::text AS delete_rule
10059WHERE false",
10060 access: vec![PUBLIC_SELECT],
10061 });
10062
10063pub static INFORMATION_SCHEMA_ROUTINES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10064 name: "routines",
10065 schema: INFORMATION_SCHEMA,
10066 oid: oid::VIEW_ROUTINES_OID,
10067 desc: RelationDesc::builder()
10068 .with_column("routine_catalog", SqlScalarType::String.nullable(false))
10069 .with_column("routine_schema", SqlScalarType::String.nullable(false))
10070 .with_column("routine_name", SqlScalarType::String.nullable(false))
10071 .with_column("routine_type", SqlScalarType::String.nullable(false))
10072 .with_column("routine_definition", SqlScalarType::String.nullable(true))
10073 .finish(),
10074 column_comments: BTreeMap::new(),
10075 sql: "SELECT
10076 current_database() as routine_catalog,
10077 s.name AS routine_schema,
10078 f.name AS routine_name,
10079 'FUNCTION' AS routine_type,
10080 NULL::text AS routine_definition
10081FROM mz_catalog.mz_functions f
10082JOIN mz_catalog.mz_schemas s ON s.id = f.schema_id
10083LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10084WHERE s.database_id IS NULL OR d.name = current_database()",
10085 access: vec![PUBLIC_SELECT],
10086});
10087
10088pub static INFORMATION_SCHEMA_SCHEMATA: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10089 name: "schemata",
10090 schema: INFORMATION_SCHEMA,
10091 oid: oid::VIEW_SCHEMATA_OID,
10092 desc: RelationDesc::builder()
10093 .with_column("catalog_name", SqlScalarType::String.nullable(false))
10094 .with_column("schema_name", SqlScalarType::String.nullable(false))
10095 .finish(),
10096 column_comments: BTreeMap::new(),
10097 sql: "
10098SELECT
10099 current_database() as catalog_name,
10100 s.name AS schema_name
10101FROM mz_catalog.mz_schemas s
10102LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10103WHERE s.database_id IS NULL OR d.name = current_database()",
10104 access: vec![PUBLIC_SELECT],
10105});
10106
10107pub static INFORMATION_SCHEMA_TABLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10108 name: "tables",
10109 schema: INFORMATION_SCHEMA,
10110 oid: oid::VIEW_TABLES_OID,
10111 desc: RelationDesc::builder()
10112 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10113 .with_column("table_schema", SqlScalarType::String.nullable(false))
10114 .with_column("table_name", SqlScalarType::String.nullable(false))
10115 .with_column("table_type", SqlScalarType::String.nullable(false))
10116 .finish(),
10117 column_comments: BTreeMap::new(),
10118 sql: "SELECT
10119 current_database() as table_catalog,
10120 s.name AS table_schema,
10121 r.name AS table_name,
10122 CASE r.type
10123 WHEN 'materialized-view' THEN 'MATERIALIZED VIEW'
10124 WHEN 'table' THEN 'BASE TABLE'
10125 ELSE pg_catalog.upper(r.type)
10126 END AS table_type
10127FROM mz_catalog.mz_relations r
10128JOIN mz_catalog.mz_schemas s ON s.id = r.schema_id
10129LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10130WHERE s.database_id IS NULL OR d.name = current_database()",
10131 access: vec![PUBLIC_SELECT],
10132});
10133
10134pub static INFORMATION_SCHEMA_TABLE_CONSTRAINTS: LazyLock<BuiltinView> =
10135 LazyLock::new(|| BuiltinView {
10136 name: "table_constraints",
10137 schema: INFORMATION_SCHEMA,
10138 oid: oid::VIEW_TABLE_CONSTRAINTS_OID,
10139 desc: RelationDesc::builder()
10140 .with_column("constraint_catalog", SqlScalarType::String.nullable(false))
10141 .with_column("constraint_schema", SqlScalarType::String.nullable(false))
10142 .with_column("constraint_name", SqlScalarType::String.nullable(false))
10143 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10144 .with_column("table_schema", SqlScalarType::String.nullable(false))
10145 .with_column("table_name", SqlScalarType::String.nullable(false))
10146 .with_column("constraint_type", SqlScalarType::String.nullable(false))
10147 .with_column("is_deferrable", SqlScalarType::String.nullable(false))
10148 .with_column("initially_deferred", SqlScalarType::String.nullable(false))
10149 .with_column("enforced", SqlScalarType::String.nullable(false))
10150 .with_column("nulls_distinct", SqlScalarType::String.nullable(false))
10151 .with_key(vec![])
10152 .finish(),
10153 column_comments: BTreeMap::new(),
10154 sql: "SELECT
10155 NULL::text AS constraint_catalog,
10156 NULL::text AS constraint_schema,
10157 NULL::text AS constraint_name,
10158 NULL::text AS table_catalog,
10159 NULL::text AS table_schema,
10160 NULL::text AS table_name,
10161 NULL::text AS constraint_type,
10162 NULL::text AS is_deferrable,
10163 NULL::text AS initially_deferred,
10164 NULL::text AS enforced,
10165 NULL::text AS nulls_distinct
10166WHERE false",
10167 access: vec![PUBLIC_SELECT],
10168 });
10169
10170pub static INFORMATION_SCHEMA_TABLE_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| {
10171 BuiltinView {
10172 name: "table_privileges",
10173 schema: INFORMATION_SCHEMA,
10174 oid: oid::VIEW_TABLE_PRIVILEGES_OID,
10175 desc: RelationDesc::builder()
10176 .with_column("grantor", SqlScalarType::String.nullable(false))
10177 .with_column("grantee", SqlScalarType::String.nullable(true))
10178 .with_column("table_catalog", SqlScalarType::String.nullable(true))
10179 .with_column("table_schema", SqlScalarType::String.nullable(false))
10180 .with_column("table_name", SqlScalarType::String.nullable(false))
10181 .with_column("privilege_type", SqlScalarType::String.nullable(true))
10182 .with_column("is_grantable", SqlScalarType::String.nullable(false))
10183 .with_column("with_hierarchy", SqlScalarType::String.nullable(false))
10184 .finish(),
10185 column_comments: BTreeMap::new(),
10186 sql: "
10187SELECT
10188 grantor,
10189 grantee,
10190 table_catalog,
10191 table_schema,
10192 table_name,
10193 privilege_type,
10194 is_grantable,
10195 CASE privilege_type
10196 WHEN 'SELECT' THEN 'YES'
10197 ELSE 'NO'
10198 END AS with_hierarchy
10199FROM
10200 (SELECT
10201 grantor.name AS grantor,
10202 CASE mz_internal.mz_aclitem_grantee(privileges)
10203 WHEN 'p' THEN 'PUBLIC'
10204 ELSE grantee.name
10205 END AS grantee,
10206 table_catalog,
10207 table_schema,
10208 table_name,
10209 unnest(mz_internal.mz_format_privileges(mz_internal.mz_aclitem_privileges(privileges))) AS privilege_type,
10210 -- ADMIN OPTION isn't implemented.
10211 'NO' AS is_grantable
10212 FROM
10213 (SELECT
10214 unnest(relations.privileges) AS privileges,
10215 CASE
10216 WHEN schemas.database_id IS NULL THEN current_database()
10217 ELSE databases.name
10218 END AS table_catalog,
10219 schemas.name AS table_schema,
10220 relations.name AS table_name
10221 FROM mz_catalog.mz_relations AS relations
10222 JOIN mz_catalog.mz_schemas AS schemas ON relations.schema_id = schemas.id
10223 LEFT JOIN mz_catalog.mz_databases AS databases ON schemas.database_id = databases.id
10224 WHERE schemas.database_id IS NULL OR databases.name = current_database())
10225 JOIN mz_catalog.mz_roles AS grantor ON mz_internal.mz_aclitem_grantor(privileges) = grantor.id
10226 LEFT JOIN mz_catalog.mz_roles AS grantee ON mz_internal.mz_aclitem_grantee(privileges) = grantee.id)
10227WHERE
10228 -- WHERE clause is not guaranteed to short-circuit and 'PUBLIC' will cause an error when passed
10229 -- to pg_has_role. Therefore we need to use a CASE statement.
10230 CASE
10231 WHEN grantee = 'PUBLIC' THEN true
10232 ELSE mz_catalog.mz_is_superuser()
10233 OR pg_has_role(current_role, grantee, 'USAGE')
10234 OR pg_has_role(current_role, grantor, 'USAGE')
10235 END",
10236 access: vec![PUBLIC_SELECT],
10237 }
10238});
10239
10240pub static INFORMATION_SCHEMA_TRIGGERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10241 name: "triggers",
10242 schema: INFORMATION_SCHEMA,
10243 oid: oid::VIEW_TRIGGERS_OID,
10244 desc: RelationDesc::builder()
10245 .with_column("trigger_catalog", SqlScalarType::String.nullable(false))
10246 .with_column("trigger_schema", SqlScalarType::String.nullable(false))
10247 .with_column("trigger_name", SqlScalarType::String.nullable(false))
10248 .with_column("event_manipulation", SqlScalarType::String.nullable(false))
10249 .with_column(
10250 "event_object_catalog",
10251 SqlScalarType::String.nullable(false),
10252 )
10253 .with_column("event_object_schema", SqlScalarType::String.nullable(false))
10254 .with_column("event_object_table", SqlScalarType::String.nullable(false))
10255 .with_column("action_order", SqlScalarType::Int32.nullable(false))
10256 .with_column("action_condition", SqlScalarType::String.nullable(false))
10257 .with_column("action_statement", SqlScalarType::String.nullable(false))
10258 .with_column("action_orientation", SqlScalarType::String.nullable(false))
10259 .with_column("action_timing", SqlScalarType::String.nullable(false))
10260 .with_column(
10261 "action_reference_old_table",
10262 SqlScalarType::String.nullable(false),
10263 )
10264 .with_column(
10265 "action_reference_new_table",
10266 SqlScalarType::String.nullable(false),
10267 )
10268 .with_key(vec![])
10269 .finish(),
10270 column_comments: BTreeMap::new(),
10271 sql: "SELECT
10272 NULL::text as trigger_catalog,
10273 NULL::text AS trigger_schema,
10274 NULL::text AS trigger_name,
10275 NULL::text AS event_manipulation,
10276 NULL::text AS event_object_catalog,
10277 NULL::text AS event_object_schema,
10278 NULL::text AS event_object_table,
10279 NULL::integer AS action_order,
10280 NULL::text AS action_condition,
10281 NULL::text AS action_statement,
10282 NULL::text AS action_orientation,
10283 NULL::text AS action_timing,
10284 NULL::text AS action_reference_old_table,
10285 NULL::text AS action_reference_new_table
10286WHERE FALSE",
10287 access: vec![PUBLIC_SELECT],
10288});
10289
10290pub static INFORMATION_SCHEMA_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10291 name: "views",
10292 schema: INFORMATION_SCHEMA,
10293 oid: oid::VIEW_VIEWS_OID,
10294 desc: RelationDesc::builder()
10295 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10296 .with_column("table_schema", SqlScalarType::String.nullable(false))
10297 .with_column("table_name", SqlScalarType::String.nullable(false))
10298 .with_column("view_definition", SqlScalarType::String.nullable(false))
10299 .finish(),
10300 column_comments: BTreeMap::new(),
10301 sql: "SELECT
10302 current_database() as table_catalog,
10303 s.name AS table_schema,
10304 v.name AS table_name,
10305 v.definition AS view_definition
10306FROM mz_catalog.mz_views v
10307JOIN mz_catalog.mz_schemas s ON s.id = v.schema_id
10308LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10309WHERE s.database_id IS NULL OR d.name = current_database()",
10310 access: vec![PUBLIC_SELECT],
10311});
10312
10313pub static INFORMATION_SCHEMA_CHARACTER_SETS: LazyLock<BuiltinView> =
10314 LazyLock::new(|| BuiltinView {
10315 name: "character_sets",
10316 schema: INFORMATION_SCHEMA,
10317 oid: oid::VIEW_CHARACTER_SETS_OID,
10318 desc: RelationDesc::builder()
10319 .with_column(
10320 "character_set_catalog",
10321 SqlScalarType::String.nullable(true),
10322 )
10323 .with_column("character_set_schema", SqlScalarType::String.nullable(true))
10324 .with_column("character_set_name", SqlScalarType::String.nullable(false))
10325 .with_column(
10326 "character_repertoire",
10327 SqlScalarType::String.nullable(false),
10328 )
10329 .with_column("form_of_use", SqlScalarType::String.nullable(false))
10330 .with_column(
10331 "default_collate_catalog",
10332 SqlScalarType::String.nullable(false),
10333 )
10334 .with_column(
10335 "default_collate_schema",
10336 SqlScalarType::String.nullable(false),
10337 )
10338 .with_column(
10339 "default_collate_name",
10340 SqlScalarType::String.nullable(false),
10341 )
10342 .with_key(vec![])
10343 .finish(),
10344 column_comments: BTreeMap::new(),
10345 sql: "SELECT
10346 NULL as character_set_catalog,
10347 NULL as character_set_schema,
10348 'UTF8' as character_set_name,
10349 'UCS' as character_repertoire,
10350 'UTF8' as form_of_use,
10351 current_database() as default_collate_catalog,
10352 'pg_catalog' as default_collate_schema,
10353 'en_US.utf8' as default_collate_name",
10354 access: vec![PUBLIC_SELECT],
10355 });
10356
10357pub static PG_COLLATION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10360 name: "pg_collation",
10361 schema: PG_CATALOG_SCHEMA,
10362 oid: oid::VIEW_PG_COLLATION_OID,
10363 desc: RelationDesc::builder()
10364 .with_column("oid", SqlScalarType::Oid.nullable(false))
10365 .with_column("collname", SqlScalarType::String.nullable(false))
10366 .with_column("collnamespace", SqlScalarType::Oid.nullable(false))
10367 .with_column("collowner", SqlScalarType::Oid.nullable(false))
10368 .with_column("collprovider", SqlScalarType::PgLegacyChar.nullable(false))
10369 .with_column("collisdeterministic", SqlScalarType::Bool.nullable(false))
10370 .with_column("collencoding", SqlScalarType::Int32.nullable(false))
10371 .with_column("collcollate", SqlScalarType::String.nullable(false))
10372 .with_column("collctype", SqlScalarType::String.nullable(false))
10373 .with_column("collversion", SqlScalarType::String.nullable(false))
10374 .with_key(vec![])
10375 .finish(),
10376 column_comments: BTreeMap::new(),
10377 sql: "
10378SELECT
10379 NULL::pg_catalog.oid AS oid,
10380 NULL::pg_catalog.text AS collname,
10381 NULL::pg_catalog.oid AS collnamespace,
10382 NULL::pg_catalog.oid AS collowner,
10383 NULL::pg_catalog.\"char\" AS collprovider,
10384 NULL::pg_catalog.bool AS collisdeterministic,
10385 NULL::pg_catalog.int4 AS collencoding,
10386 NULL::pg_catalog.text AS collcollate,
10387 NULL::pg_catalog.text AS collctype,
10388 NULL::pg_catalog.text AS collversion
10389WHERE false",
10390 access: vec![PUBLIC_SELECT],
10391});
10392
10393pub static PG_POLICY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10395 name: "pg_policy",
10396 schema: PG_CATALOG_SCHEMA,
10397 oid: oid::VIEW_PG_POLICY_OID,
10398 desc: RelationDesc::builder()
10399 .with_column("oid", SqlScalarType::Oid.nullable(false))
10400 .with_column("polname", SqlScalarType::String.nullable(false))
10401 .with_column("polrelid", SqlScalarType::Oid.nullable(false))
10402 .with_column("polcmd", SqlScalarType::PgLegacyChar.nullable(false))
10403 .with_column("polpermissive", SqlScalarType::Bool.nullable(false))
10404 .with_column(
10405 "polroles",
10406 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
10407 )
10408 .with_column("polqual", SqlScalarType::String.nullable(false))
10409 .with_column("polwithcheck", SqlScalarType::String.nullable(false))
10410 .with_key(vec![])
10411 .finish(),
10412 column_comments: BTreeMap::new(),
10413 sql: "
10414SELECT
10415 NULL::pg_catalog.oid AS oid,
10416 NULL::pg_catalog.text AS polname,
10417 NULL::pg_catalog.oid AS polrelid,
10418 NULL::pg_catalog.\"char\" AS polcmd,
10419 NULL::pg_catalog.bool AS polpermissive,
10420 NULL::pg_catalog.oid[] AS polroles,
10421 NULL::pg_catalog.text AS polqual,
10422 NULL::pg_catalog.text AS polwithcheck
10423WHERE false",
10424 access: vec![PUBLIC_SELECT],
10425});
10426
10427pub static PG_INHERITS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10429 name: "pg_inherits",
10430 schema: PG_CATALOG_SCHEMA,
10431 oid: oid::VIEW_PG_INHERITS_OID,
10432 desc: RelationDesc::builder()
10433 .with_column("inhrelid", SqlScalarType::Oid.nullable(false))
10434 .with_column("inhparent", SqlScalarType::Oid.nullable(false))
10435 .with_column("inhseqno", SqlScalarType::Int32.nullable(false))
10436 .with_column("inhdetachpending", SqlScalarType::Bool.nullable(false))
10437 .with_key(vec![])
10438 .finish(),
10439 column_comments: BTreeMap::new(),
10440 sql: "
10441SELECT
10442 NULL::pg_catalog.oid AS inhrelid,
10443 NULL::pg_catalog.oid AS inhparent,
10444 NULL::pg_catalog.int4 AS inhseqno,
10445 NULL::pg_catalog.bool AS inhdetachpending
10446WHERE false",
10447 access: vec![PUBLIC_SELECT],
10448});
10449
10450pub static PG_LOCKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10451 name: "pg_locks",
10452 schema: PG_CATALOG_SCHEMA,
10453 oid: oid::VIEW_PG_LOCKS_OID,
10454 desc: RelationDesc::builder()
10455 .with_column("locktype", SqlScalarType::String.nullable(false))
10456 .with_column("database", SqlScalarType::Oid.nullable(false))
10457 .with_column("relation", SqlScalarType::Oid.nullable(false))
10458 .with_column("page", SqlScalarType::Int32.nullable(false))
10459 .with_column("tuple", SqlScalarType::Int16.nullable(false))
10460 .with_column("virtualxid", SqlScalarType::String.nullable(false))
10461 .with_column("transactionid", SqlScalarType::String.nullable(false))
10462 .with_column("classid", SqlScalarType::Oid.nullable(false))
10463 .with_column("objid", SqlScalarType::Oid.nullable(false))
10464 .with_column("objsubid", SqlScalarType::Int16.nullable(false))
10465 .with_column("virtualtransaction", SqlScalarType::String.nullable(false))
10466 .with_column("pid", SqlScalarType::Int32.nullable(false))
10467 .with_column("mode", SqlScalarType::String.nullable(false))
10468 .with_column("granted", SqlScalarType::Bool.nullable(false))
10469 .with_column("fastpath", SqlScalarType::Bool.nullable(false))
10470 .with_column(
10471 "waitstart",
10472 SqlScalarType::TimestampTz { precision: None }.nullable(false),
10473 )
10474 .with_key(vec![])
10475 .finish(),
10476 column_comments: BTreeMap::new(),
10477 sql: "
10478SELECT
10479-- While there exist locks in Materialize, we don't expose them, so all of these fields are NULL.
10480 NULL::pg_catalog.text AS locktype,
10481 NULL::pg_catalog.oid AS database,
10482 NULL::pg_catalog.oid AS relation,
10483 NULL::pg_catalog.int4 AS page,
10484 NULL::pg_catalog.int2 AS tuple,
10485 NULL::pg_catalog.text AS virtualxid,
10486 NULL::pg_catalog.text AS transactionid,
10487 NULL::pg_catalog.oid AS classid,
10488 NULL::pg_catalog.oid AS objid,
10489 NULL::pg_catalog.int2 AS objsubid,
10490 NULL::pg_catalog.text AS virtualtransaction,
10491 NULL::pg_catalog.int4 AS pid,
10492 NULL::pg_catalog.text AS mode,
10493 NULL::pg_catalog.bool AS granted,
10494 NULL::pg_catalog.bool AS fastpath,
10495 NULL::pg_catalog.timestamptz AS waitstart
10496WHERE false",
10497 access: vec![PUBLIC_SELECT],
10498});
10499
10500pub static PG_AUTHID: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10501 name: "pg_authid",
10502 schema: PG_CATALOG_SCHEMA,
10503 oid: oid::VIEW_PG_AUTHID_OID,
10504 desc: RelationDesc::builder()
10505 .with_column("oid", SqlScalarType::Oid.nullable(false))
10506 .with_column("rolname", SqlScalarType::String.nullable(false))
10507 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
10508 .with_column("rolinherit", SqlScalarType::Bool.nullable(false))
10509 .with_column("rolcreaterole", SqlScalarType::Bool.nullable(true))
10510 .with_column("rolcreatedb", SqlScalarType::Bool.nullable(true))
10511 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(false))
10512 .with_column("rolreplication", SqlScalarType::Bool.nullable(false))
10513 .with_column("rolbypassrls", SqlScalarType::Bool.nullable(false))
10514 .with_column("rolconnlimit", SqlScalarType::Int32.nullable(false))
10515 .with_column("rolpassword", SqlScalarType::String.nullable(false))
10516 .with_column(
10517 "rolvaliduntil",
10518 SqlScalarType::TimestampTz { precision: None }.nullable(true),
10519 )
10520 .finish(),
10521 column_comments: BTreeMap::new(),
10522 sql: r#"
10523SELECT
10524 r.oid AS oid,
10525 r.name AS rolname,
10526 -- We determine superuser status each time a role logs in, so there's no way to accurately
10527 -- depict this in the catalog. Except for mz_system, which is always a superuser. For all other
10528 -- roles we hardcode NULL.
10529 CASE
10530 WHEN r.name = 'mz_system' THEN true
10531 ELSE NULL::pg_catalog.bool
10532 END AS rolsuper,
10533 inherit AS rolinherit,
10534 mz_catalog.has_system_privilege(r.oid, 'CREATEROLE') AS rolcreaterole,
10535 mz_catalog.has_system_privilege(r.oid, 'CREATEDB') AS rolcreatedb,
10536 -- We determine login status each time a role logs in, so there's no clean
10537 -- way to accurately determine this in the catalog. Instead we do something
10538 -- a little gross. For system roles, we hardcode the known roles that can
10539 -- log in. For user roles, we determine `rolcanlogin` based on whether the
10540 -- role name looks like an email address.
10541 --
10542 -- This works for the vast majority of cases in production. Roles that users
10543 -- log in to come from Frontegg and therefore *must* be valid email
10544 -- addresses, while roles that are created via `CREATE ROLE` (e.g.,
10545 -- `admin`, `prod_app`) almost certainly are not named to look like email
10546 -- addresses.
10547 --
10548 -- For the moment, we're comfortable with the edge cases here. If we discover
10549 -- that folks are regularly creating non-login roles with names that look
10550 -- like an email address (e.g., `admins@sysops.foocorp`), we can change
10551 -- course.
10552 (
10553 r.name IN ('mz_support', 'mz_system')
10554 -- This entire scheme is sloppy, so we intentionally use a simple
10555 -- regex to match email addresses, rather than one that perfectly
10556 -- matches the RFC on what constitutes a valid email address.
10557 OR r.name ~ '^[^@]+@[^@]+\.[^@]+$'
10558 ) AS rolcanlogin,
10559 -- MZ doesn't support replication in the same way Postgres does
10560 false AS rolreplication,
10561 -- MZ doesn't how row level security
10562 false AS rolbypassrls,
10563 -- MZ doesn't have a connection limit
10564 -1 AS rolconnlimit,
10565 '********'::pg_catalog.text AS rolpassword,
10566 -- MZ doesn't have role passwords
10567 NULL::pg_catalog.timestamptz AS rolvaliduntil
10568FROM mz_catalog.mz_roles r"#,
10569 access: vec![PUBLIC_SELECT],
10570});
10571
10572pub static PG_AGGREGATE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10573 name: "pg_aggregate",
10574 schema: PG_CATALOG_SCHEMA,
10575 oid: oid::VIEW_PG_AGGREGATE_OID,
10576 desc: RelationDesc::builder()
10577 .with_column("aggfnoid", SqlScalarType::Oid.nullable(false))
10578 .with_column("aggkind", SqlScalarType::String.nullable(false))
10579 .with_column("aggnumdirectargs", SqlScalarType::Int16.nullable(false))
10580 .with_column("aggtransfn", SqlScalarType::RegProc.nullable(true))
10581 .with_column("aggfinalfn", SqlScalarType::RegProc.nullable(false))
10582 .with_column("aggcombinefn", SqlScalarType::RegProc.nullable(false))
10583 .with_column("aggserialfn", SqlScalarType::RegProc.nullable(false))
10584 .with_column("aggdeserialfn", SqlScalarType::RegProc.nullable(false))
10585 .with_column("aggmtransfn", SqlScalarType::RegProc.nullable(false))
10586 .with_column("aggminvtransfn", SqlScalarType::RegProc.nullable(false))
10587 .with_column("aggmfinalfn", SqlScalarType::RegProc.nullable(false))
10588 .with_column("aggfinalextra", SqlScalarType::Bool.nullable(false))
10589 .with_column("aggmfinalextra", SqlScalarType::Bool.nullable(false))
10590 .with_column("aggfinalmodify", SqlScalarType::PgLegacyChar.nullable(true))
10591 .with_column(
10592 "aggmfinalmodify",
10593 SqlScalarType::PgLegacyChar.nullable(true),
10594 )
10595 .with_column("aggsortop", SqlScalarType::Oid.nullable(false))
10596 .with_column("aggtranstype", SqlScalarType::Oid.nullable(true))
10597 .with_column("aggtransspace", SqlScalarType::Int32.nullable(true))
10598 .with_column("aggmtranstype", SqlScalarType::Oid.nullable(false))
10599 .with_column("aggmtransspace", SqlScalarType::Int32.nullable(true))
10600 .with_column("agginitval", SqlScalarType::String.nullable(true))
10601 .with_column("aggminitval", SqlScalarType::String.nullable(true))
10602 .finish(),
10603 column_comments: BTreeMap::new(),
10604 sql: "SELECT
10605 a.oid as aggfnoid,
10606 -- Currently Materialize only support 'normal' aggregate functions.
10607 a.agg_kind as aggkind,
10608 a.agg_num_direct_args as aggnumdirectargs,
10609 -- Materialize doesn't support these fields.
10610 NULL::pg_catalog.regproc as aggtransfn,
10611 '0'::pg_catalog.regproc as aggfinalfn,
10612 '0'::pg_catalog.regproc as aggcombinefn,
10613 '0'::pg_catalog.regproc as aggserialfn,
10614 '0'::pg_catalog.regproc as aggdeserialfn,
10615 '0'::pg_catalog.regproc as aggmtransfn,
10616 '0'::pg_catalog.regproc as aggminvtransfn,
10617 '0'::pg_catalog.regproc as aggmfinalfn,
10618 false as aggfinalextra,
10619 false as aggmfinalextra,
10620 NULL::pg_catalog.\"char\" AS aggfinalmodify,
10621 NULL::pg_catalog.\"char\" AS aggmfinalmodify,
10622 '0'::pg_catalog.oid as aggsortop,
10623 NULL::pg_catalog.oid as aggtranstype,
10624 NULL::pg_catalog.int4 as aggtransspace,
10625 '0'::pg_catalog.oid as aggmtranstype,
10626 NULL::pg_catalog.int4 as aggmtransspace,
10627 NULL::pg_catalog.text as agginitval,
10628 NULL::pg_catalog.text as aggminitval
10629FROM mz_internal.mz_aggregates a",
10630 access: vec![PUBLIC_SELECT],
10631});
10632
10633pub static PG_TRIGGER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10634 name: "pg_trigger",
10635 schema: PG_CATALOG_SCHEMA,
10636 oid: oid::VIEW_PG_TRIGGER_OID,
10637 desc: RelationDesc::builder()
10638 .with_column("oid", SqlScalarType::Oid.nullable(false))
10639 .with_column("tgrelid", SqlScalarType::Oid.nullable(false))
10640 .with_column("tgparentid", SqlScalarType::Oid.nullable(false))
10641 .with_column("tgname", SqlScalarType::String.nullable(false))
10642 .with_column("tgfoid", SqlScalarType::Oid.nullable(false))
10643 .with_column("tgtype", SqlScalarType::Int16.nullable(false))
10644 .with_column("tgenabled", SqlScalarType::PgLegacyChar.nullable(false))
10645 .with_column("tgisinternal", SqlScalarType::Bool.nullable(false))
10646 .with_column("tgconstrrelid", SqlScalarType::Oid.nullable(false))
10647 .with_column("tgconstrindid", SqlScalarType::Oid.nullable(false))
10648 .with_column("tgconstraint", SqlScalarType::Oid.nullable(false))
10649 .with_column("tgdeferrable", SqlScalarType::Bool.nullable(false))
10650 .with_column("tginitdeferred", SqlScalarType::Bool.nullable(false))
10651 .with_column("tgnargs", SqlScalarType::Int16.nullable(false))
10652 .with_column("tgattr", SqlScalarType::Int2Vector.nullable(false))
10653 .with_column("tgargs", SqlScalarType::Bytes.nullable(false))
10654 .with_column("tgqual", SqlScalarType::String.nullable(false))
10655 .with_column("tgoldtable", SqlScalarType::String.nullable(false))
10656 .with_column("tgnewtable", SqlScalarType::String.nullable(false))
10657 .with_key(vec![])
10658 .finish(),
10659 column_comments: BTreeMap::new(),
10660 sql: "SELECT
10661 -- MZ doesn't support triggers so all of these fields are NULL.
10662 NULL::pg_catalog.oid AS oid,
10663 NULL::pg_catalog.oid AS tgrelid,
10664 NULL::pg_catalog.oid AS tgparentid,
10665 NULL::pg_catalog.text AS tgname,
10666 NULL::pg_catalog.oid AS tgfoid,
10667 NULL::pg_catalog.int2 AS tgtype,
10668 NULL::pg_catalog.\"char\" AS tgenabled,
10669 NULL::pg_catalog.bool AS tgisinternal,
10670 NULL::pg_catalog.oid AS tgconstrrelid,
10671 NULL::pg_catalog.oid AS tgconstrindid,
10672 NULL::pg_catalog.oid AS tgconstraint,
10673 NULL::pg_catalog.bool AS tgdeferrable,
10674 NULL::pg_catalog.bool AS tginitdeferred,
10675 NULL::pg_catalog.int2 AS tgnargs,
10676 NULL::pg_catalog.int2vector AS tgattr,
10677 NULL::pg_catalog.bytea AS tgargs,
10678 -- NOTE: The tgqual column is actually type `pg_node_tree` which we don't support. CockroachDB
10679 -- uses text as a placeholder, so we'll follow their lead here.
10680 NULL::pg_catalog.text AS tgqual,
10681 NULL::pg_catalog.text AS tgoldtable,
10682 NULL::pg_catalog.text AS tgnewtable
10683WHERE false
10684 ",
10685 access: vec![PUBLIC_SELECT],
10686});
10687
10688pub static PG_REWRITE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10689 name: "pg_rewrite",
10690 schema: PG_CATALOG_SCHEMA,
10691 oid: oid::VIEW_PG_REWRITE_OID,
10692 desc: RelationDesc::builder()
10693 .with_column("oid", SqlScalarType::Oid.nullable(false))
10694 .with_column("rulename", SqlScalarType::String.nullable(false))
10695 .with_column("ev_class", SqlScalarType::Oid.nullable(false))
10696 .with_column("ev_type", SqlScalarType::PgLegacyChar.nullable(false))
10697 .with_column("ev_enabled", SqlScalarType::PgLegacyChar.nullable(false))
10698 .with_column("is_instead", SqlScalarType::Bool.nullable(false))
10699 .with_column("ev_qual", SqlScalarType::String.nullable(false))
10700 .with_column("ev_action", SqlScalarType::String.nullable(false))
10701 .with_key(vec![])
10702 .finish(),
10703 column_comments: BTreeMap::new(),
10704 sql: "SELECT
10705 -- MZ doesn't support rewrite rules so all of these fields are NULL.
10706 NULL::pg_catalog.oid AS oid,
10707 NULL::pg_catalog.text AS rulename,
10708 NULL::pg_catalog.oid AS ev_class,
10709 NULL::pg_catalog.\"char\" AS ev_type,
10710 NULL::pg_catalog.\"char\" AS ev_enabled,
10711 NULL::pg_catalog.bool AS is_instead,
10712 -- NOTE: The ev_qual and ev_action columns are actually type `pg_node_tree` which we don't
10713 -- support. CockroachDB uses text as a placeholder, so we'll follow their lead here.
10714 NULL::pg_catalog.text AS ev_qual,
10715 NULL::pg_catalog.text AS ev_action
10716WHERE false
10717 ",
10718 access: vec![PUBLIC_SELECT],
10719});
10720
10721pub static PG_EXTENSION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10722 name: "pg_extension",
10723 schema: PG_CATALOG_SCHEMA,
10724 oid: oid::VIEW_PG_EXTENSION_OID,
10725 desc: RelationDesc::builder()
10726 .with_column("oid", SqlScalarType::Oid.nullable(false))
10727 .with_column("extname", SqlScalarType::String.nullable(false))
10728 .with_column("extowner", SqlScalarType::Oid.nullable(false))
10729 .with_column("extnamespace", SqlScalarType::Oid.nullable(false))
10730 .with_column("extrelocatable", SqlScalarType::Bool.nullable(false))
10731 .with_column("extversion", SqlScalarType::String.nullable(false))
10732 .with_column(
10733 "extconfig",
10734 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
10735 )
10736 .with_column(
10737 "extcondition",
10738 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
10739 )
10740 .with_key(vec![])
10741 .finish(),
10742 column_comments: BTreeMap::new(),
10743 sql: "SELECT
10744 -- MZ doesn't support extensions so all of these fields are NULL.
10745 NULL::pg_catalog.oid AS oid,
10746 NULL::pg_catalog.text AS extname,
10747 NULL::pg_catalog.oid AS extowner,
10748 NULL::pg_catalog.oid AS extnamespace,
10749 NULL::pg_catalog.bool AS extrelocatable,
10750 NULL::pg_catalog.text AS extversion,
10751 NULL::pg_catalog.oid[] AS extconfig,
10752 NULL::pg_catalog.text[] AS extcondition
10753WHERE false
10754 ",
10755 access: vec![PUBLIC_SELECT],
10756});
10757
10758pub static MZ_SHOW_ALL_OBJECTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10759 name: "mz_show_all_objects",
10760 schema: MZ_INTERNAL_SCHEMA,
10761 oid: oid::VIEW_MZ_SHOW_ALL_OBJECTS_OID,
10762 desc: RelationDesc::builder()
10763 .with_column("schema_id", SqlScalarType::String.nullable(false))
10764 .with_column("name", SqlScalarType::String.nullable(false))
10765 .with_column("type", SqlScalarType::String.nullable(false))
10766 .with_column("comment", SqlScalarType::String.nullable(false))
10767 .finish(),
10768 column_comments: BTreeMap::new(),
10769 sql: "WITH comments AS (
10770 SELECT id, object_type, comment
10771 FROM mz_internal.mz_comments
10772 WHERE object_sub_id IS NULL
10773 )
10774 SELECT schema_id, name, type, COALESCE(comment, '') AS comment
10775 FROM mz_catalog.mz_objects AS objs
10776 LEFT JOIN comments ON objs.id = comments.id
10777 WHERE (comments.object_type = objs.type OR comments.object_type IS NULL)",
10778 access: vec![PUBLIC_SELECT],
10779});
10780
10781pub static MZ_SHOW_CLUSTERS: LazyLock<BuiltinView> = LazyLock::new(|| {
10782 BuiltinView {
10783 name: "mz_show_clusters",
10784 schema: MZ_INTERNAL_SCHEMA,
10785 oid: oid::VIEW_MZ_SHOW_CLUSTERS_OID,
10786 desc: RelationDesc::builder()
10787 .with_column("name", SqlScalarType::String.nullable(false))
10788 .with_column("replicas", SqlScalarType::String.nullable(true))
10789 .with_column("comment", SqlScalarType::String.nullable(false))
10790 .finish(),
10791 column_comments: BTreeMap::new(),
10792 sql: "
10793 WITH clusters AS (
10794 SELECT
10795 mc.id,
10796 mc.name,
10797 pg_catalog.string_agg(mcr.name || ' (' || mcr.size || ')', ', ' ORDER BY mcr.name) AS replicas
10798 FROM mz_catalog.mz_clusters mc
10799 LEFT JOIN mz_catalog.mz_cluster_replicas mcr
10800 ON mc.id = mcr.cluster_id
10801 GROUP BY mc.id, mc.name
10802 ),
10803 comments AS (
10804 SELECT id, comment
10805 FROM mz_internal.mz_comments
10806 WHERE object_type = 'cluster' AND object_sub_id IS NULL
10807 )
10808 SELECT name, replicas, COALESCE(comment, '') as comment
10809 FROM clusters
10810 LEFT JOIN comments ON clusters.id = comments.id",
10811 access: vec![PUBLIC_SELECT],
10812}
10813});
10814
10815pub static MZ_SHOW_SECRETS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10816 name: "mz_show_secrets",
10817 schema: MZ_INTERNAL_SCHEMA,
10818 oid: oid::VIEW_MZ_SHOW_SECRETS_OID,
10819 desc: RelationDesc::builder()
10820 .with_column("schema_id", SqlScalarType::String.nullable(false))
10821 .with_column("name", SqlScalarType::String.nullable(false))
10822 .with_column("comment", SqlScalarType::String.nullable(false))
10823 .finish(),
10824 column_comments: BTreeMap::new(),
10825 sql: "WITH comments AS (
10826 SELECT id, comment
10827 FROM mz_internal.mz_comments
10828 WHERE object_type = 'secret' AND object_sub_id IS NULL
10829 )
10830 SELECT schema_id, name, COALESCE(comment, '') as comment
10831 FROM mz_catalog.mz_secrets secrets
10832 LEFT JOIN comments ON secrets.id = comments.id",
10833 access: vec![PUBLIC_SELECT],
10834});
10835
10836pub static MZ_SHOW_COLUMNS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10837 name: "mz_show_columns",
10838 schema: MZ_INTERNAL_SCHEMA,
10839 oid: oid::VIEW_MZ_SHOW_COLUMNS_OID,
10840 desc: RelationDesc::builder()
10841 .with_column("id", SqlScalarType::String.nullable(false))
10842 .with_column("name", SqlScalarType::String.nullable(false))
10843 .with_column("nullable", SqlScalarType::Bool.nullable(false))
10844 .with_column("type", SqlScalarType::String.nullable(false))
10845 .with_column("position", SqlScalarType::UInt64.nullable(false))
10846 .with_column("comment", SqlScalarType::String.nullable(false))
10847 .finish(),
10848 column_comments: BTreeMap::new(),
10849 sql: "
10850 SELECT columns.id, name, nullable, type, position, COALESCE(comment, '') as comment
10851 FROM mz_catalog.mz_columns columns
10852 LEFT JOIN mz_internal.mz_comments comments
10853 ON columns.id = comments.id AND columns.position = comments.object_sub_id",
10854 access: vec![PUBLIC_SELECT],
10855});
10856
10857pub static MZ_SHOW_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10858 name: "mz_show_databases",
10859 schema: MZ_INTERNAL_SCHEMA,
10860 oid: oid::VIEW_MZ_SHOW_DATABASES_OID,
10861 desc: RelationDesc::builder()
10862 .with_column("name", SqlScalarType::String.nullable(false))
10863 .with_column("comment", SqlScalarType::String.nullable(false))
10864 .finish(),
10865 column_comments: BTreeMap::new(),
10866 sql: "WITH comments AS (
10867 SELECT id, comment
10868 FROM mz_internal.mz_comments
10869 WHERE object_type = 'database' AND object_sub_id IS NULL
10870 )
10871 SELECT name, COALESCE(comment, '') as comment
10872 FROM mz_catalog.mz_databases databases
10873 LEFT JOIN comments ON databases.id = comments.id",
10874 access: vec![PUBLIC_SELECT],
10875});
10876
10877pub static MZ_SHOW_SCHEMAS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10878 name: "mz_show_schemas",
10879 schema: MZ_INTERNAL_SCHEMA,
10880 oid: oid::VIEW_MZ_SHOW_SCHEMAS_OID,
10881 desc: RelationDesc::builder()
10882 .with_column("database_id", SqlScalarType::String.nullable(true))
10883 .with_column("name", SqlScalarType::String.nullable(false))
10884 .with_column("comment", SqlScalarType::String.nullable(false))
10885 .finish(),
10886 column_comments: BTreeMap::new(),
10887 sql: "WITH comments AS (
10888 SELECT id, comment
10889 FROM mz_internal.mz_comments
10890 WHERE object_type = 'schema' AND object_sub_id IS NULL
10891 )
10892 SELECT database_id, name, COALESCE(comment, '') as comment
10893 FROM mz_catalog.mz_schemas schemas
10894 LEFT JOIN comments ON schemas.id = comments.id",
10895 access: vec![PUBLIC_SELECT],
10896});
10897
10898pub static MZ_SHOW_ROLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10899 name: "mz_show_roles",
10900 schema: MZ_INTERNAL_SCHEMA,
10901 oid: oid::VIEW_MZ_SHOW_ROLES_OID,
10902 desc: RelationDesc::builder()
10903 .with_column("name", SqlScalarType::String.nullable(false))
10904 .with_column("comment", SqlScalarType::String.nullable(false))
10905 .finish(),
10906 column_comments: BTreeMap::new(),
10907 sql: "WITH comments AS (
10908 SELECT id, comment
10909 FROM mz_internal.mz_comments
10910 WHERE object_type = 'role' AND object_sub_id IS NULL
10911 )
10912 SELECT name, COALESCE(comment, '') as comment
10913 FROM mz_catalog.mz_roles roles
10914 LEFT JOIN comments ON roles.id = comments.id
10915 WHERE roles.id NOT LIKE 's%'
10916 AND roles.id NOT LIKE 'g%'",
10917 access: vec![PUBLIC_SELECT],
10918});
10919
10920pub static MZ_SHOW_TABLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10921 name: "mz_show_tables",
10922 schema: MZ_INTERNAL_SCHEMA,
10923 oid: oid::VIEW_MZ_SHOW_TABLES_OID,
10924 desc: RelationDesc::builder()
10925 .with_column("schema_id", SqlScalarType::String.nullable(false))
10926 .with_column("name", SqlScalarType::String.nullable(false))
10927 .with_column("comment", SqlScalarType::String.nullable(false))
10928 .with_column("source_id", SqlScalarType::String.nullable(true))
10929 .finish(),
10930 column_comments: BTreeMap::new(),
10931 sql: "WITH comments AS (
10932 SELECT id, comment
10933 FROM mz_internal.mz_comments
10934 WHERE object_type = 'table' AND object_sub_id IS NULL
10935 )
10936 SELECT schema_id, name, COALESCE(comment, '') as comment, source_id
10937 FROM mz_catalog.mz_tables tables
10938 LEFT JOIN comments ON tables.id = comments.id",
10939 access: vec![PUBLIC_SELECT],
10940});
10941
10942pub static MZ_SHOW_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10943 name: "mz_show_views",
10944 schema: MZ_INTERNAL_SCHEMA,
10945 oid: oid::VIEW_MZ_SHOW_VIEWS_OID,
10946 desc: RelationDesc::builder()
10947 .with_column("schema_id", SqlScalarType::String.nullable(false))
10948 .with_column("name", SqlScalarType::String.nullable(false))
10949 .with_column("comment", SqlScalarType::String.nullable(false))
10950 .finish(),
10951 column_comments: BTreeMap::new(),
10952 sql: "WITH comments AS (
10953 SELECT id, comment
10954 FROM mz_internal.mz_comments
10955 WHERE object_type = 'view' AND object_sub_id IS NULL
10956 )
10957 SELECT schema_id, name, COALESCE(comment, '') as comment
10958 FROM mz_catalog.mz_views views
10959 LEFT JOIN comments ON views.id = comments.id",
10960 access: vec![PUBLIC_SELECT],
10961});
10962
10963pub static MZ_SHOW_TYPES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10964 name: "mz_show_types",
10965 schema: MZ_INTERNAL_SCHEMA,
10966 oid: oid::VIEW_MZ_SHOW_TYPES_OID,
10967 desc: RelationDesc::builder()
10968 .with_column("schema_id", SqlScalarType::String.nullable(false))
10969 .with_column("name", SqlScalarType::String.nullable(false))
10970 .with_column("comment", SqlScalarType::String.nullable(false))
10971 .finish(),
10972 column_comments: BTreeMap::new(),
10973 sql: "WITH comments AS (
10974 SELECT id, comment
10975 FROM mz_internal.mz_comments
10976 WHERE object_type = 'type' AND object_sub_id IS NULL
10977 )
10978 SELECT schema_id, name, COALESCE(comment, '') as comment
10979 FROM mz_catalog.mz_types types
10980 LEFT JOIN comments ON types.id = comments.id",
10981 access: vec![PUBLIC_SELECT],
10982});
10983
10984pub static MZ_SHOW_CONNECTIONS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10985 name: "mz_show_connections",
10986 schema: MZ_INTERNAL_SCHEMA,
10987 oid: oid::VIEW_MZ_SHOW_CONNECTIONS_OID,
10988 desc: RelationDesc::builder()
10989 .with_column("schema_id", SqlScalarType::String.nullable(false))
10990 .with_column("name", SqlScalarType::String.nullable(false))
10991 .with_column("type", SqlScalarType::String.nullable(false))
10992 .with_column("comment", SqlScalarType::String.nullable(false))
10993 .finish(),
10994 column_comments: BTreeMap::new(),
10995 sql: "WITH comments AS (
10996 SELECT id, comment
10997 FROM mz_internal.mz_comments
10998 WHERE object_type = 'connection' AND object_sub_id IS NULL
10999 )
11000 SELECT schema_id, name, type, COALESCE(comment, '') as comment
11001 FROM mz_catalog.mz_connections connections
11002 LEFT JOIN comments ON connections.id = comments.id",
11003 access: vec![PUBLIC_SELECT],
11004});
11005
11006pub static MZ_SHOW_SOURCES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11007 name: "mz_show_sources",
11008 schema: MZ_INTERNAL_SCHEMA,
11009 oid: oid::VIEW_MZ_SHOW_SOURCES_OID,
11010 desc: RelationDesc::builder()
11011 .with_column("id", SqlScalarType::String.nullable(false))
11012 .with_column("name", SqlScalarType::String.nullable(false))
11013 .with_column("type", SqlScalarType::String.nullable(false))
11014 .with_column("cluster", SqlScalarType::String.nullable(true))
11015 .with_column("schema_id", SqlScalarType::String.nullable(false))
11016 .with_column("cluster_id", SqlScalarType::String.nullable(true))
11017 .with_column("comment", SqlScalarType::String.nullable(false))
11018 .finish(),
11019 column_comments: BTreeMap::new(),
11020 sql: "
11021WITH comments AS (
11022 SELECT id, comment
11023 FROM mz_internal.mz_comments
11024 WHERE object_type = 'source' AND object_sub_id IS NULL
11025)
11026SELECT
11027 sources.id,
11028 sources.name,
11029 sources.type,
11030 clusters.name AS cluster,
11031 schema_id,
11032 cluster_id,
11033 COALESCE(comments.comment, '') as comment
11034FROM
11035 mz_catalog.mz_sources AS sources
11036 LEFT JOIN
11037 mz_catalog.mz_clusters AS clusters
11038 ON clusters.id = sources.cluster_id
11039 LEFT JOIN comments ON sources.id = comments.id",
11040 access: vec![PUBLIC_SELECT],
11041});
11042
11043pub static MZ_SHOW_SINKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11044 name: "mz_show_sinks",
11045 schema: MZ_INTERNAL_SCHEMA,
11046 oid: oid::VIEW_MZ_SHOW_SINKS_OID,
11047 desc: RelationDesc::builder()
11048 .with_column("id", SqlScalarType::String.nullable(false))
11049 .with_column("name", SqlScalarType::String.nullable(false))
11050 .with_column("type", SqlScalarType::String.nullable(false))
11051 .with_column("cluster", SqlScalarType::String.nullable(false))
11052 .with_column("schema_id", SqlScalarType::String.nullable(false))
11053 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11054 .with_column("comment", SqlScalarType::String.nullable(false))
11055 .finish(),
11056 column_comments: BTreeMap::new(),
11057 sql: "
11058WITH comments AS (
11059 SELECT id, comment
11060 FROM mz_internal.mz_comments
11061 WHERE object_type = 'sink' AND object_sub_id IS NULL
11062)
11063SELECT
11064 sinks.id,
11065 sinks.name,
11066 sinks.type,
11067 clusters.name AS cluster,
11068 schema_id,
11069 cluster_id,
11070 COALESCE(comments.comment, '') as comment
11071FROM
11072 mz_catalog.mz_sinks AS sinks
11073 JOIN
11074 mz_catalog.mz_clusters AS clusters
11075 ON clusters.id = sinks.cluster_id
11076 LEFT JOIN comments ON sinks.id = comments.id",
11077 access: vec![PUBLIC_SELECT],
11078});
11079
11080pub static MZ_SHOW_MATERIALIZED_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11081 name: "mz_show_materialized_views",
11082 schema: MZ_INTERNAL_SCHEMA,
11083 oid: oid::VIEW_MZ_SHOW_MATERIALIZED_VIEWS_OID,
11084 desc: RelationDesc::builder()
11085 .with_column("id", SqlScalarType::String.nullable(false))
11086 .with_column("name", SqlScalarType::String.nullable(false))
11087 .with_column("cluster", SqlScalarType::String.nullable(false))
11088 .with_column("schema_id", SqlScalarType::String.nullable(false))
11089 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11090 .with_column("comment", SqlScalarType::String.nullable(false))
11091 .finish(),
11092 column_comments: BTreeMap::new(),
11093 sql: "
11094WITH comments AS (
11095 SELECT id, comment
11096 FROM mz_internal.mz_comments
11097 WHERE object_type = 'materialized-view' AND object_sub_id IS NULL
11098)
11099SELECT
11100 mviews.id as id,
11101 mviews.name,
11102 clusters.name AS cluster,
11103 schema_id,
11104 cluster_id,
11105 COALESCE(comments.comment, '') as comment
11106FROM
11107 mz_catalog.mz_materialized_views AS mviews
11108 JOIN mz_catalog.mz_clusters AS clusters ON clusters.id = mviews.cluster_id
11109 LEFT JOIN comments ON mviews.id = comments.id",
11110 access: vec![PUBLIC_SELECT],
11111});
11112
11113pub static MZ_SHOW_INDEXES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11114 name: "mz_show_indexes",
11115 schema: MZ_INTERNAL_SCHEMA,
11116 oid: oid::VIEW_MZ_SHOW_INDEXES_OID,
11117 desc: RelationDesc::builder()
11118 .with_column("id", SqlScalarType::String.nullable(false))
11119 .with_column("name", SqlScalarType::String.nullable(false))
11120 .with_column("on", SqlScalarType::String.nullable(false))
11121 .with_column("cluster", SqlScalarType::String.nullable(false))
11122 .with_column(
11123 "key",
11124 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
11125 )
11126 .with_column("on_id", SqlScalarType::String.nullable(false))
11127 .with_column("schema_id", SqlScalarType::String.nullable(false))
11128 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11129 .with_column("comment", SqlScalarType::String.nullable(false))
11130 .finish(),
11131 column_comments: BTreeMap::new(),
11132 sql: "
11133WITH comments AS (
11134 SELECT id, comment
11135 FROM mz_internal.mz_comments
11136 WHERE object_type = 'index' AND object_sub_id IS NULL
11137)
11138SELECT
11139 idxs.id AS id,
11140 idxs.name AS name,
11141 objs.name AS on,
11142 clusters.name AS cluster,
11143 COALESCE(keys.key, '{}'::_text) AS key,
11144 idxs.on_id AS on_id,
11145 objs.schema_id AS schema_id,
11146 clusters.id AS cluster_id,
11147 COALESCE(comments.comment, '') as comment
11148FROM
11149 mz_catalog.mz_indexes AS idxs
11150 JOIN mz_catalog.mz_objects AS objs ON idxs.on_id = objs.id
11151 JOIN mz_catalog.mz_clusters AS clusters ON clusters.id = idxs.cluster_id
11152 LEFT JOIN
11153 (SELECT
11154 idxs.id,
11155 ARRAY_AGG(
11156 CASE
11157 WHEN idx_cols.on_expression IS NULL THEN obj_cols.name
11158 ELSE idx_cols.on_expression
11159 END
11160 ORDER BY idx_cols.index_position ASC
11161 ) AS key
11162 FROM
11163 mz_catalog.mz_indexes AS idxs
11164 JOIN mz_catalog.mz_index_columns idx_cols ON idxs.id = idx_cols.index_id
11165 LEFT JOIN mz_catalog.mz_columns obj_cols ON
11166 idxs.on_id = obj_cols.id AND idx_cols.on_position = obj_cols.position
11167 GROUP BY idxs.id) AS keys
11168 ON idxs.id = keys.id
11169 LEFT JOIN comments ON idxs.id = comments.id",
11170 access: vec![PUBLIC_SELECT],
11171});
11172
11173pub static MZ_SHOW_CLUSTER_REPLICAS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11174 name: "mz_show_cluster_replicas",
11175 schema: MZ_INTERNAL_SCHEMA,
11176 oid: oid::VIEW_MZ_SHOW_CLUSTER_REPLICAS_OID,
11177 desc: RelationDesc::builder()
11178 .with_column("cluster", SqlScalarType::String.nullable(false))
11179 .with_column("replica", SqlScalarType::String.nullable(false))
11180 .with_column("replica_id", SqlScalarType::String.nullable(false))
11181 .with_column("size", SqlScalarType::String.nullable(true))
11182 .with_column("ready", SqlScalarType::Bool.nullable(false))
11183 .with_column("comment", SqlScalarType::String.nullable(false))
11184 .finish(),
11185 column_comments: BTreeMap::new(),
11186 sql: r#"SELECT
11187 mz_catalog.mz_clusters.name AS cluster,
11188 mz_catalog.mz_cluster_replicas.name AS replica,
11189 mz_catalog.mz_cluster_replicas.id as replica_id,
11190 mz_catalog.mz_cluster_replicas.size AS size,
11191 coalesce(statuses.ready, FALSE) AS ready,
11192 coalesce(comments.comment, '') as comment
11193FROM
11194 mz_catalog.mz_cluster_replicas
11195 JOIN mz_catalog.mz_clusters
11196 ON mz_catalog.mz_cluster_replicas.cluster_id = mz_catalog.mz_clusters.id
11197 LEFT JOIN
11198 (
11199 SELECT
11200 replica_id,
11201 bool_and(hydrated) AS ready
11202 FROM mz_internal.mz_hydration_statuses
11203 WHERE replica_id is not null
11204 GROUP BY replica_id
11205 ) AS statuses
11206 ON mz_catalog.mz_cluster_replicas.id = statuses.replica_id
11207 LEFT JOIN mz_internal.mz_comments comments
11208 ON mz_catalog.mz_cluster_replicas.id = comments.id
11209WHERE (comments.object_type = 'cluster-replica' OR comments.object_type IS NULL)
11210ORDER BY 1, 2"#,
11211 access: vec![PUBLIC_SELECT],
11212});
11213
11214pub static MZ_SHOW_CONTINUAL_TASKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11215 name: "mz_show_continual_tasks",
11216 schema: MZ_INTERNAL_SCHEMA,
11217 oid: oid::VIEW_MZ_SHOW_CONTINUAL_TASKS_OID,
11218 desc: RelationDesc::builder()
11219 .with_column("id", SqlScalarType::String.nullable(false))
11220 .with_column("name", SqlScalarType::String.nullable(false))
11221 .with_column("cluster", SqlScalarType::String.nullable(false))
11222 .with_column("schema_id", SqlScalarType::String.nullable(false))
11223 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11224 .with_column("comment", SqlScalarType::String.nullable(false))
11225 .finish(),
11226 column_comments: BTreeMap::new(),
11227 sql: "
11228WITH comments AS (
11229 SELECT id, comment
11230 FROM mz_internal.mz_comments
11231 WHERE object_type = 'continual-task' AND object_sub_id IS NULL
11232)
11233SELECT
11234 cts.id as id,
11235 cts.name,
11236 clusters.name AS cluster,
11237 schema_id,
11238 cluster_id,
11239 COALESCE(comments.comment, '') as comment
11240FROM
11241 mz_internal.mz_continual_tasks AS cts
11242 JOIN mz_catalog.mz_clusters AS clusters ON clusters.id = cts.cluster_id
11243 LEFT JOIN comments ON cts.id = comments.id",
11244 access: vec![PUBLIC_SELECT],
11245});
11246
11247pub static MZ_SHOW_ROLE_MEMBERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11248 name: "mz_show_role_members",
11249 schema: MZ_INTERNAL_SCHEMA,
11250 oid: oid::VIEW_MZ_SHOW_ROLE_MEMBERS_OID,
11251 desc: RelationDesc::builder()
11252 .with_column("role", SqlScalarType::String.nullable(false))
11253 .with_column("member", SqlScalarType::String.nullable(false))
11254 .with_column("grantor", SqlScalarType::String.nullable(false))
11255 .finish(),
11256 column_comments: BTreeMap::from_iter([
11257 ("role", "The role that `member` is a member of."),
11258 ("member", "The role that is a member of `role`."),
11259 (
11260 "grantor",
11261 "The role that granted membership of `member` to `role`.",
11262 ),
11263 ]),
11264 sql: r#"SELECT
11265 r1.name AS role,
11266 r2.name AS member,
11267 r3.name AS grantor
11268FROM mz_catalog.mz_role_members rm
11269JOIN mz_catalog.mz_roles r1 ON r1.id = rm.role_id
11270JOIN mz_catalog.mz_roles r2 ON r2.id = rm.member
11271JOIN mz_catalog.mz_roles r3 ON r3.id = rm.grantor
11272ORDER BY role"#,
11273 access: vec![PUBLIC_SELECT],
11274});
11275
11276pub static MZ_SHOW_MY_ROLE_MEMBERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11277 name: "mz_show_my_role_members",
11278 schema: MZ_INTERNAL_SCHEMA,
11279 oid: oid::VIEW_MZ_SHOW_MY_ROLE_MEMBERS_OID,
11280 desc: RelationDesc::builder()
11281 .with_column("role", SqlScalarType::String.nullable(false))
11282 .with_column("member", SqlScalarType::String.nullable(false))
11283 .with_column("grantor", SqlScalarType::String.nullable(false))
11284 .finish(),
11285 column_comments: BTreeMap::from_iter([
11286 ("role", "The role that `member` is a member of."),
11287 ("member", "The role that is a member of `role`."),
11288 (
11289 "grantor",
11290 "The role that granted membership of `member` to `role`.",
11291 ),
11292 ]),
11293 sql: r#"SELECT role, member, grantor
11294FROM mz_internal.mz_show_role_members
11295WHERE pg_has_role(member, 'USAGE')"#,
11296 access: vec![PUBLIC_SELECT],
11297});
11298
11299pub static MZ_SHOW_SYSTEM_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11300 name: "mz_show_system_privileges",
11301 schema: MZ_INTERNAL_SCHEMA,
11302 oid: oid::VIEW_MZ_SHOW_SYSTEM_PRIVILEGES_OID,
11303 desc: RelationDesc::builder()
11304 .with_column("grantor", SqlScalarType::String.nullable(true))
11305 .with_column("grantee", SqlScalarType::String.nullable(true))
11306 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11307 .finish(),
11308 column_comments: BTreeMap::from_iter([
11309 ("grantor", "The role that granted the privilege."),
11310 ("grantee", "The role that the privilege was granted to."),
11311 ("privilege_type", "They type of privilege granted."),
11312 ]),
11313 sql: r#"SELECT
11314 grantor.name AS grantor,
11315 CASE privileges.grantee
11316 WHEN 'p' THEN 'PUBLIC'
11317 ELSE grantee.name
11318 END AS grantee,
11319 privileges.privilege_type AS privilege_type
11320FROM
11321 (SELECT mz_internal.mz_aclexplode(ARRAY[privileges]).*
11322 FROM mz_catalog.mz_system_privileges) AS privileges
11323LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11324LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11325WHERE privileges.grantee NOT LIKE 's%'"#,
11326 access: vec![PUBLIC_SELECT],
11327});
11328
11329pub static MZ_SHOW_MY_SYSTEM_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11330 name: "mz_show_my_system_privileges",
11331 schema: MZ_INTERNAL_SCHEMA,
11332 oid: oid::VIEW_MZ_SHOW_MY_SYSTEM_PRIVILEGES_OID,
11333 desc: RelationDesc::builder()
11334 .with_column("grantor", SqlScalarType::String.nullable(true))
11335 .with_column("grantee", SqlScalarType::String.nullable(true))
11336 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11337 .finish(),
11338 column_comments: BTreeMap::from_iter([
11339 ("grantor", "The role that granted the privilege."),
11340 ("grantee", "The role that the privilege was granted to."),
11341 ("privilege_type", "They type of privilege granted."),
11342 ]),
11343 sql: r#"SELECT grantor, grantee, privilege_type
11344FROM mz_internal.mz_show_system_privileges
11345WHERE
11346 CASE
11347 WHEN grantee = 'PUBLIC' THEN true
11348 ELSE pg_has_role(grantee, 'USAGE')
11349 END"#,
11350 access: vec![PUBLIC_SELECT],
11351});
11352
11353pub static MZ_SHOW_CLUSTER_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11354 name: "mz_show_cluster_privileges",
11355 schema: MZ_INTERNAL_SCHEMA,
11356 oid: oid::VIEW_MZ_SHOW_CLUSTER_PRIVILEGES_OID,
11357 desc: RelationDesc::builder()
11358 .with_column("grantor", SqlScalarType::String.nullable(true))
11359 .with_column("grantee", SqlScalarType::String.nullable(true))
11360 .with_column("name", SqlScalarType::String.nullable(false))
11361 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11362 .finish(),
11363 column_comments: BTreeMap::from_iter([
11364 ("grantor", "The role that granted the privilege."),
11365 ("grantee", "The role that the privilege was granted to."),
11366 ("name", "The name of the cluster."),
11367 ("privilege_type", "They type of privilege granted."),
11368 ]),
11369 sql: r#"SELECT
11370 grantor.name AS grantor,
11371 CASE privileges.grantee
11372 WHEN 'p' THEN 'PUBLIC'
11373 ELSE grantee.name
11374 END AS grantee,
11375 privileges.name AS name,
11376 privileges.privilege_type AS privilege_type
11377FROM
11378 (SELECT mz_internal.mz_aclexplode(privileges).*, name
11379 FROM mz_catalog.mz_clusters
11380 WHERE id NOT LIKE 's%') AS privileges
11381LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11382LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11383WHERE privileges.grantee NOT LIKE 's%'"#,
11384 access: vec![PUBLIC_SELECT],
11385});
11386
11387pub static MZ_SHOW_MY_CLUSTER_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11388 name: "mz_show_my_cluster_privileges",
11389 schema: MZ_INTERNAL_SCHEMA,
11390 oid: oid::VIEW_MZ_SHOW_MY_CLUSTER_PRIVILEGES_OID,
11391 desc: RelationDesc::builder()
11392 .with_column("grantor", SqlScalarType::String.nullable(true))
11393 .with_column("grantee", SqlScalarType::String.nullable(true))
11394 .with_column("name", SqlScalarType::String.nullable(false))
11395 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11396 .finish(),
11397 column_comments: BTreeMap::from_iter([
11398 ("grantor", "The role that granted the privilege."),
11399 ("grantee", "The role that the privilege was granted to."),
11400 ("name", "The name of the cluster."),
11401 ("privilege_type", "They type of privilege granted."),
11402 ]),
11403 sql: r#"SELECT grantor, grantee, name, privilege_type
11404FROM mz_internal.mz_show_cluster_privileges
11405WHERE
11406 CASE
11407 WHEN grantee = 'PUBLIC' THEN true
11408 ELSE pg_has_role(grantee, 'USAGE')
11409 END"#,
11410 access: vec![PUBLIC_SELECT],
11411});
11412
11413pub static MZ_SHOW_DATABASE_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11414 name: "mz_show_database_privileges",
11415 schema: MZ_INTERNAL_SCHEMA,
11416 oid: oid::VIEW_MZ_SHOW_DATABASE_PRIVILEGES_OID,
11417 desc: RelationDesc::builder()
11418 .with_column("grantor", SqlScalarType::String.nullable(true))
11419 .with_column("grantee", SqlScalarType::String.nullable(true))
11420 .with_column("name", SqlScalarType::String.nullable(false))
11421 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11422 .finish(),
11423 column_comments: BTreeMap::from_iter([
11424 ("grantor", "The role that granted the privilege."),
11425 ("grantee", "The role that the privilege was granted to."),
11426 ("name", "The name of the database."),
11427 ("privilege_type", "They type of privilege granted."),
11428 ]),
11429 sql: r#"SELECT
11430 grantor.name AS grantor,
11431 CASE privileges.grantee
11432 WHEN 'p' THEN 'PUBLIC'
11433 ELSE grantee.name
11434 END AS grantee,
11435 privileges.name AS name,
11436 privileges.privilege_type AS privilege_type
11437FROM
11438 (SELECT mz_internal.mz_aclexplode(privileges).*, name
11439 FROM mz_catalog.mz_databases
11440 WHERE id NOT LIKE 's%') AS privileges
11441LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11442LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11443WHERE privileges.grantee NOT LIKE 's%'"#,
11444 access: vec![PUBLIC_SELECT],
11445});
11446
11447pub static MZ_SHOW_MY_DATABASE_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11448 name: "mz_show_my_database_privileges",
11449 schema: MZ_INTERNAL_SCHEMA,
11450 oid: oid::VIEW_MZ_SHOW_MY_DATABASE_PRIVILEGES_OID,
11451 desc: RelationDesc::builder()
11452 .with_column("grantor", SqlScalarType::String.nullable(true))
11453 .with_column("grantee", SqlScalarType::String.nullable(true))
11454 .with_column("name", SqlScalarType::String.nullable(false))
11455 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11456 .finish(),
11457 column_comments: BTreeMap::from_iter([
11458 ("grantor", "The role that granted the privilege."),
11459 ("grantee", "The role that the privilege was granted to."),
11460 ("name", "The name of the cluster."),
11461 ("privilege_type", "They type of privilege granted."),
11462 ]),
11463 sql: r#"SELECT grantor, grantee, name, privilege_type
11464FROM mz_internal.mz_show_database_privileges
11465WHERE
11466 CASE
11467 WHEN grantee = 'PUBLIC' THEN true
11468 ELSE pg_has_role(grantee, 'USAGE')
11469 END"#,
11470 access: vec![PUBLIC_SELECT],
11471});
11472
11473pub static MZ_SHOW_SCHEMA_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11474 name: "mz_show_schema_privileges",
11475 schema: MZ_INTERNAL_SCHEMA,
11476 oid: oid::VIEW_MZ_SHOW_SCHEMA_PRIVILEGES_OID,
11477 desc: RelationDesc::builder()
11478 .with_column("grantor", SqlScalarType::String.nullable(true))
11479 .with_column("grantee", SqlScalarType::String.nullable(true))
11480 .with_column("database", SqlScalarType::String.nullable(true))
11481 .with_column("name", SqlScalarType::String.nullable(false))
11482 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11483 .finish(),
11484 column_comments: BTreeMap::from_iter([
11485 ("grantor", "The role that granted the privilege."),
11486 ("grantee", "The role that the privilege was granted to."),
11487 (
11488 "database",
11489 "The name of the database containing the schema.",
11490 ),
11491 ("name", "The name of the schema."),
11492 ("privilege_type", "They type of privilege granted."),
11493 ]),
11494 sql: r#"SELECT
11495 grantor.name AS grantor,
11496 CASE privileges.grantee
11497 WHEN 'p' THEN 'PUBLIC'
11498 ELSE grantee.name
11499 END AS grantee,
11500 databases.name AS database,
11501 privileges.name AS name,
11502 privileges.privilege_type AS privilege_type
11503FROM
11504 (SELECT mz_internal.mz_aclexplode(privileges).*, database_id, name
11505 FROM mz_catalog.mz_schemas
11506 WHERE id NOT LIKE 's%') AS privileges
11507LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11508LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11509LEFT JOIN mz_catalog.mz_databases databases ON privileges.database_id = databases.id
11510WHERE privileges.grantee NOT LIKE 's%'"#,
11511 access: vec![PUBLIC_SELECT],
11512});
11513
11514pub static MZ_SHOW_MY_SCHEMA_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11515 name: "mz_show_my_schema_privileges",
11516 schema: MZ_INTERNAL_SCHEMA,
11517 oid: oid::VIEW_MZ_SHOW_MY_SCHEMA_PRIVILEGES_OID,
11518 desc: RelationDesc::builder()
11519 .with_column("grantor", SqlScalarType::String.nullable(true))
11520 .with_column("grantee", SqlScalarType::String.nullable(true))
11521 .with_column("database", SqlScalarType::String.nullable(true))
11522 .with_column("name", SqlScalarType::String.nullable(false))
11523 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11524 .finish(),
11525 column_comments: BTreeMap::from_iter([
11526 ("grantor", "The role that granted the privilege."),
11527 ("grantee", "The role that the privilege was granted to."),
11528 (
11529 "database",
11530 "The name of the database containing the schema.",
11531 ),
11532 ("name", "The name of the schema."),
11533 ("privilege_type", "They type of privilege granted."),
11534 ]),
11535 sql: r#"SELECT grantor, grantee, database, name, privilege_type
11536FROM mz_internal.mz_show_schema_privileges
11537WHERE
11538 CASE
11539 WHEN grantee = 'PUBLIC' THEN true
11540 ELSE pg_has_role(grantee, 'USAGE')
11541 END"#,
11542 access: vec![PUBLIC_SELECT],
11543});
11544
11545pub static MZ_SHOW_OBJECT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11546 name: "mz_show_object_privileges",
11547 schema: MZ_INTERNAL_SCHEMA,
11548 oid: oid::VIEW_MZ_SHOW_OBJECT_PRIVILEGES_OID,
11549 desc: RelationDesc::builder()
11550 .with_column("grantor", SqlScalarType::String.nullable(true))
11551 .with_column("grantee", SqlScalarType::String.nullable(true))
11552 .with_column("database", SqlScalarType::String.nullable(true))
11553 .with_column("schema", SqlScalarType::String.nullable(true))
11554 .with_column("name", SqlScalarType::String.nullable(false))
11555 .with_column("object_type", SqlScalarType::String.nullable(false))
11556 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11557 .finish(),
11558 column_comments: BTreeMap::from_iter([
11559 ("grantor", "The role that granted the privilege."),
11560 ("grantee", "The role that the privilege was granted to."),
11561 (
11562 "database",
11563 "The name of the database containing the object.",
11564 ),
11565 ("schema", "The name of the schema containing the object."),
11566 ("name", "The name of the object."),
11567 (
11568 "object_type",
11569 "The type of object the privilege is granted on.",
11570 ),
11571 ("privilege_type", "They type of privilege granted."),
11572 ]),
11573 sql: r#"SELECT
11574 grantor.name AS grantor,
11575 CASE privileges.grantee
11576 WHEN 'p' THEN 'PUBLIC'
11577 ELSE grantee.name
11578 END AS grantee,
11579 databases.name AS database,
11580 schemas.name AS schema,
11581 privileges.name AS name,
11582 privileges.type AS object_type,
11583 privileges.privilege_type AS privilege_type
11584FROM
11585 (SELECT mz_internal.mz_aclexplode(privileges).*, schema_id, name, type
11586 FROM mz_catalog.mz_objects
11587 WHERE id NOT LIKE 's%') AS privileges
11588LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11589LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11590LEFT JOIN mz_catalog.mz_schemas schemas ON privileges.schema_id = schemas.id
11591LEFT JOIN mz_catalog.mz_databases databases ON schemas.database_id = databases.id
11592WHERE privileges.grantee NOT LIKE 's%'"#,
11593 access: vec![PUBLIC_SELECT],
11594});
11595
11596pub static MZ_SHOW_MY_OBJECT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11597 name: "mz_show_my_object_privileges",
11598 schema: MZ_INTERNAL_SCHEMA,
11599 oid: oid::VIEW_MZ_SHOW_MY_OBJECT_PRIVILEGES_OID,
11600 desc: RelationDesc::builder()
11601 .with_column("grantor", SqlScalarType::String.nullable(true))
11602 .with_column("grantee", SqlScalarType::String.nullable(true))
11603 .with_column("database", SqlScalarType::String.nullable(true))
11604 .with_column("schema", SqlScalarType::String.nullable(true))
11605 .with_column("name", SqlScalarType::String.nullable(false))
11606 .with_column("object_type", SqlScalarType::String.nullable(false))
11607 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11608 .finish(),
11609 column_comments: BTreeMap::from_iter([
11610 ("grantor", "The role that granted the privilege."),
11611 ("grantee", "The role that the privilege was granted to."),
11612 (
11613 "database",
11614 "The name of the database containing the object.",
11615 ),
11616 ("schema", "The name of the schema containing the object."),
11617 ("name", "The name of the object."),
11618 (
11619 "object_type",
11620 "The type of object the privilege is granted on.",
11621 ),
11622 ("privilege_type", "They type of privilege granted."),
11623 ]),
11624 sql: r#"SELECT grantor, grantee, database, schema, name, object_type, privilege_type
11625FROM mz_internal.mz_show_object_privileges
11626WHERE
11627 CASE
11628 WHEN grantee = 'PUBLIC' THEN true
11629 ELSE pg_has_role(grantee, 'USAGE')
11630 END"#,
11631 access: vec![PUBLIC_SELECT],
11632});
11633
11634pub static MZ_SHOW_ALL_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11635 name: "mz_show_all_privileges",
11636 schema: MZ_INTERNAL_SCHEMA,
11637 oid: oid::VIEW_MZ_SHOW_ALL_PRIVILEGES_OID,
11638 desc: RelationDesc::builder()
11639 .with_column("grantor", SqlScalarType::String.nullable(true))
11640 .with_column("grantee", SqlScalarType::String.nullable(true))
11641 .with_column("database", SqlScalarType::String.nullable(true))
11642 .with_column("schema", SqlScalarType::String.nullable(true))
11643 .with_column("name", SqlScalarType::String.nullable(true))
11644 .with_column("object_type", SqlScalarType::String.nullable(false))
11645 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11646 .finish(),
11647 column_comments: BTreeMap::from_iter([
11648 ("grantor", "The role that granted the privilege."),
11649 ("grantee", "The role that the privilege was granted to."),
11650 (
11651 "database",
11652 "The name of the database containing the object.",
11653 ),
11654 ("schema", "The name of the schema containing the object."),
11655 ("name", "The name of the privilege target."),
11656 (
11657 "object_type",
11658 "The type of object the privilege is granted on.",
11659 ),
11660 ("privilege_type", "They type of privilege granted."),
11661 ]),
11662 sql: r#"SELECT grantor, grantee, NULL AS database, NULL AS schema, NULL AS name, 'system' AS object_type, privilege_type
11663FROM mz_internal.mz_show_system_privileges
11664UNION ALL
11665SELECT grantor, grantee, NULL AS database, NULL AS schema, name, 'cluster' AS object_type, privilege_type
11666FROM mz_internal.mz_show_cluster_privileges
11667UNION ALL
11668SELECT grantor, grantee, NULL AS database, NULL AS schema, name, 'database' AS object_type, privilege_type
11669FROM mz_internal.mz_show_database_privileges
11670UNION ALL
11671SELECT grantor, grantee, database, NULL AS schema, name, 'schema' AS object_type, privilege_type
11672FROM mz_internal.mz_show_schema_privileges
11673UNION ALL
11674SELECT grantor, grantee, database, schema, name, object_type, privilege_type
11675FROM mz_internal.mz_show_object_privileges"#,
11676 access: vec![PUBLIC_SELECT],
11677});
11678
11679pub static MZ_SHOW_ALL_MY_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11680 name: "mz_show_all_my_privileges",
11681 schema: MZ_INTERNAL_SCHEMA,
11682 oid: oid::VIEW_MZ_SHOW_ALL_MY_PRIVILEGES_OID,
11683 desc: RelationDesc::builder()
11684 .with_column("grantor", SqlScalarType::String.nullable(true))
11685 .with_column("grantee", SqlScalarType::String.nullable(true))
11686 .with_column("database", SqlScalarType::String.nullable(true))
11687 .with_column("schema", SqlScalarType::String.nullable(true))
11688 .with_column("name", SqlScalarType::String.nullable(true))
11689 .with_column("object_type", SqlScalarType::String.nullable(false))
11690 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11691 .finish(),
11692 column_comments: BTreeMap::from_iter([
11693 ("grantor", "The role that granted the privilege."),
11694 ("grantee", "The role that the privilege was granted to."),
11695 (
11696 "database",
11697 "The name of the database containing the object.",
11698 ),
11699 ("schema", "The name of the schema containing the object."),
11700 ("name", "The name of the privilege target."),
11701 (
11702 "object_type",
11703 "The type of object the privilege is granted on.",
11704 ),
11705 ("privilege_type", "They type of privilege granted."),
11706 ]),
11707 sql: r#"SELECT grantor, grantee, database, schema, name, object_type, privilege_type
11708FROM mz_internal.mz_show_all_privileges
11709WHERE
11710 CASE
11711 WHEN grantee = 'PUBLIC' THEN true
11712 ELSE pg_has_role(grantee, 'USAGE')
11713 END"#,
11714 access: vec![PUBLIC_SELECT],
11715});
11716
11717pub static MZ_SHOW_DEFAULT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11718 name: "mz_show_default_privileges",
11719 schema: MZ_INTERNAL_SCHEMA,
11720 oid: oid::VIEW_MZ_SHOW_DEFAULT_PRIVILEGES_OID,
11721 desc: RelationDesc::builder()
11722 .with_column("object_owner", SqlScalarType::String.nullable(true))
11723 .with_column("database", SqlScalarType::String.nullable(true))
11724 .with_column("schema", SqlScalarType::String.nullable(true))
11725 .with_column("object_type", SqlScalarType::String.nullable(false))
11726 .with_column("grantee", SqlScalarType::String.nullable(true))
11727 .with_column("privilege_type", SqlScalarType::String.nullable(true))
11728 .finish(),
11729 column_comments: BTreeMap::from_iter([
11730 (
11731 "object_owner",
11732 "Privileges described in this row will be granted on objects created by `object_owner`.",
11733 ),
11734 (
11735 "database",
11736 "Privileges described in this row will be granted only on objects created in `database` if non-null.",
11737 ),
11738 (
11739 "schema",
11740 "Privileges described in this row will be granted only on objects created in `schema` if non-null.",
11741 ),
11742 (
11743 "object_type",
11744 "Privileges described in this row will be granted only on objects of type `object_type`.",
11745 ),
11746 (
11747 "grantee",
11748 "Privileges described in this row will be granted to `grantee`.",
11749 ),
11750 ("privilege_type", "They type of privilege to be granted."),
11751 ]),
11752 sql: r#"SELECT
11753 CASE defaults.role_id
11754 WHEN 'p' THEN 'PUBLIC'
11755 ELSE object_owner.name
11756 END AS object_owner,
11757 databases.name AS database,
11758 schemas.name AS schema,
11759 object_type,
11760 CASE defaults.grantee
11761 WHEN 'p' THEN 'PUBLIC'
11762 ELSE grantee.name
11763 END AS grantee,
11764 unnest(mz_internal.mz_format_privileges(defaults.privileges)) AS privilege_type
11765FROM mz_catalog.mz_default_privileges defaults
11766LEFT JOIN mz_catalog.mz_roles AS object_owner ON defaults.role_id = object_owner.id
11767LEFT JOIN mz_catalog.mz_roles AS grantee ON defaults.grantee = grantee.id
11768LEFT JOIN mz_catalog.mz_databases AS databases ON defaults.database_id = databases.id
11769LEFT JOIN mz_catalog.mz_schemas AS schemas ON defaults.schema_id = schemas.id
11770WHERE defaults.grantee NOT LIKE 's%'
11771 AND defaults.database_id IS NULL OR defaults.database_id NOT LIKE 's%'
11772 AND defaults.schema_id IS NULL OR defaults.schema_id NOT LIKE 's%'"#,
11773 access: vec![PUBLIC_SELECT],
11774});
11775
11776pub static MZ_SHOW_MY_DEFAULT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11777 name: "mz_show_my_default_privileges",
11778 schema: MZ_INTERNAL_SCHEMA,
11779 oid: oid::VIEW_MZ_SHOW_MY_DEFAULT_PRIVILEGES_OID,
11780 desc: RelationDesc::builder()
11781 .with_column("object_owner", SqlScalarType::String.nullable(true))
11782 .with_column("database", SqlScalarType::String.nullable(true))
11783 .with_column("schema", SqlScalarType::String.nullable(true))
11784 .with_column("object_type", SqlScalarType::String.nullable(false))
11785 .with_column("grantee", SqlScalarType::String.nullable(true))
11786 .with_column("privilege_type", SqlScalarType::String.nullable(true))
11787 .finish(),
11788 column_comments: BTreeMap::from_iter([
11789 (
11790 "object_owner",
11791 "Privileges described in this row will be granted on objects created by `object_owner`.",
11792 ),
11793 (
11794 "database",
11795 "Privileges described in this row will be granted only on objects created in `database` if non-null.",
11796 ),
11797 (
11798 "schema",
11799 "Privileges described in this row will be granted only on objects created in `schema` if non-null.",
11800 ),
11801 (
11802 "object_type",
11803 "Privileges described in this row will be granted only on objects of type `object_type`.",
11804 ),
11805 (
11806 "grantee",
11807 "Privileges described in this row will be granted to `grantee`.",
11808 ),
11809 ("privilege_type", "They type of privilege to be granted."),
11810 ]),
11811 sql: r#"SELECT object_owner, database, schema, object_type, grantee, privilege_type
11812FROM mz_internal.mz_show_default_privileges
11813WHERE
11814 CASE
11815 WHEN grantee = 'PUBLIC' THEN true
11816 ELSE pg_has_role(grantee, 'USAGE')
11817 END"#,
11818 access: vec![PUBLIC_SELECT],
11819});
11820
11821pub static MZ_SHOW_NETWORK_POLICIES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11822 name: "mz_show_network_policies",
11823 schema: MZ_INTERNAL_SCHEMA,
11824 oid: oid::VIEW_MZ_SHOW_NETWORK_POLICIES_OID,
11825 desc: RelationDesc::builder()
11826 .with_column("name", SqlScalarType::String.nullable(false))
11827 .with_column("rules", SqlScalarType::String.nullable(true))
11828 .with_column("comment", SqlScalarType::String.nullable(false))
11829 .finish(),
11830 column_comments: BTreeMap::new(),
11831 sql: "
11832WITH comments AS (
11833 SELECT id, comment
11834 FROM mz_internal.mz_comments
11835 WHERE object_type = 'network-policy' AND object_sub_id IS NULL
11836)
11837SELECT
11838 policy.name,
11839 pg_catalog.string_agg(rule.name,',' ORDER BY rule.name) as rules,
11840 COALESCE(comment, '') as comment
11841FROM
11842 mz_internal.mz_network_policies as policy
11843LEFT JOIN
11844 mz_internal.mz_network_policy_rules as rule ON policy.id = rule.policy_id
11845LEFT JOIN
11846 comments ON policy.id = comments.id
11847WHERE
11848 policy.id NOT LIKE 's%'
11849AND
11850 policy.id NOT LIKE 'g%'
11851GROUP BY policy.name, comments.comment;",
11852 access: vec![PUBLIC_SELECT],
11853});
11854
11855pub static MZ_CLUSTER_REPLICA_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11856 name: "mz_cluster_replica_history",
11857 schema: MZ_INTERNAL_SCHEMA,
11858 oid: oid::VIEW_MZ_CLUSTER_REPLICA_HISTORY_OID,
11859 desc: RelationDesc::builder()
11860 .with_column("replica_id", SqlScalarType::String.nullable(true))
11861 .with_column("size", SqlScalarType::String.nullable(true))
11862 .with_column("cluster_id", SqlScalarType::String.nullable(true))
11863 .with_column("cluster_name", SqlScalarType::String.nullable(true))
11864 .with_column("replica_name", SqlScalarType::String.nullable(true))
11865 .with_column(
11866 "created_at",
11867 SqlScalarType::TimestampTz { precision: None }.nullable(false),
11868 )
11869 .with_column(
11870 "dropped_at",
11871 SqlScalarType::TimestampTz { precision: None }.nullable(true),
11872 )
11873 .with_column(
11874 "credits_per_hour",
11875 SqlScalarType::Numeric { max_scale: None }.nullable(true),
11876 )
11877 .finish(),
11878 column_comments: BTreeMap::from_iter([
11879 ("replica_id", "The ID of a cluster replica."),
11880 (
11881 "size",
11882 "The size of the cluster replica. Corresponds to `mz_cluster_replica_sizes.size`.",
11883 ),
11884 (
11885 "cluster_id",
11886 "The ID of the cluster associated with the replica.",
11887 ),
11888 (
11889 "cluster_name",
11890 "The name of the cluster associated with the replica.",
11891 ),
11892 ("replica_name", "The name of the replica."),
11893 ("created_at", "The time at which the replica was created."),
11894 (
11895 "dropped_at",
11896 "The time at which the replica was dropped, or `NULL` if it still exists.",
11897 ),
11898 (
11899 "credits_per_hour",
11900 "The number of compute credits consumed per hour. Corresponds to `mz_cluster_replica_sizes.credits_per_hour`.",
11901 ),
11902 ]),
11903 sql: r#"
11904 WITH
11905 creates AS
11906 (
11907 SELECT
11908 details ->> 'logical_size' AS size,
11909 details ->> 'replica_id' AS replica_id,
11910 details ->> 'replica_name' AS replica_name,
11911 details ->> 'cluster_name' AS cluster_name,
11912 details ->> 'cluster_id' AS cluster_id,
11913 occurred_at
11914 FROM mz_catalog.mz_audit_events
11915 WHERE
11916 object_type = 'cluster-replica' AND event_type = 'create'
11917 AND
11918 details ->> 'replica_id' IS NOT NULL
11919 AND
11920 details ->> 'cluster_id' !~~ 's%'
11921 ),
11922 drops AS
11923 (
11924 SELECT details ->> 'replica_id' AS replica_id, occurred_at
11925 FROM mz_catalog.mz_audit_events
11926 WHERE object_type = 'cluster-replica' AND event_type = 'drop'
11927 )
11928 SELECT
11929 creates.replica_id,
11930 creates.size,
11931 creates.cluster_id,
11932 creates.cluster_name,
11933 creates.replica_name,
11934 creates.occurred_at AS created_at,
11935 drops.occurred_at AS dropped_at,
11936 mz_cluster_replica_sizes.credits_per_hour as credits_per_hour
11937 FROM
11938 creates
11939 LEFT JOIN drops ON creates.replica_id = drops.replica_id
11940 LEFT JOIN
11941 mz_catalog.mz_cluster_replica_sizes
11942 ON mz_cluster_replica_sizes.size = creates.size"#,
11943 access: vec![PUBLIC_SELECT],
11944});
11945
11946pub static MZ_CLUSTER_REPLICA_NAME_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11947 name: "mz_cluster_replica_name_history",
11948 schema: MZ_INTERNAL_SCHEMA,
11949 oid: oid::VIEW_MZ_CLUSTER_REPLICA_NAME_HISTORY_OID,
11950 desc: RelationDesc::builder()
11951 .with_column(
11952 "occurred_at",
11953 SqlScalarType::TimestampTz { precision: None }.nullable(true),
11954 )
11955 .with_column("id", SqlScalarType::String.nullable(true))
11956 .with_column("previous_name", SqlScalarType::String.nullable(true))
11957 .with_column("new_name", SqlScalarType::String.nullable(true))
11958 .finish(),
11959 column_comments: BTreeMap::from_iter([
11960 (
11961 "occurred_at",
11962 "The time at which the cluster replica was created or renamed. `NULL` if it's a built in system cluster replica.",
11963 ),
11964 ("id", "The ID of the cluster replica."),
11965 (
11966 "previous_name",
11967 "The previous name of the cluster replica. `NULL` if there was no previous name.",
11968 ),
11969 ("new_name", "The new name of the cluster replica."),
11970 ]),
11971 sql: r#"WITH user_replica_alter_history AS (
11972 SELECT occurred_at,
11973 audit_events.details->>'replica_id' AS id,
11974 audit_events.details->>'old_name' AS previous_name,
11975 audit_events.details->>'new_name' AS new_name
11976 FROM mz_catalog.mz_audit_events AS audit_events
11977 WHERE object_type = 'cluster-replica'
11978 AND audit_events.event_type = 'alter'
11979 AND audit_events.details->>'replica_id' like 'u%'
11980),
11981user_replica_create_history AS (
11982 SELECT occurred_at,
11983 audit_events.details->>'replica_id' AS id,
11984 NULL AS previous_name,
11985 audit_events.details->>'replica_name' AS new_name
11986 FROM mz_catalog.mz_audit_events AS audit_events
11987 WHERE object_type = 'cluster-replica'
11988 AND audit_events.event_type = 'create'
11989 AND audit_events.details->>'replica_id' like 'u%'
11990),
11991-- Because built in system cluster replicas don't have audit events, we need to manually add them
11992system_replicas AS (
11993 -- We assume that the system cluster replicas were created at the beginning of time
11994 SELECT NULL::timestamptz AS occurred_at,
11995 id,
11996 NULL AS previous_name,
11997 name AS new_name
11998 FROM mz_catalog.mz_cluster_replicas
11999 WHERE id LIKE 's%'
12000)
12001SELECT *
12002FROM user_replica_alter_history
12003UNION ALL
12004SELECT *
12005FROM user_replica_create_history
12006UNION ALL
12007SELECT *
12008FROM system_replicas"#,
12009 access: vec![PUBLIC_SELECT],
12010});
12011
12012pub static MZ_HYDRATION_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12013 name: "mz_hydration_statuses",
12014 schema: MZ_INTERNAL_SCHEMA,
12015 oid: oid::VIEW_MZ_HYDRATION_STATUSES_OID,
12016 desc: RelationDesc::builder()
12017 .with_column("object_id", SqlScalarType::String.nullable(false))
12018 .with_column("replica_id", SqlScalarType::String.nullable(true))
12019 .with_column("hydrated", SqlScalarType::Bool.nullable(true))
12020 .finish(),
12021 column_comments: BTreeMap::from_iter([
12022 (
12023 "object_id",
12024 "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`.",
12025 ),
12026 ("replica_id", "The ID of a cluster replica."),
12027 ("hydrated", "Whether the object is hydrated on the replica."),
12028 ]),
12029 sql: r#"WITH
12030-- Joining against the linearizable catalog tables ensures that this view
12031-- always contains the set of installed objects, even when it depends
12032-- on introspection relations that may received delayed updates.
12033--
12034-- Note that this view only includes objects that are maintained by dataflows.
12035-- In particular, some source types (webhook, introspection, ...) are not and
12036-- are therefore omitted.
12037indexes AS (
12038 SELECT
12039 i.id AS object_id,
12040 h.replica_id,
12041 COALESCE(h.hydrated, false) AS hydrated
12042 FROM mz_catalog.mz_indexes i
12043 LEFT JOIN mz_internal.mz_compute_hydration_statuses h
12044 ON (h.object_id = i.id)
12045),
12046materialized_views AS (
12047 SELECT
12048 i.id AS object_id,
12049 h.replica_id,
12050 COALESCE(h.hydrated, false) AS hydrated
12051 FROM mz_catalog.mz_materialized_views i
12052 LEFT JOIN mz_internal.mz_compute_hydration_statuses h
12053 ON (h.object_id = i.id)
12054),
12055continual_tasks AS (
12056 SELECT
12057 i.id AS object_id,
12058 h.replica_id,
12059 COALESCE(h.hydrated, false) AS hydrated
12060 FROM mz_internal.mz_continual_tasks i
12061 LEFT JOIN mz_internal.mz_compute_hydration_statuses h
12062 ON (h.object_id = i.id)
12063),
12064-- Hydration is a dataflow concept and not all sources are maintained by
12065-- dataflows, so we need to find the ones that are. Generally, sources that
12066-- have a cluster ID are maintained by a dataflow running on that cluster.
12067-- Webhook sources are an exception to this rule.
12068sources_with_clusters AS (
12069 SELECT id, cluster_id
12070 FROM mz_catalog.mz_sources
12071 WHERE cluster_id IS NOT NULL AND type != 'webhook'
12072),
12073sources AS (
12074 SELECT
12075 s.id AS object_id,
12076 ss.replica_id AS replica_id,
12077 ss.rehydration_latency IS NOT NULL AS hydrated
12078 FROM sources_with_clusters s
12079 LEFT JOIN mz_internal.mz_source_statistics ss USING (id)
12080),
12081-- We don't yet report sink hydration status (database-issues#8331), so we do a best effort attempt here and
12082-- define a sink as hydrated when it's both "running" and has a frontier greater than the minimum.
12083-- There is likely still a possibility of FPs.
12084sinks AS (
12085 SELECT
12086 s.id AS object_id,
12087 r.id AS replica_id,
12088 ss.status = 'running' AND COALESCE(f.write_frontier, 0) > 0 AS hydrated
12089 FROM mz_catalog.mz_sinks s
12090 LEFT JOIN mz_internal.mz_sink_statuses ss USING (id)
12091 JOIN mz_catalog.mz_cluster_replicas r
12092 ON (r.cluster_id = s.cluster_id)
12093 LEFT JOIN mz_catalog.mz_cluster_replica_frontiers f
12094 ON (f.object_id = s.id AND f.replica_id = r.id)
12095)
12096SELECT * FROM indexes
12097UNION ALL
12098SELECT * FROM materialized_views
12099UNION ALL
12100SELECT * FROM continual_tasks
12101UNION ALL
12102SELECT * FROM sources
12103UNION ALL
12104SELECT * FROM sinks"#,
12105 access: vec![PUBLIC_SELECT],
12106});
12107
12108pub static MZ_MATERIALIZATION_DEPENDENCIES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12109 name: "mz_materialization_dependencies",
12110 schema: MZ_INTERNAL_SCHEMA,
12111 oid: oid::VIEW_MZ_MATERIALIZATION_DEPENDENCIES_OID,
12112 desc: RelationDesc::builder()
12113 .with_column("object_id", SqlScalarType::String.nullable(false))
12114 .with_column("dependency_id", SqlScalarType::String.nullable(false))
12115 .finish(),
12116 column_comments: BTreeMap::from_iter([
12117 (
12118 "object_id",
12119 "The ID of a materialization. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, or `mz_catalog.mz_sinks.id`.",
12120 ),
12121 (
12122 "dependency_id",
12123 "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`.",
12124 ),
12125 ]),
12126 sql: "
12127SELECT object_id, dependency_id
12128FROM mz_internal.mz_compute_dependencies
12129UNION ALL
12130SELECT s.id, d.referenced_object_id AS dependency_id
12131FROM mz_internal.mz_object_dependencies d
12132JOIN mz_catalog.mz_sinks s ON (s.id = d.object_id)
12133JOIN mz_catalog.mz_relations r ON (r.id = d.referenced_object_id)",
12134 access: vec![PUBLIC_SELECT],
12135});
12136
12137pub static MZ_MATERIALIZATION_LAG: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12138 name: "mz_materialization_lag",
12139 schema: MZ_INTERNAL_SCHEMA,
12140 oid: oid::VIEW_MZ_MATERIALIZATION_LAG_OID,
12141 desc: RelationDesc::builder()
12142 .with_column("object_id", SqlScalarType::String.nullable(false))
12143 .with_column("local_lag", SqlScalarType::Interval.nullable(true))
12144 .with_column("global_lag", SqlScalarType::Interval.nullable(true))
12145 .with_column(
12146 "slowest_local_input_id",
12147 SqlScalarType::String.nullable(false),
12148 )
12149 .with_column(
12150 "slowest_global_input_id",
12151 SqlScalarType::String.nullable(false),
12152 )
12153 .finish(),
12154 column_comments: BTreeMap::from_iter([
12155 (
12156 "object_id",
12157 "The ID of the materialized view, index, or sink.",
12158 ),
12159 (
12160 "local_lag",
12161 "The amount of time the materialization lags behind its direct inputs.",
12162 ),
12163 (
12164 "global_lag",
12165 "The amount of time the materialization lags behind its root inputs (sources and tables).",
12166 ),
12167 (
12168 "slowest_local_input_id",
12169 "The ID of the slowest direct input.",
12170 ),
12171 (
12172 "slowest_global_input_id",
12173 "The ID of the slowest root input.",
12174 ),
12175 ]),
12176 sql: "
12177WITH MUTUALLY RECURSIVE
12178 -- IDs of objects for which we want to know the lag.
12179 materializations (id text) AS (
12180 SELECT id FROM mz_catalog.mz_indexes
12181 UNION ALL
12182 SELECT id FROM mz_catalog.mz_materialized_views
12183 UNION ALL
12184 SELECT id FROM mz_internal.mz_continual_tasks
12185 UNION ALL
12186 SELECT id FROM mz_catalog.mz_sinks
12187 ),
12188 -- Direct dependencies of materializations.
12189 direct_dependencies (id text, dep_id text) AS (
12190 SELECT m.id, d.dependency_id
12191 FROM materializations m
12192 JOIN mz_internal.mz_materialization_dependencies d ON (m.id = d.object_id)
12193 ),
12194 -- All transitive dependencies of materializations.
12195 transitive_dependencies (id text, dep_id text) AS (
12196 SELECT id, dep_id FROM direct_dependencies
12197 UNION
12198 SELECT td.id, dd.dep_id
12199 FROM transitive_dependencies td
12200 JOIN direct_dependencies dd ON (dd.id = td.dep_id)
12201 ),
12202 -- Root dependencies of materializations (sources and tables).
12203 root_dependencies (id text, dep_id text) AS (
12204 SELECT *
12205 FROM transitive_dependencies td
12206 WHERE NOT EXISTS (
12207 SELECT 1
12208 FROM direct_dependencies dd
12209 WHERE dd.id = td.dep_id
12210 )
12211 ),
12212 -- Write progress times of materializations.
12213 materialization_times (id text, time timestamptz) AS (
12214 SELECT m.id, to_timestamp(f.write_frontier::text::double / 1000)
12215 FROM materializations m
12216 JOIN mz_internal.mz_frontiers f ON (m.id = f.object_id)
12217 ),
12218 -- Write progress times of direct dependencies of materializations.
12219 input_times (id text, slowest_dep text, time timestamptz) AS (
12220 SELECT DISTINCT ON (d.id)
12221 d.id,
12222 d.dep_id,
12223 to_timestamp(f.write_frontier::text::double / 1000)
12224 FROM direct_dependencies d
12225 JOIN mz_internal.mz_frontiers f ON (d.dep_id = f.object_id)
12226 ORDER BY d.id, f.write_frontier ASC
12227 ),
12228 -- Write progress times of root dependencies of materializations.
12229 root_times (id text, slowest_dep text, time timestamptz) AS (
12230 SELECT DISTINCT ON (d.id)
12231 d.id,
12232 d.dep_id,
12233 to_timestamp(f.write_frontier::text::double / 1000)
12234 FROM root_dependencies d
12235 JOIN mz_internal.mz_frontiers f ON (d.dep_id = f.object_id)
12236 ORDER BY d.id, f.write_frontier ASC
12237 )
12238SELECT
12239 id AS object_id,
12240 -- Ensure that lag values are always NULL for materializations that have reached the empty
12241 -- frontier, as those have processed all their input data.
12242 -- Also make sure that lag values are never negative, even when input frontiers are before
12243 -- output frontiers (as can happen during hydration).
12244 CASE
12245 WHEN m.time IS NULL THEN INTERVAL '0'
12246 WHEN i.time IS NULL THEN NULL
12247 ELSE greatest(i.time - m.time, INTERVAL '0')
12248 END AS local_lag,
12249 CASE
12250 WHEN m.time IS NULL THEN INTERVAL '0'
12251 WHEN r.time IS NULL THEN NULL
12252 ELSE greatest(r.time - m.time, INTERVAL '0')
12253 END AS global_lag,
12254 i.slowest_dep AS slowest_local_input_id,
12255 r.slowest_dep AS slowest_global_input_id
12256FROM materialization_times m
12257JOIN input_times i USING (id)
12258JOIN root_times r USING (id)",
12259 access: vec![PUBLIC_SELECT],
12260});
12261
12262pub static MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW: LazyLock<BuiltinView> = LazyLock::new(|| {
12268 BuiltinView {
12269 name: "mz_console_cluster_utilization_overview",
12270 schema: MZ_INTERNAL_SCHEMA,
12271 oid: oid::VIEW_MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_OID,
12272 desc: RelationDesc::builder()
12273 .with_column(
12274 "bucket_start",
12275 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12276 )
12277 .with_column("replica_id", SqlScalarType::String.nullable(false))
12278 .with_column("memory_percent", SqlScalarType::Float64.nullable(true))
12279 .with_column(
12280 "max_memory_at",
12281 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12282 )
12283 .with_column("disk_percent", SqlScalarType::Float64.nullable(true))
12284 .with_column(
12285 "max_disk_at",
12286 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12287 )
12288 .with_column(
12289 "memory_and_disk_percent",
12290 SqlScalarType::Float64.nullable(true),
12291 )
12292 .with_column(
12293 "max_memory_and_disk_memory_percent",
12294 SqlScalarType::Float64.nullable(true),
12295 )
12296 .with_column(
12297 "max_memory_and_disk_disk_percent",
12298 SqlScalarType::Float64.nullable(true),
12299 )
12300 .with_column(
12301 "max_memory_and_disk_at",
12302 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12303 )
12304 .with_column("max_cpu_percent", SqlScalarType::Float64.nullable(true))
12305 .with_column(
12306 "max_cpu_at",
12307 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12308 )
12309 .with_column("offline_events", SqlScalarType::Jsonb.nullable(true))
12310 .with_column(
12311 "bucket_end",
12312 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12313 )
12314 .with_column("name", SqlScalarType::String.nullable(true))
12315 .with_column("cluster_id", SqlScalarType::String.nullable(true))
12316 .with_column("size", SqlScalarType::String.nullable(true))
12317 .finish(),
12318 column_comments: BTreeMap::new(),
12319 sql: r#"WITH replica_history AS (
12320 SELECT replica_id,
12321 size,
12322 cluster_id
12323 FROM mz_internal.mz_cluster_replica_history
12324 UNION
12325 -- We need to union the current set of cluster replicas since mz_cluster_replica_history doesn't include system clusters
12326 SELECT id AS replica_id,
12327 size,
12328 cluster_id
12329 FROM mz_catalog.mz_cluster_replicas
12330),
12331replica_metrics_history AS (
12332 SELECT
12333 m.occurred_at,
12334 m.replica_id,
12335 r.size,
12336 (SUM(m.cpu_nano_cores::float8) / NULLIF(s.cpu_nano_cores, 0)) / s.processes AS cpu_percent,
12337 (SUM(m.memory_bytes::float8) / NULLIF(s.memory_bytes, 0)) / s.processes AS memory_percent,
12338 (SUM(m.disk_bytes::float8) / NULLIF(s.disk_bytes, 0)) / s.processes AS disk_percent,
12339 SUM(m.disk_bytes::float8) AS disk_bytes,
12340 SUM(m.memory_bytes::float8) AS memory_bytes,
12341 s.disk_bytes::numeric * s.processes AS total_disk_bytes,
12342 s.memory_bytes::numeric * s.processes AS total_memory_bytes
12343 FROM
12344 replica_history AS r
12345 INNER JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size
12346 INNER JOIN mz_internal.mz_cluster_replica_metrics_history AS m ON m.replica_id = r.replica_id
12347 GROUP BY
12348 m.occurred_at,
12349 m.replica_id,
12350 r.size,
12351 s.cpu_nano_cores,
12352 s.memory_bytes,
12353 s.disk_bytes,
12354 s.processes
12355),
12356replica_utilization_history_binned AS (
12357 SELECT m.occurred_at,
12358 m.replica_id,
12359 m.cpu_percent,
12360 m.memory_percent,
12361 m.memory_bytes,
12362 m.disk_percent,
12363 m.disk_bytes,
12364 m.total_disk_bytes,
12365 m.total_memory_bytes,
12366 m.size,
12367 date_bin(
12368 '8 HOURS',
12369 occurred_at,
12370 '1970-01-01'::timestamp
12371 ) AS bucket_start
12372 FROM replica_history AS r
12373 JOIN replica_metrics_history AS m ON m.replica_id = r.replica_id
12374 WHERE mz_now() <= date_bin(
12375 '8 HOURS',
12376 occurred_at,
12377 '1970-01-01'::timestamp
12378 ) + INTERVAL '14 DAYS'
12379),
12380-- For each (replica, bucket), take the (replica, bucket) with the highest memory
12381max_memory AS (
12382 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12383 replica_id,
12384 memory_percent,
12385 occurred_at
12386 FROM replica_utilization_history_binned
12387 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12388 ORDER BY bucket_start,
12389 replica_id,
12390 COALESCE(memory_bytes, 0) DESC
12391),
12392max_disk AS (
12393 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12394 replica_id,
12395 disk_percent,
12396 occurred_at
12397 FROM replica_utilization_history_binned
12398 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12399 ORDER BY bucket_start,
12400 replica_id,
12401 COALESCE(disk_bytes, 0) DESC
12402),
12403max_cpu AS (
12404 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12405 replica_id,
12406 cpu_percent,
12407 occurred_at
12408 FROM replica_utilization_history_binned
12409 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12410 ORDER BY bucket_start,
12411 replica_id,
12412 COALESCE(cpu_percent, 0) DESC
12413),
12414/*
12415 This is different
12416 from adding max_memory
12417 and max_disk per bucket because both
12418 values may not occur at the same time if the bucket interval is large.
12419 */
12420max_memory_and_disk AS (
12421 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12422 replica_id,
12423 memory_percent,
12424 disk_percent,
12425 memory_and_disk_percent,
12426 occurred_at
12427 FROM (
12428 SELECT *,
12429 CASE
12430 WHEN disk_bytes IS NULL
12431 AND memory_bytes IS NULL THEN NULL
12432 ELSE (COALESCE(disk_bytes, 0) + COALESCE(memory_bytes, 0))
12433 / (total_disk_bytes::numeric + total_memory_bytes::numeric)
12434 END AS memory_and_disk_percent
12435 FROM replica_utilization_history_binned
12436 ) AS max_memory_and_disk_inner
12437 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12438 ORDER BY bucket_start,
12439 replica_id,
12440 COALESCE(memory_and_disk_percent, 0) DESC
12441),
12442-- For each (replica, bucket), get its offline events at that time
12443replica_offline_event_history AS (
12444 SELECT date_bin(
12445 '8 HOURS',
12446 occurred_at,
12447 '1970-01-01'::timestamp
12448 ) AS bucket_start,
12449 replica_id,
12450 jsonb_agg(
12451 jsonb_build_object(
12452 'replicaId',
12453 rsh.replica_id,
12454 'occurredAt',
12455 rsh.occurred_at,
12456 'status',
12457 rsh.status,
12458 'reason',
12459 rsh.reason
12460 )
12461 ) AS offline_events
12462 FROM mz_internal.mz_cluster_replica_status_history AS rsh -- We assume the statuses for process 0 are the same as all processes
12463 WHERE process_id = '0'
12464 AND status = 'offline'
12465 AND mz_now() <= date_bin(
12466 '8 HOURS',
12467 occurred_at,
12468 '1970-01-01'::timestamp
12469 ) + INTERVAL '14 DAYS'
12470 GROUP BY bucket_start,
12471 replica_id
12472)
12473SELECT max_memory.bucket_start,
12474 max_memory.replica_id,
12475 max_memory.memory_percent,
12476 max_memory.occurred_at as max_memory_at,
12477 max_disk.disk_percent,
12478 max_disk.occurred_at as max_disk_at,
12479 max_memory_and_disk.memory_and_disk_percent as memory_and_disk_percent,
12480 max_memory_and_disk.memory_percent as max_memory_and_disk_memory_percent,
12481 max_memory_and_disk.disk_percent as max_memory_and_disk_disk_percent,
12482 max_memory_and_disk.occurred_at as max_memory_and_disk_at,
12483 max_cpu.cpu_percent as max_cpu_percent,
12484 max_cpu.occurred_at as max_cpu_at,
12485 replica_offline_event_history.offline_events,
12486 max_memory.bucket_start + INTERVAL '8 HOURS' as bucket_end,
12487 replica_name_history.new_name AS name,
12488 replica_history.cluster_id,
12489 replica_history.size
12490FROM max_memory
12491 JOIN max_disk ON max_memory.bucket_start = max_disk.bucket_start
12492 AND max_memory.replica_id = max_disk.replica_id
12493 JOIN max_cpu ON max_memory.bucket_start = max_cpu.bucket_start
12494 AND max_memory.replica_id = max_cpu.replica_id
12495 JOIN max_memory_and_disk ON max_memory.bucket_start = max_memory_and_disk.bucket_start
12496 AND max_memory.replica_id = max_memory_and_disk.replica_id
12497 JOIN replica_history ON max_memory.replica_id = replica_history.replica_id,
12498 LATERAL (
12499 SELECT new_name
12500 FROM mz_internal.mz_cluster_replica_name_history as replica_name_history
12501 WHERE max_memory.replica_id = replica_name_history.id -- We treat NULLs as the beginning of time
12502 AND max_memory.bucket_start + INTERVAL '8 HOURS' >= COALESCE(
12503 replica_name_history.occurred_at,
12504 '1970-01-01'::timestamp
12505 )
12506 ORDER BY replica_name_history.occurred_at DESC
12507 LIMIT '1'
12508 ) AS replica_name_history
12509 LEFT JOIN replica_offline_event_history ON max_memory.bucket_start = replica_offline_event_history.bucket_start
12510 AND max_memory.replica_id = replica_offline_event_history.replica_id"#,
12511 access: vec![PUBLIC_SELECT],
12512 }
12513});
12514
12515pub static MZ_CLUSTER_DEPLOYMENT_LINEAGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12538 name: "mz_cluster_deployment_lineage",
12539 schema: MZ_INTERNAL_SCHEMA,
12540 oid: oid::VIEW_MZ_CLUSTER_DEPLOYMENT_LINEAGE_OID,
12541 desc: RelationDesc::builder()
12542 .with_column("cluster_id", SqlScalarType::String.nullable(true))
12543 .with_column(
12544 "current_deployment_cluster_id",
12545 SqlScalarType::String.nullable(false),
12546 )
12547 .with_column("cluster_name", SqlScalarType::String.nullable(false))
12548 .with_key(vec![0, 1, 2])
12549 .finish(),
12550 column_comments: BTreeMap::from_iter([
12551 (
12552 "cluster_id",
12553 "The ID of the cluster. Corresponds to `mz_clusters.id` (though the cluster may no longer exist).",
12554 ),
12555 (
12556 "current_deployment_cluster_id",
12557 "The cluster ID of the last cluster in `cluster_id`'s blue/green lineage (the cluster is guaranteed to exist).",
12558 ),
12559 ("cluster_name", "The name of the cluster"),
12560 ]),
12561 sql: r#"WITH MUTUALLY RECURSIVE cluster_events (
12562 cluster_id text,
12563 cluster_name text,
12564 event_type text,
12565 occurred_at timestamptz
12566) AS (
12567 SELECT coalesce(details->>'id', details->>'cluster_id') AS cluster_id,
12568 coalesce(details->>'name', details->>'new_name') AS cluster_name,
12569 event_type,
12570 occurred_at
12571 FROM mz_audit_events
12572 WHERE (
12573 event_type IN ('create', 'drop')
12574 OR (
12575 event_type = 'alter'
12576 AND details ? 'new_name'
12577 )
12578 )
12579 AND object_type = 'cluster'
12580 AND mz_now() < occurred_at + INTERVAL '30 days'
12581),
12582mz_cluster_deployment_lineage (
12583 cluster_id text,
12584 current_deployment_cluster_id text,
12585 cluster_name text
12586) AS (
12587 SELECT c.id,
12588 c.id,
12589 c.name
12590 FROM mz_clusters c
12591 WHERE c.id LIKE 'u%'
12592 UNION
12593 SELECT *
12594 FROM dropped_clusters
12595),
12596-- Closest create or rename event based on the current clusters in the result set
12597most_recent_create_or_rename (
12598 cluster_id text,
12599 current_deployment_cluster_id text,
12600 cluster_name text,
12601 occurred_at timestamptz
12602) AS (
12603 SELECT DISTINCT ON (e.cluster_id) e.cluster_id,
12604 c.current_deployment_cluster_id,
12605 e.cluster_name,
12606 e.occurred_at
12607 FROM mz_cluster_deployment_lineage c
12608 JOIN cluster_events e ON c.cluster_id = e.cluster_id
12609 AND c.cluster_name = e.cluster_name
12610 WHERE e.event_type <> 'drop'
12611 ORDER BY e.cluster_id,
12612 e.occurred_at DESC
12613),
12614-- Clusters that were dropped most recently within 1 minute of most_recent_create_or_rename
12615dropped_clusters (
12616 cluster_id text,
12617 current_deployment_cluster_id text,
12618 cluster_name text
12619) AS (
12620 SELECT DISTINCT ON (cr.cluster_id) e.cluster_id,
12621 cr.current_deployment_cluster_id,
12622 cr.cluster_name
12623 FROM most_recent_create_or_rename cr
12624 JOIN cluster_events e ON e.occurred_at BETWEEN cr.occurred_at - interval '1 minute'
12625 AND cr.occurred_at + interval '1 minute'
12626 AND (
12627 e.cluster_name = cr.cluster_name
12628 OR e.cluster_name = cr.cluster_name || '_dbt_deploy'
12629 )
12630 WHERE e.event_type = 'drop'
12631 ORDER BY cr.cluster_id,
12632 abs(
12633 extract(
12634 epoch
12635 FROM cr.occurred_at - e.occurred_at
12636 )
12637 )
12638)
12639SELECT *
12640FROM mz_cluster_deployment_lineage"#,
12641 access: vec![PUBLIC_SELECT],
12642});
12643
12644pub const MZ_SHOW_DATABASES_IND: BuiltinIndex = BuiltinIndex {
12645 name: "mz_show_databases_ind",
12646 schema: MZ_INTERNAL_SCHEMA,
12647 oid: oid::INDEX_MZ_SHOW_DATABASES_IND_OID,
12648 sql: "IN CLUSTER mz_catalog_server
12649ON mz_internal.mz_show_databases (name)",
12650 is_retained_metrics_object: false,
12651};
12652
12653pub const MZ_SHOW_SCHEMAS_IND: BuiltinIndex = BuiltinIndex {
12654 name: "mz_show_schemas_ind",
12655 schema: MZ_INTERNAL_SCHEMA,
12656 oid: oid::INDEX_MZ_SHOW_SCHEMAS_IND_OID,
12657 sql: "IN CLUSTER mz_catalog_server
12658ON mz_internal.mz_show_schemas (database_id)",
12659 is_retained_metrics_object: false,
12660};
12661
12662pub const MZ_SHOW_CONNECTIONS_IND: BuiltinIndex = BuiltinIndex {
12663 name: "mz_show_connections_ind",
12664 schema: MZ_INTERNAL_SCHEMA,
12665 oid: oid::INDEX_MZ_SHOW_CONNECTIONS_IND_OID,
12666 sql: "IN CLUSTER mz_catalog_server
12667ON mz_internal.mz_show_connections (schema_id)",
12668 is_retained_metrics_object: false,
12669};
12670
12671pub const MZ_SHOW_TABLES_IND: BuiltinIndex = BuiltinIndex {
12672 name: "mz_show_tables_ind",
12673 schema: MZ_INTERNAL_SCHEMA,
12674 oid: oid::INDEX_MZ_SHOW_TABLES_IND_OID,
12675 sql: "IN CLUSTER mz_catalog_server
12676ON mz_internal.mz_show_tables (schema_id)",
12677 is_retained_metrics_object: false,
12678};
12679
12680pub const MZ_SHOW_SOURCES_IND: BuiltinIndex = BuiltinIndex {
12681 name: "mz_show_sources_ind",
12682 schema: MZ_INTERNAL_SCHEMA,
12683 oid: oid::INDEX_MZ_SHOW_SOURCES_IND_OID,
12684 sql: "IN CLUSTER mz_catalog_server
12685ON mz_internal.mz_show_sources (schema_id)",
12686 is_retained_metrics_object: false,
12687};
12688
12689pub const MZ_SHOW_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12690 name: "mz_show_views_ind",
12691 schema: MZ_INTERNAL_SCHEMA,
12692 oid: oid::INDEX_MZ_SHOW_VIEWS_IND_OID,
12693 sql: "IN CLUSTER mz_catalog_server
12694ON mz_internal.mz_show_views (schema_id)",
12695 is_retained_metrics_object: false,
12696};
12697
12698pub const MZ_SHOW_MATERIALIZED_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12699 name: "mz_show_materialized_views_ind",
12700 schema: MZ_INTERNAL_SCHEMA,
12701 oid: oid::INDEX_MZ_SHOW_MATERIALIZED_VIEWS_IND_OID,
12702 sql: "IN CLUSTER mz_catalog_server
12703ON mz_internal.mz_show_materialized_views (schema_id)",
12704 is_retained_metrics_object: false,
12705};
12706
12707pub const MZ_SHOW_SINKS_IND: BuiltinIndex = BuiltinIndex {
12708 name: "mz_show_sinks_ind",
12709 schema: MZ_INTERNAL_SCHEMA,
12710 oid: oid::INDEX_MZ_SHOW_SINKS_IND_OID,
12711 sql: "IN CLUSTER mz_catalog_server
12712ON mz_internal.mz_show_sinks (schema_id)",
12713 is_retained_metrics_object: false,
12714};
12715
12716pub const MZ_SHOW_TYPES_IND: BuiltinIndex = BuiltinIndex {
12717 name: "mz_show_types_ind",
12718 schema: MZ_INTERNAL_SCHEMA,
12719 oid: oid::INDEX_MZ_SHOW_TYPES_IND_OID,
12720 sql: "IN CLUSTER mz_catalog_server
12721ON mz_internal.mz_show_types (schema_id)",
12722 is_retained_metrics_object: false,
12723};
12724
12725pub const MZ_SHOW_ROLES_IND: BuiltinIndex = BuiltinIndex {
12726 name: "mz_show_roles_ind",
12727 schema: MZ_INTERNAL_SCHEMA,
12728 oid: oid::INDEX_MZ_SHOW_ROLES_IND_OID,
12729 sql: "IN CLUSTER mz_catalog_server
12730ON mz_internal.mz_show_roles (name)",
12731 is_retained_metrics_object: false,
12732};
12733
12734pub const MZ_SHOW_ALL_OBJECTS_IND: BuiltinIndex = BuiltinIndex {
12735 name: "mz_show_all_objects_ind",
12736 schema: MZ_INTERNAL_SCHEMA,
12737 oid: oid::INDEX_MZ_SHOW_ALL_OBJECTS_IND_OID,
12738 sql: "IN CLUSTER mz_catalog_server
12739ON mz_internal.mz_show_all_objects (schema_id)",
12740 is_retained_metrics_object: false,
12741};
12742
12743pub const MZ_SHOW_INDEXES_IND: BuiltinIndex = BuiltinIndex {
12744 name: "mz_show_indexes_ind",
12745 schema: MZ_INTERNAL_SCHEMA,
12746 oid: oid::INDEX_MZ_SHOW_INDEXES_IND_OID,
12747 sql: "IN CLUSTER mz_catalog_server
12748ON mz_internal.mz_show_indexes (schema_id)",
12749 is_retained_metrics_object: false,
12750};
12751
12752pub const MZ_SHOW_COLUMNS_IND: BuiltinIndex = BuiltinIndex {
12753 name: "mz_show_columns_ind",
12754 schema: MZ_INTERNAL_SCHEMA,
12755 oid: oid::INDEX_MZ_SHOW_COLUMNS_IND_OID,
12756 sql: "IN CLUSTER mz_catalog_server
12757ON mz_internal.mz_show_columns (id)",
12758 is_retained_metrics_object: false,
12759};
12760
12761pub const MZ_SHOW_CLUSTERS_IND: BuiltinIndex = BuiltinIndex {
12762 name: "mz_show_clusters_ind",
12763 schema: MZ_INTERNAL_SCHEMA,
12764 oid: oid::INDEX_MZ_SHOW_CLUSTERS_IND_OID,
12765 sql: "IN CLUSTER mz_catalog_server
12766ON mz_internal.mz_show_clusters (name)",
12767 is_retained_metrics_object: false,
12768};
12769
12770pub const MZ_SHOW_CLUSTER_REPLICAS_IND: BuiltinIndex = BuiltinIndex {
12771 name: "mz_show_cluster_replicas_ind",
12772 schema: MZ_INTERNAL_SCHEMA,
12773 oid: oid::INDEX_MZ_SHOW_CLUSTER_REPLICAS_IND_OID,
12774 sql: "IN CLUSTER mz_catalog_server
12775ON mz_internal.mz_show_cluster_replicas (cluster)",
12776 is_retained_metrics_object: false,
12777};
12778
12779pub const MZ_SHOW_SECRETS_IND: BuiltinIndex = BuiltinIndex {
12780 name: "mz_show_secrets_ind",
12781 schema: MZ_INTERNAL_SCHEMA,
12782 oid: oid::INDEX_MZ_SHOW_SECRETS_IND_OID,
12783 sql: "IN CLUSTER mz_catalog_server
12784ON mz_internal.mz_show_secrets (schema_id)",
12785 is_retained_metrics_object: false,
12786};
12787
12788pub const MZ_DATABASES_IND: BuiltinIndex = BuiltinIndex {
12789 name: "mz_databases_ind",
12790 schema: MZ_CATALOG_SCHEMA,
12791 oid: oid::INDEX_MZ_DATABASES_IND_OID,
12792 sql: "IN CLUSTER mz_catalog_server
12793ON mz_catalog.mz_databases (name)",
12794 is_retained_metrics_object: false,
12795};
12796
12797pub const MZ_SCHEMAS_IND: BuiltinIndex = BuiltinIndex {
12798 name: "mz_schemas_ind",
12799 schema: MZ_CATALOG_SCHEMA,
12800 oid: oid::INDEX_MZ_SCHEMAS_IND_OID,
12801 sql: "IN CLUSTER mz_catalog_server
12802ON mz_catalog.mz_schemas (database_id)",
12803 is_retained_metrics_object: false,
12804};
12805
12806pub const MZ_CONNECTIONS_IND: BuiltinIndex = BuiltinIndex {
12807 name: "mz_connections_ind",
12808 schema: MZ_CATALOG_SCHEMA,
12809 oid: oid::INDEX_MZ_CONNECTIONS_IND_OID,
12810 sql: "IN CLUSTER mz_catalog_server
12811ON mz_catalog.mz_connections (schema_id)",
12812 is_retained_metrics_object: false,
12813};
12814
12815pub const MZ_TABLES_IND: BuiltinIndex = BuiltinIndex {
12816 name: "mz_tables_ind",
12817 schema: MZ_CATALOG_SCHEMA,
12818 oid: oid::INDEX_MZ_TABLES_IND_OID,
12819 sql: "IN CLUSTER mz_catalog_server
12820ON mz_catalog.mz_tables (schema_id)",
12821 is_retained_metrics_object: false,
12822};
12823
12824pub const MZ_TYPES_IND: BuiltinIndex = BuiltinIndex {
12825 name: "mz_types_ind",
12826 schema: MZ_CATALOG_SCHEMA,
12827 oid: oid::INDEX_MZ_TYPES_IND_OID,
12828 sql: "IN CLUSTER mz_catalog_server
12829ON mz_catalog.mz_types (schema_id)",
12830 is_retained_metrics_object: false,
12831};
12832
12833pub const MZ_OBJECTS_IND: BuiltinIndex = BuiltinIndex {
12834 name: "mz_objects_ind",
12835 schema: MZ_CATALOG_SCHEMA,
12836 oid: oid::INDEX_MZ_OBJECTS_IND_OID,
12837 sql: "IN CLUSTER mz_catalog_server
12838ON mz_catalog.mz_objects (schema_id)",
12839 is_retained_metrics_object: false,
12840};
12841
12842pub const MZ_COLUMNS_IND: BuiltinIndex = BuiltinIndex {
12843 name: "mz_columns_ind",
12844 schema: MZ_CATALOG_SCHEMA,
12845 oid: oid::INDEX_MZ_COLUMNS_IND_OID,
12846 sql: "IN CLUSTER mz_catalog_server
12847ON mz_catalog.mz_columns (name)",
12848 is_retained_metrics_object: false,
12849};
12850
12851pub const MZ_SECRETS_IND: BuiltinIndex = BuiltinIndex {
12852 name: "mz_secrets_ind",
12853 schema: MZ_CATALOG_SCHEMA,
12854 oid: oid::INDEX_MZ_SECRETS_IND_OID,
12855 sql: "IN CLUSTER mz_catalog_server
12856ON mz_catalog.mz_secrets (name)",
12857 is_retained_metrics_object: false,
12858};
12859
12860pub const MZ_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12861 name: "mz_views_ind",
12862 schema: MZ_CATALOG_SCHEMA,
12863 oid: oid::INDEX_MZ_VIEWS_IND_OID,
12864 sql: "IN CLUSTER mz_catalog_server
12865ON mz_catalog.mz_views (schema_id)",
12866 is_retained_metrics_object: false,
12867};
12868
12869pub const MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_IND: BuiltinIndex = BuiltinIndex {
12870 name: "mz_console_cluster_utilization_overview_ind",
12871 schema: MZ_INTERNAL_SCHEMA,
12872 oid: oid::INDEX_MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_IND_OID,
12873 sql: "IN CLUSTER mz_catalog_server
12874ON mz_internal.mz_console_cluster_utilization_overview (cluster_id)",
12875 is_retained_metrics_object: false,
12876};
12877
12878pub const MZ_CLUSTER_DEPLOYMENT_LINEAGE_IND: BuiltinIndex = BuiltinIndex {
12879 name: "mz_cluster_deployment_lineage_ind",
12880 schema: MZ_INTERNAL_SCHEMA,
12881 oid: oid::INDEX_MZ_CLUSTER_DEPLOYMENT_LINEAGE_IND_OID,
12882 sql: "IN CLUSTER mz_catalog_server
12883ON mz_internal.mz_cluster_deployment_lineage (cluster_id)",
12884 is_retained_metrics_object: false,
12885};
12886
12887pub const MZ_CLUSTERS_IND: BuiltinIndex = BuiltinIndex {
12888 name: "mz_clusters_ind",
12889 schema: MZ_CATALOG_SCHEMA,
12890 oid: oid::INDEX_MZ_CLUSTERS_IND_OID,
12891 sql: "IN CLUSTER mz_catalog_server
12892ON mz_catalog.mz_clusters (id)",
12893 is_retained_metrics_object: false,
12894};
12895
12896pub const MZ_INDEXES_IND: BuiltinIndex = BuiltinIndex {
12897 name: "mz_indexes_ind",
12898 schema: MZ_CATALOG_SCHEMA,
12899 oid: oid::INDEX_MZ_INDEXES_IND_OID,
12900 sql: "IN CLUSTER mz_catalog_server
12901ON mz_catalog.mz_indexes (id)",
12902 is_retained_metrics_object: false,
12903};
12904
12905pub const MZ_ROLES_IND: BuiltinIndex = BuiltinIndex {
12906 name: "mz_roles_ind",
12907 schema: MZ_CATALOG_SCHEMA,
12908 oid: oid::INDEX_MZ_ROLES_IND_OID,
12909 sql: "IN CLUSTER mz_catalog_server
12910ON mz_catalog.mz_roles (id)",
12911 is_retained_metrics_object: false,
12912};
12913
12914pub const MZ_SOURCES_IND: BuiltinIndex = BuiltinIndex {
12915 name: "mz_sources_ind",
12916 schema: MZ_CATALOG_SCHEMA,
12917 oid: oid::INDEX_MZ_SOURCES_IND_OID,
12918 sql: "IN CLUSTER mz_catalog_server
12919ON mz_catalog.mz_sources (id)",
12920 is_retained_metrics_object: true,
12921};
12922
12923pub const MZ_SINKS_IND: BuiltinIndex = BuiltinIndex {
12924 name: "mz_sinks_ind",
12925 schema: MZ_CATALOG_SCHEMA,
12926 oid: oid::INDEX_MZ_SINKS_IND_OID,
12927 sql: "IN CLUSTER mz_catalog_server
12928ON mz_catalog.mz_sinks (id)",
12929 is_retained_metrics_object: true,
12930};
12931
12932pub const MZ_MATERIALIZED_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12933 name: "mz_materialized_views_ind",
12934 schema: MZ_CATALOG_SCHEMA,
12935 oid: oid::INDEX_MZ_MATERIALIZED_VIEWS_IND_OID,
12936 sql: "IN CLUSTER mz_catalog_server
12937ON mz_catalog.mz_materialized_views (id)",
12938 is_retained_metrics_object: false,
12939};
12940
12941pub const MZ_CONTINUAL_TASKS_IND: BuiltinIndex = BuiltinIndex {
12942 name: "mz_continual_tasks_ind",
12943 schema: MZ_INTERNAL_SCHEMA,
12944 oid: oid::INDEX_MZ_CONTINUAL_TASKS_IND_OID,
12945 sql: "IN CLUSTER mz_catalog_server
12946ON mz_internal.mz_continual_tasks (id)",
12947 is_retained_metrics_object: false,
12948};
12949
12950pub const MZ_SOURCE_STATUSES_IND: BuiltinIndex = BuiltinIndex {
12951 name: "mz_source_statuses_ind",
12952 schema: MZ_INTERNAL_SCHEMA,
12953 oid: oid::INDEX_MZ_SOURCE_STATUSES_IND_OID,
12954 sql: "IN CLUSTER mz_catalog_server
12955ON mz_internal.mz_source_statuses (id)",
12956 is_retained_metrics_object: false,
12957};
12958
12959pub const MZ_SINK_STATUSES_IND: BuiltinIndex = BuiltinIndex {
12960 name: "mz_sink_statuses_ind",
12961 schema: MZ_INTERNAL_SCHEMA,
12962 oid: oid::INDEX_MZ_SINK_STATUSES_IND_OID,
12963 sql: "IN CLUSTER mz_catalog_server
12964ON mz_internal.mz_sink_statuses (id)",
12965 is_retained_metrics_object: false,
12966};
12967
12968pub const MZ_SOURCE_STATUS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
12969 name: "mz_source_status_history_ind",
12970 schema: MZ_INTERNAL_SCHEMA,
12971 oid: oid::INDEX_MZ_SOURCE_STATUS_HISTORY_IND_OID,
12972 sql: "IN CLUSTER mz_catalog_server
12973ON mz_internal.mz_source_status_history (source_id)",
12974 is_retained_metrics_object: false,
12975};
12976
12977pub const MZ_SINK_STATUS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
12978 name: "mz_sink_status_history_ind",
12979 schema: MZ_INTERNAL_SCHEMA,
12980 oid: oid::INDEX_MZ_SINK_STATUS_HISTORY_IND_OID,
12981 sql: "IN CLUSTER mz_catalog_server
12982ON mz_internal.mz_sink_status_history (sink_id)",
12983 is_retained_metrics_object: false,
12984};
12985
12986pub const MZ_SHOW_CONTINUAL_TASKS_IND: BuiltinIndex = BuiltinIndex {
12987 name: "mz_show_continual_tasks_ind",
12988 schema: MZ_INTERNAL_SCHEMA,
12989 oid: oid::INDEX_MZ_SHOW_CONTINUAL_TASKS_OID,
12990 sql: "IN CLUSTER mz_catalog_server
12991ON mz_internal.mz_show_continual_tasks (id)",
12992 is_retained_metrics_object: false,
12993};
12994
12995pub static MZ_SOURCE_STATISTICS_WITH_HISTORY: LazyLock<BuiltinView> =
13008 LazyLock::new(|| BuiltinView {
13009 name: "mz_source_statistics_with_history",
13010 schema: MZ_INTERNAL_SCHEMA,
13011 oid: oid::VIEW_MZ_SOURCE_STATISTICS_WITH_HISTORY_OID,
13012 desc: RelationDesc::builder()
13013 .with_column("id", SqlScalarType::String.nullable(false))
13014 .with_column("replica_id", SqlScalarType::String.nullable(true))
13015 .with_column("messages_received", SqlScalarType::UInt64.nullable(false))
13016 .with_column("bytes_received", SqlScalarType::UInt64.nullable(false))
13017 .with_column("updates_staged", SqlScalarType::UInt64.nullable(false))
13018 .with_column("updates_committed", SqlScalarType::UInt64.nullable(false))
13019 .with_column("records_indexed", SqlScalarType::UInt64.nullable(false))
13020 .with_column("bytes_indexed", SqlScalarType::UInt64.nullable(false))
13021 .with_column(
13022 "rehydration_latency",
13023 SqlScalarType::Interval.nullable(true),
13024 )
13025 .with_column(
13026 "snapshot_records_known",
13027 SqlScalarType::UInt64.nullable(true),
13028 )
13029 .with_column(
13030 "snapshot_records_staged",
13031 SqlScalarType::UInt64.nullable(true),
13032 )
13033 .with_column("snapshot_committed", SqlScalarType::Bool.nullable(false))
13034 .with_column("offset_known", SqlScalarType::UInt64.nullable(true))
13035 .with_column("offset_committed", SqlScalarType::UInt64.nullable(true))
13036 .with_key(vec![0, 1])
13037 .finish(),
13038 column_comments: BTreeMap::new(),
13039 sql: "
13040WITH
13041 -- For each subsource, statistics are reported as its parent source
13042 subsource_to_parent AS
13043 (
13044 SELECT subsource.id AS id, parent.id AS report_id
13045 FROM mz_catalog.mz_sources AS subsource
13046 JOIN mz_internal.mz_object_dependencies AS dep ON subsource.id = dep.object_id
13047 JOIN mz_catalog.mz_sources AS parent ON parent.id = dep.referenced_object_id
13048 WHERE subsource.type = 'subsource'
13049 ),
13050 -- For each table from source, statistics are reported as its parent source
13051 table_to_parent AS
13052 (
13053 SELECT id, source_id AS report_id
13054 FROM mz_catalog.mz_tables
13055 WHERE source_id IS NOT NULL
13056 ),
13057 -- For each source and subsource, statistics are reported as itself
13058 source_refl AS
13059 (
13060 SELECT id, id AS report_id
13061 FROM mz_catalog.mz_sources
13062 WHERE type NOT IN ('progress', 'log')
13063 ),
13064 -- For each table from source, statistics are reported as itself
13065 table_refl AS
13066 (
13067 SELECT id, id AS report_id
13068 FROM mz_catalog.mz_tables
13069 WHERE source_id IS NOT NULL
13070 ),
13071 report_paths AS
13072 (
13073 SELECT id, report_id FROM subsource_to_parent
13074 UNION ALL SELECT id, report_id FROM table_to_parent
13075 UNION ALL SELECT id, report_id FROM source_refl
13076 UNION ALL SELECT id, report_id FROM table_refl
13077 )
13078SELECT
13079 report_paths.report_id AS id,
13080 replica_id,
13081 -- Counters
13082 SUM(messages_received)::uint8 AS messages_received,
13083 SUM(bytes_received)::uint8 AS bytes_received,
13084 SUM(updates_staged)::uint8 AS updates_staged,
13085 SUM(updates_committed)::uint8 AS updates_committed,
13086 -- Resetting Gauges
13087 SUM(records_indexed)::uint8 AS records_indexed,
13088 SUM(bytes_indexed)::uint8 AS bytes_indexed,
13089 -- Ensure we aggregate to NULL when not all workers are done rehydrating.
13090 CASE
13091 WHEN bool_or(rehydration_latency IS NULL) THEN NULL
13092 ELSE MAX(rehydration_latency)::interval
13093 END AS rehydration_latency,
13094 SUM(snapshot_records_known)::uint8 AS snapshot_records_known,
13095 SUM(snapshot_records_staged)::uint8 AS snapshot_records_staged,
13096 bool_and(snapshot_committed) as snapshot_committed,
13097 -- Gauges
13098 MAX(offset_known)::uint8 AS offset_known,
13099 MIN(offset_committed)::uint8 AS offset_committed
13100FROM mz_internal.mz_source_statistics_raw
13101 JOIN report_paths USING (id)
13102GROUP BY report_paths.report_id, replica_id",
13103 access: vec![PUBLIC_SELECT],
13104 });
13105
13106pub const MZ_SOURCE_STATISTICS_WITH_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13107 name: "mz_source_statistics_with_history_ind",
13108 schema: MZ_INTERNAL_SCHEMA,
13109 oid: oid::INDEX_MZ_SOURCE_STATISTICS_WITH_HISTORY_IND_OID,
13110 sql: "IN CLUSTER mz_catalog_server
13111ON mz_internal.mz_source_statistics_with_history (id, replica_id)",
13112 is_retained_metrics_object: true,
13113};
13114
13115pub static MZ_SOURCE_STATISTICS: LazyLock<BuiltinView> = LazyLock::new(|| {
13118 BuiltinView {
13119 name: "mz_source_statistics",
13120 schema: MZ_INTERNAL_SCHEMA,
13121 oid: oid::VIEW_MZ_SOURCE_STATISTICS_OID,
13122 desc: RelationDesc::builder()
13124 .with_column("id", SqlScalarType::String.nullable(false))
13125 .with_column("replica_id", SqlScalarType::String.nullable(true))
13126 .with_column("messages_received", SqlScalarType::UInt64.nullable(false))
13127 .with_column("bytes_received", SqlScalarType::UInt64.nullable(false))
13128 .with_column("updates_staged", SqlScalarType::UInt64.nullable(false))
13129 .with_column("updates_committed", SqlScalarType::UInt64.nullable(false))
13130 .with_column("records_indexed", SqlScalarType::UInt64.nullable(false))
13131 .with_column("bytes_indexed", SqlScalarType::UInt64.nullable(false))
13132 .with_column(
13133 "rehydration_latency",
13134 SqlScalarType::Interval.nullable(true),
13135 )
13136 .with_column(
13137 "snapshot_records_known",
13138 SqlScalarType::UInt64.nullable(true),
13139 )
13140 .with_column(
13141 "snapshot_records_staged",
13142 SqlScalarType::UInt64.nullable(true),
13143 )
13144 .with_column("snapshot_committed", SqlScalarType::Bool.nullable(false))
13145 .with_column("offset_known", SqlScalarType::UInt64.nullable(true))
13146 .with_column("offset_committed", SqlScalarType::UInt64.nullable(true))
13147 .with_key(vec![0, 1])
13148 .finish(),
13149 column_comments: BTreeMap::from_iter([
13150 (
13151 "id",
13152 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
13153 ),
13154 (
13155 "replica_id",
13156 "The ID of a replica running the source. Corresponds to `mz_catalog.mz_cluster_replicas.id`.",
13157 ),
13158 (
13159 "messages_received",
13160 "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.",
13161 ),
13162 (
13163 "bytes_received",
13164 "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.",
13165 ),
13166 (
13167 "updates_staged",
13168 "The number of updates (insertions plus deletions) the source has written but not yet committed to the storage layer.",
13169 ),
13170 (
13171 "updates_committed",
13172 "The number of updates (insertions plus deletions) the source has committed to the storage layer.",
13173 ),
13174 (
13175 "records_indexed",
13176 "The number of individual records indexed in the source envelope state.",
13177 ),
13178 (
13179 "bytes_indexed",
13180 "The number of bytes stored in the source's internal index, if any.",
13181 ),
13182 (
13183 "rehydration_latency",
13184 "The amount of time it took for the source to rehydrate its internal index, if any, after the source last restarted.",
13185 ),
13186 (
13187 "snapshot_records_known",
13188 "The size of the source's snapshot, measured in number of records. See below to learn what constitutes a record.",
13189 ),
13190 (
13191 "snapshot_records_staged",
13192 "The number of records in the source's snapshot that Materialize has read. See below to learn what constitutes a record.",
13193 ),
13194 (
13195 "snapshot_committed",
13196 "Whether the source has committed the initial snapshot for a source.",
13197 ),
13198 (
13199 "offset_known",
13200 "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.",
13201 ),
13202 (
13203 "offset_committed",
13204 "The offset of the the data that Materialize has durably ingested. See below to learn what constitutes an offset.",
13205 ),
13206 ]),
13207 sql: "SELECT * FROM mz_internal.mz_source_statistics_with_history WHERE length(id) > 0",
13208 access: vec![PUBLIC_SELECT],
13209 }
13210});
13211
13212pub const MZ_SOURCE_STATISTICS_IND: BuiltinIndex = BuiltinIndex {
13213 name: "mz_source_statistics_ind",
13214 schema: MZ_INTERNAL_SCHEMA,
13215 oid: oid::INDEX_MZ_SOURCE_STATISTICS_IND_OID,
13216 sql: "IN CLUSTER mz_catalog_server
13217ON mz_internal.mz_source_statistics (id, replica_id)",
13218 is_retained_metrics_object: false,
13219};
13220
13221pub static MZ_SINK_STATISTICS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
13222 name: "mz_sink_statistics",
13223 schema: MZ_INTERNAL_SCHEMA,
13224 oid: oid::VIEW_MZ_SINK_STATISTICS_OID,
13225 desc: RelationDesc::builder()
13226 .with_column("id", SqlScalarType::String.nullable(false))
13227 .with_column("replica_id", SqlScalarType::String.nullable(true))
13228 .with_column("messages_staged", SqlScalarType::UInt64.nullable(false))
13229 .with_column("messages_committed", SqlScalarType::UInt64.nullable(false))
13230 .with_column("bytes_staged", SqlScalarType::UInt64.nullable(false))
13231 .with_column("bytes_committed", SqlScalarType::UInt64.nullable(false))
13232 .with_key(vec![0, 1])
13233 .finish(),
13234 column_comments: BTreeMap::from_iter([
13235 (
13236 "id",
13237 "The ID of the sink. Corresponds to `mz_catalog.mz_sources.id`.",
13238 ),
13239 (
13240 "replica_id",
13241 "The ID of a replica running the sink. Corresponds to `mz_catalog.mz_cluster_replicas.id`.",
13242 ),
13243 (
13244 "messages_staged",
13245 "The number of messages staged but possibly not committed to the sink.",
13246 ),
13247 (
13248 "messages_committed",
13249 "The number of messages committed to the sink.",
13250 ),
13251 (
13252 "bytes_staged",
13253 "The number of bytes staged but possibly not committed to the sink. This counts both keys and values, if applicable.",
13254 ),
13255 (
13256 "bytes_committed",
13257 "The number of bytes committed to the sink. This counts both keys and values, if applicable.",
13258 ),
13259 ]),
13260 sql: "
13261SELECT
13262 id,
13263 replica_id,
13264 SUM(messages_staged)::uint8 AS messages_staged,
13265 SUM(messages_committed)::uint8 AS messages_committed,
13266 SUM(bytes_staged)::uint8 AS bytes_staged,
13267 SUM(bytes_committed)::uint8 AS bytes_committed
13268FROM mz_internal.mz_sink_statistics_raw
13269GROUP BY id, replica_id",
13270 access: vec![PUBLIC_SELECT],
13271});
13272
13273pub const MZ_SINK_STATISTICS_IND: BuiltinIndex = BuiltinIndex {
13274 name: "mz_sink_statistics_ind",
13275 schema: MZ_INTERNAL_SCHEMA,
13276 oid: oid::INDEX_MZ_SINK_STATISTICS_IND_OID,
13277 sql: "IN CLUSTER mz_catalog_server
13278ON mz_internal.mz_sink_statistics (id, replica_id)",
13279 is_retained_metrics_object: true,
13280};
13281
13282pub const MZ_CLUSTER_REPLICAS_IND: BuiltinIndex = BuiltinIndex {
13283 name: "mz_cluster_replicas_ind",
13284 schema: MZ_CATALOG_SCHEMA,
13285 oid: oid::INDEX_MZ_CLUSTER_REPLICAS_IND_OID,
13286 sql: "IN CLUSTER mz_catalog_server
13287ON mz_catalog.mz_cluster_replicas (id)",
13288 is_retained_metrics_object: true,
13289};
13290
13291pub const MZ_CLUSTER_REPLICA_SIZES_IND: BuiltinIndex = BuiltinIndex {
13292 name: "mz_cluster_replica_sizes_ind",
13293 schema: MZ_CATALOG_SCHEMA,
13294 oid: oid::INDEX_MZ_CLUSTER_REPLICA_SIZES_IND_OID,
13295 sql: "IN CLUSTER mz_catalog_server
13296ON mz_catalog.mz_cluster_replica_sizes (size)",
13297 is_retained_metrics_object: true,
13298};
13299
13300pub const MZ_CLUSTER_REPLICA_STATUSES_IND: BuiltinIndex = BuiltinIndex {
13301 name: "mz_cluster_replica_statuses_ind",
13302 schema: MZ_INTERNAL_SCHEMA,
13303 oid: oid::INDEX_MZ_CLUSTER_REPLICA_STATUSES_IND_OID,
13304 sql: "IN CLUSTER mz_catalog_server
13305ON mz_internal.mz_cluster_replica_statuses (replica_id)",
13306 is_retained_metrics_object: false,
13307};
13308
13309pub const MZ_CLUSTER_REPLICA_STATUS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13310 name: "mz_cluster_replica_status_history_ind",
13311 schema: MZ_INTERNAL_SCHEMA,
13312 oid: oid::INDEX_MZ_CLUSTER_REPLICA_STATUS_HISTORY_IND_OID,
13313 sql: "IN CLUSTER mz_catalog_server
13314ON mz_internal.mz_cluster_replica_status_history (replica_id)",
13315 is_retained_metrics_object: false,
13316};
13317
13318pub const MZ_CLUSTER_REPLICA_METRICS_IND: BuiltinIndex = BuiltinIndex {
13319 name: "mz_cluster_replica_metrics_ind",
13320 schema: MZ_INTERNAL_SCHEMA,
13321 oid: oid::INDEX_MZ_CLUSTER_REPLICA_METRICS_IND_OID,
13322 sql: "IN CLUSTER mz_catalog_server
13323ON mz_internal.mz_cluster_replica_metrics (replica_id)",
13324 is_retained_metrics_object: false,
13325};
13326
13327pub const MZ_CLUSTER_REPLICA_METRICS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13328 name: "mz_cluster_replica_metrics_history_ind",
13329 schema: MZ_INTERNAL_SCHEMA,
13330 oid: oid::INDEX_MZ_CLUSTER_REPLICA_METRICS_HISTORY_IND_OID,
13331 sql: "IN CLUSTER mz_catalog_server
13332ON mz_internal.mz_cluster_replica_metrics_history (replica_id)",
13333 is_retained_metrics_object: false,
13334};
13335
13336pub const MZ_CLUSTER_REPLICA_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13337 name: "mz_cluster_replica_history_ind",
13338 schema: MZ_INTERNAL_SCHEMA,
13339 oid: oid::INDEX_MZ_CLUSTER_REPLICA_HISTORY_IND_OID,
13340 sql: "IN CLUSTER mz_catalog_server
13341ON mz_internal.mz_cluster_replica_history (dropped_at)",
13342 is_retained_metrics_object: true,
13343};
13344
13345pub const MZ_CLUSTER_REPLICA_NAME_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13346 name: "mz_cluster_replica_name_history_ind",
13347 schema: MZ_INTERNAL_SCHEMA,
13348 oid: oid::INDEX_MZ_CLUSTER_REPLICA_NAME_HISTORY_IND_OID,
13349 sql: "IN CLUSTER mz_catalog_server
13350ON mz_internal.mz_cluster_replica_name_history (id)",
13351 is_retained_metrics_object: false,
13352};
13353
13354pub const MZ_OBJECT_LIFETIMES_IND: BuiltinIndex = BuiltinIndex {
13355 name: "mz_object_lifetimes_ind",
13356 schema: MZ_INTERNAL_SCHEMA,
13357 oid: oid::INDEX_MZ_OBJECT_LIFETIMES_IND_OID,
13358 sql: "IN CLUSTER mz_catalog_server
13359ON mz_internal.mz_object_lifetimes (id)",
13360 is_retained_metrics_object: false,
13361};
13362
13363pub const MZ_OBJECT_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13364 name: "mz_object_history_ind",
13365 schema: MZ_INTERNAL_SCHEMA,
13366 oid: oid::INDEX_MZ_OBJECT_HISTORY_IND_OID,
13367 sql: "IN CLUSTER mz_catalog_server
13368ON mz_internal.mz_object_history (id)",
13369 is_retained_metrics_object: false,
13370};
13371
13372pub const MZ_OBJECT_DEPENDENCIES_IND: BuiltinIndex = BuiltinIndex {
13373 name: "mz_object_dependencies_ind",
13374 schema: MZ_INTERNAL_SCHEMA,
13375 oid: oid::INDEX_MZ_OBJECT_DEPENDENCIES_IND_OID,
13376 sql: "IN CLUSTER mz_catalog_server
13377ON mz_internal.mz_object_dependencies (object_id)",
13378 is_retained_metrics_object: true,
13379};
13380
13381pub const MZ_COMPUTE_DEPENDENCIES_IND: BuiltinIndex = BuiltinIndex {
13382 name: "mz_compute_dependencies_ind",
13383 schema: MZ_INTERNAL_SCHEMA,
13384 oid: oid::INDEX_MZ_COMPUTE_DEPENDENCIES_IND_OID,
13385 sql: "IN CLUSTER mz_catalog_server
13386ON mz_internal.mz_compute_dependencies (dependency_id)",
13387 is_retained_metrics_object: false,
13388};
13389
13390pub const MZ_OBJECT_TRANSITIVE_DEPENDENCIES_IND: BuiltinIndex = BuiltinIndex {
13391 name: "mz_object_transitive_dependencies_ind",
13392 schema: MZ_INTERNAL_SCHEMA,
13393 oid: oid::INDEX_MZ_OBJECT_TRANSITIVE_DEPENDENCIES_IND_OID,
13394 sql: "IN CLUSTER mz_catalog_server
13395ON mz_internal.mz_object_transitive_dependencies (object_id)",
13396 is_retained_metrics_object: false,
13397};
13398
13399pub const MZ_FRONTIERS_IND: BuiltinIndex = BuiltinIndex {
13400 name: "mz_frontiers_ind",
13401 schema: MZ_INTERNAL_SCHEMA,
13402 oid: oid::INDEX_MZ_FRONTIERS_IND_OID,
13403 sql: "IN CLUSTER mz_catalog_server
13404ON mz_internal.mz_frontiers (object_id)",
13405 is_retained_metrics_object: false,
13406};
13407
13408pub const MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13409 name: "mz_wallclock_global_lag_recent_history_ind",
13410 schema: MZ_INTERNAL_SCHEMA,
13411 oid: oid::INDEX_MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_IND_OID,
13412 sql: "IN CLUSTER mz_catalog_server
13413ON mz_internal.mz_wallclock_global_lag_recent_history (object_id)",
13414 is_retained_metrics_object: false,
13415};
13416
13417pub const MZ_RECENT_ACTIVITY_LOG_THINNED_IND: BuiltinIndex = BuiltinIndex {
13418 name: "mz_recent_activity_log_thinned_ind",
13419 schema: MZ_INTERNAL_SCHEMA,
13420 oid: oid::INDEX_MZ_RECENT_ACTIVITY_LOG_THINNED_IND_OID,
13421 sql: "IN CLUSTER mz_catalog_server
13422-- sql_hash because we plan to join
13423-- this against mz_internal.mz_sql_text
13424ON mz_internal.mz_recent_activity_log_thinned (sql_hash)",
13425 is_retained_metrics_object: false,
13426};
13427
13428pub const MZ_KAFKA_SOURCES_IND: BuiltinIndex = BuiltinIndex {
13429 name: "mz_kafka_sources_ind",
13430 schema: MZ_CATALOG_SCHEMA,
13431 oid: oid::INDEX_MZ_KAFKA_SOURCES_IND_OID,
13432 sql: "IN CLUSTER mz_catalog_server
13433ON mz_catalog.mz_kafka_sources (id)",
13434 is_retained_metrics_object: true,
13435};
13436
13437pub const MZ_WEBHOOK_SOURCES_IND: BuiltinIndex = BuiltinIndex {
13438 name: "mz_webhook_sources_ind",
13439 schema: MZ_INTERNAL_SCHEMA,
13440 oid: oid::INDEX_MZ_WEBHOOK_SOURCES_IND_OID,
13441 sql: "IN CLUSTER mz_catalog_server
13442ON mz_internal.mz_webhook_sources (id)",
13443 is_retained_metrics_object: true,
13444};
13445
13446pub const MZ_COMMENTS_IND: BuiltinIndex = BuiltinIndex {
13447 name: "mz_comments_ind",
13448 schema: MZ_INTERNAL_SCHEMA,
13449 oid: oid::INDEX_MZ_COMMENTS_IND_OID,
13450 sql: "IN CLUSTER mz_catalog_server
13451ON mz_internal.mz_comments (id)",
13452 is_retained_metrics_object: true,
13453};
13454
13455pub static MZ_ANALYTICS: BuiltinConnection = BuiltinConnection {
13456 name: "mz_analytics",
13457 schema: MZ_INTERNAL_SCHEMA,
13458 oid: oid::CONNECTION_MZ_ANALYTICS_OID,
13459 sql: "CREATE CONNECTION mz_internal.mz_analytics TO AWS (ASSUME ROLE ARN = '')",
13460 access: &[MzAclItem {
13461 grantee: MZ_SYSTEM_ROLE_ID,
13462 grantor: MZ_ANALYTICS_ROLE_ID,
13463 acl_mode: rbac::all_object_privileges(SystemObjectType::Object(ObjectType::Connection)),
13464 }],
13465 owner_id: &MZ_ANALYTICS_ROLE_ID,
13466 runtime_alterable: true,
13467};
13468
13469pub const MZ_SYSTEM_ROLE: BuiltinRole = BuiltinRole {
13470 id: MZ_SYSTEM_ROLE_ID,
13471 name: SYSTEM_USER_NAME,
13472 oid: oid::ROLE_MZ_SYSTEM_OID,
13473 attributes: RoleAttributesRaw::new().with_all(),
13474};
13475
13476pub const MZ_SUPPORT_ROLE: BuiltinRole = BuiltinRole {
13477 id: MZ_SUPPORT_ROLE_ID,
13478 name: SUPPORT_USER_NAME,
13479 oid: oid::ROLE_MZ_SUPPORT_OID,
13480 attributes: RoleAttributesRaw::new(),
13481};
13482
13483pub const MZ_ANALYTICS_ROLE: BuiltinRole = BuiltinRole {
13484 id: MZ_ANALYTICS_ROLE_ID,
13485 name: ANALYTICS_USER_NAME,
13486 oid: oid::ROLE_MZ_ANALYTICS_OID,
13487 attributes: RoleAttributesRaw::new(),
13488};
13489
13490pub const MZ_MONITOR_ROLE: BuiltinRole = BuiltinRole {
13493 id: MZ_MONITOR_ROLE_ID,
13494 name: "mz_monitor",
13495 oid: oid::ROLE_MZ_MONITOR_OID,
13496 attributes: RoleAttributesRaw::new(),
13497};
13498
13499pub const MZ_MONITOR_REDACTED: BuiltinRole = BuiltinRole {
13502 id: MZ_MONITOR_REDACTED_ROLE_ID,
13503 name: "mz_monitor_redacted",
13504 oid: oid::ROLE_MZ_MONITOR_REDACTED_OID,
13505 attributes: RoleAttributesRaw::new(),
13506};
13507
13508pub const MZ_SYSTEM_CLUSTER: BuiltinCluster = BuiltinCluster {
13509 name: SYSTEM_USER_NAME,
13510 owner_id: &MZ_SYSTEM_ROLE_ID,
13511 privileges: &[
13512 MzAclItem {
13513 grantee: MZ_SUPPORT_ROLE_ID,
13514 grantor: MZ_SYSTEM_ROLE_ID,
13515 acl_mode: AclMode::USAGE,
13516 },
13517 rbac::owner_privilege(ObjectType::Cluster, MZ_SYSTEM_ROLE_ID),
13518 ],
13519};
13520
13521pub const MZ_SYSTEM_CLUSTER_REPLICA: BuiltinClusterReplica = BuiltinClusterReplica {
13522 name: BUILTIN_CLUSTER_REPLICA_NAME,
13523 cluster_name: MZ_SYSTEM_CLUSTER.name,
13524};
13525
13526pub const MZ_CATALOG_SERVER_CLUSTER: BuiltinCluster = BuiltinCluster {
13527 name: "mz_catalog_server",
13528 owner_id: &MZ_SYSTEM_ROLE_ID,
13529 privileges: &[
13530 MzAclItem {
13531 grantee: RoleId::Public,
13532 grantor: MZ_SYSTEM_ROLE_ID,
13533 acl_mode: AclMode::USAGE,
13534 },
13535 MzAclItem {
13536 grantee: MZ_SUPPORT_ROLE_ID,
13537 grantor: MZ_SYSTEM_ROLE_ID,
13538 acl_mode: AclMode::USAGE.union(AclMode::CREATE),
13539 },
13540 rbac::owner_privilege(ObjectType::Cluster, MZ_SYSTEM_ROLE_ID),
13541 ],
13542};
13543
13544pub const MZ_CATALOG_SERVER_CLUSTER_REPLICA: BuiltinClusterReplica = BuiltinClusterReplica {
13545 name: BUILTIN_CLUSTER_REPLICA_NAME,
13546 cluster_name: MZ_CATALOG_SERVER_CLUSTER.name,
13547};
13548
13549pub const MZ_PROBE_CLUSTER: BuiltinCluster = BuiltinCluster {
13550 name: "mz_probe",
13551 owner_id: &MZ_SYSTEM_ROLE_ID,
13552 privileges: &[
13553 MzAclItem {
13554 grantee: MZ_SUPPORT_ROLE_ID,
13555 grantor: MZ_SYSTEM_ROLE_ID,
13556 acl_mode: AclMode::USAGE,
13557 },
13558 MzAclItem {
13559 grantee: MZ_MONITOR_ROLE_ID,
13560 grantor: MZ_SYSTEM_ROLE_ID,
13561 acl_mode: AclMode::USAGE,
13562 },
13563 rbac::owner_privilege(ObjectType::Cluster, MZ_SYSTEM_ROLE_ID),
13564 ],
13565};
13566pub const MZ_PROBE_CLUSTER_REPLICA: BuiltinClusterReplica = BuiltinClusterReplica {
13567 name: BUILTIN_CLUSTER_REPLICA_NAME,
13568 cluster_name: MZ_PROBE_CLUSTER.name,
13569};
13570
13571pub const MZ_SUPPORT_CLUSTER: BuiltinCluster = BuiltinCluster {
13572 name: "mz_support",
13573 owner_id: &MZ_SUPPORT_ROLE_ID,
13574 privileges: &[
13575 MzAclItem {
13576 grantee: MZ_SYSTEM_ROLE_ID,
13577 grantor: MZ_SUPPORT_ROLE_ID,
13578 acl_mode: rbac::all_object_privileges(SystemObjectType::Object(ObjectType::Cluster)),
13579 },
13580 rbac::owner_privilege(ObjectType::Cluster, MZ_SUPPORT_ROLE_ID),
13581 ],
13582};
13583
13584pub const MZ_ANALYTICS_CLUSTER: BuiltinCluster = BuiltinCluster {
13585 name: "mz_analytics",
13586 owner_id: &MZ_ANALYTICS_ROLE_ID,
13587 privileges: &[
13588 MzAclItem {
13589 grantee: MZ_SYSTEM_ROLE_ID,
13590 grantor: MZ_ANALYTICS_ROLE_ID,
13591 acl_mode: rbac::all_object_privileges(SystemObjectType::Object(ObjectType::Cluster)),
13592 },
13593 rbac::owner_privilege(ObjectType::Cluster, MZ_ANALYTICS_ROLE_ID),
13594 ],
13595};
13596
13597pub static BUILTINS_STATIC: LazyLock<Vec<Builtin<NameReference>>> = LazyLock::new(|| {
13599 let mut builtins = vec![
13600 Builtin::Type(&TYPE_ANY),
13601 Builtin::Type(&TYPE_ANYARRAY),
13602 Builtin::Type(&TYPE_ANYELEMENT),
13603 Builtin::Type(&TYPE_ANYNONARRAY),
13604 Builtin::Type(&TYPE_ANYRANGE),
13605 Builtin::Type(&TYPE_BOOL),
13606 Builtin::Type(&TYPE_BOOL_ARRAY),
13607 Builtin::Type(&TYPE_BYTEA),
13608 Builtin::Type(&TYPE_BYTEA_ARRAY),
13609 Builtin::Type(&TYPE_BPCHAR),
13610 Builtin::Type(&TYPE_BPCHAR_ARRAY),
13611 Builtin::Type(&TYPE_CHAR),
13612 Builtin::Type(&TYPE_CHAR_ARRAY),
13613 Builtin::Type(&TYPE_DATE),
13614 Builtin::Type(&TYPE_DATE_ARRAY),
13615 Builtin::Type(&TYPE_FLOAT4),
13616 Builtin::Type(&TYPE_FLOAT4_ARRAY),
13617 Builtin::Type(&TYPE_FLOAT8),
13618 Builtin::Type(&TYPE_FLOAT8_ARRAY),
13619 Builtin::Type(&TYPE_INT4),
13620 Builtin::Type(&TYPE_INT4_ARRAY),
13621 Builtin::Type(&TYPE_INT8),
13622 Builtin::Type(&TYPE_INT8_ARRAY),
13623 Builtin::Type(&TYPE_INTERVAL),
13624 Builtin::Type(&TYPE_INTERVAL_ARRAY),
13625 Builtin::Type(&TYPE_JSONB),
13626 Builtin::Type(&TYPE_JSONB_ARRAY),
13627 Builtin::Type(&TYPE_LIST),
13628 Builtin::Type(&TYPE_MAP),
13629 Builtin::Type(&TYPE_NAME),
13630 Builtin::Type(&TYPE_NAME_ARRAY),
13631 Builtin::Type(&TYPE_NUMERIC),
13632 Builtin::Type(&TYPE_NUMERIC_ARRAY),
13633 Builtin::Type(&TYPE_OID),
13634 Builtin::Type(&TYPE_OID_ARRAY),
13635 Builtin::Type(&TYPE_RECORD),
13636 Builtin::Type(&TYPE_RECORD_ARRAY),
13637 Builtin::Type(&TYPE_REGCLASS),
13638 Builtin::Type(&TYPE_REGCLASS_ARRAY),
13639 Builtin::Type(&TYPE_REGPROC),
13640 Builtin::Type(&TYPE_REGPROC_ARRAY),
13641 Builtin::Type(&TYPE_REGTYPE),
13642 Builtin::Type(&TYPE_REGTYPE_ARRAY),
13643 Builtin::Type(&TYPE_INT2),
13644 Builtin::Type(&TYPE_INT2_ARRAY),
13645 Builtin::Type(&TYPE_TEXT),
13646 Builtin::Type(&TYPE_TEXT_ARRAY),
13647 Builtin::Type(&TYPE_TIME),
13648 Builtin::Type(&TYPE_TIME_ARRAY),
13649 Builtin::Type(&TYPE_TIMESTAMP),
13650 Builtin::Type(&TYPE_TIMESTAMP_ARRAY),
13651 Builtin::Type(&TYPE_TIMESTAMPTZ),
13652 Builtin::Type(&TYPE_TIMESTAMPTZ_ARRAY),
13653 Builtin::Type(&TYPE_UUID),
13654 Builtin::Type(&TYPE_UUID_ARRAY),
13655 Builtin::Type(&TYPE_VARCHAR),
13656 Builtin::Type(&TYPE_VARCHAR_ARRAY),
13657 Builtin::Type(&TYPE_INT2_VECTOR),
13658 Builtin::Type(&TYPE_INT2_VECTOR_ARRAY),
13659 Builtin::Type(&TYPE_ANYCOMPATIBLE),
13660 Builtin::Type(&TYPE_ANYCOMPATIBLEARRAY),
13661 Builtin::Type(&TYPE_ANYCOMPATIBLENONARRAY),
13662 Builtin::Type(&TYPE_ANYCOMPATIBLELIST),
13663 Builtin::Type(&TYPE_ANYCOMPATIBLEMAP),
13664 Builtin::Type(&TYPE_ANYCOMPATIBLERANGE),
13665 Builtin::Type(&TYPE_UINT2),
13666 Builtin::Type(&TYPE_UINT2_ARRAY),
13667 Builtin::Type(&TYPE_UINT4),
13668 Builtin::Type(&TYPE_UINT4_ARRAY),
13669 Builtin::Type(&TYPE_UINT8),
13670 Builtin::Type(&TYPE_UINT8_ARRAY),
13671 Builtin::Type(&TYPE_MZ_TIMESTAMP),
13672 Builtin::Type(&TYPE_MZ_TIMESTAMP_ARRAY),
13673 Builtin::Type(&TYPE_INT4_RANGE),
13674 Builtin::Type(&TYPE_INT4_RANGE_ARRAY),
13675 Builtin::Type(&TYPE_INT8_RANGE),
13676 Builtin::Type(&TYPE_INT8_RANGE_ARRAY),
13677 Builtin::Type(&TYPE_DATE_RANGE),
13678 Builtin::Type(&TYPE_DATE_RANGE_ARRAY),
13679 Builtin::Type(&TYPE_NUM_RANGE),
13680 Builtin::Type(&TYPE_NUM_RANGE_ARRAY),
13681 Builtin::Type(&TYPE_TS_RANGE),
13682 Builtin::Type(&TYPE_TS_RANGE_ARRAY),
13683 Builtin::Type(&TYPE_TSTZ_RANGE),
13684 Builtin::Type(&TYPE_TSTZ_RANGE_ARRAY),
13685 Builtin::Type(&TYPE_MZ_ACL_ITEM),
13686 Builtin::Type(&TYPE_MZ_ACL_ITEM_ARRAY),
13687 Builtin::Type(&TYPE_ACL_ITEM),
13688 Builtin::Type(&TYPE_ACL_ITEM_ARRAY),
13689 Builtin::Type(&TYPE_INTERNAL),
13690 ];
13691 for (schema, funcs) in &[
13692 (PG_CATALOG_SCHEMA, &*mz_sql::func::PG_CATALOG_BUILTINS),
13693 (
13694 INFORMATION_SCHEMA,
13695 &*mz_sql::func::INFORMATION_SCHEMA_BUILTINS,
13696 ),
13697 (MZ_CATALOG_SCHEMA, &*mz_sql::func::MZ_CATALOG_BUILTINS),
13698 (MZ_INTERNAL_SCHEMA, &*mz_sql::func::MZ_INTERNAL_BUILTINS),
13699 (MZ_UNSAFE_SCHEMA, &*mz_sql::func::MZ_UNSAFE_BUILTINS),
13700 ] {
13701 for (name, func) in funcs.iter() {
13702 builtins.push(Builtin::Func(BuiltinFunc {
13703 name,
13704 schema,
13705 inner: func,
13706 }));
13707 }
13708 }
13709 builtins.append(&mut vec![
13710 Builtin::Log(&MZ_ARRANGEMENT_SHARING_RAW),
13711 Builtin::Log(&MZ_ARRANGEMENT_BATCHES_RAW),
13712 Builtin::Log(&MZ_ARRANGEMENT_RECORDS_RAW),
13713 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_RECORDS_RAW),
13714 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_SIZE_RAW),
13715 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_CAPACITY_RAW),
13716 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_ALLOCATIONS_RAW),
13717 Builtin::Log(&MZ_DATAFLOW_CHANNELS_PER_WORKER),
13718 Builtin::Log(&MZ_DATAFLOW_OPERATORS_PER_WORKER),
13719 Builtin::Log(&MZ_DATAFLOW_ADDRESSES_PER_WORKER),
13720 Builtin::Log(&MZ_DATAFLOW_OPERATOR_REACHABILITY_RAW),
13721 Builtin::Log(&MZ_COMPUTE_EXPORTS_PER_WORKER),
13722 Builtin::Log(&MZ_COMPUTE_DATAFLOW_GLOBAL_IDS_PER_WORKER),
13723 Builtin::Log(&MZ_MESSAGE_COUNTS_RECEIVED_RAW),
13724 Builtin::Log(&MZ_MESSAGE_COUNTS_SENT_RAW),
13725 Builtin::Log(&MZ_MESSAGE_BATCH_COUNTS_RECEIVED_RAW),
13726 Builtin::Log(&MZ_MESSAGE_BATCH_COUNTS_SENT_RAW),
13727 Builtin::Log(&MZ_ACTIVE_PEEKS_PER_WORKER),
13728 Builtin::Log(&MZ_PEEK_DURATIONS_HISTOGRAM_RAW),
13729 Builtin::Log(&MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_RAW),
13730 Builtin::Log(&MZ_ARRANGEMENT_HEAP_CAPACITY_RAW),
13731 Builtin::Log(&MZ_ARRANGEMENT_HEAP_ALLOCATIONS_RAW),
13732 Builtin::Log(&MZ_ARRANGEMENT_HEAP_SIZE_RAW),
13733 Builtin::Log(&MZ_SCHEDULING_ELAPSED_RAW),
13734 Builtin::Log(&MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_RAW),
13735 Builtin::Log(&MZ_SCHEDULING_PARKS_HISTOGRAM_RAW),
13736 Builtin::Log(&MZ_COMPUTE_FRONTIERS_PER_WORKER),
13737 Builtin::Log(&MZ_COMPUTE_IMPORT_FRONTIERS_PER_WORKER),
13738 Builtin::Log(&MZ_COMPUTE_ERROR_COUNTS_RAW),
13739 Builtin::Log(&MZ_COMPUTE_HYDRATION_TIMES_PER_WORKER),
13740 Builtin::Log(&MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_PER_WORKER),
13741 Builtin::Table(&MZ_KAFKA_SINKS),
13742 Builtin::Table(&MZ_KAFKA_CONNECTIONS),
13743 Builtin::Table(&MZ_KAFKA_SOURCES),
13744 Builtin::Table(&MZ_OBJECT_DEPENDENCIES),
13745 Builtin::Table(&MZ_DATABASES),
13746 Builtin::Table(&MZ_SCHEMAS),
13747 Builtin::Table(&MZ_COLUMNS),
13748 Builtin::Table(&MZ_INDEXES),
13749 Builtin::Table(&MZ_INDEX_COLUMNS),
13750 Builtin::Table(&MZ_TABLES),
13751 Builtin::Table(&MZ_SOURCES),
13752 Builtin::Table(&MZ_SOURCE_REFERENCES),
13753 Builtin::Table(&MZ_POSTGRES_SOURCES),
13754 Builtin::Table(&MZ_POSTGRES_SOURCE_TABLES),
13755 Builtin::Table(&MZ_MYSQL_SOURCE_TABLES),
13756 Builtin::Table(&MZ_SQL_SERVER_SOURCE_TABLES),
13757 Builtin::Table(&MZ_KAFKA_SOURCE_TABLES),
13758 Builtin::Table(&MZ_SINKS),
13759 Builtin::Table(&MZ_VIEWS),
13760 Builtin::Table(&MZ_MATERIALIZED_VIEWS),
13761 Builtin::Table(&MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES),
13762 Builtin::Table(&MZ_TYPES),
13763 Builtin::Table(&MZ_TYPE_PG_METADATA),
13764 Builtin::Table(&MZ_ARRAY_TYPES),
13765 Builtin::Table(&MZ_BASE_TYPES),
13766 Builtin::Table(&MZ_LIST_TYPES),
13767 Builtin::Table(&MZ_MAP_TYPES),
13768 Builtin::Table(&MZ_ROLES),
13769 Builtin::Table(&MZ_ROLE_MEMBERS),
13770 Builtin::Table(&MZ_ROLE_PARAMETERS),
13771 Builtin::Table(&MZ_PSEUDO_TYPES),
13772 Builtin::Table(&MZ_FUNCTIONS),
13773 Builtin::Table(&MZ_OPERATORS),
13774 Builtin::Table(&MZ_AGGREGATES),
13775 Builtin::Table(&MZ_CLUSTERS),
13776 Builtin::Table(&MZ_CLUSTER_WORKLOAD_CLASSES),
13777 Builtin::Table(&MZ_CLUSTER_SCHEDULES),
13778 Builtin::Table(&MZ_SECRETS),
13779 Builtin::Table(&MZ_CONNECTIONS),
13780 Builtin::Table(&MZ_SSH_TUNNEL_CONNECTIONS),
13781 Builtin::Table(&MZ_CLUSTER_REPLICAS),
13782 Builtin::Source(&MZ_CLUSTER_REPLICA_METRICS_HISTORY),
13783 Builtin::View(&MZ_CLUSTER_REPLICA_METRICS),
13784 Builtin::Table(&MZ_CLUSTER_REPLICA_SIZES),
13785 Builtin::Source(&MZ_CLUSTER_REPLICA_STATUS_HISTORY),
13786 Builtin::View(&MZ_CLUSTER_REPLICA_STATUSES),
13787 Builtin::Table(&MZ_INTERNAL_CLUSTER_REPLICAS),
13788 Builtin::Table(&MZ_PENDING_CLUSTER_REPLICAS),
13789 Builtin::Table(&MZ_AUDIT_EVENTS),
13790 Builtin::Table(&MZ_STORAGE_USAGE_BY_SHARD),
13791 Builtin::Table(&MZ_EGRESS_IPS),
13792 Builtin::Table(&MZ_AWS_PRIVATELINK_CONNECTIONS),
13793 Builtin::Table(&MZ_AWS_CONNECTIONS),
13794 Builtin::Table(&MZ_SUBSCRIPTIONS),
13795 Builtin::Table(&MZ_SESSIONS),
13796 Builtin::Table(&MZ_DEFAULT_PRIVILEGES),
13797 Builtin::Table(&MZ_SYSTEM_PRIVILEGES),
13798 Builtin::Table(&MZ_COMMENTS),
13799 Builtin::Table(&MZ_WEBHOOKS_SOURCES),
13800 Builtin::Table(&MZ_HISTORY_RETENTION_STRATEGIES),
13801 Builtin::Table(&MZ_CONTINUAL_TASKS),
13802 Builtin::Table(&MZ_NETWORK_POLICIES),
13803 Builtin::Table(&MZ_NETWORK_POLICY_RULES),
13804 Builtin::Table(&MZ_LICENSE_KEYS),
13805 Builtin::View(&MZ_RELATIONS),
13806 Builtin::View(&MZ_OBJECT_OID_ALIAS),
13807 Builtin::View(&MZ_OBJECTS),
13808 Builtin::View(&MZ_OBJECT_FULLY_QUALIFIED_NAMES),
13809 Builtin::View(&MZ_OBJECTS_ID_NAMESPACE_TYPES),
13810 Builtin::View(&MZ_OBJECT_HISTORY),
13811 Builtin::View(&MZ_OBJECT_LIFETIMES),
13812 Builtin::View(&MZ_ARRANGEMENT_SHARING_PER_WORKER),
13813 Builtin::View(&MZ_ARRANGEMENT_SHARING),
13814 Builtin::View(&MZ_ARRANGEMENT_SIZES_PER_WORKER),
13815 Builtin::View(&MZ_ARRANGEMENT_SIZES),
13816 Builtin::View(&MZ_DATAFLOWS_PER_WORKER),
13817 Builtin::View(&MZ_DATAFLOWS),
13818 Builtin::View(&MZ_DATAFLOW_ADDRESSES),
13819 Builtin::View(&MZ_DATAFLOW_CHANNELS),
13820 Builtin::View(&MZ_DATAFLOW_OPERATORS),
13821 Builtin::View(&MZ_DATAFLOW_GLOBAL_IDS),
13822 Builtin::View(&MZ_MAPPABLE_OBJECTS),
13823 Builtin::View(&MZ_DATAFLOW_OPERATOR_DATAFLOWS_PER_WORKER),
13824 Builtin::View(&MZ_DATAFLOW_OPERATOR_DATAFLOWS),
13825 Builtin::View(&MZ_OBJECT_TRANSITIVE_DEPENDENCIES),
13826 Builtin::View(&MZ_DATAFLOW_OPERATOR_REACHABILITY_PER_WORKER),
13827 Builtin::View(&MZ_DATAFLOW_OPERATOR_REACHABILITY),
13828 Builtin::View(&MZ_CLUSTER_REPLICA_UTILIZATION),
13829 Builtin::View(&MZ_CLUSTER_REPLICA_UTILIZATION_HISTORY),
13830 Builtin::View(&MZ_DATAFLOW_OPERATOR_PARENTS_PER_WORKER),
13831 Builtin::View(&MZ_DATAFLOW_OPERATOR_PARENTS),
13832 Builtin::View(&MZ_COMPUTE_EXPORTS),
13833 Builtin::View(&MZ_DATAFLOW_ARRANGEMENT_SIZES),
13834 Builtin::View(&MZ_EXPECTED_GROUP_SIZE_ADVICE),
13835 Builtin::View(&MZ_COMPUTE_FRONTIERS),
13836 Builtin::View(&MZ_DATAFLOW_CHANNEL_OPERATORS_PER_WORKER),
13837 Builtin::View(&MZ_DATAFLOW_CHANNEL_OPERATORS),
13838 Builtin::View(&MZ_COMPUTE_IMPORT_FRONTIERS),
13839 Builtin::View(&MZ_MESSAGE_COUNTS_PER_WORKER),
13840 Builtin::View(&MZ_MESSAGE_COUNTS),
13841 Builtin::View(&MZ_ACTIVE_PEEKS),
13842 Builtin::View(&MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_PER_WORKER),
13843 Builtin::View(&MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM),
13844 Builtin::View(&MZ_RECORDS_PER_DATAFLOW_OPERATOR_PER_WORKER),
13845 Builtin::View(&MZ_RECORDS_PER_DATAFLOW_OPERATOR),
13846 Builtin::View(&MZ_RECORDS_PER_DATAFLOW_PER_WORKER),
13847 Builtin::View(&MZ_RECORDS_PER_DATAFLOW),
13848 Builtin::View(&MZ_PEEK_DURATIONS_HISTOGRAM_PER_WORKER),
13849 Builtin::View(&MZ_PEEK_DURATIONS_HISTOGRAM),
13850 Builtin::View(&MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_PER_WORKER),
13851 Builtin::View(&MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM),
13852 Builtin::View(&MZ_SCHEDULING_ELAPSED_PER_WORKER),
13853 Builtin::View(&MZ_SCHEDULING_ELAPSED),
13854 Builtin::View(&MZ_SCHEDULING_PARKS_HISTOGRAM_PER_WORKER),
13855 Builtin::View(&MZ_SCHEDULING_PARKS_HISTOGRAM),
13856 Builtin::View(&MZ_SHOW_ALL_OBJECTS),
13857 Builtin::View(&MZ_SHOW_COLUMNS),
13858 Builtin::View(&MZ_SHOW_CLUSTERS),
13859 Builtin::View(&MZ_SHOW_SECRETS),
13860 Builtin::View(&MZ_SHOW_DATABASES),
13861 Builtin::View(&MZ_SHOW_SCHEMAS),
13862 Builtin::View(&MZ_SHOW_TABLES),
13863 Builtin::View(&MZ_SHOW_VIEWS),
13864 Builtin::View(&MZ_SHOW_TYPES),
13865 Builtin::View(&MZ_SHOW_ROLES),
13866 Builtin::View(&MZ_SHOW_CONNECTIONS),
13867 Builtin::View(&MZ_SHOW_SOURCES),
13868 Builtin::View(&MZ_SHOW_SINKS),
13869 Builtin::View(&MZ_SHOW_MATERIALIZED_VIEWS),
13870 Builtin::View(&MZ_SHOW_INDEXES),
13871 Builtin::View(&MZ_SHOW_CONTINUAL_TASKS),
13872 Builtin::View(&MZ_CLUSTER_REPLICA_HISTORY),
13873 Builtin::View(&MZ_CLUSTER_REPLICA_NAME_HISTORY),
13874 Builtin::View(&MZ_TIMEZONE_NAMES),
13875 Builtin::View(&MZ_TIMEZONE_ABBREVIATIONS),
13876 Builtin::View(&PG_NAMESPACE_ALL_DATABASES),
13877 Builtin::Index(&PG_NAMESPACE_ALL_DATABASES_IND),
13878 Builtin::View(&PG_NAMESPACE),
13879 Builtin::View(&PG_CLASS_ALL_DATABASES),
13880 Builtin::Index(&PG_CLASS_ALL_DATABASES_IND),
13881 Builtin::View(&PG_CLASS),
13882 Builtin::View(&PG_DEPEND),
13883 Builtin::View(&PG_DATABASE),
13884 Builtin::View(&PG_INDEX),
13885 Builtin::View(&PG_TYPE_ALL_DATABASES),
13886 Builtin::Index(&PG_TYPE_ALL_DATABASES_IND),
13887 Builtin::View(&PG_TYPE),
13888 Builtin::View(&PG_DESCRIPTION_ALL_DATABASES),
13889 Builtin::Index(&PG_DESCRIPTION_ALL_DATABASES_IND),
13890 Builtin::View(&PG_DESCRIPTION),
13891 Builtin::View(&PG_ATTRIBUTE_ALL_DATABASES),
13892 Builtin::Index(&PG_ATTRIBUTE_ALL_DATABASES_IND),
13893 Builtin::View(&PG_ATTRIBUTE),
13894 Builtin::View(&PG_PROC),
13895 Builtin::View(&PG_OPERATOR),
13896 Builtin::View(&PG_RANGE),
13897 Builtin::View(&PG_ENUM),
13898 Builtin::View(&PG_ATTRDEF_ALL_DATABASES),
13899 Builtin::Index(&PG_ATTRDEF_ALL_DATABASES_IND),
13900 Builtin::View(&PG_ATTRDEF),
13901 Builtin::View(&PG_SETTINGS),
13902 Builtin::View(&PG_AUTH_MEMBERS),
13903 Builtin::View(&PG_CONSTRAINT),
13904 Builtin::View(&PG_TABLES),
13905 Builtin::View(&PG_TABLESPACE),
13906 Builtin::View(&PG_ACCESS_METHODS),
13907 Builtin::View(&PG_LOCKS),
13908 Builtin::View(&PG_AUTHID),
13909 Builtin::View(&PG_ROLES),
13910 Builtin::View(&PG_USER),
13911 Builtin::View(&PG_VIEWS),
13912 Builtin::View(&PG_MATVIEWS),
13913 Builtin::View(&PG_COLLATION),
13914 Builtin::View(&PG_POLICY),
13915 Builtin::View(&PG_INHERITS),
13916 Builtin::View(&PG_AGGREGATE),
13917 Builtin::View(&PG_TRIGGER),
13918 Builtin::View(&PG_REWRITE),
13919 Builtin::View(&PG_EXTENSION),
13920 Builtin::View(&PG_EVENT_TRIGGER),
13921 Builtin::View(&PG_LANGUAGE),
13922 Builtin::View(&PG_SHDESCRIPTION),
13923 Builtin::View(&PG_INDEXES),
13924 Builtin::View(&PG_TIMEZONE_ABBREVS),
13925 Builtin::View(&PG_TIMEZONE_NAMES),
13926 Builtin::View(&INFORMATION_SCHEMA_APPLICABLE_ROLES),
13927 Builtin::View(&INFORMATION_SCHEMA_COLUMNS),
13928 Builtin::View(&INFORMATION_SCHEMA_ENABLED_ROLES),
13929 Builtin::View(&INFORMATION_SCHEMA_KEY_COLUMN_USAGE),
13930 Builtin::View(&INFORMATION_SCHEMA_REFERENTIAL_CONSTRAINTS),
13931 Builtin::View(&INFORMATION_SCHEMA_ROUTINES),
13932 Builtin::View(&INFORMATION_SCHEMA_SCHEMATA),
13933 Builtin::View(&INFORMATION_SCHEMA_TABLES),
13934 Builtin::View(&INFORMATION_SCHEMA_TABLE_CONSTRAINTS),
13935 Builtin::View(&INFORMATION_SCHEMA_TABLE_PRIVILEGES),
13936 Builtin::View(&INFORMATION_SCHEMA_ROLE_TABLE_GRANTS),
13937 Builtin::View(&INFORMATION_SCHEMA_TRIGGERS),
13938 Builtin::View(&INFORMATION_SCHEMA_VIEWS),
13939 Builtin::View(&INFORMATION_SCHEMA_CHARACTER_SETS),
13940 Builtin::View(&MZ_SHOW_ROLE_MEMBERS),
13941 Builtin::View(&MZ_SHOW_MY_ROLE_MEMBERS),
13942 Builtin::View(&MZ_SHOW_SYSTEM_PRIVILEGES),
13943 Builtin::View(&MZ_SHOW_MY_SYSTEM_PRIVILEGES),
13944 Builtin::View(&MZ_SHOW_CLUSTER_PRIVILEGES),
13945 Builtin::View(&MZ_SHOW_MY_CLUSTER_PRIVILEGES),
13946 Builtin::View(&MZ_SHOW_DATABASE_PRIVILEGES),
13947 Builtin::View(&MZ_SHOW_MY_DATABASE_PRIVILEGES),
13948 Builtin::View(&MZ_SHOW_SCHEMA_PRIVILEGES),
13949 Builtin::View(&MZ_SHOW_MY_SCHEMA_PRIVILEGES),
13950 Builtin::View(&MZ_SHOW_OBJECT_PRIVILEGES),
13951 Builtin::View(&MZ_SHOW_MY_OBJECT_PRIVILEGES),
13952 Builtin::View(&MZ_SHOW_ALL_PRIVILEGES),
13953 Builtin::View(&MZ_SHOW_ALL_MY_PRIVILEGES),
13954 Builtin::View(&MZ_SHOW_DEFAULT_PRIVILEGES),
13955 Builtin::View(&MZ_SHOW_MY_DEFAULT_PRIVILEGES),
13956 Builtin::Source(&MZ_SINK_STATUS_HISTORY),
13957 Builtin::View(&MZ_SINK_STATUSES),
13958 Builtin::Source(&MZ_SOURCE_STATUS_HISTORY),
13959 Builtin::Source(&MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY),
13960 Builtin::View(&MZ_AWS_PRIVATELINK_CONNECTION_STATUSES),
13961 Builtin::Source(&MZ_STATEMENT_EXECUTION_HISTORY),
13962 Builtin::View(&MZ_STATEMENT_EXECUTION_HISTORY_REDACTED),
13963 Builtin::Source(&MZ_PREPARED_STATEMENT_HISTORY),
13964 Builtin::Source(&MZ_SESSION_HISTORY),
13965 Builtin::Source(&MZ_SQL_TEXT),
13966 Builtin::View(&MZ_SQL_TEXT_REDACTED),
13967 Builtin::View(&MZ_RECENT_SQL_TEXT),
13968 Builtin::View(&MZ_RECENT_SQL_TEXT_REDACTED),
13969 Builtin::Index(&MZ_RECENT_SQL_TEXT_IND),
13970 Builtin::View(&MZ_ACTIVITY_LOG_THINNED),
13971 Builtin::View(&MZ_RECENT_ACTIVITY_LOG_THINNED),
13972 Builtin::View(&MZ_RECENT_ACTIVITY_LOG),
13973 Builtin::View(&MZ_RECENT_ACTIVITY_LOG_REDACTED),
13974 Builtin::Index(&MZ_RECENT_ACTIVITY_LOG_THINNED_IND),
13975 Builtin::View(&MZ_SOURCE_STATUSES),
13976 Builtin::Source(&MZ_STATEMENT_LIFECYCLE_HISTORY),
13977 Builtin::Source(&MZ_STORAGE_SHARDS),
13978 Builtin::Source(&MZ_SOURCE_STATISTICS_RAW),
13979 Builtin::Source(&MZ_SINK_STATISTICS_RAW),
13980 Builtin::View(&MZ_SOURCE_STATISTICS_WITH_HISTORY),
13981 Builtin::Index(&MZ_SOURCE_STATISTICS_WITH_HISTORY_IND),
13982 Builtin::View(&MZ_SOURCE_STATISTICS),
13983 Builtin::Index(&MZ_SOURCE_STATISTICS_IND),
13984 Builtin::View(&MZ_SINK_STATISTICS),
13985 Builtin::Index(&MZ_SINK_STATISTICS_IND),
13986 Builtin::View(&MZ_STORAGE_USAGE),
13987 Builtin::Source(&MZ_FRONTIERS),
13988 Builtin::View(&MZ_GLOBAL_FRONTIERS),
13989 Builtin::Source(&MZ_WALLCLOCK_LAG_HISTORY),
13990 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG_HISTORY),
13991 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY),
13992 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG),
13993 Builtin::Source(&MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW),
13994 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM),
13995 Builtin::Source(&MZ_MATERIALIZED_VIEW_REFRESHES),
13996 Builtin::Source(&MZ_COMPUTE_DEPENDENCIES),
13997 Builtin::View(&MZ_MATERIALIZATION_DEPENDENCIES),
13998 Builtin::View(&MZ_MATERIALIZATION_LAG),
13999 Builtin::View(&MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW),
14000 Builtin::View(&MZ_COMPUTE_ERROR_COUNTS_PER_WORKER),
14001 Builtin::View(&MZ_COMPUTE_ERROR_COUNTS),
14002 Builtin::Source(&MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED),
14003 Builtin::Source(&MZ_COMPUTE_HYDRATION_TIMES),
14004 Builtin::Log(&MZ_COMPUTE_LIR_MAPPING_PER_WORKER),
14005 Builtin::View(&MZ_LIR_MAPPING),
14006 Builtin::Source(&MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES),
14007 Builtin::Source(&MZ_CLUSTER_REPLICA_FRONTIERS),
14008 Builtin::View(&MZ_COMPUTE_HYDRATION_STATUSES),
14009 Builtin::View(&MZ_HYDRATION_STATUSES),
14010 Builtin::View(&MZ_SHOW_CLUSTER_REPLICAS),
14011 Builtin::View(&MZ_SHOW_NETWORK_POLICIES),
14012 Builtin::View(&MZ_CLUSTER_DEPLOYMENT_LINEAGE),
14013 Builtin::Index(&MZ_SHOW_DATABASES_IND),
14014 Builtin::Index(&MZ_SHOW_SCHEMAS_IND),
14015 Builtin::Index(&MZ_SHOW_CONNECTIONS_IND),
14016 Builtin::Index(&MZ_SHOW_TABLES_IND),
14017 Builtin::Index(&MZ_SHOW_SOURCES_IND),
14018 Builtin::Index(&MZ_SHOW_VIEWS_IND),
14019 Builtin::Index(&MZ_SHOW_MATERIALIZED_VIEWS_IND),
14020 Builtin::Index(&MZ_SHOW_SINKS_IND),
14021 Builtin::Index(&MZ_SHOW_TYPES_IND),
14022 Builtin::Index(&MZ_SHOW_ALL_OBJECTS_IND),
14023 Builtin::Index(&MZ_SHOW_INDEXES_IND),
14024 Builtin::Index(&MZ_SHOW_COLUMNS_IND),
14025 Builtin::Index(&MZ_SHOW_CLUSTERS_IND),
14026 Builtin::Index(&MZ_SHOW_CLUSTER_REPLICAS_IND),
14027 Builtin::Index(&MZ_SHOW_SECRETS_IND),
14028 Builtin::Index(&MZ_SHOW_ROLES_IND),
14029 Builtin::Index(&MZ_CLUSTERS_IND),
14030 Builtin::Index(&MZ_INDEXES_IND),
14031 Builtin::Index(&MZ_ROLES_IND),
14032 Builtin::Index(&MZ_SOURCES_IND),
14033 Builtin::Index(&MZ_SINKS_IND),
14034 Builtin::Index(&MZ_MATERIALIZED_VIEWS_IND),
14035 Builtin::Index(&MZ_CONTINUAL_TASKS_IND),
14036 Builtin::Index(&MZ_SOURCE_STATUSES_IND),
14037 Builtin::Index(&MZ_SOURCE_STATUS_HISTORY_IND),
14038 Builtin::Index(&MZ_SINK_STATUSES_IND),
14039 Builtin::Index(&MZ_SINK_STATUS_HISTORY_IND),
14040 Builtin::Index(&MZ_CLUSTER_REPLICAS_IND),
14041 Builtin::Index(&MZ_CLUSTER_REPLICA_SIZES_IND),
14042 Builtin::Index(&MZ_CLUSTER_REPLICA_STATUSES_IND),
14043 Builtin::Index(&MZ_CLUSTER_REPLICA_STATUS_HISTORY_IND),
14044 Builtin::Index(&MZ_CLUSTER_REPLICA_METRICS_IND),
14045 Builtin::Index(&MZ_CLUSTER_REPLICA_METRICS_HISTORY_IND),
14046 Builtin::Index(&MZ_CLUSTER_REPLICA_HISTORY_IND),
14047 Builtin::Index(&MZ_CLUSTER_REPLICA_NAME_HISTORY_IND),
14048 Builtin::Index(&MZ_OBJECT_LIFETIMES_IND),
14049 Builtin::Index(&MZ_OBJECT_HISTORY_IND),
14050 Builtin::Index(&MZ_OBJECT_DEPENDENCIES_IND),
14051 Builtin::Index(&MZ_COMPUTE_DEPENDENCIES_IND),
14052 Builtin::Index(&MZ_OBJECT_TRANSITIVE_DEPENDENCIES_IND),
14053 Builtin::Index(&MZ_FRONTIERS_IND),
14054 Builtin::Index(&MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_IND),
14055 Builtin::Index(&MZ_KAFKA_SOURCES_IND),
14056 Builtin::Index(&MZ_WEBHOOK_SOURCES_IND),
14057 Builtin::Index(&MZ_COMMENTS_IND),
14058 Builtin::Index(&MZ_DATABASES_IND),
14059 Builtin::Index(&MZ_SCHEMAS_IND),
14060 Builtin::Index(&MZ_CONNECTIONS_IND),
14061 Builtin::Index(&MZ_TABLES_IND),
14062 Builtin::Index(&MZ_TYPES_IND),
14063 Builtin::Index(&MZ_OBJECTS_IND),
14064 Builtin::Index(&MZ_COLUMNS_IND),
14065 Builtin::Index(&MZ_SECRETS_IND),
14066 Builtin::Index(&MZ_VIEWS_IND),
14067 Builtin::Index(&MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_IND),
14068 Builtin::Index(&MZ_CLUSTER_DEPLOYMENT_LINEAGE_IND),
14069 Builtin::Index(&MZ_CLUSTER_REPLICA_FRONTIERS_IND),
14070 Builtin::Index(&MZ_COMPUTE_HYDRATION_TIMES_IND),
14071 Builtin::View(&MZ_RECENT_STORAGE_USAGE),
14072 Builtin::Index(&MZ_RECENT_STORAGE_USAGE_IND),
14073 Builtin::Connection(&MZ_ANALYTICS),
14074 Builtin::ContinualTask(&MZ_CLUSTER_REPLICA_METRICS_HISTORY_CT),
14075 Builtin::ContinualTask(&MZ_CLUSTER_REPLICA_STATUS_HISTORY_CT),
14076 Builtin::ContinualTask(&MZ_WALLCLOCK_LAG_HISTORY_CT),
14077 Builtin::View(&MZ_INDEX_ADVICE),
14078 ]);
14079
14080 builtins.extend(notice::builtins());
14081
14082 builtins
14083});
14084pub const BUILTIN_ROLES: &[&BuiltinRole] = &[
14085 &MZ_SYSTEM_ROLE,
14086 &MZ_SUPPORT_ROLE,
14087 &MZ_ANALYTICS_ROLE,
14088 &MZ_MONITOR_ROLE,
14089 &MZ_MONITOR_REDACTED,
14090];
14091pub const BUILTIN_CLUSTERS: &[&BuiltinCluster] = &[
14092 &MZ_SYSTEM_CLUSTER,
14093 &MZ_CATALOG_SERVER_CLUSTER,
14094 &MZ_PROBE_CLUSTER,
14095 &MZ_SUPPORT_CLUSTER,
14096 &MZ_ANALYTICS_CLUSTER,
14097];
14098pub const BUILTIN_CLUSTER_REPLICAS: &[&BuiltinClusterReplica] = &[
14099 &MZ_SYSTEM_CLUSTER_REPLICA,
14100 &MZ_CATALOG_SERVER_CLUSTER_REPLICA,
14101 &MZ_PROBE_CLUSTER_REPLICA,
14102];
14103
14104#[allow(non_snake_case)]
14105pub mod BUILTINS {
14106 use mz_sql::catalog::BuiltinsConfig;
14107
14108 use super::*;
14109
14110 pub fn logs() -> impl Iterator<Item = &'static BuiltinLog> {
14111 BUILTINS_STATIC.iter().filter_map(|b| match b {
14112 Builtin::Log(log) => Some(*log),
14113 _ => None,
14114 })
14115 }
14116
14117 pub fn types() -> impl Iterator<Item = &'static BuiltinType<NameReference>> {
14118 BUILTINS_STATIC.iter().filter_map(|b| match b {
14119 Builtin::Type(typ) => Some(*typ),
14120 _ => None,
14121 })
14122 }
14123
14124 pub fn views() -> impl Iterator<Item = &'static BuiltinView> {
14125 BUILTINS_STATIC.iter().filter_map(|b| match b {
14126 Builtin::View(view) => Some(*view),
14127 _ => None,
14128 })
14129 }
14130
14131 pub fn funcs() -> impl Iterator<Item = &'static BuiltinFunc> {
14132 BUILTINS_STATIC.iter().filter_map(|b| match b {
14133 Builtin::Func(func) => Some(func),
14134 _ => None,
14135 })
14136 }
14137
14138 pub fn iter(cfg: &BuiltinsConfig) -> impl Iterator<Item = &'static Builtin<NameReference>> {
14139 let include_continual_tasks = cfg.include_continual_tasks;
14140 BUILTINS_STATIC.iter().filter(move |x| match x {
14141 Builtin::ContinualTask(_) if !include_continual_tasks => false,
14142 _ => true,
14143 })
14144 }
14145}
14146
14147pub static BUILTIN_LOG_LOOKUP: LazyLock<HashMap<&'static str, &'static BuiltinLog>> =
14148 LazyLock::new(|| BUILTINS::logs().map(|log| (log.name, log)).collect());
14149pub static BUILTIN_LOOKUP: LazyLock<
14152 HashMap<SystemObjectDescription, (usize, &'static Builtin<NameReference>)>,
14153> = LazyLock::new(|| {
14154 BUILTINS_STATIC
14159 .iter()
14160 .enumerate()
14161 .map(|(idx, builtin)| {
14162 (
14163 SystemObjectDescription {
14164 schema_name: builtin.schema().to_string(),
14165 object_type: builtin.catalog_item_type(),
14166 object_name: builtin.name().to_string(),
14167 },
14168 (idx, builtin),
14169 )
14170 })
14171 .collect()
14172});
14173
14174#[mz_ore::test]
14175#[cfg_attr(miri, ignore)] fn test_builtin_type_schema() {
14177 use mz_pgrepr::oid::FIRST_MATERIALIZE_OID;
14178
14179 for typ in BUILTINS::types() {
14180 if typ.oid < FIRST_MATERIALIZE_OID {
14181 assert_eq!(
14182 typ.schema, PG_CATALOG_SCHEMA,
14183 "{typ:?} should be in {PG_CATALOG_SCHEMA} schema"
14184 );
14185 } else {
14186 assert_eq!(
14189 typ.schema, MZ_CATALOG_SCHEMA,
14190 "{typ:?} should be in {MZ_CATALOG_SCHEMA} schema"
14191 );
14192 }
14193 }
14194}