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_ICEBERG_SINKS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2067 name: "mz_iceberg_sinks",
2068 schema: MZ_CATALOG_SCHEMA,
2069 oid: oid::TABLE_MZ_ICEBERG_SINKS_OID,
2070 desc: RelationDesc::builder()
2071 .with_column("id", SqlScalarType::String.nullable(false))
2072 .with_column("namespace", SqlScalarType::String.nullable(false))
2073 .with_column("table", SqlScalarType::String.nullable(false))
2074 .finish(),
2075 column_comments: BTreeMap::from_iter([
2076 ("id", "The ID of the sink."),
2077 ("namespace", "The namespace of the sink."),
2078 ("table", "The table the sink is writing to."),
2079 ]),
2080 is_retained_metrics_object: false,
2081 access: vec![PUBLIC_SELECT],
2082});
2083
2084pub static MZ_KAFKA_SINKS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2085 name: "mz_kafka_sinks",
2086 schema: MZ_CATALOG_SCHEMA,
2087 oid: oid::TABLE_MZ_KAFKA_SINKS_OID,
2088 desc: RelationDesc::builder()
2089 .with_column("id", SqlScalarType::String.nullable(false))
2090 .with_column("topic", SqlScalarType::String.nullable(false))
2091 .with_key(vec![0])
2092 .finish(),
2093 column_comments: BTreeMap::from_iter([
2094 ("id", "The ID of the sink."),
2095 (
2096 "topic",
2097 "The name of the Kafka topic into which the sink is writing.",
2098 ),
2099 ]),
2100 is_retained_metrics_object: false,
2101 access: vec![PUBLIC_SELECT],
2102});
2103pub static MZ_KAFKA_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2104 name: "mz_kafka_connections",
2105 schema: MZ_CATALOG_SCHEMA,
2106 oid: oid::TABLE_MZ_KAFKA_CONNECTIONS_OID,
2107 desc: RelationDesc::builder()
2108 .with_column("id", SqlScalarType::String.nullable(false))
2109 .with_column(
2110 "brokers",
2111 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
2112 )
2113 .with_column("sink_progress_topic", SqlScalarType::String.nullable(false))
2114 .finish(),
2115 column_comments: BTreeMap::from_iter([
2116 ("id", "The ID of the connection."),
2117 (
2118 "brokers",
2119 "The addresses of the Kafka brokers to connect to.",
2120 ),
2121 (
2122 "sink_progress_topic",
2123 "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.",
2124 ),
2125 ]),
2126 is_retained_metrics_object: false,
2127 access: vec![PUBLIC_SELECT],
2128});
2129pub static MZ_KAFKA_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2130 name: "mz_kafka_sources",
2131 schema: MZ_CATALOG_SCHEMA,
2132 oid: oid::TABLE_MZ_KAFKA_SOURCES_OID,
2133 desc: RelationDesc::builder()
2134 .with_column("id", SqlScalarType::String.nullable(false))
2135 .with_column("group_id_prefix", SqlScalarType::String.nullable(false))
2136 .with_column("topic", SqlScalarType::String.nullable(false))
2137 .finish(),
2138 column_comments: BTreeMap::from_iter([
2139 (
2140 "id",
2141 "The ID of the Kafka source. Corresponds to `mz_catalog.mz_sources.id`.",
2142 ),
2143 (
2144 "group_id_prefix",
2145 "The value of the `GROUP ID PREFIX` connection option.",
2146 ),
2147 (
2148 "topic",
2149 "The name of the Kafka topic the source is reading from.",
2150 ),
2151 ]),
2152 is_retained_metrics_object: false,
2153 access: vec![PUBLIC_SELECT],
2154});
2155pub static MZ_POSTGRES_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2156 name: "mz_postgres_sources",
2157 schema: MZ_INTERNAL_SCHEMA,
2158 oid: oid::TABLE_MZ_POSTGRES_SOURCES_OID,
2159 desc: RelationDesc::builder()
2160 .with_column("id", SqlScalarType::String.nullable(false))
2161 .with_column("replication_slot", SqlScalarType::String.nullable(false))
2162 .with_column("timeline_id", SqlScalarType::UInt64.nullable(true))
2163 .finish(),
2164 column_comments: BTreeMap::from_iter([
2165 (
2166 "id",
2167 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
2168 ),
2169 (
2170 "replication_slot",
2171 "The name of the replication slot in the PostgreSQL database that Materialize will create and stream data from.",
2172 ),
2173 (
2174 "timeline_id",
2175 "The PostgreSQL timeline ID determined on source creation.",
2176 ),
2177 ]),
2178 is_retained_metrics_object: false,
2179 access: vec![PUBLIC_SELECT],
2180});
2181pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2182 name: "mz_postgres_source_tables",
2183 schema: MZ_INTERNAL_SCHEMA,
2184 oid: oid::TABLE_MZ_POSTGRES_SOURCE_TABLES_OID,
2185 desc: RelationDesc::builder()
2186 .with_column("id", SqlScalarType::String.nullable(false))
2187 .with_column("schema_name", SqlScalarType::String.nullable(false))
2188 .with_column("table_name", SqlScalarType::String.nullable(false))
2189 .finish(),
2190 column_comments: BTreeMap::from_iter([
2191 (
2192 "id",
2193 "The ID of the subsource or table. Corresponds to `mz_catalog.mz_sources.id` or `mz_catalog.mz_tables.id`.",
2194 ),
2195 (
2196 "schema_name",
2197 "The schema of the upstream table being ingested.",
2198 ),
2199 (
2200 "table_name",
2201 "The name of the upstream table being ingested.",
2202 ),
2203 ]),
2204 is_retained_metrics_object: true,
2205 access: vec![PUBLIC_SELECT],
2206});
2207pub static MZ_MYSQL_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2208 name: "mz_mysql_source_tables",
2209 schema: MZ_INTERNAL_SCHEMA,
2210 oid: oid::TABLE_MZ_MYSQL_SOURCE_TABLES_OID,
2211 desc: RelationDesc::builder()
2212 .with_column("id", SqlScalarType::String.nullable(false))
2213 .with_column("schema_name", SqlScalarType::String.nullable(false))
2214 .with_column("table_name", SqlScalarType::String.nullable(false))
2215 .finish(),
2216 column_comments: BTreeMap::from_iter([
2217 (
2218 "id",
2219 "The ID of the subsource or table. Corresponds to `mz_catalog.mz_sources.id` or `mz_catalog.mz_tables.id`.",
2220 ),
2221 (
2222 "schema_name",
2223 "The schema (or, database) of the upstream table being ingested.",
2224 ),
2225 (
2226 "table_name",
2227 "The name of the upstream table being ingested.",
2228 ),
2229 ]),
2230 is_retained_metrics_object: true,
2231 access: vec![PUBLIC_SELECT],
2232});
2233pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2234 name: "mz_sql_server_source_tables",
2235 schema: MZ_INTERNAL_SCHEMA,
2236 oid: oid::TABLE_MZ_SQL_SERVER_SOURCE_TABLES_OID,
2237 desc: RelationDesc::builder()
2238 .with_column("id", SqlScalarType::String.nullable(false))
2239 .with_column("schema_name", SqlScalarType::String.nullable(false))
2240 .with_column("table_name", SqlScalarType::String.nullable(false))
2241 .finish(),
2242 column_comments: BTreeMap::from_iter([
2243 (
2244 "id",
2245 "The ID of the subsource or table. Corresponds to `mz_catalog.mz_sources.id` or `mz_catalog.mz_tables.id`.",
2246 ),
2247 (
2248 "schema_name",
2249 "The schema (or, database) of the upstream table being ingested.",
2250 ),
2251 (
2252 "table_name",
2253 "The name of the upstream table being ingested.",
2254 ),
2255 ]),
2256 is_retained_metrics_object: true,
2257 access: vec![PUBLIC_SELECT],
2258});
2259pub static MZ_KAFKA_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2260 name: "mz_kafka_source_tables",
2261 schema: MZ_INTERNAL_SCHEMA,
2262 oid: oid::TABLE_MZ_KAFKA_SOURCE_TABLES_OID,
2263 desc: RelationDesc::builder()
2264 .with_column("id", SqlScalarType::String.nullable(false))
2265 .with_column("topic", SqlScalarType::String.nullable(false))
2266 .with_column("envelope_type", SqlScalarType::String.nullable(true))
2267 .with_column("key_format", SqlScalarType::String.nullable(true))
2268 .with_column("value_format", SqlScalarType::String.nullable(true))
2269 .finish(),
2270 column_comments: BTreeMap::from_iter([
2271 (
2272 "id",
2273 "The ID of the table. Corresponds to `mz_catalog.mz_tables.id`.",
2274 ),
2275 ("topic", "The topic being ingested."),
2276 (
2277 "envelope_type",
2278 "The envelope type: `none`, `upsert`, or `debezium`. `NULL` for other source types.",
2279 ),
2280 (
2281 "key_format",
2282 "The format of the Kafka message key: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`, or `NULL`.",
2283 ),
2284 (
2285 "value_format",
2286 "The format of the Kafka message value: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`. `NULL` for other source types.",
2287 ),
2288 ]),
2289 is_retained_metrics_object: true,
2290 access: vec![PUBLIC_SELECT],
2291});
2292pub static MZ_OBJECT_DEPENDENCIES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2293 name: "mz_object_dependencies",
2294 schema: MZ_INTERNAL_SCHEMA,
2295 oid: oid::TABLE_MZ_OBJECT_DEPENDENCIES_OID,
2296 desc: RelationDesc::builder()
2297 .with_column("object_id", SqlScalarType::String.nullable(false))
2298 .with_column(
2299 "referenced_object_id",
2300 SqlScalarType::String.nullable(false),
2301 )
2302 .finish(),
2303 column_comments: BTreeMap::from_iter([
2304 (
2305 "object_id",
2306 "The ID of the dependent object. Corresponds to `mz_objects.id`.",
2307 ),
2308 (
2309 "referenced_object_id",
2310 "The ID of the referenced object. Corresponds to `mz_objects.id`.",
2311 ),
2312 ]),
2313 is_retained_metrics_object: true,
2314 access: vec![PUBLIC_SELECT],
2315});
2316pub static MZ_COMPUTE_DEPENDENCIES: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
2317 name: "mz_compute_dependencies",
2318 schema: MZ_INTERNAL_SCHEMA,
2319 oid: oid::SOURCE_MZ_COMPUTE_DEPENDENCIES_OID,
2320 data_source: IntrospectionType::ComputeDependencies,
2321 desc: RelationDesc::builder()
2322 .with_column("object_id", SqlScalarType::String.nullable(false))
2323 .with_column("dependency_id", SqlScalarType::String.nullable(false))
2324 .finish(),
2325 column_comments: BTreeMap::from_iter([
2326 (
2327 "object_id",
2328 "The ID of a compute object. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, or `mz_internal.mz_subscriptions`.",
2329 ),
2330 (
2331 "dependency_id",
2332 "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`.",
2333 ),
2334 ]),
2335 is_retained_metrics_object: false,
2336 access: vec![PUBLIC_SELECT],
2337});
2338
2339pub static MZ_DATABASES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2340 name: "mz_databases",
2341 schema: MZ_CATALOG_SCHEMA,
2342 oid: oid::TABLE_MZ_DATABASES_OID,
2343 desc: RelationDesc::builder()
2344 .with_column("id", SqlScalarType::String.nullable(false))
2345 .with_column("oid", SqlScalarType::Oid.nullable(false))
2346 .with_column("name", SqlScalarType::String.nullable(false))
2347 .with_column("owner_id", SqlScalarType::String.nullable(false))
2348 .with_column(
2349 "privileges",
2350 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2351 )
2352 .with_key(vec![0])
2353 .with_key(vec![1])
2354 .finish(),
2355 column_comments: BTreeMap::from_iter([
2356 ("id", "Materialize's unique ID for the database."),
2357 (
2358 "oid",
2359 "A [PostgreSQL-compatible OID][`oid`] for the database.",
2360 ),
2361 ("name", "The name of the database."),
2362 (
2363 "owner_id",
2364 "The role ID of the owner of the database. Corresponds to `mz_roles.id`.",
2365 ),
2366 ("privileges", "The privileges belonging to the database."),
2367 ]),
2368 is_retained_metrics_object: false,
2369 access: vec![PUBLIC_SELECT],
2370});
2371pub static MZ_SCHEMAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2372 name: "mz_schemas",
2373 schema: MZ_CATALOG_SCHEMA,
2374 oid: oid::TABLE_MZ_SCHEMAS_OID,
2375 desc: RelationDesc::builder()
2376 .with_column("id", SqlScalarType::String.nullable(false))
2377 .with_column("oid", SqlScalarType::Oid.nullable(false))
2378 .with_column("database_id", SqlScalarType::String.nullable(true))
2379 .with_column("name", SqlScalarType::String.nullable(false))
2380 .with_column("owner_id", SqlScalarType::String.nullable(false))
2381 .with_column(
2382 "privileges",
2383 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2384 )
2385 .with_key(vec![0])
2386 .with_key(vec![1])
2387 .finish(),
2388 column_comments: BTreeMap::from_iter([
2389 ("id", "Materialize's unique ID for the schema."),
2390 (
2391 "oid",
2392 "A [PostgreSQL-compatible oid][`oid`] for the schema.",
2393 ),
2394 (
2395 "database_id",
2396 "The ID of the database containing the schema. Corresponds to `mz_databases.id`.",
2397 ),
2398 ("name", "The name of the schema."),
2399 (
2400 "owner_id",
2401 "The role ID of the owner of the schema. Corresponds to `mz_roles.id`.",
2402 ),
2403 ("privileges", "The privileges belonging to the schema."),
2404 ]),
2405 is_retained_metrics_object: false,
2406 access: vec![PUBLIC_SELECT],
2407});
2408pub static MZ_COLUMNS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2409 name: "mz_columns",
2410 schema: MZ_CATALOG_SCHEMA,
2411 oid: oid::TABLE_MZ_COLUMNS_OID,
2412 desc: RelationDesc::builder()
2413 .with_column("id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false))
2415 .with_column("position", SqlScalarType::UInt64.nullable(false))
2416 .with_column("nullable", SqlScalarType::Bool.nullable(false))
2417 .with_column("type", SqlScalarType::String.nullable(false))
2418 .with_column("default", SqlScalarType::String.nullable(true))
2419 .with_column("type_oid", SqlScalarType::Oid.nullable(false))
2420 .with_column("type_mod", SqlScalarType::Int32.nullable(false))
2421 .finish(),
2422 column_comments: BTreeMap::from_iter([
2423 (
2424 "id",
2425 "The unique ID of the table, source, or view containing the column.",
2426 ),
2427 ("name", "The name of the column."),
2428 (
2429 "position",
2430 "The 1-indexed position of the column in its containing table, source, or view.",
2431 ),
2432 ("nullable", "Can the column contain a `NULL` value?"),
2433 ("type", "The data type of the column."),
2434 ("default", "The default expression of the column."),
2435 (
2436 "type_oid",
2437 "The OID of the type of the column (references `mz_types`).",
2438 ),
2439 ("type_mod", "The packed type identifier of the column."),
2440 ]),
2441 is_retained_metrics_object: false,
2442 access: vec![PUBLIC_SELECT],
2443});
2444pub static MZ_INDEXES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2445 name: "mz_indexes",
2446 schema: MZ_CATALOG_SCHEMA,
2447 oid: oid::TABLE_MZ_INDEXES_OID,
2448 desc: RelationDesc::builder()
2449 .with_column("id", SqlScalarType::String.nullable(false))
2450 .with_column("oid", SqlScalarType::Oid.nullable(false))
2451 .with_column("name", SqlScalarType::String.nullable(false))
2452 .with_column("on_id", SqlScalarType::String.nullable(false))
2453 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2454 .with_column("owner_id", SqlScalarType::String.nullable(false))
2455 .with_column("create_sql", SqlScalarType::String.nullable(false))
2456 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2457 .with_key(vec![0])
2458 .with_key(vec![1])
2459 .finish(),
2460 column_comments: BTreeMap::from_iter([
2461 ("id", "Materialize's unique ID for the index."),
2462 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the index."),
2463 ("name", "The name of the index."),
2464 (
2465 "on_id",
2466 "The ID of the relation on which the index is built.",
2467 ),
2468 (
2469 "cluster_id",
2470 "The ID of the cluster in which the index is built.",
2471 ),
2472 (
2473 "owner_id",
2474 "The role ID of the owner of the index. Corresponds to `mz_roles.id`.",
2475 ),
2476 ("create_sql", "The `CREATE` SQL statement for the index."),
2477 (
2478 "redacted_create_sql",
2479 "The redacted `CREATE` SQL statement for the index.",
2480 ),
2481 ]),
2482 is_retained_metrics_object: false,
2483 access: vec![PUBLIC_SELECT],
2484});
2485pub static MZ_INDEX_COLUMNS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2486 name: "mz_index_columns",
2487 schema: MZ_CATALOG_SCHEMA,
2488 oid: oid::TABLE_MZ_INDEX_COLUMNS_OID,
2489 desc: RelationDesc::builder()
2490 .with_column("index_id", SqlScalarType::String.nullable(false))
2491 .with_column("index_position", SqlScalarType::UInt64.nullable(false))
2492 .with_column("on_position", SqlScalarType::UInt64.nullable(true))
2493 .with_column("on_expression", SqlScalarType::String.nullable(true))
2494 .with_column("nullable", SqlScalarType::Bool.nullable(false))
2495 .finish(),
2496 column_comments: BTreeMap::from_iter([
2497 (
2498 "index_id",
2499 "The ID of the index which contains this column. Corresponds to `mz_indexes.id`.",
2500 ),
2501 (
2502 "index_position",
2503 "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.)",
2504 ),
2505 (
2506 "on_position",
2507 "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.",
2508 ),
2509 (
2510 "on_expression",
2511 "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.",
2512 ),
2513 (
2514 "nullable",
2515 "Can this column of the index evaluate to `NULL`?",
2516 ),
2517 ]),
2518 is_retained_metrics_object: false,
2519 access: vec![PUBLIC_SELECT],
2520});
2521pub static MZ_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2522 name: "mz_tables",
2523 schema: MZ_CATALOG_SCHEMA,
2524 oid: oid::TABLE_MZ_TABLES_OID,
2525 desc: RelationDesc::builder()
2526 .with_column("id", SqlScalarType::String.nullable(false))
2527 .with_column("oid", SqlScalarType::Oid.nullable(false))
2528 .with_column("schema_id", SqlScalarType::String.nullable(false))
2529 .with_column("name", SqlScalarType::String.nullable(false))
2530 .with_column("owner_id", SqlScalarType::String.nullable(false))
2531 .with_column(
2532 "privileges",
2533 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2534 )
2535 .with_column("create_sql", SqlScalarType::String.nullable(true))
2536 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
2537 .with_column("source_id", SqlScalarType::String.nullable(true))
2538 .with_key(vec![0])
2539 .with_key(vec![1])
2540 .finish(),
2541 column_comments: BTreeMap::from_iter([
2542 ("id", "Materialize's unique ID for the table."),
2543 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the table."),
2544 (
2545 "schema_id",
2546 "The ID of the schema to which the table belongs. Corresponds to `mz_schemas.id`.",
2547 ),
2548 ("name", "The name of the table."),
2549 (
2550 "owner_id",
2551 "The role ID of the owner of the table. Corresponds to `mz_roles.id`.",
2552 ),
2553 ("privileges", "The privileges belonging to the table."),
2554 ("create_sql", "The `CREATE` SQL statement for the table."),
2555 (
2556 "redacted_create_sql",
2557 "The redacted `CREATE` SQL statement for the table.",
2558 ),
2559 (
2560 "source_id",
2561 "The ID of the source associated with the table, if any. Corresponds to `mz_sources.id`.",
2562 ),
2563 ]),
2564 is_retained_metrics_object: true,
2565 access: vec![PUBLIC_SELECT],
2566});
2567pub static MZ_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2568 name: "mz_connections",
2569 schema: MZ_CATALOG_SCHEMA,
2570 oid: oid::TABLE_MZ_CONNECTIONS_OID,
2571 desc: RelationDesc::builder()
2572 .with_column("id", SqlScalarType::String.nullable(false))
2573 .with_column("oid", SqlScalarType::Oid.nullable(false))
2574 .with_column("schema_id", SqlScalarType::String.nullable(false))
2575 .with_column("name", SqlScalarType::String.nullable(false))
2576 .with_column("type", SqlScalarType::String.nullable(false))
2577 .with_column("owner_id", SqlScalarType::String.nullable(false))
2578 .with_column(
2579 "privileges",
2580 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2581 )
2582 .with_column("create_sql", SqlScalarType::String.nullable(false))
2583 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2584 .with_key(vec![0])
2585 .with_key(vec![1])
2586 .finish(),
2587 column_comments: BTreeMap::from_iter([
2588 ("id", "The unique ID of the connection."),
2589 (
2590 "oid",
2591 "A [PostgreSQL-compatible OID][`oid`] for the connection.",
2592 ),
2593 (
2594 "schema_id",
2595 "The ID of the schema to which the connection belongs. Corresponds to `mz_schemas.id`.",
2596 ),
2597 ("name", "The name of the connection."),
2598 (
2599 "type",
2600 "The type of the connection: `confluent-schema-registry`, `kafka`, `postgres`, or `ssh-tunnel`.",
2601 ),
2602 (
2603 "owner_id",
2604 "The role ID of the owner of the connection. Corresponds to `mz_roles.id`.",
2605 ),
2606 ("privileges", "The privileges belonging to the connection."),
2607 (
2608 "create_sql",
2609 "The `CREATE` SQL statement for the connection.",
2610 ),
2611 (
2612 "redacted_create_sql",
2613 "The redacted `CREATE` SQL statement for the connection.",
2614 ),
2615 ]),
2616 is_retained_metrics_object: false,
2617 access: vec![PUBLIC_SELECT],
2618});
2619pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2620 name: "mz_ssh_tunnel_connections",
2621 schema: MZ_CATALOG_SCHEMA,
2622 oid: oid::TABLE_MZ_SSH_TUNNEL_CONNECTIONS_OID,
2623 desc: RelationDesc::builder()
2624 .with_column("id", SqlScalarType::String.nullable(false))
2625 .with_column("public_key_1", SqlScalarType::String.nullable(false))
2626 .with_column("public_key_2", SqlScalarType::String.nullable(false))
2627 .finish(),
2628 column_comments: BTreeMap::from_iter([
2629 ("id", "The ID of the connection."),
2630 (
2631 "public_key_1",
2632 "The first public key associated with the SSH tunnel.",
2633 ),
2634 (
2635 "public_key_2",
2636 "The second public key associated with the SSH tunnel.",
2637 ),
2638 ]),
2639 is_retained_metrics_object: false,
2640 access: vec![PUBLIC_SELECT],
2641});
2642pub static MZ_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2643 name: "mz_sources",
2644 schema: MZ_CATALOG_SCHEMA,
2645 oid: oid::TABLE_MZ_SOURCES_OID,
2646 desc: RelationDesc::builder()
2647 .with_column("id", SqlScalarType::String.nullable(false))
2648 .with_column("oid", SqlScalarType::Oid.nullable(false))
2649 .with_column("schema_id", SqlScalarType::String.nullable(false))
2650 .with_column("name", SqlScalarType::String.nullable(false))
2651 .with_column("type", SqlScalarType::String.nullable(false))
2652 .with_column("connection_id", SqlScalarType::String.nullable(true))
2653 .with_column("size", SqlScalarType::String.nullable(true))
2654 .with_column("envelope_type", SqlScalarType::String.nullable(true))
2655 .with_column("key_format", SqlScalarType::String.nullable(true))
2656 .with_column("value_format", SqlScalarType::String.nullable(true))
2657 .with_column("cluster_id", SqlScalarType::String.nullable(true))
2658 .with_column("owner_id", SqlScalarType::String.nullable(false))
2659 .with_column(
2660 "privileges",
2661 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2662 )
2663 .with_column("create_sql", SqlScalarType::String.nullable(true))
2664 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
2665 .with_key(vec![0])
2666 .with_key(vec![1])
2667 .finish(),
2668 column_comments: BTreeMap::from_iter([
2669 ("id", "Materialize's unique ID for the source."),
2670 (
2671 "oid",
2672 "A [PostgreSQL-compatible OID][`oid`] for the source.",
2673 ),
2674 (
2675 "schema_id",
2676 "The ID of the schema to which the source belongs. Corresponds to `mz_schemas.id`.",
2677 ),
2678 ("name", "The name of the source."),
2679 (
2680 "type",
2681 "The type of the source: `kafka`, `mysql`, `postgres`, `load-generator`, `progress`, or `subsource`.",
2682 ),
2683 (
2684 "connection_id",
2685 "The ID of the connection associated with the source, if any. Corresponds to `mz_connections.id`.",
2686 ),
2687 ("size", "Deprecated The size of the source."),
2688 (
2689 "envelope_type",
2690 "For Kafka sources, the envelope type: `none`, `upsert`, or `debezium`. `NULL` for other source types.",
2691 ),
2692 (
2693 "key_format",
2694 "For Kafka sources, the format of the Kafka message key: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`, or `NULL`.",
2695 ),
2696 (
2697 "value_format",
2698 "For Kafka sources, the format of the Kafka message value: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`. `NULL` for other source types.",
2699 ),
2700 (
2701 "cluster_id",
2702 "The ID of the cluster maintaining the source. Corresponds to `mz_clusters.id`.",
2703 ),
2704 (
2705 "owner_id",
2706 "The role ID of the owner of the source. Corresponds to `mz_roles.id`.",
2707 ),
2708 ("privileges", "The privileges granted on the source."),
2709 ("create_sql", "The `CREATE` SQL statement for the source."),
2710 (
2711 "redacted_create_sql",
2712 "The redacted `CREATE` SQL statement for the source.",
2713 ),
2714 ]),
2715 is_retained_metrics_object: true,
2716 access: vec![PUBLIC_SELECT],
2717});
2718pub static MZ_SINKS: LazyLock<BuiltinTable> = LazyLock::new(|| {
2719 BuiltinTable {
2720 name: "mz_sinks",
2721 schema: MZ_CATALOG_SCHEMA,
2722 oid: oid::TABLE_MZ_SINKS_OID,
2723 desc: RelationDesc::builder()
2724 .with_column("id", SqlScalarType::String.nullable(false))
2725 .with_column("oid", SqlScalarType::Oid.nullable(false))
2726 .with_column("schema_id", SqlScalarType::String.nullable(false))
2727 .with_column("name", SqlScalarType::String.nullable(false))
2728 .with_column("type", SqlScalarType::String.nullable(false))
2729 .with_column("connection_id", SqlScalarType::String.nullable(true))
2730 .with_column("size", SqlScalarType::String.nullable(true))
2731 .with_column("envelope_type", SqlScalarType::String.nullable(true))
2732 .with_column("format", SqlScalarType::String.nullable(true))
2735 .with_column("key_format", SqlScalarType::String.nullable(true))
2736 .with_column("value_format", SqlScalarType::String.nullable(true))
2737 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2738 .with_column("owner_id", SqlScalarType::String.nullable(false))
2739 .with_column("create_sql", SqlScalarType::String.nullable(false))
2740 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2741 .with_key(vec![0])
2742 .with_key(vec![1])
2743 .finish(),
2744 column_comments: BTreeMap::from_iter([
2745 ("id", "Materialize's unique ID for the sink."),
2746 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the sink."),
2747 (
2748 "schema_id",
2749 "The ID of the schema to which the sink belongs. Corresponds to `mz_schemas.id`.",
2750 ),
2751 ("name", "The name of the sink."),
2752 ("type", "The type of the sink: `kafka`."),
2753 (
2754 "connection_id",
2755 "The ID of the connection associated with the sink, if any. Corresponds to `mz_connections.id`.",
2756 ),
2757 ("size", "The size of the sink."),
2758 (
2759 "envelope_type",
2760 "The envelope of the sink: `upsert`, or `debezium`.",
2761 ),
2762 (
2763 "format",
2764 "Deprecated The format of the Kafka messages produced by the sink: `avro`, `json`, `text`, or `bytes`.",
2765 ),
2766 (
2767 "key_format",
2768 "The format of the Kafka message key for messages produced by the sink: `avro`, `json`, `bytes`, `text`, or `NULL`.",
2769 ),
2770 (
2771 "value_format",
2772 "The format of the Kafka message value for messages produced by the sink: `avro`, `json`, `text`, or `bytes`.",
2773 ),
2774 (
2775 "cluster_id",
2776 "The ID of the cluster maintaining the sink. Corresponds to `mz_clusters.id`.",
2777 ),
2778 (
2779 "owner_id",
2780 "The role ID of the owner of the sink. Corresponds to `mz_roles.id`.",
2781 ),
2782 ("create_sql", "The `CREATE` SQL statement for the sink."),
2783 (
2784 "redacted_create_sql",
2785 "The redacted `CREATE` SQL statement for the sink.",
2786 ),
2787 ]),
2788 is_retained_metrics_object: true,
2789 access: vec![PUBLIC_SELECT],
2790 }
2791});
2792pub static MZ_VIEWS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2793 name: "mz_views",
2794 schema: MZ_CATALOG_SCHEMA,
2795 oid: oid::TABLE_MZ_VIEWS_OID,
2796 desc: RelationDesc::builder()
2797 .with_column("id", SqlScalarType::String.nullable(false))
2798 .with_column("oid", SqlScalarType::Oid.nullable(false))
2799 .with_column("schema_id", SqlScalarType::String.nullable(false))
2800 .with_column("name", SqlScalarType::String.nullable(false))
2801 .with_column("definition", SqlScalarType::String.nullable(false))
2802 .with_column("owner_id", SqlScalarType::String.nullable(false))
2803 .with_column(
2804 "privileges",
2805 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2806 )
2807 .with_column("create_sql", SqlScalarType::String.nullable(false))
2808 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2809 .with_key(vec![0])
2810 .with_key(vec![1])
2811 .finish(),
2812 column_comments: BTreeMap::from_iter([
2813 ("id", "Materialize's unique ID for the view."),
2814 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the view."),
2815 (
2816 "schema_id",
2817 "The ID of the schema to which the view belongs. Corresponds to `mz_schemas.id`.",
2818 ),
2819 ("name", "The name of the view."),
2820 ("definition", "The view definition (a `SELECT` query)."),
2821 (
2822 "owner_id",
2823 "The role ID of the owner of the view. Corresponds to `mz_roles.id`.",
2824 ),
2825 ("privileges", "The privileges belonging to the view."),
2826 ("create_sql", "The `CREATE` SQL statement for the view."),
2827 (
2828 "redacted_create_sql",
2829 "The redacted `CREATE` SQL statement for the view.",
2830 ),
2831 ]),
2832 is_retained_metrics_object: false,
2833 access: vec![PUBLIC_SELECT],
2834});
2835pub static MZ_MATERIALIZED_VIEWS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2836 name: "mz_materialized_views",
2837 schema: MZ_CATALOG_SCHEMA,
2838 oid: oid::TABLE_MZ_MATERIALIZED_VIEWS_OID,
2839 desc: RelationDesc::builder()
2840 .with_column("id", SqlScalarType::String.nullable(false))
2841 .with_column("oid", SqlScalarType::Oid.nullable(false))
2842 .with_column("schema_id", SqlScalarType::String.nullable(false))
2843 .with_column("name", SqlScalarType::String.nullable(false))
2844 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2845 .with_column("definition", SqlScalarType::String.nullable(false))
2846 .with_column("owner_id", SqlScalarType::String.nullable(false))
2847 .with_column(
2848 "privileges",
2849 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2850 )
2851 .with_column("create_sql", SqlScalarType::String.nullable(false))
2852 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2853 .with_key(vec![0])
2854 .with_key(vec![1])
2855 .finish(),
2856 column_comments: BTreeMap::from_iter([
2857 ("id", "Materialize's unique ID for the materialized view."),
2858 (
2859 "oid",
2860 "A [PostgreSQL-compatible OID][`oid`] for the materialized view.",
2861 ),
2862 (
2863 "schema_id",
2864 "The ID of the schema to which the materialized view belongs. Corresponds to `mz_schemas.id`.",
2865 ),
2866 ("name", "The name of the materialized view."),
2867 (
2868 "cluster_id",
2869 "The ID of the cluster maintaining the materialized view. Corresponds to `mz_clusters.id`.",
2870 ),
2871 (
2872 "definition",
2873 "The materialized view definition (a `SELECT` query).",
2874 ),
2875 (
2876 "owner_id",
2877 "The role ID of the owner of the materialized view. Corresponds to `mz_roles.id`.",
2878 ),
2879 (
2880 "privileges",
2881 "The privileges belonging to the materialized view.",
2882 ),
2883 (
2884 "create_sql",
2885 "The `CREATE` SQL statement for the materialized view.",
2886 ),
2887 (
2888 "redacted_create_sql",
2889 "The redacted `CREATE` SQL statement for the materialized view.",
2890 ),
2891 ]),
2892 is_retained_metrics_object: false,
2893 access: vec![PUBLIC_SELECT],
2894});
2895pub static MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES: LazyLock<BuiltinTable> = LazyLock::new(|| {
2896 BuiltinTable {
2897 name: "mz_materialized_view_refresh_strategies",
2898 schema: MZ_INTERNAL_SCHEMA,
2899 oid: oid::TABLE_MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES_OID,
2900 desc: RelationDesc::builder()
2901 .with_column(
2902 "materialized_view_id",
2903 SqlScalarType::String.nullable(false),
2904 )
2905 .with_column("type", SqlScalarType::String.nullable(false))
2906 .with_column("interval", SqlScalarType::Interval.nullable(true))
2907 .with_column(
2908 "aligned_to",
2909 SqlScalarType::TimestampTz { precision: None }.nullable(true),
2910 )
2911 .with_column(
2912 "at",
2913 SqlScalarType::TimestampTz { precision: None }.nullable(true),
2914 )
2915 .finish(),
2916 column_comments: BTreeMap::from_iter([
2917 (
2918 "materialized_view_id",
2919 "The ID of the materialized view. Corresponds to `mz_catalog.mz_materialized_views.id`",
2920 ),
2921 (
2922 "type",
2923 "`at`, `every`, or `on-commit`. Default: `on-commit`",
2924 ),
2925 (
2926 "interval",
2927 "The refresh interval of a `REFRESH EVERY` option, or `NULL` if the `type` is not `every`.",
2928 ),
2929 (
2930 "aligned_to",
2931 "The `ALIGNED TO` option of a `REFRESH EVERY` option, or `NULL` if the `type` is not `every`.",
2932 ),
2933 (
2934 "at",
2935 "The time of a `REFRESH AT`, or `NULL` if the `type` is not `at`.",
2936 ),
2937 ]),
2938 is_retained_metrics_object: false,
2939 access: vec![PUBLIC_SELECT],
2940 }
2941});
2942pub static MZ_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2943 name: "mz_types",
2944 schema: MZ_CATALOG_SCHEMA,
2945 oid: oid::TABLE_MZ_TYPES_OID,
2946 desc: RelationDesc::builder()
2947 .with_column("id", SqlScalarType::String.nullable(false))
2948 .with_column("oid", SqlScalarType::Oid.nullable(false))
2949 .with_column("schema_id", SqlScalarType::String.nullable(false))
2950 .with_column("name", SqlScalarType::String.nullable(false))
2951 .with_column("category", SqlScalarType::String.nullable(false))
2952 .with_column("owner_id", SqlScalarType::String.nullable(false))
2953 .with_column(
2954 "privileges",
2955 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2956 )
2957 .with_column("create_sql", SqlScalarType::String.nullable(true))
2958 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
2959 .with_key(vec![0])
2960 .with_key(vec![1])
2961 .finish(),
2962 column_comments: BTreeMap::from_iter([
2963 ("id", "Materialize's unique ID for the type."),
2964 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the type."),
2965 (
2966 "schema_id",
2967 "The ID of the schema to which the type belongs. Corresponds to `mz_schemas.id`.",
2968 ),
2969 ("name", "The name of the type."),
2970 ("category", "The category of the type."),
2971 (
2972 "owner_id",
2973 "The role ID of the owner of the type. Corresponds to `mz_roles.id`.",
2974 ),
2975 ("privileges", "The privileges belonging to the type."),
2976 ("create_sql", "The `CREATE` SQL statement for the type."),
2977 (
2978 "redacted_create_sql",
2979 "The redacted `CREATE` SQL statement for the type.",
2980 ),
2981 ]),
2982 is_retained_metrics_object: false,
2983 access: vec![PUBLIC_SELECT],
2984});
2985pub static MZ_CONTINUAL_TASKS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2986 name: "mz_continual_tasks",
2987 schema: MZ_INTERNAL_SCHEMA,
2988 oid: oid::TABLE_MZ_CONTINUAL_TASKS_OID,
2989 desc: RelationDesc::builder()
2990 .with_column("id", SqlScalarType::String.nullable(false))
2991 .with_column("oid", SqlScalarType::Oid.nullable(false))
2992 .with_column("schema_id", SqlScalarType::String.nullable(false))
2993 .with_column("name", SqlScalarType::String.nullable(false))
2994 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2995 .with_column("definition", SqlScalarType::String.nullable(false))
2996 .with_column("owner_id", SqlScalarType::String.nullable(false))
2997 .with_column(
2998 "privileges",
2999 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
3000 )
3001 .with_column("create_sql", SqlScalarType::String.nullable(false))
3002 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
3003 .with_key(vec![0])
3004 .with_key(vec![1])
3005 .finish(),
3006 column_comments: BTreeMap::new(),
3007 is_retained_metrics_object: false,
3008 access: vec![PUBLIC_SELECT],
3009});
3010pub static MZ_NETWORK_POLICIES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3011 name: "mz_network_policies",
3012 schema: MZ_INTERNAL_SCHEMA,
3013 oid: oid::TABLE_MZ_NETWORK_POLICIES_OID,
3014 desc: RelationDesc::builder()
3015 .with_column("id", SqlScalarType::String.nullable(false))
3016 .with_column("name", SqlScalarType::String.nullable(false))
3017 .with_column("owner_id", SqlScalarType::String.nullable(false))
3018 .with_column(
3019 "privileges",
3020 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
3021 )
3022 .with_column("oid", SqlScalarType::Oid.nullable(false))
3023 .finish(),
3024 column_comments: BTreeMap::from_iter([
3025 ("id", "The ID of the network policy."),
3026 ("name", "The name of the network policy."),
3027 (
3028 "owner_id",
3029 "The role ID of the owner of the network policy. Corresponds to `mz_catalog.mz_roles.id`.",
3030 ),
3031 (
3032 "privileges",
3033 "The privileges belonging to the network policy.",
3034 ),
3035 (
3036 "oid",
3037 "A [PostgreSQL-compatible OID][`oid`] for the network policy.",
3038 ),
3039 ]),
3040 is_retained_metrics_object: false,
3041 access: vec![PUBLIC_SELECT],
3042});
3043pub static MZ_NETWORK_POLICY_RULES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3044 name: "mz_network_policy_rules",
3045 schema: MZ_INTERNAL_SCHEMA,
3046 oid: oid::TABLE_MZ_NETWORK_POLICY_RULES_OID,
3047 desc: RelationDesc::builder()
3048 .with_column("name", SqlScalarType::String.nullable(false))
3049 .with_column("policy_id", SqlScalarType::String.nullable(false))
3050 .with_column("action", SqlScalarType::String.nullable(false))
3051 .with_column("address", SqlScalarType::String.nullable(false))
3052 .with_column("direction", SqlScalarType::String.nullable(false))
3053 .finish(),
3054 column_comments: BTreeMap::from_iter([
3055 (
3056 "name",
3057 "The name of the network policy rule. Can be combined with `policy_id` to form a unique identifier.",
3058 ),
3059 (
3060 "policy_id",
3061 "The ID the network policy the rule is part of. Corresponds to `mz_network_policy_rules.id`.",
3062 ),
3063 (
3064 "action",
3065 "The action of the rule. `allow` is the only supported action.",
3066 ),
3067 ("address", "The address the rule will take action on."),
3068 (
3069 "direction",
3070 "The direction of traffic the rule applies to. `ingress` is the only supported direction.",
3071 ),
3072 ]),
3073 is_retained_metrics_object: false,
3074 access: vec![PUBLIC_SELECT],
3075});
3076pub static MZ_TYPE_PG_METADATA: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3079 name: "mz_type_pg_metadata",
3080 schema: MZ_INTERNAL_SCHEMA,
3081 oid: oid::TABLE_MZ_TYPE_PG_METADATA_OID,
3082 desc: RelationDesc::builder()
3083 .with_column("id", SqlScalarType::String.nullable(false))
3084 .with_column("typinput", SqlScalarType::Oid.nullable(false))
3085 .with_column("typreceive", SqlScalarType::Oid.nullable(false))
3086 .finish(),
3087 column_comments: BTreeMap::new(),
3088 is_retained_metrics_object: false,
3089 access: vec![PUBLIC_SELECT],
3090});
3091pub static MZ_ARRAY_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3092 name: "mz_array_types",
3093 schema: MZ_CATALOG_SCHEMA,
3094 oid: oid::TABLE_MZ_ARRAY_TYPES_OID,
3095 desc: RelationDesc::builder()
3096 .with_column("id", SqlScalarType::String.nullable(false))
3097 .with_column("element_id", SqlScalarType::String.nullable(false))
3098 .finish(),
3099 column_comments: BTreeMap::from_iter([
3100 ("id", "The ID of the array type."),
3101 ("element_id", "The ID of the array's element type."),
3102 ]),
3103 is_retained_metrics_object: false,
3104 access: vec![PUBLIC_SELECT],
3105});
3106pub static MZ_BASE_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3107 name: "mz_base_types",
3108 schema: MZ_CATALOG_SCHEMA,
3109 oid: oid::TABLE_MZ_BASE_TYPES_OID,
3110 desc: RelationDesc::builder()
3111 .with_column("id", SqlScalarType::String.nullable(false))
3112 .finish(),
3113 column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]),
3114 is_retained_metrics_object: false,
3115 access: vec![PUBLIC_SELECT],
3116});
3117pub static MZ_LIST_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3118 name: "mz_list_types",
3119 schema: MZ_CATALOG_SCHEMA,
3120 oid: oid::TABLE_MZ_LIST_TYPES_OID,
3121 desc: RelationDesc::builder()
3122 .with_column("id", SqlScalarType::String.nullable(false))
3123 .with_column("element_id", SqlScalarType::String.nullable(false))
3124 .with_column(
3125 "element_modifiers",
3126 SqlScalarType::List {
3127 element_type: Box::new(SqlScalarType::Int64),
3128 custom_id: None,
3129 }
3130 .nullable(true),
3131 )
3132 .finish(),
3133 column_comments: BTreeMap::from_iter([
3134 ("id", "The ID of the list type."),
3135 ("element_id", "The IID of the list's element type."),
3136 (
3137 "element_modifiers",
3138 "The element type modifiers, or `NULL` if none.",
3139 ),
3140 ]),
3141 is_retained_metrics_object: false,
3142 access: vec![PUBLIC_SELECT],
3143});
3144pub static MZ_MAP_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3145 name: "mz_map_types",
3146 schema: MZ_CATALOG_SCHEMA,
3147 oid: oid::TABLE_MZ_MAP_TYPES_OID,
3148 desc: RelationDesc::builder()
3149 .with_column("id", SqlScalarType::String.nullable(false))
3150 .with_column("key_id", SqlScalarType::String.nullable(false))
3151 .with_column("value_id", SqlScalarType::String.nullable(false))
3152 .with_column(
3153 "key_modifiers",
3154 SqlScalarType::List {
3155 element_type: Box::new(SqlScalarType::Int64),
3156 custom_id: None,
3157 }
3158 .nullable(true),
3159 )
3160 .with_column(
3161 "value_modifiers",
3162 SqlScalarType::List {
3163 element_type: Box::new(SqlScalarType::Int64),
3164 custom_id: None,
3165 }
3166 .nullable(true),
3167 )
3168 .finish(),
3169 column_comments: BTreeMap::from_iter([
3170 ("id", "The ID of the map type."),
3171 ("key_id", "The ID of the map's key type."),
3172 ("value_id", "The ID of the map's value type."),
3173 (
3174 "key_modifiers",
3175 "The key type modifiers, or `NULL` if none.",
3176 ),
3177 (
3178 "value_modifiers",
3179 "The value type modifiers, or `NULL` if none.",
3180 ),
3181 ]),
3182 is_retained_metrics_object: false,
3183 access: vec![PUBLIC_SELECT],
3184});
3185pub static MZ_ROLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3186 name: "mz_roles",
3187 schema: MZ_CATALOG_SCHEMA,
3188 oid: oid::TABLE_MZ_ROLES_OID,
3189 desc: RelationDesc::builder()
3190 .with_column("id", SqlScalarType::String.nullable(false))
3191 .with_column("oid", SqlScalarType::Oid.nullable(false))
3192 .with_column("name", SqlScalarType::String.nullable(false))
3193 .with_column("inherit", SqlScalarType::Bool.nullable(false))
3194 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(true))
3195 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
3196 .with_key(vec![0])
3197 .with_key(vec![1])
3198 .finish(),
3199 column_comments: BTreeMap::from_iter([
3200 ("id", "Materialize's unique ID for the role."),
3201 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the role."),
3202 ("name", "The name of the role."),
3203 (
3204 "inherit",
3205 "Indicates whether the role has inheritance of privileges.",
3206 ),
3207 (
3208 "rolcanlogin",
3209 "Indicates whether the role can log in (i.e., is a user).",
3210 ),
3211 ("rolsuper", "Indicates whether the role is a superuser."),
3212 ]),
3213 is_retained_metrics_object: false,
3214 access: vec![PUBLIC_SELECT],
3215});
3216pub static MZ_ROLE_MEMBERS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3217 name: "mz_role_members",
3218 schema: MZ_CATALOG_SCHEMA,
3219 oid: oid::TABLE_MZ_ROLE_MEMBERS_OID,
3220 desc: RelationDesc::builder()
3221 .with_column("role_id", SqlScalarType::String.nullable(false))
3222 .with_column("member", SqlScalarType::String.nullable(false))
3223 .with_column("grantor", SqlScalarType::String.nullable(false))
3224 .finish(),
3225 column_comments: BTreeMap::from_iter([
3226 (
3227 "role_id",
3228 "The ID of the role the `member` is a member of. Corresponds to `mz_roles.id`.",
3229 ),
3230 (
3231 "member",
3232 "The ID of the role that is a member of `role_id`. Corresponds to `mz_roles.id`.",
3233 ),
3234 (
3235 "grantor",
3236 "The ID of the role that granted membership of `member` to `role_id`. Corresponds to `mz_roles.id`.",
3237 ),
3238 ]),
3239 is_retained_metrics_object: false,
3240 access: vec![PUBLIC_SELECT],
3241});
3242pub static MZ_ROLE_PARAMETERS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3243 name: "mz_role_parameters",
3244 schema: MZ_CATALOG_SCHEMA,
3245 oid: oid::TABLE_MZ_ROLE_PARAMETERS_OID,
3246 desc: RelationDesc::builder()
3247 .with_column("role_id", SqlScalarType::String.nullable(false))
3248 .with_column("parameter_name", SqlScalarType::String.nullable(false))
3249 .with_column("parameter_value", SqlScalarType::String.nullable(false))
3250 .finish(),
3251 column_comments: BTreeMap::from_iter([
3252 (
3253 "role_id",
3254 "The ID of the role whose configuration parameter default is set. Corresponds to `mz_roles.id`.",
3255 ),
3256 (
3257 "parameter_name",
3258 "The configuration parameter name. One of the supported configuration parameters.",
3259 ),
3260 (
3261 "parameter_value",
3262 "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.",
3263 ),
3264 ]),
3265 is_retained_metrics_object: false,
3266 access: vec![PUBLIC_SELECT],
3267});
3268pub static MZ_ROLE_AUTH: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3269 name: "mz_role_auth",
3270 schema: MZ_CATALOG_SCHEMA,
3271 oid: oid::TABLE_MZ_ROLE_AUTH_OID,
3272 desc: RelationDesc::builder()
3273 .with_column("role_id", SqlScalarType::String.nullable(false))
3274 .with_column("role_oid", SqlScalarType::Oid.nullable(false))
3275 .with_column("password_hash", SqlScalarType::String.nullable(true))
3276 .with_column(
3277 "updated_at",
3278 SqlScalarType::TimestampTz { precision: None }.nullable(false),
3279 )
3280 .finish(),
3281 column_comments: BTreeMap::from_iter([
3282 (
3283 "role_id",
3284 "The ID of the role. Corresponds to `mz_roles.id`.",
3285 ),
3286 (
3287 "role_oid",
3288 "The OID of the role whose configuration parameter default is set. Corresponds to `mz_roles.oid`.",
3289 ),
3290 ("password_hash", "The hashed password for the role"),
3291 (
3292 "updated_at",
3293 "The timestamp when the password was last updated.",
3294 ),
3295 ]),
3296 is_retained_metrics_object: false,
3297 access: vec![rbac::owner_privilege(ObjectType::Table, MZ_SYSTEM_ROLE_ID)],
3298});
3299pub static MZ_PSEUDO_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3300 name: "mz_pseudo_types",
3301 schema: MZ_CATALOG_SCHEMA,
3302 oid: oid::TABLE_MZ_PSEUDO_TYPES_OID,
3303 desc: RelationDesc::builder()
3304 .with_column("id", SqlScalarType::String.nullable(false))
3305 .finish(),
3306 column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]),
3307 is_retained_metrics_object: false,
3308 access: vec![PUBLIC_SELECT],
3309});
3310pub static MZ_FUNCTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| {
3311 BuiltinTable {
3312 name: "mz_functions",
3313 schema: MZ_CATALOG_SCHEMA,
3314 oid: oid::TABLE_MZ_FUNCTIONS_OID,
3315 desc: RelationDesc::builder()
3316 .with_column("id", SqlScalarType::String.nullable(false)) .with_column("oid", SqlScalarType::Oid.nullable(false))
3318 .with_column("schema_id", SqlScalarType::String.nullable(false))
3319 .with_column("name", SqlScalarType::String.nullable(false))
3320 .with_column(
3321 "argument_type_ids",
3322 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
3323 )
3324 .with_column(
3325 "variadic_argument_type_id",
3326 SqlScalarType::String.nullable(true),
3327 )
3328 .with_column("return_type_id", SqlScalarType::String.nullable(true))
3329 .with_column("returns_set", SqlScalarType::Bool.nullable(false))
3330 .with_column("owner_id", SqlScalarType::String.nullable(false))
3331 .finish(),
3332 column_comments: BTreeMap::from_iter([
3333 ("id", "Materialize's unique ID for the function."),
3334 (
3335 "oid",
3336 "A [PostgreSQL-compatible OID][`oid`] for the function.",
3337 ),
3338 (
3339 "schema_id",
3340 "The ID of the schema to which the function belongs. Corresponds to `mz_schemas.id`.",
3341 ),
3342 ("name", "The name of the function."),
3343 (
3344 "argument_type_ids",
3345 "The ID of each argument's type. Each entry refers to `mz_types.id`.",
3346 ),
3347 (
3348 "variadic_argument_type_id",
3349 "The ID of the variadic argument's type, or `NULL` if the function does not have a variadic argument. Refers to `mz_types.id`.",
3350 ),
3351 (
3352 "return_type_id",
3353 "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`].",
3354 ),
3355 (
3356 "returns_set",
3357 "Whether the function returns a set, i.e. the function is a table function.",
3358 ),
3359 (
3360 "owner_id",
3361 "The role ID of the owner of the function. Corresponds to `mz_roles.id`.",
3362 ),
3363 ]),
3364 is_retained_metrics_object: false,
3365 access: vec![PUBLIC_SELECT],
3366 }
3367});
3368pub static MZ_OPERATORS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3369 name: "mz_operators",
3370 schema: MZ_CATALOG_SCHEMA,
3371 oid: oid::TABLE_MZ_OPERATORS_OID,
3372 desc: RelationDesc::builder()
3373 .with_column("oid", SqlScalarType::Oid.nullable(false))
3374 .with_column("name", SqlScalarType::String.nullable(false))
3375 .with_column(
3376 "argument_type_ids",
3377 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
3378 )
3379 .with_column("return_type_id", SqlScalarType::String.nullable(true))
3380 .finish(),
3381 column_comments: BTreeMap::new(),
3382 is_retained_metrics_object: false,
3383 access: vec![PUBLIC_SELECT],
3384});
3385pub static MZ_AGGREGATES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3386 name: "mz_aggregates",
3387 schema: MZ_INTERNAL_SCHEMA,
3388 oid: oid::TABLE_MZ_AGGREGATES_OID,
3389 desc: RelationDesc::builder()
3390 .with_column("oid", SqlScalarType::Oid.nullable(false))
3391 .with_column("agg_kind", SqlScalarType::String.nullable(false))
3392 .with_column("agg_num_direct_args", SqlScalarType::Int16.nullable(false))
3393 .finish(),
3394 column_comments: BTreeMap::new(),
3395 is_retained_metrics_object: false,
3396 access: vec![PUBLIC_SELECT],
3397});
3398
3399pub static MZ_CLUSTERS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3400 name: "mz_clusters",
3401 schema: MZ_CATALOG_SCHEMA,
3402 oid: oid::TABLE_MZ_CLUSTERS_OID,
3403 desc: RelationDesc::builder()
3404 .with_column("id", SqlScalarType::String.nullable(false))
3405 .with_column("name", SqlScalarType::String.nullable(false))
3406 .with_column("owner_id", SqlScalarType::String.nullable(false))
3407 .with_column(
3408 "privileges",
3409 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
3410 )
3411 .with_column("managed", SqlScalarType::Bool.nullable(false))
3412 .with_column("size", SqlScalarType::String.nullable(true))
3413 .with_column("replication_factor", SqlScalarType::UInt32.nullable(true))
3414 .with_column("disk", SqlScalarType::Bool.nullable(true))
3415 .with_column(
3416 "availability_zones",
3417 SqlScalarType::List {
3418 element_type: Box::new(SqlScalarType::String),
3419 custom_id: None,
3420 }
3421 .nullable(true),
3422 )
3423 .with_column(
3424 "introspection_debugging",
3425 SqlScalarType::Bool.nullable(true),
3426 )
3427 .with_column(
3428 "introspection_interval",
3429 SqlScalarType::Interval.nullable(true),
3430 )
3431 .with_key(vec![0])
3432 .finish(),
3433 column_comments: BTreeMap::from_iter([
3434 ("id", "Materialize's unique ID for the cluster."),
3435 ("name", "The name of the cluster."),
3436 (
3437 "owner_id",
3438 "The role ID of the owner of the cluster. Corresponds to `mz_roles.id`.",
3439 ),
3440 ("privileges", "The privileges belonging to the cluster."),
3441 (
3442 "managed",
3443 "Whether the cluster is a managed cluster with automatically managed replicas.",
3444 ),
3445 (
3446 "size",
3447 "If the cluster is managed, the desired size of the cluster's replicas. `NULL` for unmanaged clusters.",
3448 ),
3449 (
3450 "replication_factor",
3451 "If the cluster is managed, the desired number of replicas of the cluster. `NULL` for unmanaged clusters.",
3452 ),
3453 (
3454 "disk",
3455 "Unstable If the cluster is managed, `true` if the replicas have the `DISK` option . `NULL` for unmanaged clusters.",
3456 ),
3457 (
3458 "availability_zones",
3459 "Unstable If the cluster is managed, the list of availability zones specified in `AVAILABILITY ZONES`. `NULL` for unmanaged clusters.",
3460 ),
3461 (
3462 "introspection_debugging",
3463 "Whether introspection of the gathering of the introspection data is enabled.",
3464 ),
3465 (
3466 "introspection_interval",
3467 "The interval at which to collect introspection data.",
3468 ),
3469 ]),
3470 is_retained_metrics_object: false,
3471 access: vec![PUBLIC_SELECT],
3472});
3473
3474pub static MZ_CLUSTER_WORKLOAD_CLASSES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3475 name: "mz_cluster_workload_classes",
3476 schema: MZ_INTERNAL_SCHEMA,
3477 oid: oid::TABLE_MZ_CLUSTER_WORKLOAD_CLASSES_OID,
3478 desc: RelationDesc::builder()
3479 .with_column("id", SqlScalarType::String.nullable(false))
3480 .with_column("workload_class", SqlScalarType::String.nullable(true))
3481 .with_key(vec![0])
3482 .finish(),
3483 column_comments: BTreeMap::new(),
3484 is_retained_metrics_object: false,
3485 access: vec![PUBLIC_SELECT],
3486});
3487
3488pub const MZ_CLUSTER_WORKLOAD_CLASSES_IND: BuiltinIndex = BuiltinIndex {
3489 name: "mz_cluster_workload_classes_ind",
3490 schema: MZ_INTERNAL_SCHEMA,
3491 oid: oid::INDEX_MZ_CLUSTER_WORKLOAD_CLASSES_IND_OID,
3492 sql: "IN CLUSTER mz_catalog_server
3493ON mz_internal.mz_cluster_workload_classes (id)",
3494 is_retained_metrics_object: false,
3495};
3496
3497pub static MZ_CLUSTER_SCHEDULES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3498 name: "mz_cluster_schedules",
3499 schema: MZ_INTERNAL_SCHEMA,
3500 oid: oid::TABLE_MZ_CLUSTER_SCHEDULES_OID,
3501 desc: RelationDesc::builder()
3502 .with_column("cluster_id", SqlScalarType::String.nullable(false))
3503 .with_column("type", SqlScalarType::String.nullable(false))
3504 .with_column(
3505 "refresh_hydration_time_estimate",
3506 SqlScalarType::Interval.nullable(true),
3507 )
3508 .finish(),
3509 column_comments: BTreeMap::from_iter([
3510 (
3511 "cluster_id",
3512 "The ID of the cluster. Corresponds to `mz_clusters.id`.",
3513 ),
3514 ("type", "`on-refresh`, or `manual`. Default: `manual`"),
3515 (
3516 "refresh_hydration_time_estimate",
3517 "The interval given in the `HYDRATION TIME ESTIMATE` option.",
3518 ),
3519 ]),
3520 is_retained_metrics_object: false,
3521 access: vec![PUBLIC_SELECT],
3522});
3523
3524pub static MZ_SECRETS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3525 name: "mz_secrets",
3526 schema: MZ_CATALOG_SCHEMA,
3527 oid: oid::TABLE_MZ_SECRETS_OID,
3528 desc: RelationDesc::builder()
3529 .with_column("id", SqlScalarType::String.nullable(false))
3530 .with_column("oid", SqlScalarType::Oid.nullable(false))
3531 .with_column("schema_id", SqlScalarType::String.nullable(false))
3532 .with_column("name", SqlScalarType::String.nullable(false))
3533 .with_column("owner_id", SqlScalarType::String.nullable(false))
3534 .with_column(
3535 "privileges",
3536 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
3537 )
3538 .finish(),
3539 column_comments: BTreeMap::from_iter([
3540 ("id", "The unique ID of the secret."),
3541 (
3542 "oid",
3543 "A [PostgreSQL-compatible oid][`oid`] for the secret.",
3544 ),
3545 (
3546 "schema_id",
3547 "The ID of the schema to which the secret belongs. Corresponds to `mz_schemas.id`.",
3548 ),
3549 ("name", "The name of the secret."),
3550 (
3551 "owner_id",
3552 "The role ID of the owner of the secret. Corresponds to `mz_roles.id`.",
3553 ),
3554 ("privileges", "The privileges belonging to the secret."),
3555 ]),
3556 is_retained_metrics_object: false,
3557 access: vec![PUBLIC_SELECT],
3558});
3559
3560pub static MZ_CLUSTER_REPLICAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3561 name: "mz_cluster_replicas",
3562 schema: MZ_CATALOG_SCHEMA,
3563 oid: oid::TABLE_MZ_CLUSTER_REPLICAS_OID,
3564 desc: RelationDesc::builder()
3565 .with_column("id", SqlScalarType::String.nullable(false))
3566 .with_column("name", SqlScalarType::String.nullable(false))
3567 .with_column("cluster_id", SqlScalarType::String.nullable(false))
3568 .with_column("size", SqlScalarType::String.nullable(true))
3569 .with_column("availability_zone", SqlScalarType::String.nullable(true))
3572 .with_column("owner_id", SqlScalarType::String.nullable(false))
3573 .with_column("disk", SqlScalarType::Bool.nullable(true))
3574 .finish(),
3575 column_comments: BTreeMap::from_iter([
3576 ("id", "Materialize's unique ID for the cluster replica."),
3577 ("name", "The name of the cluster replica."),
3578 (
3579 "cluster_id",
3580 "The ID of the cluster to which the replica belongs. Corresponds to `mz_clusters.id`.",
3581 ),
3582 (
3583 "size",
3584 "The cluster replica's size, selected during creation.",
3585 ),
3586 (
3587 "availability_zone",
3588 "The availability zone in which the cluster is running.",
3589 ),
3590 (
3591 "owner_id",
3592 "The role ID of the owner of the cluster replica. Corresponds to `mz_roles.id`.",
3593 ),
3594 ("disk", "If the replica has a local disk."),
3595 ]),
3596 is_retained_metrics_object: true,
3597 access: vec![PUBLIC_SELECT],
3598});
3599
3600pub static MZ_INTERNAL_CLUSTER_REPLICAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3601 name: "mz_internal_cluster_replicas",
3602 schema: MZ_INTERNAL_SCHEMA,
3603 oid: oid::TABLE_MZ_INTERNAL_CLUSTER_REPLICAS_OID,
3604 desc: RelationDesc::builder()
3605 .with_column("id", SqlScalarType::String.nullable(false))
3606 .finish(),
3607 column_comments: BTreeMap::from_iter([(
3608 "id",
3609 "The ID of a cluster replica. Corresponds to `mz_cluster_replicas.id`.",
3610 )]),
3611 is_retained_metrics_object: false,
3612 access: vec![PUBLIC_SELECT],
3613});
3614
3615pub static MZ_PENDING_CLUSTER_REPLICAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3616 name: "mz_pending_cluster_replicas",
3617 schema: MZ_INTERNAL_SCHEMA,
3618 oid: oid::TABLE_MZ_PENDING_CLUSTER_REPLICAS_OID,
3619 desc: RelationDesc::builder()
3620 .with_column("id", SqlScalarType::String.nullable(false))
3621 .finish(),
3622 column_comments: BTreeMap::from_iter([(
3623 "id",
3624 "The ID of a cluster replica. Corresponds to `mz_cluster_replicas.id`.",
3625 )]),
3626 is_retained_metrics_object: false,
3627 access: vec![PUBLIC_SELECT],
3628});
3629
3630pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| {
3631 BuiltinSource {
3632 name: "mz_cluster_replica_status_history",
3633 schema: MZ_INTERNAL_SCHEMA,
3634 oid: oid::SOURCE_MZ_CLUSTER_REPLICA_STATUS_HISTORY_OID,
3635 data_source: IntrospectionType::ReplicaStatusHistory,
3636 desc: REPLICA_STATUS_HISTORY_DESC.clone(),
3637 column_comments: BTreeMap::from_iter([
3638 ("replica_id", "The ID of a cluster replica."),
3639 ("process_id", "The ID of a process within the replica."),
3640 (
3641 "status",
3642 "The status of the cluster replica: `online` or `offline`.",
3643 ),
3644 (
3645 "reason",
3646 "If the cluster replica is in an `offline` state, the reason (if available). For example, `oom-killed`.",
3647 ),
3648 (
3649 "occurred_at",
3650 "Wall-clock timestamp at which the event occurred.",
3651 ),
3652 ]),
3653 is_retained_metrics_object: false,
3654 access: vec![PUBLIC_SELECT],
3655 }
3656});
3657
3658pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY_CT: LazyLock<BuiltinContinualTask> = LazyLock::new(
3659 || {
3660 BuiltinContinualTask {
3661 name: "mz_cluster_replica_status_history_ct",
3662 schema: MZ_INTERNAL_SCHEMA,
3663 oid: oid::CT_MZ_CLUSTER_REPLICA_STATUS_HISTORY_OID,
3664 desc: REPLICA_STATUS_HISTORY_DESC.clone(),
3665 sql: "
3666IN CLUSTER mz_catalog_server
3667ON INPUT mz_internal.mz_cluster_replica_status_history AS (
3668 DELETE FROM mz_internal.mz_cluster_replica_status_history_ct WHERE occurred_at + '30d' < mz_now();
3669 INSERT INTO mz_internal.mz_cluster_replica_status_history_ct SELECT * FROM mz_internal.mz_cluster_replica_status_history;
3670)",
3671 access: vec![PUBLIC_SELECT],
3672 }
3673 },
3674);
3675
3676pub static MZ_CLUSTER_REPLICA_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
3677 name: "mz_cluster_replica_statuses",
3678 schema: MZ_INTERNAL_SCHEMA,
3679 oid: oid::VIEW_MZ_CLUSTER_REPLICA_STATUSES_OID,
3680 desc: RelationDesc::builder()
3681 .with_column("replica_id", SqlScalarType::String.nullable(false))
3682 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
3683 .with_column("status", SqlScalarType::String.nullable(false))
3684 .with_column("reason", SqlScalarType::String.nullable(true))
3685 .with_column(
3686 "updated_at",
3687 SqlScalarType::TimestampTz { precision: None }.nullable(false),
3688 )
3689 .with_key(vec![0, 1])
3690 .finish(),
3691 column_comments: BTreeMap::from_iter([
3692 (
3693 "replica_id",
3694 "Materialize's unique ID for the cluster replica.",
3695 ),
3696 (
3697 "process_id",
3698 "The ID of the process within the cluster replica.",
3699 ),
3700 (
3701 "status",
3702 "The status of the cluster replica: `online` or `offline`.",
3703 ),
3704 (
3705 "reason",
3706 "If the cluster replica is in a `offline` state, the reason (if available). For example, `oom-killed`.",
3707 ),
3708 (
3709 "updated_at",
3710 "The time at which the status was last updated.",
3711 ),
3712 ]),
3713 sql: "
3714SELECT
3715 DISTINCT ON (replica_id, process_id)
3716 replica_id,
3717 process_id,
3718 status,
3719 reason,
3720 occurred_at as updated_at
3721FROM mz_internal.mz_cluster_replica_status_history
3722JOIN mz_cluster_replicas r ON r.id = replica_id
3723ORDER BY replica_id, process_id, occurred_at DESC",
3724 access: vec![PUBLIC_SELECT],
3725});
3726
3727pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3728 name: "mz_cluster_replica_sizes",
3729 schema: MZ_CATALOG_SCHEMA,
3730 oid: oid::TABLE_MZ_CLUSTER_REPLICA_SIZES_OID,
3731 desc: RelationDesc::builder()
3732 .with_column("size", SqlScalarType::String.nullable(false))
3733 .with_column("processes", SqlScalarType::UInt64.nullable(false))
3734 .with_column("workers", SqlScalarType::UInt64.nullable(false))
3735 .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(false))
3736 .with_column("memory_bytes", SqlScalarType::UInt64.nullable(false))
3737 .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true))
3738 .with_column(
3739 "credits_per_hour",
3740 SqlScalarType::Numeric { max_scale: None }.nullable(false),
3741 )
3742 .finish(),
3743 column_comments: BTreeMap::from_iter([
3744 ("size", "The human-readable replica size."),
3745 ("processes", "The number of processes in the replica."),
3746 (
3747 "workers",
3748 "The number of Timely Dataflow workers per process.",
3749 ),
3750 (
3751 "cpu_nano_cores",
3752 "The CPU allocation per process, in billionths of a vCPU core.",
3753 ),
3754 (
3755 "memory_bytes",
3756 "The RAM allocation per process, in billionths of a vCPU core.",
3757 ),
3758 ("disk_bytes", "The disk allocation per process."),
3759 (
3760 "credits_per_hour",
3761 "The number of compute credits consumed per hour.",
3762 ),
3763 ]),
3764 is_retained_metrics_object: true,
3765 access: vec![PUBLIC_SELECT],
3766});
3767
3768pub static MZ_AUDIT_EVENTS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3769 name: "mz_audit_events",
3770 schema: MZ_CATALOG_SCHEMA,
3771 oid: oid::TABLE_MZ_AUDIT_EVENTS_OID,
3772 desc: RelationDesc::builder()
3773 .with_column("id", SqlScalarType::UInt64.nullable(false))
3774 .with_column("event_type", SqlScalarType::String.nullable(false))
3775 .with_column("object_type", SqlScalarType::String.nullable(false))
3776 .with_column("details", SqlScalarType::Jsonb.nullable(false))
3777 .with_column("user", SqlScalarType::String.nullable(true))
3778 .with_column(
3779 "occurred_at",
3780 SqlScalarType::TimestampTz { precision: None }.nullable(false),
3781 )
3782 .with_key(vec![0])
3783 .finish(),
3784 column_comments: BTreeMap::from_iter([
3785 (
3786 "id",
3787 "Materialize's unique, monotonically increasing ID for the event.",
3788 ),
3789 (
3790 "event_type",
3791 "The type of the event: `create`, `drop`, or `alter`.",
3792 ),
3793 (
3794 "object_type",
3795 "The type of the affected object: `cluster`, `cluster-replica`, `connection`, `database`, `function`, `index`, `materialized-view`, `role`, `schema`, `secret`, `sink`, `source`, `table`, `type`, or `view`.",
3796 ),
3797 (
3798 "details",
3799 "Additional details about the event. The shape of the details varies based on `event_type` and `object_type`.",
3800 ),
3801 (
3802 "user",
3803 "The user who triggered the event, or `NULL` if triggered by the system.",
3804 ),
3805 (
3806 "occurred_at",
3807 "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.",
3808 ),
3809 ]),
3810 is_retained_metrics_object: false,
3811 access: vec![PUBLIC_SELECT],
3812});
3813
3814pub static MZ_SOURCE_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
3815 name: "mz_source_status_history",
3816 schema: MZ_INTERNAL_SCHEMA,
3817 oid: oid::SOURCE_MZ_SOURCE_STATUS_HISTORY_OID,
3818 data_source: IntrospectionType::SourceStatusHistory,
3819 desc: MZ_SOURCE_STATUS_HISTORY_DESC.clone(),
3820 column_comments: BTreeMap::from_iter([
3821 (
3822 "occurred_at",
3823 "Wall-clock timestamp of the source status change.",
3824 ),
3825 (
3826 "source_id",
3827 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
3828 ),
3829 (
3830 "status",
3831 "The status of the source: one of `created`, `starting`, `running`, `paused`, `stalled`, `failed`, or `dropped`.",
3832 ),
3833 (
3834 "error",
3835 "If the source is in an error state, the error message.",
3836 ),
3837 (
3838 "details",
3839 "Additional metadata provided by the source. In case of error, may contain a `hint` field with helpful suggestions.",
3840 ),
3841 (
3842 "replica_id",
3843 "The ID of the replica that an instance of a source is running on.",
3844 ),
3845 ]),
3846 is_retained_metrics_object: false,
3847 access: vec![PUBLIC_SELECT],
3848});
3849
3850pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(
3851 || BuiltinSource {
3852 name: "mz_aws_privatelink_connection_status_history",
3853 schema: MZ_INTERNAL_SCHEMA,
3854 oid: oid::SOURCE_MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_OID,
3855 data_source: IntrospectionType::PrivatelinkConnectionStatusHistory,
3856 desc: MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_DESC.clone(),
3857 column_comments: BTreeMap::from_iter([
3858 ("occurred_at", "Wall-clock timestamp of the status change."),
3859 (
3860 "connection_id",
3861 "The unique identifier of the AWS PrivateLink connection. Corresponds to `mz_catalog.mz_connections.id`.",
3862 ),
3863 (
3864 "status",
3865 "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`.",
3866 ),
3867 ]),
3868 is_retained_metrics_object: false,
3869 access: vec![PUBLIC_SELECT],
3870 },
3871);
3872
3873pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUSES: LazyLock<BuiltinView> =
3874 LazyLock::new(|| BuiltinView {
3875 name: "mz_aws_privatelink_connection_statuses",
3876 schema: MZ_INTERNAL_SCHEMA,
3877 oid: oid::VIEW_MZ_AWS_PRIVATELINK_CONNECTION_STATUSES_OID,
3878 desc: RelationDesc::builder()
3879 .with_column("id", SqlScalarType::String.nullable(false))
3880 .with_column("name", SqlScalarType::String.nullable(false))
3881 .with_column(
3882 "last_status_change_at",
3883 SqlScalarType::TimestampTz { precision: None }.nullable(true),
3884 )
3885 .with_column("status", SqlScalarType::String.nullable(true))
3886 .with_key(vec![0])
3887 .finish(),
3888 column_comments: BTreeMap::from_iter([
3889 (
3890 "id",
3891 "The ID of the connection. Corresponds to `mz_catalog.mz_connections.id`.",
3892 ),
3893 ("name", "The name of the connection."),
3894 (
3895 "last_status_change_at",
3896 "Wall-clock timestamp of the connection status change.",
3897 ),
3898 ("status", ""),
3899 ]),
3900 sql: "
3901 WITH statuses_w_last_status AS (
3902 SELECT
3903 connection_id,
3904 occurred_at,
3905 status,
3906 lag(status) OVER (PARTITION BY connection_id ORDER BY occurred_at) AS last_status
3907 FROM mz_internal.mz_aws_privatelink_connection_status_history
3908 ),
3909 latest_events AS (
3910 -- Only take the most recent transition for each ID
3911 SELECT DISTINCT ON(connection_id) connection_id, occurred_at, status
3912 FROM statuses_w_last_status
3913 -- Only keep first status transitions
3914 WHERE status <> last_status OR last_status IS NULL
3915 ORDER BY connection_id, occurred_at DESC
3916 )
3917 SELECT
3918 conns.id,
3919 name,
3920 occurred_at as last_status_change_at,
3921 status
3922 FROM latest_events
3923 JOIN mz_catalog.mz_connections AS conns
3924 ON conns.id = latest_events.connection_id",
3925 access: vec![PUBLIC_SELECT],
3926 });
3927
3928pub static MZ_STATEMENT_EXECUTION_HISTORY: LazyLock<BuiltinSource> =
3929 LazyLock::new(|| BuiltinSource {
3930 name: "mz_statement_execution_history",
3931 schema: MZ_INTERNAL_SCHEMA,
3932 oid: oid::SOURCE_MZ_STATEMENT_EXECUTION_HISTORY_OID,
3933 data_source: IntrospectionType::StatementExecutionHistory,
3934 desc: MZ_STATEMENT_EXECUTION_HISTORY_DESC.clone(),
3935 column_comments: BTreeMap::new(),
3936 is_retained_metrics_object: false,
3937 access: vec![MONITOR_SELECT],
3938 });
3939
3940pub static MZ_STATEMENT_EXECUTION_HISTORY_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| {
3941 BuiltinView {
3942 name: "mz_statement_execution_history_redacted",
3943 schema: MZ_INTERNAL_SCHEMA,
3944 oid: oid::VIEW_MZ_STATEMENT_EXECUTION_HISTORY_REDACTED_OID,
3945 desc: RelationDesc::builder()
3947 .with_column("id", SqlScalarType::Uuid.nullable(false))
3948 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
3949 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
3950 .with_column("cluster_id", SqlScalarType::String.nullable(true))
3951 .with_column("application_name", SqlScalarType::String.nullable(false))
3952 .with_column("cluster_name", SqlScalarType::String.nullable(true))
3953 .with_column("database_name", SqlScalarType::String.nullable(false))
3954 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
3955 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
3956 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
3957 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
3958 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
3959 .with_column("mz_version", SqlScalarType::String.nullable(false))
3960 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
3961 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
3962 .with_column("finished_status", SqlScalarType::String.nullable(true))
3963 .with_column("result_size", SqlScalarType::Int64.nullable(true))
3964 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
3965 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
3966 .finish(),
3967 column_comments: BTreeMap::new(),
3968 sql: "
3969SELECT id, prepared_statement_id, sample_rate, cluster_id, application_name,
3970cluster_name, database_name, search_path, transaction_isolation, execution_timestamp, transaction_id,
3971transient_index_id, mz_version, began_at, finished_at, finished_status,
3972result_size, rows_returned, execution_strategy
3973FROM mz_internal.mz_statement_execution_history",
3974 access: vec![SUPPORT_SELECT, ANALYTICS_SELECT, MONITOR_REDACTED_SELECT, MONITOR_SELECT],
3975}
3976});
3977
3978pub static MZ_PREPARED_STATEMENT_HISTORY: LazyLock<BuiltinSource> =
3979 LazyLock::new(|| BuiltinSource {
3980 name: "mz_prepared_statement_history",
3981 schema: MZ_INTERNAL_SCHEMA,
3982 oid: oid::SOURCE_MZ_PREPARED_STATEMENT_HISTORY_OID,
3983 data_source: IntrospectionType::PreparedStatementHistory,
3984 desc: MZ_PREPARED_STATEMENT_HISTORY_DESC.clone(),
3985 column_comments: BTreeMap::new(),
3986 is_retained_metrics_object: false,
3987 access: vec![
3988 SUPPORT_SELECT,
3989 ANALYTICS_SELECT,
3990 MONITOR_REDACTED_SELECT,
3991 MONITOR_SELECT,
3992 ],
3993 });
3994
3995pub static MZ_SQL_TEXT: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
3996 name: "mz_sql_text",
3997 schema: MZ_INTERNAL_SCHEMA,
3998 oid: oid::SOURCE_MZ_SQL_TEXT_OID,
3999 desc: MZ_SQL_TEXT_DESC.clone(),
4000 data_source: IntrospectionType::SqlText,
4001 column_comments: BTreeMap::new(),
4002 is_retained_metrics_object: false,
4003 access: vec![MONITOR_SELECT],
4004});
4005
4006pub static MZ_SQL_TEXT_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4007 name: "mz_sql_text_redacted",
4008 schema: MZ_INTERNAL_SCHEMA,
4009 oid: oid::VIEW_MZ_SQL_TEXT_REDACTED_OID,
4010 desc: RelationDesc::builder()
4011 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4012 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
4013 .finish(),
4014 column_comments: BTreeMap::new(),
4015 sql: "SELECT sql_hash, redacted_sql FROM mz_internal.mz_sql_text",
4016 access: vec![
4017 MONITOR_SELECT,
4018 MONITOR_REDACTED_SELECT,
4019 SUPPORT_SELECT,
4020 ANALYTICS_SELECT,
4021 ],
4022});
4023
4024pub static MZ_RECENT_SQL_TEXT: LazyLock<BuiltinView> = LazyLock::new(|| {
4025 BuiltinView {
4026 name: "mz_recent_sql_text",
4027 schema: MZ_INTERNAL_SCHEMA,
4028 oid: oid::VIEW_MZ_RECENT_SQL_TEXT_OID,
4029 desc: RelationDesc::builder()
4034 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4035 .with_column("sql", SqlScalarType::String.nullable(false))
4036 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
4037 .with_key(vec![0, 1, 2])
4038 .finish(),
4039 column_comments: BTreeMap::new(),
4040 sql: "SELECT DISTINCT sql_hash, sql, redacted_sql FROM mz_internal.mz_sql_text WHERE prepared_day + INTERVAL '4 days' >= mz_now()",
4041 access: vec![MONITOR_SELECT],
4042 }
4043});
4044
4045pub static MZ_RECENT_SQL_TEXT_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4046 name: "mz_recent_sql_text_redacted",
4047 schema: MZ_INTERNAL_SCHEMA,
4048 oid: oid::VIEW_MZ_RECENT_SQL_TEXT_REDACTED_OID,
4049 desc: RelationDesc::builder()
4050 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4051 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
4052 .finish(),
4053 column_comments: BTreeMap::new(),
4054 sql: "SELECT sql_hash, redacted_sql FROM mz_internal.mz_recent_sql_text",
4055 access: vec![
4056 MONITOR_SELECT,
4057 MONITOR_REDACTED_SELECT,
4058 SUPPORT_SELECT,
4059 ANALYTICS_SELECT,
4060 ],
4061});
4062
4063pub static MZ_RECENT_SQL_TEXT_IND: LazyLock<BuiltinIndex> = LazyLock::new(|| BuiltinIndex {
4064 name: "mz_recent_sql_text_ind",
4065 schema: MZ_INTERNAL_SCHEMA,
4066 oid: oid::INDEX_MZ_RECENT_SQL_TEXT_IND_OID,
4067 sql: "IN CLUSTER mz_catalog_server ON mz_internal.mz_recent_sql_text (sql_hash)",
4068 is_retained_metrics_object: false,
4069});
4070
4071pub static MZ_SESSION_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
4072 name: "mz_session_history",
4073 schema: MZ_INTERNAL_SCHEMA,
4074 oid: oid::SOURCE_MZ_SESSION_HISTORY_OID,
4075 data_source: IntrospectionType::SessionHistory,
4076 desc: MZ_SESSION_HISTORY_DESC.clone(),
4077 column_comments: BTreeMap::new(),
4078 is_retained_metrics_object: false,
4079 access: vec![PUBLIC_SELECT],
4080});
4081
4082pub static MZ_ACTIVITY_LOG_THINNED: LazyLock<BuiltinView> = LazyLock::new(|| {
4083 BuiltinView {
4084 name: "mz_activity_log_thinned",
4085 schema: MZ_INTERNAL_SCHEMA,
4086 oid: oid::VIEW_MZ_ACTIVITY_LOG_THINNED_OID,
4087 desc: RelationDesc::builder()
4088 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4089 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4090 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4091 .with_column("application_name", SqlScalarType::String.nullable(false))
4092 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4093 .with_column("database_name", SqlScalarType::String.nullable(false))
4094 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
4095 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
4096 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4097 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4098 .with_column("params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false))
4099 .with_column("mz_version", SqlScalarType::String.nullable(false))
4100 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4101 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
4102 .with_column("finished_status", SqlScalarType::String.nullable(true))
4103 .with_column("error_message", SqlScalarType::String.nullable(true))
4104 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4105 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4106 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4107 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4108 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4109 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4110 .with_column("prepared_statement_name", SqlScalarType::String.nullable(false))
4111 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4112 .with_column("prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4113 .with_column("statement_type", SqlScalarType::String.nullable(true))
4114 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4115 .with_column("connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4116 .with_column("initial_application_name", SqlScalarType::String.nullable(false))
4117 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4118 .finish(),
4119 column_comments: BTreeMap::new(),
4120 sql: "
4121SELECT mseh.id AS execution_id, sample_rate, cluster_id, application_name, cluster_name, database_name, search_path,
4122transaction_isolation, execution_timestamp, transient_index_id, params, mz_version, began_at, finished_at, finished_status,
4123error_message, result_size, rows_returned, execution_strategy, transaction_id,
4124mpsh.id AS prepared_statement_id, sql_hash, mpsh.name AS prepared_statement_name,
4125mpsh.session_id, prepared_at, statement_type, throttled_count,
4126connected_at, initial_application_name, authenticated_user
4127FROM mz_internal.mz_statement_execution_history mseh,
4128 mz_internal.mz_prepared_statement_history mpsh,
4129 mz_internal.mz_session_history msh
4130WHERE mseh.prepared_statement_id = mpsh.id
4131AND mpsh.session_id = msh.session_id",
4132 access: vec![MONITOR_SELECT],
4133 }
4134});
4135
4136pub static MZ_RECENT_ACTIVITY_LOG_THINNED: LazyLock<BuiltinView> = LazyLock::new(|| {
4137 BuiltinView {
4138 name: "mz_recent_activity_log_thinned",
4139 schema: MZ_INTERNAL_SCHEMA,
4140 oid: oid::VIEW_MZ_RECENT_ACTIVITY_LOG_THINNED_OID,
4141 desc: RelationDesc::builder()
4142 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4143 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4144 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4145 .with_column("application_name", SqlScalarType::String.nullable(false))
4146 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4147 .with_column("database_name", SqlScalarType::String.nullable(false))
4148 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
4149 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
4150 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4151 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4152 .with_column("params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false))
4153 .with_column("mz_version", SqlScalarType::String.nullable(false))
4154 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4155 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
4156 .with_column("finished_status", SqlScalarType::String.nullable(true))
4157 .with_column("error_message", SqlScalarType::String.nullable(true))
4158 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4159 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4160 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4161 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4162 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4163 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4164 .with_column("prepared_statement_name", SqlScalarType::String.nullable(false))
4165 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4166 .with_column("prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4167 .with_column("statement_type", SqlScalarType::String.nullable(true))
4168 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4169 .with_column("connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4170 .with_column("initial_application_name", SqlScalarType::String.nullable(false))
4171 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4172 .finish(),
4173 column_comments: BTreeMap::new(),
4174 sql:
4177 "SELECT * FROM mz_internal.mz_activity_log_thinned WHERE prepared_at + INTERVAL '1 day' > mz_now()
4178AND began_at + INTERVAL '1 day' > mz_now() AND connected_at + INTERVAL '2 days' > mz_now()",
4179 access: vec![MONITOR_SELECT],
4180 }
4181});
4182
4183pub static MZ_RECENT_ACTIVITY_LOG: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4184 name: "mz_recent_activity_log",
4185 schema: MZ_INTERNAL_SCHEMA,
4186 oid: oid::VIEW_MZ_RECENT_ACTIVITY_LOG_OID,
4187 desc: RelationDesc::builder()
4188 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4189 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4190 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4191 .with_column("application_name", SqlScalarType::String.nullable(false))
4192 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4193 .with_column("database_name", SqlScalarType::String.nullable(false))
4194 .with_column(
4195 "search_path",
4196 SqlScalarType::List {
4197 element_type: Box::new(SqlScalarType::String),
4198 custom_id: None,
4199 }
4200 .nullable(false),
4201 )
4202 .with_column(
4203 "transaction_isolation",
4204 SqlScalarType::String.nullable(false),
4205 )
4206 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4207 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4208 .with_column(
4209 "params",
4210 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
4211 )
4212 .with_column("mz_version", SqlScalarType::String.nullable(false))
4213 .with_column(
4214 "began_at",
4215 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4216 )
4217 .with_column(
4218 "finished_at",
4219 SqlScalarType::TimestampTz { precision: None }.nullable(true),
4220 )
4221 .with_column("finished_status", SqlScalarType::String.nullable(true))
4222 .with_column("error_message", SqlScalarType::String.nullable(true))
4223 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4224 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4225 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4226 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4227 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4228 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4229 .with_column(
4230 "prepared_statement_name",
4231 SqlScalarType::String.nullable(false),
4232 )
4233 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4234 .with_column(
4235 "prepared_at",
4236 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4237 )
4238 .with_column("statement_type", SqlScalarType::String.nullable(true))
4239 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4240 .with_column(
4241 "connected_at",
4242 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4243 )
4244 .with_column(
4245 "initial_application_name",
4246 SqlScalarType::String.nullable(false),
4247 )
4248 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4249 .with_column("sql", SqlScalarType::String.nullable(false))
4250 .finish(),
4251 column_comments: BTreeMap::from_iter([
4252 (
4253 "execution_id",
4254 "An ID that is unique for each executed statement.",
4255 ),
4256 (
4257 "sample_rate",
4258 "The actual rate at which the statement was sampled.",
4259 ),
4260 (
4261 "cluster_id",
4262 "The ID of the cluster the statement execution was directed to. Corresponds to mz_clusters.id.",
4263 ),
4264 (
4265 "application_name",
4266 "The value of the `application_name` configuration parameter at execution time.",
4267 ),
4268 (
4269 "cluster_name",
4270 "The name of the cluster with ID `cluster_id` at execution time.",
4271 ),
4272 (
4273 "database_name",
4274 "The value of the `database` configuration parameter at execution time.",
4275 ),
4276 (
4277 "search_path",
4278 "The value of the `search_path` configuration parameter at execution time.",
4279 ),
4280 (
4281 "transaction_isolation",
4282 "The value of the `transaction_isolation` configuration parameter at execution time.",
4283 ),
4284 (
4285 "execution_timestamp",
4286 "The logical timestamp at which execution was scheduled.",
4287 ),
4288 (
4289 "transient_index_id",
4290 "The internal index of the compute dataflow created for the query, if any.",
4291 ),
4292 (
4293 "params",
4294 "The parameters with which the statement was executed.",
4295 ),
4296 (
4297 "mz_version",
4298 "The version of Materialize that was running when the statement was executed.",
4299 ),
4300 (
4301 "began_at",
4302 "The wall-clock time at which the statement began executing.",
4303 ),
4304 (
4305 "finished_at",
4306 "The wall-clock time at which the statement finished executing.",
4307 ),
4308 (
4309 "finished_status",
4310 "The final status of the statement (e.g., `success`, `canceled`, `error`, or `aborted`). `aborted` means that Materialize exited before the statement finished executing.",
4311 ),
4312 (
4313 "error_message",
4314 "The error message, if the statement failed.",
4315 ),
4316 (
4317 "result_size",
4318 "The size in bytes of the result, for statements that return rows.",
4319 ),
4320 (
4321 "rows_returned",
4322 "The number of rows returned, for statements that return rows.",
4323 ),
4324 (
4325 "execution_strategy",
4326 "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.",
4327 ),
4328 (
4329 "transaction_id",
4330 "The ID of the transaction that the statement was part of. Note that transaction IDs are only unique per session.",
4331 ),
4332 (
4333 "prepared_statement_id",
4334 "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`).",
4335 ),
4336 (
4337 "sql_hash",
4338 "An opaque value uniquely identifying the text of the query.",
4339 ),
4340 (
4341 "prepared_statement_name",
4342 "The name given by the client library to the prepared statement.",
4343 ),
4344 (
4345 "session_id",
4346 "An ID that is unique for each session. Corresponds to mz_sessions.id.",
4347 ),
4348 (
4349 "prepared_at",
4350 "The time at which the statement was prepared.",
4351 ),
4352 (
4353 "statement_type",
4354 "The type of the statement, e.g. `select` for a `SELECT` query, or `NULL` if the statement was empty.",
4355 ),
4356 (
4357 "throttled_count",
4358 "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.",
4359 ),
4360 (
4361 "connected_at",
4362 "The time at which the session was established.",
4363 ),
4364 (
4365 "initial_application_name",
4366 "The initial value of `application_name` at the beginning of the session.",
4367 ),
4368 (
4369 "authenticated_user",
4370 "The name of the user for which the session was established.",
4371 ),
4372 ("sql", "The SQL text of the statement."),
4373 ]),
4374 sql: "SELECT mralt.*, mrst.sql
4375FROM mz_internal.mz_recent_activity_log_thinned mralt,
4376 mz_internal.mz_recent_sql_text mrst
4377WHERE mralt.sql_hash = mrst.sql_hash",
4378 access: vec![MONITOR_SELECT],
4379});
4380
4381pub static MZ_RECENT_ACTIVITY_LOG_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| {
4382 BuiltinView {
4383 name: "mz_recent_activity_log_redacted",
4384 schema: MZ_INTERNAL_SCHEMA,
4385 oid: oid::VIEW_MZ_RECENT_ACTIVITY_LOG_REDACTED_OID,
4386 desc: RelationDesc::builder()
4388 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4389 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4390 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4391 .with_column("application_name", SqlScalarType::String.nullable(false))
4392 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4393 .with_column("database_name", SqlScalarType::String.nullable(false))
4394 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
4395 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
4396 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4397 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4398 .with_column("params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false))
4399 .with_column("mz_version", SqlScalarType::String.nullable(false))
4400 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4401 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
4402 .with_column("finished_status", SqlScalarType::String.nullable(true))
4403 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4404 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4405 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4406 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4407 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4408 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4409 .with_column("prepared_statement_name", SqlScalarType::String.nullable(false))
4410 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4411 .with_column("prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4412 .with_column("statement_type", SqlScalarType::String.nullable(true))
4413 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4414 .with_column("initial_application_name", SqlScalarType::String.nullable(false))
4415 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4416 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
4417 .finish(),
4418 column_comments: BTreeMap::new(),
4419 sql: "SELECT mralt.execution_id, mralt.sample_rate, mralt.cluster_id, mralt.application_name,
4420 mralt.cluster_name, mralt.database_name, mralt.search_path, mralt.transaction_isolation, mralt.execution_timestamp,
4421 mralt.transient_index_id, mralt.params, mralt.mz_version, mralt.began_at, mralt.finished_at,
4422 mralt.finished_status, mralt.result_size, mralt.rows_returned, mralt.execution_strategy, mralt.transaction_id,
4423 mralt.prepared_statement_id, mralt.sql_hash, mralt.prepared_statement_name, mralt.session_id,
4424 mralt.prepared_at, mralt.statement_type, mralt.throttled_count,
4425 mralt.initial_application_name, mralt.authenticated_user,
4426 mrst.redacted_sql
4427FROM mz_internal.mz_recent_activity_log_thinned mralt,
4428 mz_internal.mz_recent_sql_text mrst
4429WHERE mralt.sql_hash = mrst.sql_hash",
4430 access: vec![MONITOR_SELECT, MONITOR_REDACTED_SELECT, SUPPORT_SELECT, ANALYTICS_SELECT],
4431}
4432});
4433
4434pub static MZ_STATEMENT_LIFECYCLE_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| {
4435 BuiltinSource {
4436 name: "mz_statement_lifecycle_history",
4437 schema: MZ_INTERNAL_SCHEMA,
4438 oid: oid::SOURCE_MZ_STATEMENT_LIFECYCLE_HISTORY_OID,
4439 desc: RelationDesc::builder()
4440 .with_column("statement_id", SqlScalarType::Uuid.nullable(false))
4441 .with_column("event_type", SqlScalarType::String.nullable(false))
4442 .with_column(
4443 "occurred_at",
4444 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4445 )
4446 .finish(),
4447 data_source: IntrospectionType::StatementLifecycleHistory,
4448 column_comments: BTreeMap::from_iter([
4449 (
4450 "statement_id",
4451 "The ID of the execution event. Corresponds to `mz_recent_activity_log.execution_id`",
4452 ),
4453 (
4454 "event_type",
4455 "The type of lifecycle event, e.g. `'execution-began'`, `'storage-dependencies-finished'`, `'compute-dependencies-finished'`, or `'execution-finished'`",
4456 ),
4457 ("occurred_at", "The time at which the event took place."),
4458 ]),
4459 is_retained_metrics_object: false,
4460 access: vec![
4464 SUPPORT_SELECT,
4465 ANALYTICS_SELECT,
4466 MONITOR_REDACTED_SELECT,
4467 MONITOR_SELECT,
4468 ],
4469 }
4470});
4471
4472pub static MZ_SOURCE_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4473 name: "mz_source_statuses",
4474 schema: MZ_INTERNAL_SCHEMA,
4475 oid: oid::VIEW_MZ_SOURCE_STATUSES_OID,
4476 desc: RelationDesc::builder()
4477 .with_column("id", SqlScalarType::String.nullable(false))
4478 .with_column("name", SqlScalarType::String.nullable(false))
4479 .with_column("type", SqlScalarType::String.nullable(false))
4480 .with_column(
4481 "last_status_change_at",
4482 SqlScalarType::TimestampTz { precision: None }.nullable(true),
4483 )
4484 .with_column("status", SqlScalarType::String.nullable(false))
4485 .with_column("error", SqlScalarType::String.nullable(true))
4486 .with_column("details", SqlScalarType::Jsonb.nullable(true))
4487 .finish(),
4488 column_comments: BTreeMap::from_iter([
4489 (
4490 "id",
4491 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
4492 ),
4493 ("name", "The name of the source."),
4494 ("type", "The type of the source."),
4495 (
4496 "last_status_change_at",
4497 "Wall-clock timestamp of the source status change.",
4498 ),
4499 (
4500 "status",
4501 "The status of the source: one of `created`, `starting`, `running`, `paused`, `stalled`, `failed`, or `dropped`.",
4502 ),
4503 (
4504 "error",
4505 "If the source is in an error state, the error message.",
4506 ),
4507 (
4508 "details",
4509 "Additional metadata provided by the source. In case of error, may contain a `hint` field with helpful suggestions.",
4510 ),
4511 ]),
4512 sql: "
4513 WITH
4514 -- The status history contains per-replica events and source-global events.
4515 -- For the latter, replica_id is NULL. We turn these into '<source>', so that
4516 -- we can treat them uniformly below.
4517 uniform_status_history AS
4518 (
4519 SELECT
4520 s.source_id,
4521 COALESCE(s.replica_id, '<source>') as replica_id,
4522 s.occurred_at,
4523 s.status,
4524 s.error,
4525 s.details
4526 FROM mz_internal.mz_source_status_history s
4527 ),
4528 -- For getting the latest events, we first determine the latest per-replica
4529 -- events here and then apply precedence rules below.
4530 latest_per_replica_events AS
4531 (
4532 SELECT DISTINCT ON (source_id, replica_id)
4533 occurred_at, source_id, replica_id, status, error, details
4534 FROM uniform_status_history
4535 ORDER BY source_id, replica_id, occurred_at DESC
4536 ),
4537 -- We have a precedence list that determines the overall status in case
4538 -- there is differing per-replica (including source-global) statuses. If
4539 -- there is no 'dropped' status, and any replica reports 'running', the
4540 -- overall status is 'running' even if there might be some replica that has
4541 -- errors or is paused.
4542 latest_events AS
4543 (
4544 SELECT DISTINCT ON (source_id)
4545 source_id,
4546 occurred_at,
4547 status,
4548 error,
4549 details
4550 FROM latest_per_replica_events
4551 ORDER BY source_id, CASE status
4552 WHEN 'dropped' THEN 1
4553 WHEN 'running' THEN 2
4554 WHEN 'stalled' THEN 3
4555 WHEN 'starting' THEN 4
4556 WHEN 'paused' THEN 5
4557 WHEN 'ceased' THEN 6
4558 ELSE 7 -- For any other status values
4559 END
4560 ),
4561 -- Determine which sources are subsources and which are parent sources
4562 subsources AS
4563 (
4564 SELECT subsources.id AS self, sources.id AS parent
4565 FROM
4566 mz_catalog.mz_sources AS subsources
4567 JOIN
4568 mz_internal.mz_object_dependencies AS deps
4569 ON subsources.id = deps.object_id
4570 JOIN mz_catalog.mz_sources AS sources ON sources.id = deps.referenced_object_id
4571 ),
4572 -- Determine which sources are source tables
4573 tables AS
4574 (
4575 SELECT tables.id AS self, tables.source_id AS parent, tables.name
4576 FROM mz_catalog.mz_tables AS tables
4577 WHERE tables.source_id IS NOT NULL
4578 ),
4579 -- Determine which collection's ID to use for the status
4580 id_of_status_to_use AS
4581 (
4582 SELECT
4583 self_events.source_id,
4584 -- If self not errored, but parent is, use parent; else self
4585 CASE
4586 WHEN
4587 self_events.status <> 'ceased' AND
4588 parent_events.status = 'stalled'
4589 THEN parent_events.source_id
4590 ELSE self_events.source_id
4591 END AS id_to_use
4592 FROM
4593 latest_events AS self_events
4594 LEFT JOIN subsources ON self_events.source_id = subsources.self
4595 LEFT JOIN tables ON self_events.source_id = tables.self
4596 LEFT JOIN
4597 latest_events AS parent_events
4598 ON parent_events.source_id = COALESCE(subsources.parent, tables.parent)
4599 ),
4600 -- Swap out events for the ID of the event we plan to use instead
4601 latest_events_to_use AS
4602 (
4603 SELECT occurred_at, s.source_id, status, error, details
4604 FROM
4605 id_of_status_to_use AS s
4606 JOIN latest_events AS e ON e.source_id = s.id_to_use
4607 ),
4608 combined AS (
4609 SELECT
4610 mz_sources.id,
4611 mz_sources.name,
4612 mz_sources.type,
4613 occurred_at,
4614 status,
4615 error,
4616 details
4617 FROM
4618 mz_catalog.mz_sources
4619 LEFT JOIN latest_events_to_use AS e ON mz_sources.id = e.source_id
4620 UNION ALL
4621 SELECT
4622 tables.self AS id,
4623 tables.name,
4624 'table' AS type,
4625 occurred_at,
4626 status,
4627 error,
4628 details
4629 FROM
4630 tables
4631 LEFT JOIN latest_events_to_use AS e ON tables.self = e.source_id
4632 )
4633SELECT
4634 id,
4635 name,
4636 type,
4637 occurred_at AS last_status_change_at,
4638 -- TODO(parkmycar): Report status of webhook source once database-issues#5986 is closed.
4639 CASE
4640 WHEN
4641 type = 'webhook' OR
4642 type = 'progress'
4643 THEN 'running'
4644 ELSE COALESCE(status, 'created')
4645 END AS status,
4646 error,
4647 details
4648FROM combined
4649WHERE id NOT LIKE 's%';",
4650 access: vec![PUBLIC_SELECT],
4651});
4652
4653pub static MZ_SINK_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
4654 name: "mz_sink_status_history",
4655 schema: MZ_INTERNAL_SCHEMA,
4656 oid: oid::SOURCE_MZ_SINK_STATUS_HISTORY_OID,
4657 data_source: IntrospectionType::SinkStatusHistory,
4658 desc: MZ_SINK_STATUS_HISTORY_DESC.clone(),
4659 column_comments: BTreeMap::from_iter([
4660 (
4661 "occurred_at",
4662 "Wall-clock timestamp of the sink status change.",
4663 ),
4664 (
4665 "sink_id",
4666 "The ID of the sink. Corresponds to `mz_catalog.mz_sinks.id`.",
4667 ),
4668 (
4669 "status",
4670 "The status of the sink: one of `created`, `starting`, `running`, `stalled`, `failed`, or `dropped`.",
4671 ),
4672 (
4673 "error",
4674 "If the sink is in an error state, the error message.",
4675 ),
4676 (
4677 "details",
4678 "Additional metadata provided by the sink. In case of error, may contain a `hint` field with helpful suggestions.",
4679 ),
4680 (
4681 "replica_id",
4682 "The ID of the replica that an instance of a sink is running on.",
4683 ),
4684 ]),
4685 is_retained_metrics_object: false,
4686 access: vec![PUBLIC_SELECT],
4687});
4688
4689pub static MZ_SINK_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4690 name: "mz_sink_statuses",
4691 schema: MZ_INTERNAL_SCHEMA,
4692 oid: oid::VIEW_MZ_SINK_STATUSES_OID,
4693 desc: RelationDesc::builder()
4694 .with_column("id", SqlScalarType::String.nullable(false))
4695 .with_column("name", SqlScalarType::String.nullable(false))
4696 .with_column("type", SqlScalarType::String.nullable(false))
4697 .with_column(
4698 "last_status_change_at",
4699 SqlScalarType::TimestampTz { precision: None }.nullable(true),
4700 )
4701 .with_column("status", SqlScalarType::String.nullable(false))
4702 .with_column("error", SqlScalarType::String.nullable(true))
4703 .with_column("details", SqlScalarType::Jsonb.nullable(true))
4704 .finish(),
4705 column_comments: BTreeMap::from_iter([
4706 (
4707 "id",
4708 "The ID of the sink. Corresponds to `mz_catalog.mz_sinks.id`.",
4709 ),
4710 ("name", "The name of the sink."),
4711 ("type", "The type of the sink."),
4712 (
4713 "last_status_change_at",
4714 "Wall-clock timestamp of the sink status change.",
4715 ),
4716 (
4717 "status",
4718 "The status of the sink: one of `created`, `starting`, `running`, `stalled`, `failed`, or `dropped`.",
4719 ),
4720 (
4721 "error",
4722 "If the sink is in an error state, the error message.",
4723 ),
4724 (
4725 "details",
4726 "Additional metadata provided by the sink. In case of error, may contain a `hint` field with helpful suggestions.",
4727 ),
4728 ]),
4729 sql: "
4730WITH
4731-- The status history contains per-replica events and sink-global events.
4732-- For the latter, replica_id is NULL. We turn these into '<sink>', so that
4733-- we can treat them uniformly below.
4734uniform_status_history AS
4735(
4736 SELECT
4737 s.sink_id,
4738 COALESCE(s.replica_id, '<sink>') as replica_id,
4739 s.occurred_at,
4740 s.status,
4741 s.error,
4742 s.details
4743 FROM mz_internal.mz_sink_status_history s
4744),
4745-- For getting the latest events, we first determine the latest per-replica
4746-- events here and then apply precedence rules below.
4747latest_per_replica_events AS
4748(
4749 SELECT DISTINCT ON (sink_id, replica_id)
4750 occurred_at, sink_id, replica_id, status, error, details
4751 FROM uniform_status_history
4752 ORDER BY sink_id, replica_id, occurred_at DESC
4753),
4754-- We have a precedence list that determines the overall status in case
4755-- there is differing per-replica (including sink-global) statuses. If
4756-- there is no 'dropped' status, and any replica reports 'running', the
4757-- overall status is 'running' even if there might be some replica that has
4758-- errors or is paused.
4759latest_events AS
4760(
4761 SELECT DISTINCT ON (sink_id)
4762 sink_id,
4763 occurred_at,
4764 status,
4765 error,
4766 details
4767 FROM latest_per_replica_events
4768 ORDER BY sink_id, CASE status
4769 WHEN 'dropped' THEN 1
4770 WHEN 'running' THEN 2
4771 WHEN 'stalled' THEN 3
4772 WHEN 'starting' THEN 4
4773 WHEN 'paused' THEN 5
4774 WHEN 'ceased' THEN 6
4775 ELSE 7 -- For any other status values
4776 END
4777)
4778SELECT
4779 mz_sinks.id,
4780 name,
4781 mz_sinks.type,
4782 occurred_at as last_status_change_at,
4783 coalesce(status, 'created') as status,
4784 error,
4785 details
4786FROM mz_catalog.mz_sinks
4787LEFT JOIN latest_events ON mz_sinks.id = latest_events.sink_id
4788WHERE
4789 -- This is a convenient way to filter out system sinks, like the status_history table itself.
4790 mz_sinks.id NOT LIKE 's%'",
4791 access: vec![PUBLIC_SELECT],
4792});
4793
4794pub static MZ_STORAGE_USAGE_BY_SHARD_DESCRIPTION: LazyLock<SystemObjectDescription> =
4795 LazyLock::new(|| SystemObjectDescription {
4796 schema_name: MZ_STORAGE_USAGE_BY_SHARD.schema.to_string(),
4797 object_type: CatalogItemType::Table,
4798 object_name: MZ_STORAGE_USAGE_BY_SHARD.name.to_string(),
4799 });
4800
4801pub static MZ_STORAGE_USAGE_BY_SHARD: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
4802 name: "mz_storage_usage_by_shard",
4803 schema: MZ_INTERNAL_SCHEMA,
4804 oid: oid::TABLE_MZ_STORAGE_USAGE_BY_SHARD_OID,
4805 desc: RelationDesc::builder()
4806 .with_column("id", SqlScalarType::UInt64.nullable(false))
4807 .with_column("shard_id", SqlScalarType::String.nullable(true))
4808 .with_column("size_bytes", SqlScalarType::UInt64.nullable(false))
4809 .with_column(
4810 "collection_timestamp",
4811 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4812 )
4813 .finish(),
4814 column_comments: BTreeMap::new(),
4815 is_retained_metrics_object: false,
4816 access: vec![PUBLIC_SELECT],
4817});
4818
4819pub static MZ_EGRESS_IPS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
4820 name: "mz_egress_ips",
4821 schema: MZ_CATALOG_SCHEMA,
4822 oid: oid::TABLE_MZ_EGRESS_IPS_OID,
4823 desc: RelationDesc::builder()
4824 .with_column("egress_ip", SqlScalarType::String.nullable(false))
4825 .with_column("prefix_length", SqlScalarType::Int32.nullable(false))
4826 .with_column("cidr", SqlScalarType::String.nullable(false))
4827 .finish(),
4828 column_comments: BTreeMap::from_iter([
4829 ("egress_ip", "The start of the range of IP addresses."),
4830 (
4831 "prefix_length",
4832 "The number of leading bits in the CIDR netmask.",
4833 ),
4834 ("cidr", "The CIDR representation."),
4835 ]),
4836 is_retained_metrics_object: false,
4837 access: vec![PUBLIC_SELECT],
4838});
4839
4840pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock<BuiltinTable> =
4841 LazyLock::new(|| BuiltinTable {
4842 name: "mz_aws_privatelink_connections",
4843 schema: MZ_CATALOG_SCHEMA,
4844 oid: oid::TABLE_MZ_AWS_PRIVATELINK_CONNECTIONS_OID,
4845 desc: RelationDesc::builder()
4846 .with_column("id", SqlScalarType::String.nullable(false))
4847 .with_column("principal", SqlScalarType::String.nullable(false))
4848 .finish(),
4849 column_comments: BTreeMap::from_iter([
4850 ("id", "The ID of the connection."),
4851 (
4852 "principal",
4853 "The AWS Principal that Materialize will use to connect to the VPC endpoint.",
4854 ),
4855 ]),
4856 is_retained_metrics_object: false,
4857 access: vec![PUBLIC_SELECT],
4858 });
4859
4860pub static MZ_AWS_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
4861 name: "mz_aws_connections",
4862 schema: MZ_INTERNAL_SCHEMA,
4863 oid: oid::TABLE_MZ_AWS_CONNECTIONS_OID,
4864 desc: RelationDesc::builder()
4865 .with_column("id", SqlScalarType::String.nullable(false))
4866 .with_column("endpoint", SqlScalarType::String.nullable(true))
4867 .with_column("region", SqlScalarType::String.nullable(true))
4868 .with_column("access_key_id", SqlScalarType::String.nullable(true))
4869 .with_column(
4870 "access_key_id_secret_id",
4871 SqlScalarType::String.nullable(true),
4872 )
4873 .with_column(
4874 "secret_access_key_secret_id",
4875 SqlScalarType::String.nullable(true),
4876 )
4877 .with_column("session_token", SqlScalarType::String.nullable(true))
4878 .with_column(
4879 "session_token_secret_id",
4880 SqlScalarType::String.nullable(true),
4881 )
4882 .with_column("assume_role_arn", SqlScalarType::String.nullable(true))
4883 .with_column(
4884 "assume_role_session_name",
4885 SqlScalarType::String.nullable(true),
4886 )
4887 .with_column("principal", SqlScalarType::String.nullable(true))
4888 .with_column("external_id", SqlScalarType::String.nullable(true))
4889 .with_column("example_trust_policy", SqlScalarType::Jsonb.nullable(true))
4890 .finish(),
4891 column_comments: BTreeMap::from_iter([
4892 ("id", "The ID of the connection."),
4893 ("endpoint", "The value of the `ENDPOINT` option, if set."),
4894 ("region", "The value of the `REGION` option, if set."),
4895 (
4896 "access_key_id",
4897 "The value of the `ACCESS KEY ID` option, if provided in line.",
4898 ),
4899 (
4900 "access_key_id_secret_id",
4901 "The ID of the secret referenced by the `ACCESS KEY ID` option, if provided via a secret.",
4902 ),
4903 (
4904 "secret_access_key_secret_id",
4905 "The ID of the secret referenced by the `SECRET ACCESS KEY` option, if set.",
4906 ),
4907 (
4908 "session_token",
4909 "The value of the `SESSION TOKEN` option, if provided in line.",
4910 ),
4911 (
4912 "session_token_secret_id",
4913 "The ID of the secret referenced by the `SESSION TOKEN` option, if provided via a secret.",
4914 ),
4915 (
4916 "assume_role_arn",
4917 "The value of the `ASSUME ROLE ARN` option, if set.",
4918 ),
4919 (
4920 "assume_role_session_name",
4921 "The value of the `ASSUME ROLE SESSION NAME` option, if set.",
4922 ),
4923 (
4924 "principal",
4925 "The ARN of the AWS principal Materialize will use when assuming the provided role, if the connection is configured to use role assumption.",
4926 ),
4927 (
4928 "external_id",
4929 "The external ID Materialize will use when assuming the provided role, if the connection is configured to use role assumption.",
4930 ),
4931 (
4932 "example_trust_policy",
4933 "An example of an IAM role trust policy that allows this connection's principal and external ID to assume the role.",
4934 ),
4935 ]),
4936 is_retained_metrics_object: false,
4937 access: vec![PUBLIC_SELECT],
4938});
4939
4940pub static MZ_CLUSTER_REPLICA_METRICS_HISTORY: LazyLock<BuiltinSource> =
4941 LazyLock::new(|| BuiltinSource {
4942 name: "mz_cluster_replica_metrics_history",
4943 schema: MZ_INTERNAL_SCHEMA,
4944 oid: oid::SOURCE_MZ_CLUSTER_REPLICA_METRICS_HISTORY_OID,
4945 data_source: IntrospectionType::ReplicaMetricsHistory,
4946 desc: REPLICA_METRICS_HISTORY_DESC.clone(),
4947 column_comments: BTreeMap::from_iter([
4948 ("replica_id", "The ID of a cluster replica."),
4949 ("process_id", "The ID of a process within the replica."),
4950 (
4951 "cpu_nano_cores",
4952 "Approximate CPU usage, in billionths of a vCPU core.",
4953 ),
4954 ("memory_bytes", "Approximate memory usage, in bytes."),
4955 ("disk_bytes", "Approximate disk usage, in bytes."),
4956 (
4957 "occurred_at",
4958 "Wall-clock timestamp at which the event occurred.",
4959 ),
4960 (
4961 "heap_bytes",
4962 "Approximate heap (RAM + swap) usage, in bytes.",
4963 ),
4964 ("heap_limit", "Available heap (RAM + swap) space, in bytes."),
4965 ]),
4966 is_retained_metrics_object: false,
4967 access: vec![PUBLIC_SELECT],
4968 });
4969
4970pub static MZ_CLUSTER_REPLICA_METRICS_HISTORY_CT: LazyLock<BuiltinContinualTask> = LazyLock::new(
4971 || {
4972 BuiltinContinualTask {
4973 name: "mz_cluster_replica_metrics_history_ct",
4974 schema: MZ_INTERNAL_SCHEMA,
4975 oid: oid::CT_MZ_CLUSTER_REPLICA_METRICS_HISTORY_OID,
4976 desc: REPLICA_METRICS_HISTORY_DESC.clone(),
4977 sql: "
4978IN CLUSTER mz_catalog_server
4979ON INPUT mz_internal.mz_cluster_replica_metrics_history AS (
4980 DELETE FROM mz_internal.mz_cluster_replica_metrics_history_ct WHERE occurred_at + '30d' < mz_now();
4981 INSERT INTO mz_internal.mz_cluster_replica_metrics_history_ct SELECT * FROM mz_internal.mz_cluster_replica_metrics_history;
4982)",
4983 access: vec![PUBLIC_SELECT],
4984 }
4985 },
4986);
4987
4988pub static MZ_CLUSTER_REPLICA_METRICS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4989 name: "mz_cluster_replica_metrics",
4990 schema: MZ_INTERNAL_SCHEMA,
4991 oid: oid::VIEW_MZ_CLUSTER_REPLICA_METRICS_OID,
4992 desc: RelationDesc::builder()
4993 .with_column("replica_id", SqlScalarType::String.nullable(false))
4994 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
4995 .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(true))
4996 .with_column("memory_bytes", SqlScalarType::UInt64.nullable(true))
4997 .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true))
4998 .with_column("heap_bytes", SqlScalarType::UInt64.nullable(true))
4999 .with_column("heap_limit", SqlScalarType::UInt64.nullable(true))
5000 .with_key(vec![0, 1])
5001 .finish(),
5002 column_comments: BTreeMap::from_iter([
5003 ("replica_id", "The ID of a cluster replica."),
5004 ("process_id", "The ID of a process within the replica."),
5005 (
5006 "cpu_nano_cores",
5007 "Approximate CPU usage, in billionths of a vCPU core.",
5008 ),
5009 ("memory_bytes", "Approximate RAM usage, in bytes."),
5010 ("disk_bytes", "Approximate disk usage, in bytes."),
5011 (
5012 "heap_bytes",
5013 "Approximate heap (RAM + swap) usage, in bytes.",
5014 ),
5015 ("heap_limit", "Available heap (RAM + swap) space, in bytes."),
5016 ]),
5017 sql: "
5018SELECT
5019 DISTINCT ON (replica_id, process_id)
5020 replica_id,
5021 process_id,
5022 cpu_nano_cores,
5023 memory_bytes,
5024 disk_bytes,
5025 heap_bytes,
5026 heap_limit
5027FROM mz_internal.mz_cluster_replica_metrics_history
5028JOIN mz_cluster_replicas r ON r.id = replica_id
5029ORDER BY replica_id, process_id, occurred_at DESC",
5030 access: vec![PUBLIC_SELECT],
5031});
5032
5033pub static MZ_CLUSTER_REPLICA_FRONTIERS: LazyLock<BuiltinSource> =
5034 LazyLock::new(|| BuiltinSource {
5035 name: "mz_cluster_replica_frontiers",
5036 schema: MZ_CATALOG_SCHEMA,
5037 oid: oid::SOURCE_MZ_CLUSTER_REPLICA_FRONTIERS_OID,
5038 data_source: IntrospectionType::ReplicaFrontiers,
5039 desc: RelationDesc::builder()
5040 .with_column("object_id", SqlScalarType::String.nullable(false))
5041 .with_column("replica_id", SqlScalarType::String.nullable(false))
5042 .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true))
5043 .finish(),
5044 column_comments: BTreeMap::from_iter([
5045 (
5046 "object_id",
5047 "The ID of the source, sink, index, materialized view, or subscription.",
5048 ),
5049 ("replica_id", "The ID of a cluster replica."),
5050 (
5051 "write_frontier",
5052 "The next timestamp at which the output may change.",
5053 ),
5054 ]),
5055 is_retained_metrics_object: false,
5056 access: vec![PUBLIC_SELECT],
5057 });
5058
5059pub static MZ_CLUSTER_REPLICA_FRONTIERS_IND: LazyLock<BuiltinIndex> =
5060 LazyLock::new(|| BuiltinIndex {
5061 name: "mz_cluster_replica_frontiers_ind",
5062 schema: MZ_CATALOG_SCHEMA,
5063 oid: oid::INDEX_MZ_CLUSTER_REPLICA_FRONTIERS_IND_OID,
5064 sql: "IN CLUSTER mz_catalog_server ON mz_catalog.mz_cluster_replica_frontiers (object_id)",
5065 is_retained_metrics_object: false,
5066 });
5067
5068pub static MZ_FRONTIERS: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5069 name: "mz_frontiers",
5070 schema: MZ_INTERNAL_SCHEMA,
5071 oid: oid::SOURCE_MZ_FRONTIERS_OID,
5072 data_source: IntrospectionType::Frontiers,
5073 desc: RelationDesc::builder()
5074 .with_column("object_id", SqlScalarType::String.nullable(false))
5075 .with_column("read_frontier", SqlScalarType::MzTimestamp.nullable(true))
5076 .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true))
5077 .finish(),
5078 column_comments: BTreeMap::from_iter([
5079 (
5080 "object_id",
5081 "The ID of the source, sink, table, index, materialized view, or subscription.",
5082 ),
5083 (
5084 "read_frontier",
5085 "The earliest timestamp at which the output is still readable.",
5086 ),
5087 (
5088 "write_frontier",
5089 "The next timestamp at which the output may change.",
5090 ),
5091 ]),
5092 is_retained_metrics_object: false,
5093 access: vec![PUBLIC_SELECT],
5094});
5095
5096pub static MZ_GLOBAL_FRONTIERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5098 name: "mz_global_frontiers",
5099 schema: MZ_INTERNAL_SCHEMA,
5100 oid: oid::VIEW_MZ_GLOBAL_FRONTIERS_OID,
5101 desc: RelationDesc::builder()
5102 .with_column("object_id", SqlScalarType::String.nullable(false))
5103 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
5104 .finish(),
5105 column_comments: BTreeMap::new(),
5106 sql: "
5107SELECT object_id, write_frontier AS time
5108FROM mz_internal.mz_frontiers
5109WHERE write_frontier IS NOT NULL",
5110 access: vec![PUBLIC_SELECT],
5111});
5112
5113pub static MZ_WALLCLOCK_LAG_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5114 name: "mz_wallclock_lag_history",
5115 schema: MZ_INTERNAL_SCHEMA,
5116 oid: oid::SOURCE_MZ_WALLCLOCK_LAG_HISTORY_OID,
5117 desc: WALLCLOCK_LAG_HISTORY_DESC.clone(),
5118 data_source: IntrospectionType::WallclockLagHistory,
5119 column_comments: BTreeMap::from_iter([
5120 (
5121 "object_id",
5122 "The ID of the table, source, materialized view, index, or sink. Corresponds to `mz_objects.id`.",
5123 ),
5124 (
5125 "replica_id",
5126 "The ID of a replica computing the object, or `NULL` for persistent objects. Corresponds to `mz_cluster_replicas.id`.",
5127 ),
5128 (
5129 "lag",
5130 "The amount of time the object's write frontier lags behind wallclock time.",
5131 ),
5132 (
5133 "occurred_at",
5134 "Wall-clock timestamp at which the event occurred.",
5135 ),
5136 ]),
5137 is_retained_metrics_object: false,
5138 access: vec![PUBLIC_SELECT],
5139});
5140
5141pub static MZ_WALLCLOCK_LAG_HISTORY_CT: LazyLock<BuiltinContinualTask> = LazyLock::new(|| {
5142 BuiltinContinualTask {
5143 name: "mz_wallclock_lag_history_ct",
5144 schema: MZ_INTERNAL_SCHEMA,
5145 oid: oid::CT_MZ_WALLCLOCK_LAG_HISTORY_OID,
5146 desc: WALLCLOCK_LAG_HISTORY_DESC.clone(),
5147 sql: "
5148IN CLUSTER mz_catalog_server
5149ON INPUT mz_internal.mz_wallclock_lag_history AS (
5150 DELETE FROM mz_internal.mz_wallclock_lag_history_ct WHERE occurred_at + '30d' < mz_now();
5151 INSERT INTO mz_internal.mz_wallclock_lag_history_ct SELECT * FROM mz_internal.mz_wallclock_lag_history;
5152)",
5153 access: vec![PUBLIC_SELECT],
5154 }
5155});
5156
5157pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5158 name: "mz_wallclock_global_lag_history",
5159 schema: MZ_INTERNAL_SCHEMA,
5160 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_HISTORY_OID,
5161 desc: RelationDesc::builder()
5162 .with_column("object_id", SqlScalarType::String.nullable(false))
5163 .with_column("lag", SqlScalarType::Interval.nullable(true))
5164 .with_column(
5165 "occurred_at",
5166 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5167 )
5168 .with_key(vec![0, 2])
5169 .finish(),
5170 column_comments: BTreeMap::new(),
5171 sql: "
5172WITH times_binned AS (
5173 SELECT
5174 object_id,
5175 lag,
5176 date_trunc('minute', occurred_at) AS occurred_at
5177 FROM mz_internal.mz_wallclock_lag_history
5178)
5179SELECT
5180 object_id,
5181 min(lag) AS lag,
5182 occurred_at
5183FROM times_binned
5184GROUP BY object_id, occurred_at
5185OPTIONS (AGGREGATE INPUT GROUP SIZE = 1)",
5186 access: vec![PUBLIC_SELECT],
5187});
5188
5189pub static MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY: LazyLock<BuiltinView> =
5190 LazyLock::new(|| BuiltinView {
5191 name: "mz_wallclock_global_lag_recent_history",
5192 schema: MZ_INTERNAL_SCHEMA,
5193 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_OID,
5194 desc: RelationDesc::builder()
5195 .with_column("object_id", SqlScalarType::String.nullable(false))
5196 .with_column("lag", SqlScalarType::Interval.nullable(true))
5197 .with_column(
5198 "occurred_at",
5199 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5200 )
5201 .with_key(vec![0, 2])
5202 .finish(),
5203 column_comments: BTreeMap::new(),
5204 sql: "
5205SELECT object_id, lag, occurred_at
5206FROM mz_internal.mz_wallclock_global_lag_history
5207WHERE occurred_at + '1 day' > mz_now()",
5208 access: vec![PUBLIC_SELECT],
5209 });
5210
5211pub static MZ_WALLCLOCK_GLOBAL_LAG: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5212 name: "mz_wallclock_global_lag",
5213 schema: MZ_INTERNAL_SCHEMA,
5214 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_OID,
5215 desc: RelationDesc::builder()
5216 .with_column("object_id", SqlScalarType::String.nullable(false))
5217 .with_column("lag", SqlScalarType::Interval.nullable(true))
5218 .with_key(vec![0])
5219 .finish(),
5220 column_comments: BTreeMap::from_iter([
5221 (
5222 "object_id",
5223 "The ID of the table, source, materialized view, index, or sink. Corresponds to `mz_objects.id`.",
5224 ),
5225 (
5226 "lag",
5227 "The amount of time the object's write frontier lags behind wallclock time.",
5228 ),
5229 ]),
5230 sql: "
5231SELECT DISTINCT ON (object_id) object_id, lag
5232FROM mz_internal.mz_wallclock_global_lag_recent_history
5233WHERE occurred_at + '5 minutes' > mz_now()
5234ORDER BY object_id, occurred_at DESC",
5235 access: vec![PUBLIC_SELECT],
5236});
5237
5238pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW: LazyLock<BuiltinSource> =
5239 LazyLock::new(|| BuiltinSource {
5240 name: "mz_wallclock_global_lag_histogram_raw",
5241 schema: MZ_INTERNAL_SCHEMA,
5242 oid: oid::SOURCE_MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW_OID,
5243 desc: WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW_DESC.clone(),
5244 column_comments: BTreeMap::new(),
5245 data_source: IntrospectionType::WallclockLagHistogram,
5246 is_retained_metrics_object: false,
5247 access: vec![PUBLIC_SELECT],
5248 });
5249
5250pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM: LazyLock<BuiltinView> =
5251 LazyLock::new(|| BuiltinView {
5252 name: "mz_wallclock_global_lag_histogram",
5253 schema: MZ_INTERNAL_SCHEMA,
5254 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_OID,
5255 desc: RelationDesc::builder()
5256 .with_column(
5257 "period_start",
5258 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5259 )
5260 .with_column(
5261 "period_end",
5262 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5263 )
5264 .with_column("object_id", SqlScalarType::String.nullable(false))
5265 .with_column("lag_seconds", SqlScalarType::UInt64.nullable(true))
5266 .with_column("labels", SqlScalarType::Jsonb.nullable(false))
5267 .with_column("count", SqlScalarType::Int64.nullable(false))
5268 .with_key(vec![0, 1, 2, 3, 4])
5269 .finish(),
5270 column_comments: BTreeMap::new(),
5271 sql: "
5272SELECT *, count(*) AS count
5273FROM mz_internal.mz_wallclock_global_lag_histogram_raw
5274GROUP BY period_start, period_end, object_id, lag_seconds, labels",
5275 access: vec![PUBLIC_SELECT],
5276 });
5277
5278pub static MZ_MATERIALIZED_VIEW_REFRESHES: LazyLock<BuiltinSource> = LazyLock::new(|| {
5279 BuiltinSource {
5280 name: "mz_materialized_view_refreshes",
5281 schema: MZ_INTERNAL_SCHEMA,
5282 oid: oid::SOURCE_MZ_MATERIALIZED_VIEW_REFRESHES_OID,
5283 data_source: IntrospectionType::ComputeMaterializedViewRefreshes,
5284 desc: RelationDesc::builder()
5285 .with_column(
5286 "materialized_view_id",
5287 SqlScalarType::String.nullable(false),
5288 )
5289 .with_column(
5290 "last_completed_refresh",
5291 SqlScalarType::MzTimestamp.nullable(true),
5292 )
5293 .with_column("next_refresh", SqlScalarType::MzTimestamp.nullable(true))
5294 .finish(),
5295 column_comments: BTreeMap::from_iter([
5296 (
5297 "materialized_view_id",
5298 "The ID of the materialized view. Corresponds to `mz_catalog.mz_materialized_views.id`",
5299 ),
5300 (
5301 "last_completed_refresh",
5302 "The time of the last successfully completed refresh. `NULL` if the materialized view hasn't completed any refreshes yet.",
5303 ),
5304 (
5305 "next_refresh",
5306 "The time of the next scheduled refresh. `NULL` if the materialized view has no future scheduled refreshes.",
5307 ),
5308 ]),
5309 is_retained_metrics_object: false,
5310 access: vec![PUBLIC_SELECT],
5311 }
5312});
5313
5314pub static MZ_SUBSCRIPTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5315 name: "mz_subscriptions",
5316 schema: MZ_INTERNAL_SCHEMA,
5317 oid: oid::TABLE_MZ_SUBSCRIPTIONS_OID,
5318 desc: RelationDesc::builder()
5319 .with_column("id", SqlScalarType::String.nullable(false))
5320 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
5321 .with_column("cluster_id", SqlScalarType::String.nullable(false))
5322 .with_column(
5323 "created_at",
5324 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5325 )
5326 .with_column(
5327 "referenced_object_ids",
5328 SqlScalarType::List {
5329 element_type: Box::new(SqlScalarType::String),
5330 custom_id: None,
5331 }
5332 .nullable(false),
5333 )
5334 .finish(),
5335 column_comments: BTreeMap::from_iter([
5336 ("id", "The ID of the subscription."),
5337 (
5338 "session_id",
5339 "The ID of the session that runs the subscription. Corresponds to `mz_sessions.id`.",
5340 ),
5341 (
5342 "cluster_id",
5343 "The ID of the cluster on which the subscription is running. Corresponds to `mz_clusters.id`.",
5344 ),
5345 (
5346 "created_at",
5347 "The time at which the subscription was created.",
5348 ),
5349 (
5350 "referenced_object_ids",
5351 "The IDs of objects referenced by the subscription. Corresponds to `mz_objects.id`",
5352 ),
5353 ]),
5354 is_retained_metrics_object: false,
5355 access: vec![PUBLIC_SELECT],
5356});
5357
5358pub static MZ_SESSIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5359 name: "mz_sessions",
5360 schema: MZ_INTERNAL_SCHEMA,
5361 oid: oid::TABLE_MZ_SESSIONS_OID,
5362 desc: RelationDesc::builder()
5363 .with_column("id", SqlScalarType::Uuid.nullable(false))
5364 .with_column("connection_id", SqlScalarType::UInt32.nullable(false))
5365 .with_column("role_id", SqlScalarType::String.nullable(false))
5366 .with_column("client_ip", SqlScalarType::String.nullable(true))
5367 .with_column(
5368 "connected_at",
5369 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5370 )
5371 .finish(),
5372 column_comments: BTreeMap::from_iter([
5373 ("id", "The globally unique ID of the session."),
5374 (
5375 "connection_id",
5376 "The connection ID of the session. Unique only for active sessions and can be recycled. Corresponds to `pg_backend_pid()`.",
5377 ),
5378 (
5379 "role_id",
5380 "The role ID of the role that the session is logged in as. Corresponds to `mz_catalog.mz_roles`.",
5381 ),
5382 (
5383 "client_ip",
5384 "The IP address of the client that initiated the session.",
5385 ),
5386 (
5387 "connected_at",
5388 "The time at which the session connected to the system.",
5389 ),
5390 ]),
5391 is_retained_metrics_object: false,
5392 access: vec![PUBLIC_SELECT],
5393});
5394
5395pub static MZ_DEFAULT_PRIVILEGES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5396 name: "mz_default_privileges",
5397 schema: MZ_CATALOG_SCHEMA,
5398 oid: oid::TABLE_MZ_DEFAULT_PRIVILEGES_OID,
5399 desc: RelationDesc::builder()
5400 .with_column("role_id", SqlScalarType::String.nullable(false))
5401 .with_column("database_id", SqlScalarType::String.nullable(true))
5402 .with_column("schema_id", SqlScalarType::String.nullable(true))
5403 .with_column("object_type", SqlScalarType::String.nullable(false))
5404 .with_column("grantee", SqlScalarType::String.nullable(false))
5405 .with_column("privileges", SqlScalarType::String.nullable(false))
5406 .finish(),
5407 column_comments: BTreeMap::from_iter([
5408 (
5409 "role_id",
5410 "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.",
5411 ),
5412 (
5413 "database_id",
5414 "Privileges described in this row will be granted only on objects in the database identified by `database_id` if non-null.",
5415 ),
5416 (
5417 "schema_id",
5418 "Privileges described in this row will be granted only on objects in the schema identified by `schema_id` if non-null.",
5419 ),
5420 (
5421 "object_type",
5422 "Privileges described in this row will be granted only on objects of type `object_type`.",
5423 ),
5424 (
5425 "grantee",
5426 "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.",
5427 ),
5428 ("privileges", "The set of privileges that will be granted."),
5429 ]),
5430 is_retained_metrics_object: false,
5431 access: vec![PUBLIC_SELECT],
5432});
5433
5434pub static MZ_SYSTEM_PRIVILEGES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5435 name: "mz_system_privileges",
5436 schema: MZ_CATALOG_SCHEMA,
5437 oid: oid::TABLE_MZ_SYSTEM_PRIVILEGES_OID,
5438 desc: RelationDesc::builder()
5439 .with_column("privileges", SqlScalarType::MzAclItem.nullable(false))
5440 .finish(),
5441 column_comments: BTreeMap::from_iter([(
5442 "privileges",
5443 "The privileges belonging to the system.",
5444 )]),
5445 is_retained_metrics_object: false,
5446 access: vec![PUBLIC_SELECT],
5447});
5448
5449pub static MZ_COMMENTS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5450 name: "mz_comments",
5451 schema: MZ_INTERNAL_SCHEMA,
5452 oid: oid::TABLE_MZ_COMMENTS_OID,
5453 desc: RelationDesc::builder()
5454 .with_column("id", SqlScalarType::String.nullable(false))
5455 .with_column("object_type", SqlScalarType::String.nullable(false))
5456 .with_column("object_sub_id", SqlScalarType::Int32.nullable(true))
5457 .with_column("comment", SqlScalarType::String.nullable(false))
5458 .finish(),
5459 column_comments: BTreeMap::from_iter([
5460 (
5461 "id",
5462 "The ID of the object. Corresponds to `mz_objects.id`.",
5463 ),
5464 (
5465 "object_type",
5466 "The type of object the comment is associated with.",
5467 ),
5468 (
5469 "object_sub_id",
5470 "For a comment on a column of a relation, the column number. `NULL` for other object types.",
5471 ),
5472 ("comment", "The comment itself."),
5473 ]),
5474 is_retained_metrics_object: false,
5475 access: vec![PUBLIC_SELECT],
5476});
5477
5478pub static MZ_SOURCE_REFERENCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5479 name: "mz_source_references",
5480 schema: MZ_INTERNAL_SCHEMA,
5481 oid: oid::TABLE_MZ_SOURCE_REFERENCES_OID,
5482 desc: RelationDesc::builder()
5483 .with_column("source_id", SqlScalarType::String.nullable(false))
5484 .with_column("namespace", SqlScalarType::String.nullable(true))
5485 .with_column("name", SqlScalarType::String.nullable(false))
5486 .with_column(
5487 "updated_at",
5488 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5489 )
5490 .with_column(
5491 "columns",
5492 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
5493 )
5494 .finish(),
5495 column_comments: BTreeMap::new(),
5496 is_retained_metrics_object: false,
5497 access: vec![PUBLIC_SELECT],
5498});
5499
5500pub static MZ_WEBHOOKS_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5501 name: "mz_webhook_sources",
5502 schema: MZ_INTERNAL_SCHEMA,
5503 oid: oid::TABLE_MZ_WEBHOOK_SOURCES_OID,
5504 desc: RelationDesc::builder()
5505 .with_column("id", SqlScalarType::String.nullable(false))
5506 .with_column("name", SqlScalarType::String.nullable(false))
5507 .with_column("url", SqlScalarType::String.nullable(false))
5508 .finish(),
5509 column_comments: BTreeMap::from_iter([
5510 (
5511 "id",
5512 "The ID of the webhook source. Corresponds to `mz_sources.id`.",
5513 ),
5514 ("name", "The name of the webhook source."),
5515 (
5516 "url",
5517 "The URL which can be used to send events to the source.",
5518 ),
5519 ]),
5520 is_retained_metrics_object: false,
5521 access: vec![PUBLIC_SELECT],
5522});
5523
5524pub static MZ_HISTORY_RETENTION_STRATEGIES: LazyLock<BuiltinTable> = LazyLock::new(|| {
5525 BuiltinTable {
5526 name: "mz_history_retention_strategies",
5527 schema: MZ_INTERNAL_SCHEMA,
5528 oid: oid::TABLE_MZ_HISTORY_RETENTION_STRATEGIES_OID,
5529 desc: RelationDesc::builder()
5530 .with_column("id", SqlScalarType::String.nullable(false))
5531 .with_column("strategy", SqlScalarType::String.nullable(false))
5532 .with_column("value", SqlScalarType::Jsonb.nullable(false))
5533 .finish(),
5534 column_comments: BTreeMap::from_iter([
5535 ("id", "The ID of the object."),
5536 (
5537 "strategy",
5538 "The strategy. `FOR` is the only strategy, and means the object's compaction window is the duration of the `value` field.",
5539 ),
5540 (
5541 "value",
5542 "The value of the strategy. For `FOR`, is a number of milliseconds.",
5543 ),
5544 ]),
5545 is_retained_metrics_object: false,
5546 access: vec![PUBLIC_SELECT],
5547 }
5548});
5549
5550pub static MZ_LICENSE_KEYS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5551 name: "mz_license_keys",
5552 schema: MZ_INTERNAL_SCHEMA,
5553 oid: oid::TABLE_MZ_LICENSE_KEYS_OID,
5554 desc: RelationDesc::builder()
5555 .with_column("id", SqlScalarType::String.nullable(false))
5556 .with_column("organization", SqlScalarType::String.nullable(false))
5557 .with_column("environment_id", SqlScalarType::String.nullable(false))
5558 .with_column(
5559 "expiration",
5560 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5561 )
5562 .with_column(
5563 "not_before",
5564 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5565 )
5566 .finish(),
5567 column_comments: BTreeMap::from_iter([
5568 ("id", "The identifier of the license key."),
5569 (
5570 "organization",
5571 "The name of the organization that this license key was issued to.",
5572 ),
5573 (
5574 "environment_id",
5575 "The environment ID that this license key was issued for.",
5576 ),
5577 (
5578 "expiration",
5579 "The date and time when this license key expires.",
5580 ),
5581 (
5582 "not_before",
5583 "The start of the validity period for this license key.",
5584 ),
5585 ]),
5586 is_retained_metrics_object: false,
5587 access: vec![PUBLIC_SELECT],
5588});
5589
5590pub static MZ_SOURCE_STATISTICS_RAW: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5593 name: "mz_source_statistics_raw",
5594 schema: MZ_INTERNAL_SCHEMA,
5595 oid: oid::SOURCE_MZ_SOURCE_STATISTICS_RAW_OID,
5596 data_source: IntrospectionType::StorageSourceStatistics,
5597 desc: MZ_SOURCE_STATISTICS_RAW_DESC.clone(),
5598 column_comments: BTreeMap::new(),
5599 is_retained_metrics_object: true,
5600 access: vec![PUBLIC_SELECT],
5601});
5602pub static MZ_SINK_STATISTICS_RAW: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5603 name: "mz_sink_statistics_raw",
5604 schema: MZ_INTERNAL_SCHEMA,
5605 oid: oid::SOURCE_MZ_SINK_STATISTICS_RAW_OID,
5606 data_source: IntrospectionType::StorageSinkStatistics,
5607 desc: MZ_SINK_STATISTICS_RAW_DESC.clone(),
5608 column_comments: BTreeMap::new(),
5609 is_retained_metrics_object: true,
5610 access: vec![PUBLIC_SELECT],
5611});
5612
5613pub static MZ_STORAGE_SHARDS: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5614 name: "mz_storage_shards",
5615 schema: MZ_INTERNAL_SCHEMA,
5616 oid: oid::SOURCE_MZ_STORAGE_SHARDS_OID,
5617 data_source: IntrospectionType::ShardMapping,
5618 desc: RelationDesc::builder()
5619 .with_column("object_id", SqlScalarType::String.nullable(false))
5620 .with_column("shard_id", SqlScalarType::String.nullable(false))
5621 .finish(),
5622 column_comments: BTreeMap::new(),
5623 is_retained_metrics_object: false,
5624 access: vec![PUBLIC_SELECT],
5625});
5626
5627pub static MZ_STORAGE_USAGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5628 name: "mz_storage_usage",
5629 schema: MZ_CATALOG_SCHEMA,
5630 oid: oid::VIEW_MZ_STORAGE_USAGE_OID,
5631 desc: RelationDesc::builder()
5632 .with_column("object_id", SqlScalarType::String.nullable(false))
5633 .with_column("size_bytes", SqlScalarType::UInt64.nullable(false))
5634 .with_column(
5635 "collection_timestamp",
5636 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5637 )
5638 .with_key(vec![0, 2])
5639 .finish(),
5640 column_comments: BTreeMap::from_iter([
5641 (
5642 "object_id",
5643 "The ID of the table, source, or materialized view.",
5644 ),
5645 (
5646 "size_bytes",
5647 "The number of storage bytes used by the object.",
5648 ),
5649 (
5650 "collection_timestamp",
5651 "The time at which storage usage of the object was assessed.",
5652 ),
5653 ]),
5654 sql: "
5655SELECT
5656 object_id,
5657 sum(size_bytes)::uint8 AS size_bytes,
5658 collection_timestamp
5659FROM
5660 mz_internal.mz_storage_shards
5661 JOIN mz_internal.mz_storage_usage_by_shard USING (shard_id)
5662GROUP BY object_id, collection_timestamp",
5663 access: vec![PUBLIC_SELECT],
5664});
5665
5666pub static MZ_RECENT_STORAGE_USAGE: LazyLock<BuiltinView> = LazyLock::new(|| {
5667 BuiltinView {
5668 name: "mz_recent_storage_usage",
5669 schema: MZ_CATALOG_SCHEMA,
5670 oid: oid::VIEW_MZ_RECENT_STORAGE_USAGE_OID,
5671 desc: RelationDesc::builder()
5672 .with_column("object_id", SqlScalarType::String.nullable(false))
5673 .with_column("size_bytes", SqlScalarType::UInt64.nullable(true))
5674 .with_key(vec![0])
5675 .finish(),
5676 column_comments: BTreeMap::from_iter([
5677 ("object_id", "The ID of the table, source, or materialized view."),
5678 ("size_bytes", "The number of storage bytes used by the object in the most recent assessment."),
5679 ]),
5680 sql: "
5681WITH
5682
5683recent_storage_usage_by_shard AS (
5684 SELECT shard_id, size_bytes, collection_timestamp
5685 FROM mz_internal.mz_storage_usage_by_shard
5686 -- Restricting to the last 6 hours makes it feasible to index the view.
5687 WHERE collection_timestamp + '6 hours' >= mz_now()
5688),
5689
5690most_recent_collection_timestamp_by_shard AS (
5691 SELECT shard_id, max(collection_timestamp) AS collection_timestamp
5692 FROM recent_storage_usage_by_shard
5693 GROUP BY shard_id
5694)
5695
5696SELECT
5697 object_id,
5698 sum(size_bytes)::uint8 AS size_bytes
5699FROM
5700 mz_internal.mz_storage_shards
5701 LEFT JOIN most_recent_collection_timestamp_by_shard
5702 ON mz_storage_shards.shard_id = most_recent_collection_timestamp_by_shard.shard_id
5703 LEFT JOIN recent_storage_usage_by_shard
5704 ON mz_storage_shards.shard_id = recent_storage_usage_by_shard.shard_id
5705 AND most_recent_collection_timestamp_by_shard.collection_timestamp = recent_storage_usage_by_shard.collection_timestamp
5706GROUP BY object_id",
5707 access: vec![PUBLIC_SELECT],
5708}
5709});
5710
5711pub static MZ_RECENT_STORAGE_USAGE_IND: LazyLock<BuiltinIndex> = LazyLock::new(|| BuiltinIndex {
5712 name: "mz_recent_storage_usage_ind",
5713 schema: MZ_CATALOG_SCHEMA,
5714 oid: oid::INDEX_MZ_RECENT_STORAGE_USAGE_IND_OID,
5715 sql: "IN CLUSTER mz_catalog_server ON mz_catalog.mz_recent_storage_usage (object_id)",
5716 is_retained_metrics_object: false,
5717});
5718
5719pub static MZ_RELATIONS: LazyLock<BuiltinView> = LazyLock::new(|| {
5720 BuiltinView {
5721 name: "mz_relations",
5722 schema: MZ_CATALOG_SCHEMA,
5723 oid: oid::VIEW_MZ_RELATIONS_OID,
5724 desc: RelationDesc::builder()
5725 .with_column("id", SqlScalarType::String.nullable(false))
5726 .with_column("oid", SqlScalarType::Oid.nullable(false))
5727 .with_column("schema_id", SqlScalarType::String.nullable(false))
5728 .with_column("name", SqlScalarType::String.nullable(false))
5729 .with_column("type", SqlScalarType::String.nullable(false))
5730 .with_column("owner_id", SqlScalarType::String.nullable(false))
5731 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5732 .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false))
5733 .finish(),
5734 column_comments: BTreeMap::from_iter([
5735 ("id", "Materialize's unique ID for the relation."),
5736 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the relation."),
5737 ("schema_id", "The ID of the schema to which the relation belongs. Corresponds to `mz_schemas.id`."),
5738 ("name", "The name of the relation."),
5739 ("type", "The type of the relation: either `table`, `source`, `view`, or `materialized view`."),
5740 ("owner_id", "The role ID of the owner of the relation. Corresponds to `mz_roles.id`."),
5741 ("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."),
5742 ("privileges", "The privileges belonging to the relation."),
5743 ]),
5744 sql: "
5745 SELECT id, oid, schema_id, name, 'table' AS type, owner_id, NULL::text AS cluster_id, privileges FROM mz_catalog.mz_tables
5746UNION ALL SELECT id, oid, schema_id, name, 'source', owner_id, cluster_id, privileges FROM mz_catalog.mz_sources
5747UNION ALL SELECT id, oid, schema_id, name, 'view', owner_id, NULL::text, privileges FROM mz_catalog.mz_views
5748UNION ALL SELECT id, oid, schema_id, name, 'materialized-view', owner_id, cluster_id, privileges FROM mz_catalog.mz_materialized_views
5749UNION ALL SELECT id, oid, schema_id, name, 'continual-task', owner_id, cluster_id, privileges FROM mz_internal.mz_continual_tasks",
5750 access: vec![PUBLIC_SELECT],
5751 }
5752});
5753
5754pub static MZ_OBJECTS_ID_NAMESPACE_TYPES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5755 name: "mz_objects_id_namespace_types",
5756 schema: MZ_INTERNAL_SCHEMA,
5757 oid: oid::VIEW_MZ_OBJECTS_ID_NAMESPACE_TYPES_OID,
5758 desc: RelationDesc::builder()
5759 .with_column("object_type", SqlScalarType::String.nullable(false))
5760 .with_key(vec![0])
5761 .finish(),
5762 column_comments: BTreeMap::new(),
5763 sql: r#"SELECT *
5764 FROM (
5765 VALUES
5766 ('table'),
5767 ('view'),
5768 ('materialized-view'),
5769 ('source'),
5770 ('sink'),
5771 ('index'),
5772 ('connection'),
5773 ('type'),
5774 ('function'),
5775 ('secret')
5776 )
5777 AS _ (object_type)"#,
5778 access: vec![PUBLIC_SELECT],
5779});
5780
5781pub static MZ_OBJECT_OID_ALIAS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5782 name: "mz_object_oid_alias",
5783 schema: MZ_INTERNAL_SCHEMA,
5784 oid: oid::VIEW_MZ_OBJECT_OID_ALIAS_OID,
5785 desc: RelationDesc::builder()
5786 .with_column("object_type", SqlScalarType::String.nullable(false))
5787 .with_column("oid_alias", SqlScalarType::String.nullable(false))
5788 .with_key(vec![0])
5789 .finish(),
5790 column_comments: BTreeMap::new(),
5791 sql: "SELECT object_type, oid_alias
5792 FROM (
5793 VALUES
5794 (
5795 'table'::pg_catalog.text,
5796 'regclass'::pg_catalog.text
5797 ),
5798 ('source', 'regclass'),
5799 ('view', 'regclass'),
5800 ('materialized-view', 'regclass'),
5801 ('index', 'regclass'),
5802 ('type', 'regtype'),
5803 ('function', 'regproc')
5804 )
5805 AS _ (object_type, oid_alias);",
5806 access: vec![PUBLIC_SELECT],
5807});
5808
5809pub static MZ_OBJECTS: LazyLock<BuiltinView> = LazyLock::new(|| {
5810 BuiltinView {
5811 name: "mz_objects",
5812 schema: MZ_CATALOG_SCHEMA,
5813 oid: oid::VIEW_MZ_OBJECTS_OID,
5814 desc: RelationDesc::builder()
5815 .with_column("id", SqlScalarType::String.nullable(false))
5816 .with_column("oid", SqlScalarType::Oid.nullable(false))
5817 .with_column("schema_id", SqlScalarType::String.nullable(false))
5818 .with_column("name", SqlScalarType::String.nullable(false))
5819 .with_column("type", SqlScalarType::String.nullable(false))
5820 .with_column("owner_id", SqlScalarType::String.nullable(false))
5821 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5822 .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(true))
5823 .finish(),
5824 column_comments: BTreeMap::from_iter([
5825 ("id", "Materialize's unique ID for the object."),
5826 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the object."),
5827 ("schema_id", "The ID of the schema to which the object belongs. Corresponds to `mz_schemas.id`."),
5828 ("name", "The name of the object."),
5829 ("type", "The type of the object: one of `table`, `source`, `view`, `materialized-view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`."),
5830 ("owner_id", "The role ID of the owner of the object. Corresponds to `mz_roles.id`."),
5831 ("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."),
5832 ("privileges", "The privileges belonging to the object."),
5833 ]),
5834 sql:
5835 "SELECT id, oid, schema_id, name, type, owner_id, cluster_id, privileges FROM mz_catalog.mz_relations
5836UNION ALL
5837 SELECT id, oid, schema_id, name, 'sink', owner_id, cluster_id, NULL::mz_catalog.mz_aclitem[] FROM mz_catalog.mz_sinks
5838UNION ALL
5839 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[]
5840 FROM mz_catalog.mz_indexes
5841 JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
5842UNION ALL
5843 SELECT id, oid, schema_id, name, 'connection', owner_id, NULL::text, privileges FROM mz_catalog.mz_connections
5844UNION ALL
5845 SELECT id, oid, schema_id, name, 'type', owner_id, NULL::text, privileges FROM mz_catalog.mz_types
5846UNION ALL
5847 SELECT id, oid, schema_id, name, 'function', owner_id, NULL::text, NULL::mz_catalog.mz_aclitem[] FROM mz_catalog.mz_functions
5848UNION ALL
5849 SELECT id, oid, schema_id, name, 'secret', owner_id, NULL::text, privileges FROM mz_catalog.mz_secrets",
5850 access: vec![PUBLIC_SELECT],
5851 }
5852});
5853
5854pub static MZ_OBJECT_FULLY_QUALIFIED_NAMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5855 name: "mz_object_fully_qualified_names",
5856 schema: MZ_INTERNAL_SCHEMA,
5857 oid: oid::VIEW_MZ_OBJECT_FULLY_QUALIFIED_NAMES_OID,
5858 desc: RelationDesc::builder()
5859 .with_column("id", SqlScalarType::String.nullable(false))
5860 .with_column("name", SqlScalarType::String.nullable(false))
5861 .with_column("object_type", SqlScalarType::String.nullable(false))
5862 .with_column("schema_id", SqlScalarType::String.nullable(false))
5863 .with_column("schema_name", SqlScalarType::String.nullable(false))
5864 .with_column("database_id", SqlScalarType::String.nullable(true))
5865 .with_column("database_name", SqlScalarType::String.nullable(true))
5866 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5867 .finish(),
5868 column_comments: BTreeMap::from_iter([
5869 ("id", "Materialize's unique ID for the object."),
5870 ("name", "The name of the object."),
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 "schema_id",
5877 "The ID of the schema to which the object belongs. Corresponds to `mz_schemas.id`.",
5878 ),
5879 (
5880 "schema_name",
5881 "The name of the schema to which the object belongs. Corresponds to `mz_schemas.name`.",
5882 ),
5883 (
5884 "database_id",
5885 "The ID of the database to which the object belongs. Corresponds to `mz_databases.id`.",
5886 ),
5887 (
5888 "database_name",
5889 "The name of the database to which the object belongs. Corresponds to `mz_databases.name`.",
5890 ),
5891 (
5892 "cluster_id",
5893 "The ID of the cluster maintaining the source, materialized view, index, or sink. Corresponds to `mz_clusters.id`. `NULL` for other object types.",
5894 ),
5895 ]),
5896 sql: "
5897 SELECT o.id,
5898 o.name,
5899 o.type as object_type,
5900 sc.id as schema_id,
5901 sc.name as schema_name,
5902 db.id as database_id,
5903 db.name as database_name,
5904 o.cluster_id
5905 FROM mz_catalog.mz_objects o
5906 INNER JOIN mz_catalog.mz_schemas sc ON sc.id = o.schema_id
5907 -- LEFT JOIN accounts for objects in the ambient database.
5908 LEFT JOIN mz_catalog.mz_databases db ON db.id = sc.database_id",
5909 access: vec![PUBLIC_SELECT],
5910});
5911
5912pub static MZ_OBJECT_LIFETIMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5914 name: "mz_object_lifetimes",
5915 schema: MZ_INTERNAL_SCHEMA,
5916 oid: oid::VIEW_MZ_OBJECT_LIFETIMES_OID,
5917 desc: RelationDesc::builder()
5918 .with_column("id", SqlScalarType::String.nullable(true))
5919 .with_column("previous_id", SqlScalarType::String.nullable(true))
5920 .with_column("object_type", SqlScalarType::String.nullable(false))
5921 .with_column("event_type", SqlScalarType::String.nullable(false))
5922 .with_column(
5923 "occurred_at",
5924 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5925 )
5926 .finish(),
5927 column_comments: BTreeMap::from_iter([
5928 ("id", "Materialize's unique ID for the object."),
5929 ("previous_id", "The object's previous ID, if one exists."),
5930 (
5931 "object_type",
5932 "The type of the object: one of `table`, `source`, `view`, `materialized view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`.",
5933 ),
5934 (
5935 "event_type",
5936 "The lifetime event, either `create` or `drop`.",
5937 ),
5938 (
5939 "occurred_at",
5940 "Wall-clock timestamp of when the event occurred.",
5941 ),
5942 ]),
5943 sql: "
5944 SELECT
5945 CASE
5946 WHEN a.object_type = 'cluster-replica' THEN a.details ->> 'replica_id'
5947 ELSE a.details ->> 'id'
5948 END id,
5949 a.details ->> 'previous_id' as previous_id,
5950 a.object_type,
5951 a.event_type,
5952 a.occurred_at
5953 FROM mz_catalog.mz_audit_events a
5954 WHERE a.event_type = 'create' OR a.event_type = 'drop'",
5955 access: vec![PUBLIC_SELECT],
5956});
5957
5958pub static MZ_OBJECT_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5959 name: "mz_object_history",
5960 schema: MZ_INTERNAL_SCHEMA,
5961 oid: oid::VIEW_MZ_OBJECT_HISTORY_OID,
5962 desc: RelationDesc::builder()
5963 .with_column("id", SqlScalarType::String.nullable(true))
5964 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5965 .with_column("object_type", SqlScalarType::String.nullable(false))
5966 .with_column(
5967 "created_at",
5968 SqlScalarType::TimestampTz { precision: None }.nullable(true),
5969 )
5970 .with_column(
5971 "dropped_at",
5972 SqlScalarType::TimestampTz { precision: None }.nullable(true),
5973 )
5974 .finish(),
5975 column_comments: BTreeMap::from_iter([
5976 ("id", "Materialize's unique ID for the object."),
5977 (
5978 "cluster_id",
5979 "The object's cluster ID. `NULL` if the object has no associated cluster.",
5980 ),
5981 (
5982 "object_type",
5983 "The type of the object: one of `table`, `source`, `view`, `materialized view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`.",
5984 ),
5985 (
5986 "created_at",
5987 "Wall-clock timestamp of when the object was created. `NULL` for built in system objects.",
5988 ),
5989 (
5990 "dropped_at",
5991 "Wall-clock timestamp of when the object was dropped. `NULL` for built in system objects or if the object hasn't been dropped.",
5992 ),
5993 ]),
5994 sql: r#"
5995 WITH
5996 creates AS
5997 (
5998 SELECT
5999 details ->> 'id' AS id,
6000 -- We need to backfill cluster_id since older object create events don't include the cluster ID in the audit log
6001 COALESCE(details ->> 'cluster_id', objects.cluster_id) AS cluster_id,
6002 object_type,
6003 occurred_at
6004 FROM
6005 mz_catalog.mz_audit_events AS events
6006 LEFT JOIN mz_catalog.mz_objects AS objects ON details ->> 'id' = objects.id
6007 WHERE event_type = 'create' AND object_type IN ( SELECT object_type FROM mz_internal.mz_objects_id_namespace_types )
6008 ),
6009 drops AS
6010 (
6011 SELECT details ->> 'id' AS id, occurred_at
6012 FROM mz_catalog.mz_audit_events
6013 WHERE event_type = 'drop' AND object_type IN ( SELECT object_type FROM mz_internal.mz_objects_id_namespace_types )
6014 ),
6015 user_object_history AS
6016 (
6017 SELECT
6018 creates.id,
6019 creates.cluster_id,
6020 creates.object_type,
6021 creates.occurred_at AS created_at,
6022 drops.occurred_at AS dropped_at
6023 FROM creates LEFT JOIN drops ON creates.id = drops.id
6024 WHERE creates.id LIKE 'u%'
6025 ),
6026 -- We need to union built in objects since they aren't in the audit log
6027 built_in_objects AS
6028 (
6029 -- Functions that accept different arguments have different oids but the same id. We deduplicate in this case.
6030 SELECT DISTINCT ON (objects.id)
6031 objects.id,
6032 objects.cluster_id,
6033 objects.type AS object_type,
6034 NULL::timestamptz AS created_at,
6035 NULL::timestamptz AS dropped_at
6036 FROM mz_catalog.mz_objects AS objects
6037 WHERE objects.id LIKE 's%'
6038 )
6039 SELECT * FROM user_object_history UNION ALL (SELECT * FROM built_in_objects)"#,
6040 access: vec![PUBLIC_SELECT],
6041});
6042
6043pub static MZ_DATAFLOWS_PER_WORKER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6044 name: "mz_dataflows_per_worker",
6045 schema: MZ_INTROSPECTION_SCHEMA,
6046 oid: oid::VIEW_MZ_DATAFLOWS_PER_WORKER_OID,
6047 desc: RelationDesc::builder()
6048 .with_column("id", SqlScalarType::UInt64.nullable(true))
6049 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6050 .with_column("name", SqlScalarType::String.nullable(false))
6051 .finish(),
6052 column_comments: BTreeMap::new(),
6053 sql: "SELECT
6054 addrs.address[1] AS id,
6055 ops.worker_id,
6056 ops.name
6057FROM
6058 mz_introspection.mz_dataflow_addresses_per_worker addrs,
6059 mz_introspection.mz_dataflow_operators_per_worker ops
6060WHERE
6061 addrs.id = ops.id AND
6062 addrs.worker_id = ops.worker_id AND
6063 mz_catalog.list_length(addrs.address) = 1",
6064 access: vec![PUBLIC_SELECT],
6065});
6066
6067pub static MZ_DATAFLOWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6068 name: "mz_dataflows",
6069 schema: MZ_INTROSPECTION_SCHEMA,
6070 oid: oid::VIEW_MZ_DATAFLOWS_OID,
6071 desc: RelationDesc::builder()
6072 .with_column("id", SqlScalarType::UInt64.nullable(true))
6073 .with_column("name", SqlScalarType::String.nullable(false))
6074 .finish(),
6075 column_comments: BTreeMap::from_iter([
6076 ("id", "The ID of the dataflow."),
6077 ("name", "The internal name of the dataflow."),
6078 ]),
6079 sql: "
6080SELECT id, name
6081FROM mz_introspection.mz_dataflows_per_worker
6082WHERE worker_id = 0",
6083 access: vec![PUBLIC_SELECT],
6084});
6085
6086pub static MZ_DATAFLOW_ADDRESSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6087 name: "mz_dataflow_addresses",
6088 schema: MZ_INTROSPECTION_SCHEMA,
6089 oid: oid::VIEW_MZ_DATAFLOW_ADDRESSES_OID,
6090 desc: RelationDesc::builder()
6091 .with_column("id", SqlScalarType::UInt64.nullable(false))
6092 .with_column(
6093 "address",
6094 SqlScalarType::List {
6095 element_type: Box::new(SqlScalarType::UInt64),
6096 custom_id: None,
6097 }
6098 .nullable(false),
6099 )
6100 .finish(),
6101 column_comments: BTreeMap::from_iter([
6102 (
6103 "id",
6104 "The ID of the channel or operator. Corresponds to `mz_dataflow_channels.id` or `mz_dataflow_operators.id`.",
6105 ),
6106 (
6107 "address",
6108 "A list of scope-local indexes indicating the path from the root to this channel or operator.",
6109 ),
6110 ]),
6111 sql: "
6112SELECT id, address
6113FROM mz_introspection.mz_dataflow_addresses_per_worker
6114WHERE worker_id = 0",
6115 access: vec![PUBLIC_SELECT],
6116});
6117
6118pub static MZ_DATAFLOW_CHANNELS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6119 name: "mz_dataflow_channels",
6120 schema: MZ_INTROSPECTION_SCHEMA,
6121 oid: oid::VIEW_MZ_DATAFLOW_CHANNELS_OID,
6122 desc: RelationDesc::builder()
6123 .with_column("id", SqlScalarType::UInt64.nullable(false))
6124 .with_column("from_index", SqlScalarType::UInt64.nullable(false))
6125 .with_column("from_port", SqlScalarType::UInt64.nullable(false))
6126 .with_column("to_index", SqlScalarType::UInt64.nullable(false))
6127 .with_column("to_port", SqlScalarType::UInt64.nullable(false))
6128 .with_column("type", SqlScalarType::String.nullable(false))
6129 .finish(),
6130 column_comments: BTreeMap::from_iter([
6131 ("id", "The ID of the channel."),
6132 (
6133 "from_index",
6134 "The scope-local index of the source operator. Corresponds to `mz_dataflow_addresses.address`.",
6135 ),
6136 ("from_port", "The source operator's output port."),
6137 (
6138 "to_index",
6139 "The scope-local index of the target operator. Corresponds to `mz_dataflow_addresses.address`.",
6140 ),
6141 ("to_port", "The target operator's input port."),
6142 ("type", "The container type of the channel."),
6143 ]),
6144 sql: "
6145SELECT id, from_index, from_port, to_index, to_port, type
6146FROM mz_introspection.mz_dataflow_channels_per_worker
6147WHERE worker_id = 0",
6148 access: vec![PUBLIC_SELECT],
6149});
6150
6151pub static MZ_DATAFLOW_OPERATORS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6152 name: "mz_dataflow_operators",
6153 schema: MZ_INTROSPECTION_SCHEMA,
6154 oid: oid::VIEW_MZ_DATAFLOW_OPERATORS_OID,
6155 desc: RelationDesc::builder()
6156 .with_column("id", SqlScalarType::UInt64.nullable(false))
6157 .with_column("name", SqlScalarType::String.nullable(false))
6158 .finish(),
6159 column_comments: BTreeMap::from_iter([
6160 ("id", "The ID of the operator."),
6161 ("name", "The internal name of the operator."),
6162 ]),
6163 sql: "
6164SELECT id, name
6165FROM mz_introspection.mz_dataflow_operators_per_worker
6166WHERE worker_id = 0",
6167 access: vec![PUBLIC_SELECT],
6168});
6169
6170pub static MZ_DATAFLOW_GLOBAL_IDS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6171 name: "mz_dataflow_global_ids",
6172 schema: MZ_INTROSPECTION_SCHEMA,
6173 oid: oid::VIEW_MZ_DATAFLOW_GLOBAL_IDS_OID,
6174 desc: RelationDesc::builder()
6175 .with_column("id", SqlScalarType::UInt64.nullable(false))
6176 .with_column("global_id", SqlScalarType::String.nullable(false))
6177 .finish(),
6178 column_comments: BTreeMap::from_iter([
6179 ("id", "The dataflow ID."),
6180 ("global_id", "A global ID associated with that dataflow."),
6181 ]),
6182 sql: "
6183SELECT id, global_id
6184FROM mz_introspection.mz_compute_dataflow_global_ids_per_worker
6185WHERE worker_id = 0",
6186 access: vec![PUBLIC_SELECT],
6187});
6188
6189pub static MZ_MAPPABLE_OBJECTS: LazyLock<BuiltinView> = LazyLock::new(|| {
6190 BuiltinView {
6191 name: "mz_mappable_objects",
6192 schema: MZ_INTROSPECTION_SCHEMA,
6193 oid: oid::VIEW_MZ_MAPPABLE_OBJECTS_OID,
6194 desc: RelationDesc::builder()
6195 .with_column("name", SqlScalarType::String.nullable(false))
6196 .with_column("global_id", SqlScalarType::String.nullable(false))
6197 .finish(),
6198 column_comments: BTreeMap::from_iter([
6199 ("name", "The name of the object."),
6200 ("global_id", "The global ID of the object."),
6201 ]),
6202 sql: "
6203SELECT quote_ident(md.name) || '.' || quote_ident(ms.name) || '.' || quote_ident(mo.name) AS name, mgi.global_id AS global_id
6204FROM mz_catalog.mz_objects mo
6205 JOIN mz_introspection.mz_compute_exports mce ON (mo.id = mce.export_id)
6206 JOIN mz_catalog.mz_schemas ms ON (mo.schema_id = ms.id)
6207 JOIN mz_catalog.mz_databases md ON (ms.database_id = md.id)
6208 JOIN mz_introspection.mz_dataflow_global_ids mgi ON (mce.dataflow_id = mgi.id);",
6209 access: vec![PUBLIC_SELECT],
6210}
6211});
6212
6213pub static MZ_LIR_MAPPING: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6214 name: "mz_lir_mapping",
6215 schema: MZ_INTROSPECTION_SCHEMA,
6216 oid: oid::VIEW_MZ_LIR_MAPPING_OID,
6217 desc: RelationDesc::builder()
6218 .with_column("global_id", SqlScalarType::String.nullable(false))
6219 .with_column("lir_id", SqlScalarType::UInt64.nullable(false))
6220 .with_column("operator", SqlScalarType::String.nullable(false))
6221 .with_column("parent_lir_id", SqlScalarType::UInt64.nullable(true))
6222 .with_column("nesting", SqlScalarType::UInt16.nullable(false))
6223 .with_column("operator_id_start", SqlScalarType::UInt64.nullable(false))
6224 .with_column("operator_id_end", SqlScalarType::UInt64.nullable(false))
6225 .finish(),
6226 column_comments: BTreeMap::from_iter([
6227 ("global_id", "The global ID."),
6228 ("lir_id", "The LIR node ID."),
6229 (
6230 "operator",
6231 "The LIR operator, in the format `OperatorName INPUTS [OPTIONS]`.",
6232 ),
6233 (
6234 "parent_lir_id",
6235 "The parent of this LIR node. May be `NULL`.",
6236 ),
6237 ("nesting", "The nesting level of this LIR node."),
6238 (
6239 "operator_id_start",
6240 "The first dataflow operator ID implementing this LIR operator (inclusive).",
6241 ),
6242 (
6243 "operator_id_end",
6244 "The first dataflow operator ID after this LIR operator (exclusive).",
6245 ),
6246 ]),
6247 sql: "
6248SELECT global_id, lir_id, operator, parent_lir_id, nesting, operator_id_start, operator_id_end
6249FROM mz_introspection.mz_compute_lir_mapping_per_worker
6250WHERE worker_id = 0",
6251 access: vec![PUBLIC_SELECT],
6252});
6253
6254pub static MZ_DATAFLOW_OPERATOR_DATAFLOWS_PER_WORKER: LazyLock<BuiltinView> =
6255 LazyLock::new(|| BuiltinView {
6256 name: "mz_dataflow_operator_dataflows_per_worker",
6257 schema: MZ_INTROSPECTION_SCHEMA,
6258 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_DATAFLOWS_PER_WORKER_OID,
6259 desc: RelationDesc::builder()
6260 .with_column("id", SqlScalarType::UInt64.nullable(false))
6261 .with_column("name", SqlScalarType::String.nullable(false))
6262 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6263 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6264 .with_column("dataflow_name", SqlScalarType::String.nullable(false))
6265 .finish(),
6266 column_comments: BTreeMap::new(),
6267 sql: "SELECT
6268 ops.id,
6269 ops.name,
6270 ops.worker_id,
6271 dfs.id as dataflow_id,
6272 dfs.name as dataflow_name
6273FROM
6274 mz_introspection.mz_dataflow_operators_per_worker ops,
6275 mz_introspection.mz_dataflow_addresses_per_worker addrs,
6276 mz_introspection.mz_dataflows_per_worker dfs
6277WHERE
6278 ops.id = addrs.id AND
6279 ops.worker_id = addrs.worker_id AND
6280 dfs.id = addrs.address[1] AND
6281 dfs.worker_id = addrs.worker_id",
6282 access: vec![PUBLIC_SELECT],
6283 });
6284
6285pub static MZ_DATAFLOW_OPERATOR_DATAFLOWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6286 name: "mz_dataflow_operator_dataflows",
6287 schema: MZ_INTROSPECTION_SCHEMA,
6288 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_DATAFLOWS_OID,
6289 desc: RelationDesc::builder()
6290 .with_column("id", SqlScalarType::UInt64.nullable(false))
6291 .with_column("name", SqlScalarType::String.nullable(false))
6292 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6293 .with_column("dataflow_name", SqlScalarType::String.nullable(false))
6294 .finish(),
6295 column_comments: BTreeMap::from_iter([
6296 (
6297 "id",
6298 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
6299 ),
6300 ("name", "The internal name of the operator."),
6301 (
6302 "dataflow_id",
6303 "The ID of the dataflow hosting the operator. Corresponds to `mz_dataflows.id`.",
6304 ),
6305 (
6306 "dataflow_name",
6307 "The internal name of the dataflow hosting the operator.",
6308 ),
6309 ]),
6310 sql: "
6311SELECT id, name, dataflow_id, dataflow_name
6312FROM mz_introspection.mz_dataflow_operator_dataflows_per_worker
6313WHERE worker_id = 0",
6314 access: vec![PUBLIC_SELECT],
6315});
6316
6317pub static MZ_OBJECT_TRANSITIVE_DEPENDENCIES: LazyLock<BuiltinView> = LazyLock::new(|| {
6318 BuiltinView {
6319 name: "mz_object_transitive_dependencies",
6320 schema: MZ_INTERNAL_SCHEMA,
6321 oid: oid::VIEW_MZ_OBJECT_TRANSITIVE_DEPENDENCIES_OID,
6322 desc: RelationDesc::builder()
6323 .with_column("object_id", SqlScalarType::String.nullable(false))
6324 .with_column(
6325 "referenced_object_id",
6326 SqlScalarType::String.nullable(false),
6327 )
6328 .with_key(vec![0, 1])
6329 .finish(),
6330 column_comments: BTreeMap::from_iter([
6331 (
6332 "object_id",
6333 "The ID of the dependent object. Corresponds to `mz_objects.id`.",
6334 ),
6335 (
6336 "referenced_object_id",
6337 "The ID of the (possibly transitively) referenced object. Corresponds to `mz_objects.id`.",
6338 ),
6339 ]),
6340 sql: "
6341WITH MUTUALLY RECURSIVE
6342 reach(object_id text, referenced_object_id text) AS (
6343 SELECT object_id, referenced_object_id FROM mz_internal.mz_object_dependencies
6344 UNION
6345 SELECT x, z FROM reach r1(x, y) JOIN reach r2(y, z) USING(y)
6346 )
6347SELECT object_id, referenced_object_id FROM reach;",
6348 access: vec![PUBLIC_SELECT],
6349 }
6350});
6351
6352pub static MZ_COMPUTE_EXPORTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6353 name: "mz_compute_exports",
6354 schema: MZ_INTROSPECTION_SCHEMA,
6355 oid: oid::VIEW_MZ_COMPUTE_EXPORTS_OID,
6356 desc: RelationDesc::builder()
6357 .with_column("export_id", SqlScalarType::String.nullable(false))
6358 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6359 .finish(),
6360 column_comments: BTreeMap::from_iter([
6361 (
6362 "export_id",
6363 "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`.",
6364 ),
6365 (
6366 "dataflow_id",
6367 "The ID of the dataflow. Corresponds to `mz_dataflows.id`.",
6368 ),
6369 ]),
6370 sql: "
6371SELECT export_id, dataflow_id
6372FROM mz_introspection.mz_compute_exports_per_worker
6373WHERE worker_id = 0",
6374 access: vec![PUBLIC_SELECT],
6375});
6376
6377pub static MZ_COMPUTE_FRONTIERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6378 name: "mz_compute_frontiers",
6379 schema: MZ_INTROSPECTION_SCHEMA,
6380 oid: oid::VIEW_MZ_COMPUTE_FRONTIERS_OID,
6381 desc: RelationDesc::builder()
6382 .with_column("export_id", SqlScalarType::String.nullable(false))
6383 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
6384 .with_key(vec![0])
6385 .finish(),
6386 column_comments: BTreeMap::from_iter([
6387 (
6388 "export_id",
6389 "The ID of the dataflow export. Corresponds to `mz_compute_exports.export_id`.",
6390 ),
6391 (
6392 "time",
6393 "The next timestamp at which the dataflow output may change.",
6394 ),
6395 ]),
6396 sql: "SELECT
6397 export_id, pg_catalog.min(time) AS time
6398FROM mz_introspection.mz_compute_frontiers_per_worker
6399GROUP BY export_id",
6400 access: vec![PUBLIC_SELECT],
6401});
6402
6403pub static MZ_DATAFLOW_CHANNEL_OPERATORS_PER_WORKER: LazyLock<BuiltinView> =
6404 LazyLock::new(|| BuiltinView {
6405 name: "mz_dataflow_channel_operators_per_worker",
6406 schema: MZ_INTROSPECTION_SCHEMA,
6407 oid: oid::VIEW_MZ_DATAFLOW_CHANNEL_OPERATORS_PER_WORKER_OID,
6408 desc: RelationDesc::builder()
6409 .with_column("id", SqlScalarType::UInt64.nullable(false))
6410 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6411 .with_column("from_operator_id", SqlScalarType::UInt64.nullable(true))
6412 .with_column(
6413 "from_operator_address",
6414 SqlScalarType::List {
6415 element_type: Box::new(SqlScalarType::UInt64),
6416 custom_id: None,
6417 }
6418 .nullable(true),
6419 )
6420 .with_column("to_operator_id", SqlScalarType::UInt64.nullable(true))
6421 .with_column(
6422 "to_operator_address",
6423 SqlScalarType::List {
6424 element_type: Box::new(SqlScalarType::UInt64),
6425 custom_id: None,
6426 }
6427 .nullable(true),
6428 )
6429 .with_column("type", SqlScalarType::String.nullable(false))
6430 .finish(),
6431 column_comments: BTreeMap::new(),
6432 sql: "
6433WITH
6434channel_addresses(id, worker_id, address, from_index, to_index, type) AS (
6435 SELECT id, worker_id, address, from_index, to_index, type
6436 FROM mz_introspection.mz_dataflow_channels_per_worker mdc
6437 INNER JOIN mz_introspection.mz_dataflow_addresses_per_worker mda
6438 USING (id, worker_id)
6439),
6440channel_operator_addresses(id, worker_id, from_address, to_address, type) AS (
6441 SELECT id, worker_id,
6442 address || from_index AS from_address,
6443 address || to_index AS to_address,
6444 type
6445 FROM channel_addresses
6446),
6447operator_addresses(id, worker_id, address) AS (
6448 SELECT id, worker_id, address
6449 FROM mz_introspection.mz_dataflow_addresses_per_worker mda
6450 INNER JOIN mz_introspection.mz_dataflow_operators_per_worker mdo
6451 USING (id, worker_id)
6452)
6453SELECT coa.id,
6454 coa.worker_id,
6455 from_ops.id AS from_operator_id,
6456 coa.from_address AS from_operator_address,
6457 to_ops.id AS to_operator_id,
6458 coa.to_address AS to_operator_address,
6459 coa.type
6460FROM channel_operator_addresses coa
6461 LEFT OUTER JOIN operator_addresses from_ops
6462 ON coa.from_address = from_ops.address AND
6463 coa.worker_id = from_ops.worker_id
6464 LEFT OUTER JOIN operator_addresses to_ops
6465 ON coa.to_address = to_ops.address AND
6466 coa.worker_id = to_ops.worker_id
6467",
6468 access: vec![PUBLIC_SELECT],
6469 });
6470
6471pub static MZ_DATAFLOW_CHANNEL_OPERATORS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6472 name: "mz_dataflow_channel_operators",
6473 schema: MZ_INTROSPECTION_SCHEMA,
6474 oid: oid::VIEW_MZ_DATAFLOW_CHANNEL_OPERATORS_OID,
6475 desc: RelationDesc::builder()
6476 .with_column("id", SqlScalarType::UInt64.nullable(false))
6477 .with_column("from_operator_id", SqlScalarType::UInt64.nullable(true))
6478 .with_column(
6479 "from_operator_address",
6480 SqlScalarType::List {
6481 element_type: Box::new(SqlScalarType::UInt64),
6482 custom_id: None,
6483 }
6484 .nullable(true),
6485 )
6486 .with_column("to_operator_id", SqlScalarType::UInt64.nullable(true))
6487 .with_column(
6488 "to_operator_address",
6489 SqlScalarType::List {
6490 element_type: Box::new(SqlScalarType::UInt64),
6491 custom_id: None,
6492 }
6493 .nullable(true),
6494 )
6495 .with_column("type", SqlScalarType::String.nullable(false))
6496 .finish(),
6497 column_comments: BTreeMap::from_iter([
6498 (
6499 "id",
6500 "The ID of the channel. Corresponds to `mz_dataflow_channels.id`.",
6501 ),
6502 (
6503 "from_operator_id",
6504 "The ID of the source of the channel. Corresponds to `mz_dataflow_operators.id`.",
6505 ),
6506 (
6507 "from_operator_address",
6508 "The address of the source of the channel. Corresponds to `mz_dataflow_addresses.address`.",
6509 ),
6510 (
6511 "to_operator_id",
6512 "The ID of the target of the channel. Corresponds to `mz_dataflow_operators.id`.",
6513 ),
6514 (
6515 "to_operator_address",
6516 "The address of the target of the channel. Corresponds to `mz_dataflow_addresses.address`.",
6517 ),
6518 ("type", "The container type of the channel."),
6519 ]),
6520 sql: "
6521SELECT id, from_operator_id, from_operator_address, to_operator_id, to_operator_address, type
6522FROM mz_introspection.mz_dataflow_channel_operators_per_worker
6523WHERE worker_id = 0",
6524 access: vec![PUBLIC_SELECT],
6525});
6526
6527pub static MZ_COMPUTE_IMPORT_FRONTIERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6528 name: "mz_compute_import_frontiers",
6529 schema: MZ_INTROSPECTION_SCHEMA,
6530 oid: oid::VIEW_MZ_COMPUTE_IMPORT_FRONTIERS_OID,
6531 desc: RelationDesc::builder()
6532 .with_column("export_id", SqlScalarType::String.nullable(false))
6533 .with_column("import_id", SqlScalarType::String.nullable(false))
6534 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
6535 .with_key(vec![0, 1])
6536 .finish(),
6537 column_comments: BTreeMap::from_iter([
6538 (
6539 "export_id",
6540 "The ID of the dataflow export. Corresponds to `mz_compute_exports.export_id`.",
6541 ),
6542 (
6543 "import_id",
6544 "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`.",
6545 ),
6546 (
6547 "time",
6548 "The next timestamp at which the dataflow input may change.",
6549 ),
6550 ]),
6551 sql: "SELECT
6552 export_id, import_id, pg_catalog.min(time) AS time
6553FROM mz_introspection.mz_compute_import_frontiers_per_worker
6554GROUP BY export_id, import_id",
6555 access: vec![PUBLIC_SELECT],
6556});
6557
6558pub static MZ_RECORDS_PER_DATAFLOW_OPERATOR_PER_WORKER: LazyLock<BuiltinView> =
6559 LazyLock::new(|| BuiltinView {
6560 name: "mz_records_per_dataflow_operator_per_worker",
6561 schema: MZ_INTROSPECTION_SCHEMA,
6562 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_OPERATOR_PER_WORKER_OID,
6563 desc: RelationDesc::builder()
6564 .with_column("id", SqlScalarType::UInt64.nullable(false))
6565 .with_column("name", SqlScalarType::String.nullable(false))
6566 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6567 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6568 .with_column("records", SqlScalarType::Int64.nullable(true))
6569 .with_column("batches", SqlScalarType::Int64.nullable(true))
6570 .with_column("size", SqlScalarType::Int64.nullable(true))
6571 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6572 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6573 .finish(),
6574 column_comments: BTreeMap::new(),
6575 sql: "
6576SELECT
6577 dod.id,
6578 dod.name,
6579 dod.worker_id,
6580 dod.dataflow_id,
6581 ar_size.records AS records,
6582 ar_size.batches AS batches,
6583 ar_size.size AS size,
6584 ar_size.capacity AS capacity,
6585 ar_size.allocations AS allocations
6586FROM
6587 mz_introspection.mz_dataflow_operator_dataflows_per_worker dod
6588 LEFT OUTER JOIN mz_introspection.mz_arrangement_sizes_per_worker ar_size ON
6589 dod.id = ar_size.operator_id AND
6590 dod.worker_id = ar_size.worker_id",
6591 access: vec![PUBLIC_SELECT],
6592 });
6593
6594pub static MZ_RECORDS_PER_DATAFLOW_OPERATOR: LazyLock<BuiltinView> =
6595 LazyLock::new(|| BuiltinView {
6596 name: "mz_records_per_dataflow_operator",
6597 schema: MZ_INTROSPECTION_SCHEMA,
6598 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_OPERATOR_OID,
6599 desc: RelationDesc::builder()
6600 .with_column("id", SqlScalarType::UInt64.nullable(false))
6601 .with_column("name", SqlScalarType::String.nullable(false))
6602 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6603 .with_column("records", SqlScalarType::Int64.nullable(true))
6604 .with_column("batches", SqlScalarType::Int64.nullable(true))
6605 .with_column("size", SqlScalarType::Int64.nullable(true))
6606 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6607 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6608 .with_key(vec![0, 1, 2])
6609 .finish(),
6610 column_comments: BTreeMap::from_iter([
6611 (
6612 "id",
6613 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
6614 ),
6615 ("name", "The internal name of the operator."),
6616 (
6617 "dataflow_id",
6618 "The ID of the dataflow. Corresponds to `mz_dataflows.id`.",
6619 ),
6620 ("records", "The number of records in the operator."),
6621 ("batches", "The number of batches in the dataflow."),
6622 ("size", "The utilized size in bytes of the arrangement."),
6623 (
6624 "capacity",
6625 "The capacity in bytes of the arrangement. Can be larger than the size.",
6626 ),
6627 (
6628 "allocations",
6629 "The number of separate memory allocations backing the arrangement.",
6630 ),
6631 ]),
6632 sql: "
6633SELECT
6634 id,
6635 name,
6636 dataflow_id,
6637 SUM(records)::int8 AS records,
6638 SUM(batches)::int8 AS batches,
6639 SUM(size)::int8 AS size,
6640 SUM(capacity)::int8 AS capacity,
6641 SUM(allocations)::int8 AS allocations
6642FROM mz_introspection.mz_records_per_dataflow_operator_per_worker
6643GROUP BY id, name, dataflow_id",
6644 access: vec![PUBLIC_SELECT],
6645 });
6646
6647pub static MZ_RECORDS_PER_DATAFLOW_PER_WORKER: LazyLock<BuiltinView> =
6648 LazyLock::new(|| BuiltinView {
6649 name: "mz_records_per_dataflow_per_worker",
6650 schema: MZ_INTROSPECTION_SCHEMA,
6651 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_PER_WORKER_OID,
6652 desc: RelationDesc::builder()
6653 .with_column("id", SqlScalarType::UInt64.nullable(false))
6654 .with_column("name", SqlScalarType::String.nullable(false))
6655 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6656 .with_column("records", SqlScalarType::Int64.nullable(true))
6657 .with_column("batches", SqlScalarType::Int64.nullable(true))
6658 .with_column("size", SqlScalarType::Int64.nullable(true))
6659 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6660 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6661 .with_key(vec![0, 1, 2])
6662 .finish(),
6663 column_comments: BTreeMap::new(),
6664 sql: "
6665SELECT
6666 rdo.dataflow_id as id,
6667 dfs.name,
6668 rdo.worker_id,
6669 SUM(rdo.records)::int8 as records,
6670 SUM(rdo.batches)::int8 as batches,
6671 SUM(rdo.size)::int8 as size,
6672 SUM(rdo.capacity)::int8 as capacity,
6673 SUM(rdo.allocations)::int8 as allocations
6674FROM
6675 mz_introspection.mz_records_per_dataflow_operator_per_worker rdo,
6676 mz_introspection.mz_dataflows_per_worker dfs
6677WHERE
6678 rdo.dataflow_id = dfs.id AND
6679 rdo.worker_id = dfs.worker_id
6680GROUP BY
6681 rdo.dataflow_id,
6682 dfs.name,
6683 rdo.worker_id",
6684 access: vec![PUBLIC_SELECT],
6685 });
6686
6687pub static MZ_RECORDS_PER_DATAFLOW: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6688 name: "mz_records_per_dataflow",
6689 schema: MZ_INTROSPECTION_SCHEMA,
6690 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_OID,
6691 desc: RelationDesc::builder()
6692 .with_column("id", SqlScalarType::UInt64.nullable(false))
6693 .with_column("name", SqlScalarType::String.nullable(false))
6694 .with_column("records", SqlScalarType::Int64.nullable(true))
6695 .with_column("batches", SqlScalarType::Int64.nullable(true))
6696 .with_column("size", SqlScalarType::Int64.nullable(true))
6697 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6698 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6699 .with_key(vec![0, 1])
6700 .finish(),
6701 column_comments: BTreeMap::from_iter([
6702 (
6703 "id",
6704 "The ID of the dataflow. Corresponds to `mz_dataflows.id`.",
6705 ),
6706 ("name", "The internal name of the dataflow."),
6707 ("records", "The number of records in the dataflow."),
6708 ("batches", "The number of batches in the dataflow."),
6709 ("size", "The utilized size in bytes of the arrangements."),
6710 (
6711 "capacity",
6712 "The capacity in bytes of the arrangements. Can be larger than the size.",
6713 ),
6714 (
6715 "allocations",
6716 "The number of separate memory allocations backing the arrangements.",
6717 ),
6718 ]),
6719 sql: "
6720SELECT
6721 id,
6722 name,
6723 SUM(records)::int8 as records,
6724 SUM(batches)::int8 as batches,
6725 SUM(size)::int8 as size,
6726 SUM(capacity)::int8 as capacity,
6727 SUM(allocations)::int8 as allocations
6728FROM
6729 mz_introspection.mz_records_per_dataflow_per_worker
6730GROUP BY
6731 id,
6732 name",
6733 access: vec![PUBLIC_SELECT],
6734});
6735
6736pub static PG_NAMESPACE_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6742 name: "pg_namespace_all_databases",
6743 schema: MZ_INTERNAL_SCHEMA,
6744 oid: oid::VIEW_PG_NAMESPACE_ALL_DATABASES_OID,
6745 desc: RelationDesc::builder()
6746 .with_column("oid", SqlScalarType::Oid.nullable(false))
6747 .with_column("nspname", SqlScalarType::String.nullable(false))
6748 .with_column("nspowner", SqlScalarType::Oid.nullable(false))
6749 .with_column(
6750 "nspacl",
6751 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
6752 )
6753 .with_column("database_name", SqlScalarType::String.nullable(true))
6754 .finish(),
6755 column_comments: BTreeMap::new(),
6756 sql: "
6757SELECT
6758 s.oid AS oid,
6759 s.name AS nspname,
6760 role_owner.oid AS nspowner,
6761 NULL::pg_catalog.text[] AS nspacl,
6762 d.name as database_name
6763FROM mz_catalog.mz_schemas s
6764LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
6765JOIN mz_catalog.mz_roles role_owner ON role_owner.id = s.owner_id",
6766 access: vec![PUBLIC_SELECT],
6767});
6768
6769pub const PG_NAMESPACE_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
6770 name: "pg_namespace_all_databases_ind",
6771 schema: MZ_INTERNAL_SCHEMA,
6772 oid: oid::INDEX_PG_NAMESPACE_ALL_DATABASES_IND_OID,
6773 sql: "IN CLUSTER mz_catalog_server
6774ON mz_internal.pg_namespace_all_databases (nspname)",
6775 is_retained_metrics_object: false,
6776};
6777
6778pub static PG_NAMESPACE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6779 name: "pg_namespace",
6780 schema: PG_CATALOG_SCHEMA,
6781 oid: oid::VIEW_PG_NAMESPACE_OID,
6782 desc: RelationDesc::builder()
6783 .with_column("oid", SqlScalarType::Oid.nullable(false))
6784 .with_column("nspname", SqlScalarType::String.nullable(false))
6785 .with_column("nspowner", SqlScalarType::Oid.nullable(false))
6786 .with_column(
6787 "nspacl",
6788 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
6789 )
6790 .finish(),
6791 column_comments: BTreeMap::new(),
6792 sql: "
6793SELECT
6794 oid, nspname, nspowner, nspacl
6795FROM mz_internal.pg_namespace_all_databases
6796WHERE database_name IS NULL OR database_name = pg_catalog.current_database();",
6797 access: vec![PUBLIC_SELECT],
6798});
6799
6800pub static PG_CLASS_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
6806 BuiltinView {
6807 name: "pg_class_all_databases",
6808 schema: MZ_INTERNAL_SCHEMA,
6809 oid: oid::VIEW_PG_CLASS_ALL_DATABASES_OID,
6810 desc: RelationDesc::builder()
6811 .with_column("oid", SqlScalarType::Oid.nullable(false))
6812 .with_column("relname", SqlScalarType::String.nullable(false))
6813 .with_column("relnamespace", SqlScalarType::Oid.nullable(false))
6814 .with_column("reloftype", SqlScalarType::Oid.nullable(false))
6815 .with_column("relowner", SqlScalarType::Oid.nullable(false))
6816 .with_column("relam", SqlScalarType::Oid.nullable(false))
6817 .with_column("reltablespace", SqlScalarType::Oid.nullable(false))
6818 .with_column("reltuples", SqlScalarType::Float32.nullable(false))
6819 .with_column("reltoastrelid", SqlScalarType::Oid.nullable(false))
6820 .with_column("relhasindex", SqlScalarType::Bool.nullable(false))
6821 .with_column("relpersistence", SqlScalarType::PgLegacyChar.nullable(false))
6822 .with_column("relkind", SqlScalarType::String.nullable(true))
6823 .with_column("relnatts", SqlScalarType::Int16.nullable(false))
6824 .with_column("relchecks", SqlScalarType::Int16.nullable(false))
6825 .with_column("relhasrules", SqlScalarType::Bool.nullable(false))
6826 .with_column("relhastriggers", SqlScalarType::Bool.nullable(false))
6827 .with_column("relhassubclass", SqlScalarType::Bool.nullable(false))
6828 .with_column("relrowsecurity", SqlScalarType::Bool.nullable(false))
6829 .with_column("relforcerowsecurity", SqlScalarType::Bool.nullable(false))
6830 .with_column("relreplident", SqlScalarType::PgLegacyChar.nullable(false))
6831 .with_column("relispartition", SqlScalarType::Bool.nullable(false))
6832 .with_column("relhasoids", SqlScalarType::Bool.nullable(false))
6833 .with_column("reloptions", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true))
6834 .with_column("database_name", SqlScalarType::String.nullable(true))
6835 .finish(),
6836 column_comments: BTreeMap::new(),
6837 sql: "
6838SELECT
6839 class_objects.oid,
6840 class_objects.name AS relname,
6841 mz_schemas.oid AS relnamespace,
6842 -- MZ doesn't support typed tables so reloftype is filled with 0
6843 0::pg_catalog.oid AS reloftype,
6844 role_owner.oid AS relowner,
6845 0::pg_catalog.oid AS relam,
6846 -- MZ doesn't have tablespaces so reltablespace is filled in with 0 implying the default tablespace
6847 0::pg_catalog.oid AS reltablespace,
6848 -- MZ doesn't support (estimated) row counts currently.
6849 -- Postgres defines a value of -1 as unknown.
6850 -1::float4 as reltuples,
6851 -- MZ doesn't use TOAST tables so reltoastrelid is filled with 0
6852 0::pg_catalog.oid AS reltoastrelid,
6853 EXISTS (SELECT id, oid, name, on_id, cluster_id FROM mz_catalog.mz_indexes where mz_indexes.on_id = class_objects.id) AS relhasindex,
6854 -- MZ doesn't have unlogged tables and because of (https://github.com/MaterializeInc/database-issues/issues/2689)
6855 -- temporary objects don't show up here, so relpersistence is filled with 'p' for permanent.
6856 -- TODO(jkosh44): update this column when issue is resolved.
6857 'p'::pg_catalog.\"char\" AS relpersistence,
6858 CASE
6859 WHEN class_objects.type = 'table' THEN 'r'
6860 WHEN class_objects.type = 'source' THEN 'r'
6861 WHEN class_objects.type = 'index' THEN 'i'
6862 WHEN class_objects.type = 'view' THEN 'v'
6863 WHEN class_objects.type = 'materialized-view' THEN 'm'
6864 END relkind,
6865 COALESCE(
6866 (
6867 SELECT count(*)::pg_catalog.int2
6868 FROM mz_catalog.mz_columns
6869 WHERE mz_columns.id = class_objects.id
6870 ),
6871 0::pg_catalog.int2
6872 ) AS relnatts,
6873 -- MZ doesn't support CHECK constraints so relchecks is filled with 0
6874 0::pg_catalog.int2 AS relchecks,
6875 -- MZ doesn't support creating rules so relhasrules is filled with false
6876 false AS relhasrules,
6877 -- MZ doesn't support creating triggers so relhastriggers is filled with false
6878 false AS relhastriggers,
6879 -- MZ doesn't support table inheritance or partitions so relhassubclass is filled with false
6880 false AS relhassubclass,
6881 -- MZ doesn't have row level security so relrowsecurity and relforcerowsecurity is filled with false
6882 false AS relrowsecurity,
6883 false AS relforcerowsecurity,
6884 -- MZ doesn't support replication so relreplident is filled with 'd' for default
6885 'd'::pg_catalog.\"char\" AS relreplident,
6886 -- MZ doesn't support table partitioning so relispartition is filled with false
6887 false AS relispartition,
6888 -- PG removed relhasoids in v12 so it's filled with false
6889 false AS relhasoids,
6890 -- MZ doesn't support options for relations
6891 NULL::pg_catalog.text[] as reloptions,
6892 d.name as database_name
6893FROM (
6894 -- pg_class catalogs relations and indexes
6895 SELECT id, oid, schema_id, name, type, owner_id FROM mz_catalog.mz_relations
6896 UNION ALL
6897 SELECT mz_indexes.id, mz_indexes.oid, mz_relations.schema_id, mz_indexes.name, 'index' AS type, mz_indexes.owner_id
6898 FROM mz_catalog.mz_indexes
6899 JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
6900) AS class_objects
6901JOIN mz_catalog.mz_schemas ON mz_schemas.id = class_objects.schema_id
6902LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
6903JOIN mz_catalog.mz_roles role_owner ON role_owner.id = class_objects.owner_id",
6904 access: vec![PUBLIC_SELECT],
6905 }
6906});
6907
6908pub const PG_CLASS_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
6909 name: "pg_class_all_databases_ind",
6910 schema: MZ_INTERNAL_SCHEMA,
6911 oid: oid::INDEX_PG_CLASS_ALL_DATABASES_IND_OID,
6912 sql: "IN CLUSTER mz_catalog_server
6913ON mz_internal.pg_class_all_databases (relname)",
6914 is_retained_metrics_object: false,
6915};
6916
6917pub static PG_CLASS: LazyLock<BuiltinView> = LazyLock::new(|| {
6918 BuiltinView {
6919 name: "pg_class",
6920 schema: PG_CATALOG_SCHEMA,
6921 oid: oid::VIEW_PG_CLASS_OID,
6922 desc: RelationDesc::builder()
6923 .with_column("oid", SqlScalarType::Oid.nullable(false))
6924 .with_column("relname", SqlScalarType::String.nullable(false))
6925 .with_column("relnamespace", SqlScalarType::Oid.nullable(false))
6926 .with_column("reloftype", SqlScalarType::Oid.nullable(false))
6927 .with_column("relowner", SqlScalarType::Oid.nullable(false))
6928 .with_column("relam", SqlScalarType::Oid.nullable(false))
6929 .with_column("reltablespace", SqlScalarType::Oid.nullable(false))
6930 .with_column("reltuples", SqlScalarType::Float32.nullable(false))
6931 .with_column("reltoastrelid", SqlScalarType::Oid.nullable(false))
6932 .with_column("relhasindex", SqlScalarType::Bool.nullable(false))
6933 .with_column("relpersistence", SqlScalarType::PgLegacyChar.nullable(false))
6934 .with_column("relkind", SqlScalarType::String.nullable(true))
6935 .with_column("relnatts", SqlScalarType::Int16.nullable(false))
6936 .with_column("relchecks", SqlScalarType::Int16.nullable(false))
6937 .with_column("relhasrules", SqlScalarType::Bool.nullable(false))
6938 .with_column("relhastriggers", SqlScalarType::Bool.nullable(false))
6939 .with_column("relhassubclass", SqlScalarType::Bool.nullable(false))
6940 .with_column("relrowsecurity", SqlScalarType::Bool.nullable(false))
6941 .with_column("relforcerowsecurity", SqlScalarType::Bool.nullable(false))
6942 .with_column("relreplident", SqlScalarType::PgLegacyChar.nullable(false))
6943 .with_column("relispartition", SqlScalarType::Bool.nullable(false))
6944 .with_column("relhasoids", SqlScalarType::Bool.nullable(false))
6945 .with_column(
6946 "reloptions",
6947 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
6948 )
6949 .finish(),
6950 column_comments: BTreeMap::new(),
6951 sql: "
6952SELECT
6953 oid, relname, relnamespace, reloftype, relowner, relam, reltablespace, reltuples, reltoastrelid,
6954 relhasindex, relpersistence, relkind, relnatts, relchecks, relhasrules, relhastriggers, relhassubclass,
6955 relrowsecurity, relforcerowsecurity, relreplident, relispartition, relhasoids, reloptions
6956FROM mz_internal.pg_class_all_databases
6957WHERE database_name IS NULL OR database_name = pg_catalog.current_database();
6958",
6959 access: vec![PUBLIC_SELECT],
6960}
6961});
6962
6963pub static PG_DEPEND: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6964 name: "pg_depend",
6965 schema: PG_CATALOG_SCHEMA,
6966 oid: oid::VIEW_PG_DEPEND_OID,
6967 desc: RelationDesc::builder()
6968 .with_column("classid", SqlScalarType::Oid.nullable(true))
6969 .with_column("objid", SqlScalarType::Oid.nullable(false))
6970 .with_column("objsubid", SqlScalarType::Int32.nullable(false))
6971 .with_column("refclassid", SqlScalarType::Oid.nullable(true))
6972 .with_column("refobjid", SqlScalarType::Oid.nullable(false))
6973 .with_column("refobjsubid", SqlScalarType::Int32.nullable(false))
6974 .with_column("deptype", SqlScalarType::PgLegacyChar.nullable(false))
6975 .finish(),
6976 column_comments: BTreeMap::new(),
6977 sql: "
6978WITH class_objects AS (
6979 SELECT
6980 CASE
6981 WHEN type = 'table' THEN 'pg_tables'::pg_catalog.regclass::pg_catalog.oid
6982 WHEN type = 'source' THEN 'pg_tables'::pg_catalog.regclass::pg_catalog.oid
6983 WHEN type = 'view' THEN 'pg_views'::pg_catalog.regclass::pg_catalog.oid
6984 WHEN type = 'materialized-view' THEN 'pg_matviews'::pg_catalog.regclass::pg_catalog.oid
6985 END classid,
6986 id,
6987 oid,
6988 schema_id
6989 FROM mz_catalog.mz_relations
6990 UNION ALL
6991 SELECT
6992 'pg_index'::pg_catalog.regclass::pg_catalog.oid AS classid,
6993 i.id,
6994 i.oid,
6995 r.schema_id
6996 FROM mz_catalog.mz_indexes i
6997 JOIN mz_catalog.mz_relations r ON i.on_id = r.id
6998),
6999
7000current_objects AS (
7001 SELECT class_objects.*
7002 FROM class_objects
7003 JOIN mz_catalog.mz_schemas ON mz_schemas.id = class_objects.schema_id
7004 LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
7005 -- This filter is tricky, as it filters out not just objects outside the
7006 -- database, but *dependencies* on objects outside this database. It's not
7007 -- clear that this is the right choice, but because PostgreSQL doesn't
7008 -- support cross-database references, it's not clear that the other choice
7009 -- is better.
7010 WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()
7011)
7012
7013SELECT
7014 objects.classid::pg_catalog.oid,
7015 objects.oid::pg_catalog.oid AS objid,
7016 0::pg_catalog.int4 AS objsubid,
7017 dependents.classid::pg_catalog.oid AS refclassid,
7018 dependents.oid::pg_catalog.oid AS refobjid,
7019 0::pg_catalog.int4 AS refobjsubid,
7020 'n'::pg_catalog.char AS deptype
7021FROM mz_internal.mz_object_dependencies
7022JOIN current_objects objects ON object_id = objects.id
7023JOIN current_objects dependents ON referenced_object_id = dependents.id",
7024 access: vec![PUBLIC_SELECT],
7025});
7026
7027pub static PG_DATABASE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7028 name: "pg_database",
7029 schema: PG_CATALOG_SCHEMA,
7030 oid: oid::VIEW_PG_DATABASE_OID,
7031 desc: RelationDesc::builder()
7032 .with_column("oid", SqlScalarType::Oid.nullable(false))
7033 .with_column("datname", SqlScalarType::String.nullable(false))
7034 .with_column("datdba", SqlScalarType::Oid.nullable(false))
7035 .with_column("encoding", SqlScalarType::Int32.nullable(false))
7036 .with_column("datistemplate", SqlScalarType::Bool.nullable(false))
7037 .with_column("datallowconn", SqlScalarType::Bool.nullable(false))
7038 .with_column("datcollate", SqlScalarType::String.nullable(false))
7039 .with_column("datctype", SqlScalarType::String.nullable(false))
7040 .with_column(
7041 "datacl",
7042 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
7043 )
7044 .with_key(vec![0])
7045 .finish(),
7046 column_comments: BTreeMap::new(),
7047 sql: "SELECT
7048 d.oid as oid,
7049 d.name as datname,
7050 role_owner.oid as datdba,
7051 6 as encoding,
7052 -- Materialize doesn't support database cloning.
7053 FALSE AS datistemplate,
7054 TRUE AS datallowconn,
7055 'C' as datcollate,
7056 'C' as datctype,
7057 NULL::pg_catalog.text[] as datacl
7058FROM mz_catalog.mz_databases d
7059JOIN mz_catalog.mz_roles role_owner ON role_owner.id = d.owner_id",
7060 access: vec![PUBLIC_SELECT],
7061});
7062
7063pub static PG_INDEX: LazyLock<BuiltinView> = LazyLock::new(|| {
7064 BuiltinView {
7065 name: "pg_index",
7066 schema: PG_CATALOG_SCHEMA,
7067 oid: oid::VIEW_PG_INDEX_OID,
7068 desc: RelationDesc::builder()
7069 .with_column("indexrelid", SqlScalarType::Oid.nullable(false))
7070 .with_column("indrelid", SqlScalarType::Oid.nullable(false))
7071 .with_column("indnatts", SqlScalarType::Int16.nullable(false))
7072 .with_column("indisunique", SqlScalarType::Bool.nullable(false))
7073 .with_column("indisprimary", SqlScalarType::Bool.nullable(false))
7074 .with_column("indimmediate", SqlScalarType::Bool.nullable(false))
7075 .with_column("indisclustered", SqlScalarType::Bool.nullable(false))
7076 .with_column("indisvalid", SqlScalarType::Bool.nullable(false))
7077 .with_column("indisreplident", SqlScalarType::Bool.nullable(false))
7078 .with_column("indkey", SqlScalarType::Int2Vector.nullable(false))
7079 .with_column("indoption", SqlScalarType::Int2Vector.nullable(false))
7080 .with_column("indexprs", SqlScalarType::String.nullable(true))
7081 .with_column("indpred", SqlScalarType::String.nullable(true))
7082 .with_key(vec![0, 1])
7083 .finish(),
7084 column_comments: BTreeMap::new(),
7085 sql: "SELECT
7086 mz_indexes.oid AS indexrelid,
7087 mz_relations.oid AS indrelid,
7088 COALESCE(
7089 (
7090 SELECT count(*)::pg_catalog.int2
7091 FROM mz_catalog.mz_columns
7092 JOIN mz_catalog.mz_relations mri ON mz_columns.id = mri.id
7093 WHERE mri.oid = mz_catalog.mz_relations.oid
7094 ),
7095 0::pg_catalog.int2
7096 ) AS indnatts,
7097 -- MZ doesn't support creating unique indexes so indisunique is filled with false
7098 false::pg_catalog.bool AS indisunique,
7099 false::pg_catalog.bool AS indisprimary,
7100 -- MZ doesn't support unique indexes so indimmediate is filled with false
7101 false::pg_catalog.bool AS indimmediate,
7102 -- MZ doesn't support CLUSTER so indisclustered is filled with false
7103 false::pg_catalog.bool AS indisclustered,
7104 -- MZ never creates invalid indexes so indisvalid is filled with true
7105 true::pg_catalog.bool AS indisvalid,
7106 -- MZ doesn't support replication so indisreplident is filled with false
7107 false::pg_catalog.bool AS indisreplident,
7108 -- Return zero if the index attribute is not a simple column reference, column position otherwise
7109 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,
7110 -- MZ doesn't have per-column flags, so returning a 0 for each column in the index
7111 pg_catalog.string_agg('0', ' ')::pg_catalog.int2vector AS indoption,
7112 -- Index expressions are returned in MZ format
7113 CASE pg_catalog.string_agg(mz_index_columns.on_expression, ' ' ORDER BY mz_index_columns.index_position::int8)
7114 WHEN NULL THEN NULL
7115 ELSE '{' || pg_catalog.string_agg(mz_index_columns.on_expression, '}, {' ORDER BY mz_index_columns.index_position::int8) || '}'
7116 END AS indexprs,
7117 -- MZ doesn't support indexes with predicates
7118 NULL::pg_catalog.text AS indpred
7119FROM mz_catalog.mz_indexes
7120JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
7121JOIN mz_catalog.mz_index_columns ON mz_index_columns.index_id = mz_indexes.id
7122JOIN mz_catalog.mz_schemas ON mz_schemas.id = mz_relations.schema_id
7123LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
7124WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()
7125GROUP BY mz_indexes.oid, mz_relations.oid",
7126 access: vec![PUBLIC_SELECT],
7127 }
7128});
7129
7130pub static PG_INDEXES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7131 name: "pg_indexes",
7132 schema: PG_CATALOG_SCHEMA,
7133 oid: oid::VIEW_PG_INDEXES_OID,
7134 desc: RelationDesc::builder()
7135 .with_column("table_catalog", SqlScalarType::String.nullable(false))
7136 .with_column("schemaname", SqlScalarType::String.nullable(false))
7137 .with_column("tablename", SqlScalarType::String.nullable(false))
7138 .with_column("indexname", SqlScalarType::String.nullable(false))
7139 .with_column("tablespace", SqlScalarType::String.nullable(true))
7140 .with_column("indexdef", SqlScalarType::String.nullable(true))
7141 .finish(),
7142 column_comments: BTreeMap::new(),
7143 sql: "SELECT
7144 current_database() as table_catalog,
7145 s.name AS schemaname,
7146 r.name AS tablename,
7147 i.name AS indexname,
7148 NULL::text AS tablespace,
7149 -- TODO(jkosh44) Fill in with actual index definition.
7150 NULL::text AS indexdef
7151FROM mz_catalog.mz_indexes i
7152JOIN mz_catalog.mz_relations r ON i.on_id = r.id
7153JOIN mz_catalog.mz_schemas s ON s.id = r.schema_id
7154LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
7155WHERE s.database_id IS NULL OR d.name = current_database()",
7156 access: vec![PUBLIC_SELECT],
7157});
7158
7159pub static PG_DESCRIPTION_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
7165 BuiltinView {
7166 name: "pg_description_all_databases",
7167 schema: MZ_INTERNAL_SCHEMA,
7168 oid: oid::VIEW_PG_DESCRIPTION_ALL_DATABASES_OID,
7169 desc: RelationDesc::builder()
7170 .with_column("objoid", SqlScalarType::Oid.nullable(false))
7171 .with_column("classoid", SqlScalarType::Oid.nullable(true))
7172 .with_column("objsubid", SqlScalarType::Int32.nullable(false))
7173 .with_column("description", SqlScalarType::String.nullable(false))
7174 .with_column("oid_database_name", SqlScalarType::String.nullable(true))
7175 .with_column("class_database_name", SqlScalarType::String.nullable(true))
7176 .finish(),
7177 column_comments: BTreeMap::new(),
7178 sql: "
7179(
7180 -- Gather all of the class oid's for objects that can have comments.
7181 WITH pg_classoids AS (
7182 SELECT oid, database_name as oid_database_name,
7183 (SELECT oid FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_class') AS classoid,
7184 (SELECT database_name FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_class') AS class_database_name
7185 FROM mz_internal.pg_class_all_databases
7186 UNION ALL
7187 SELECT oid, database_name as oid_database_name,
7188 (SELECT oid FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_type') AS classoid,
7189 (SELECT database_name FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_type') AS class_database_name
7190 FROM mz_internal.pg_type_all_databases
7191 UNION ALL
7192 SELECT oid, database_name as oid_database_name,
7193 (SELECT oid FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_namespace') AS classoid,
7194 (SELECT database_name FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_namespace') AS class_database_name
7195 FROM mz_internal.pg_namespace_all_databases
7196 ),
7197
7198 -- Gather all of the MZ ids for objects that can have comments.
7199 mz_objects AS (
7200 SELECT id, oid, type FROM mz_catalog.mz_objects
7201 UNION ALL
7202 SELECT id, oid, 'schema' AS type FROM mz_catalog.mz_schemas
7203 )
7204 SELECT
7205 pg_classoids.oid AS objoid,
7206 pg_classoids.classoid as classoid,
7207 COALESCE(cmt.object_sub_id, 0) AS objsubid,
7208 cmt.comment AS description,
7209 -- Columns added because of the peeling. (Note that there are 2 of these here.)
7210 oid_database_name,
7211 class_database_name
7212 FROM
7213 pg_classoids
7214 JOIN
7215 mz_objects ON pg_classoids.oid = mz_objects.oid
7216 JOIN
7217 mz_internal.mz_comments AS cmt ON mz_objects.id = cmt.id AND lower(mz_objects.type) = lower(cmt.object_type)
7218)",
7219 access: vec![PUBLIC_SELECT],
7220 }
7221});
7222
7223pub const PG_DESCRIPTION_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7224 name: "pg_description_all_databases_ind",
7225 schema: MZ_INTERNAL_SCHEMA,
7226 oid: oid::INDEX_PG_DESCRIPTION_ALL_DATABASES_IND_OID,
7227 sql: "IN CLUSTER mz_catalog_server
7228ON mz_internal.pg_description_all_databases (objoid, classoid, objsubid, description, oid_database_name, class_database_name)",
7229 is_retained_metrics_object: false,
7230};
7231
7232pub static PG_DESCRIPTION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7236 name: "pg_description",
7237 schema: PG_CATALOG_SCHEMA,
7238 oid: oid::VIEW_PG_DESCRIPTION_OID,
7239 desc: RelationDesc::builder()
7240 .with_column("objoid", SqlScalarType::Oid.nullable(false))
7241 .with_column("classoid", SqlScalarType::Oid.nullable(true))
7242 .with_column("objsubid", SqlScalarType::Int32.nullable(false))
7243 .with_column("description", SqlScalarType::String.nullable(false))
7244 .finish(),
7245 column_comments: BTreeMap::new(),
7246 sql: "
7247SELECT
7248 objoid,
7249 classoid,
7250 objsubid,
7251 description
7252FROM
7253 mz_internal.pg_description_all_databases
7254WHERE
7255 (oid_database_name IS NULL OR oid_database_name = pg_catalog.current_database()) AND
7256 (class_database_name IS NULL OR class_database_name = pg_catalog.current_database());",
7257 access: vec![PUBLIC_SELECT],
7258});
7259
7260pub static PG_TYPE_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
7266 BuiltinView {
7267 name: "pg_type_all_databases",
7268 schema: MZ_INTERNAL_SCHEMA,
7269 oid: oid::VIEW_PG_TYPE_ALL_DATABASES_OID,
7270 desc: RelationDesc::builder()
7271 .with_column("oid", SqlScalarType::Oid.nullable(false))
7272 .with_column("typname", SqlScalarType::String.nullable(false))
7273 .with_column("typnamespace", SqlScalarType::Oid.nullable(false))
7274 .with_column("typowner", SqlScalarType::Oid.nullable(false))
7275 .with_column("typlen", SqlScalarType::Int16.nullable(true))
7276 .with_column("typtype", SqlScalarType::PgLegacyChar.nullable(false))
7277 .with_column("typcategory", SqlScalarType::PgLegacyChar.nullable(true))
7278 .with_column("typdelim", SqlScalarType::PgLegacyChar.nullable(false))
7279 .with_column("typrelid", SqlScalarType::Oid.nullable(false))
7280 .with_column("typelem", SqlScalarType::Oid.nullable(false))
7281 .with_column("typarray", SqlScalarType::Oid.nullable(false))
7282 .with_column("typinput", SqlScalarType::RegProc.nullable(true))
7283 .with_column("typreceive", SqlScalarType::Oid.nullable(false))
7284 .with_column("typnotnull", SqlScalarType::Bool.nullable(false))
7285 .with_column("typbasetype", SqlScalarType::Oid.nullable(false))
7286 .with_column("typtypmod", SqlScalarType::Int32.nullable(false))
7287 .with_column("typcollation", SqlScalarType::Oid.nullable(false))
7288 .with_column("typdefault", SqlScalarType::String.nullable(true))
7289 .with_column("database_name", SqlScalarType::String.nullable(true))
7290 .finish(),
7291 column_comments: BTreeMap::new(),
7292 sql: "
7293SELECT
7294 mz_types.oid,
7295 mz_types.name AS typname,
7296 mz_schemas.oid AS typnamespace,
7297 role_owner.oid AS typowner,
7298 NULL::pg_catalog.int2 AS typlen,
7299 -- 'a' is used internally to denote an array type, but in postgres they show up
7300 -- as 'b'.
7301 (CASE mztype WHEN 'a' THEN 'b' ELSE mztype END)::pg_catalog.char AS typtype,
7302 (CASE category
7303 WHEN 'array' THEN 'A'
7304 WHEN 'bit-string' THEN 'V'
7305 WHEN 'boolean' THEN 'B'
7306 WHEN 'composite' THEN 'C'
7307 WHEN 'date-time' THEN 'D'
7308 WHEN 'enum' THEN 'E'
7309 WHEN 'geometric' THEN 'G'
7310 WHEN 'list' THEN 'U' -- List types are user-defined from PostgreSQL's perspective.
7311 WHEN 'network-address' THEN 'I'
7312 WHEN 'numeric' THEN 'N'
7313 WHEN 'pseudo' THEN 'P'
7314 WHEN 'string' THEN 'S'
7315 WHEN 'timespan' THEN 'T'
7316 WHEN 'user-defined' THEN 'U'
7317 WHEN 'unknown' THEN 'X'
7318 END)::pg_catalog.char AS typcategory,
7319 -- In pg only the 'box' type is not ','.
7320 ','::pg_catalog.char AS typdelim,
7321 0::pg_catalog.oid AS typrelid,
7322 coalesce(
7323 (
7324 SELECT t.oid
7325 FROM mz_catalog.mz_array_types a
7326 JOIN mz_catalog.mz_types t ON a.element_id = t.id
7327 WHERE a.id = mz_types.id
7328 ),
7329 0
7330 ) AS typelem,
7331 coalesce(
7332 (
7333 SELECT
7334 t.oid
7335 FROM
7336 mz_catalog.mz_array_types AS a
7337 JOIN mz_catalog.mz_types AS t ON a.id = t.id
7338 WHERE
7339 a.element_id = mz_types.id
7340 ),
7341 0
7342 )
7343 AS typarray,
7344 mz_internal.mz_type_pg_metadata.typinput::pg_catalog.regproc AS typinput,
7345 COALESCE(mz_internal.mz_type_pg_metadata.typreceive, 0) AS typreceive,
7346 false::pg_catalog.bool AS typnotnull,
7347 0::pg_catalog.oid AS typbasetype,
7348 -1::pg_catalog.int4 AS typtypmod,
7349 -- MZ doesn't support COLLATE so typcollation is filled with 0
7350 0::pg_catalog.oid AS typcollation,
7351 NULL::pg_catalog.text AS typdefault,
7352 d.name as database_name
7353FROM
7354 mz_catalog.mz_types
7355 LEFT JOIN mz_internal.mz_type_pg_metadata ON mz_catalog.mz_types.id = mz_internal.mz_type_pg_metadata.id
7356 JOIN mz_catalog.mz_schemas ON mz_schemas.id = mz_types.schema_id
7357 JOIN (
7358 -- 'a' is not a supported typtype, but we use it to denote an array. It is
7359 -- converted to the correct value above.
7360 SELECT id, 'a' AS mztype FROM mz_catalog.mz_array_types
7361 UNION ALL SELECT id, 'b' FROM mz_catalog.mz_base_types
7362 UNION ALL SELECT id, 'l' FROM mz_catalog.mz_list_types
7363 UNION ALL SELECT id, 'm' FROM mz_catalog.mz_map_types
7364 UNION ALL SELECT id, 'p' FROM mz_catalog.mz_pseudo_types
7365 )
7366 AS t ON mz_types.id = t.id
7367 LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
7368 JOIN mz_catalog.mz_roles role_owner ON role_owner.id = mz_types.owner_id",
7369 access: vec![PUBLIC_SELECT],
7370 }
7371});
7372
7373pub const PG_TYPE_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7374 name: "pg_type_all_databases_ind",
7375 schema: MZ_INTERNAL_SCHEMA,
7376 oid: oid::INDEX_PG_TYPE_ALL_DATABASES_IND_OID,
7377 sql: "IN CLUSTER mz_catalog_server
7378ON mz_internal.pg_type_all_databases (oid)",
7379 is_retained_metrics_object: false,
7380};
7381
7382pub static PG_TYPE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7383 name: "pg_type",
7384 schema: PG_CATALOG_SCHEMA,
7385 oid: oid::VIEW_PG_TYPE_OID,
7386 desc: RelationDesc::builder()
7387 .with_column("oid", SqlScalarType::Oid.nullable(false))
7388 .with_column("typname", SqlScalarType::String.nullable(false))
7389 .with_column("typnamespace", SqlScalarType::Oid.nullable(false))
7390 .with_column("typowner", SqlScalarType::Oid.nullable(false))
7391 .with_column("typlen", SqlScalarType::Int16.nullable(true))
7392 .with_column("typtype", SqlScalarType::PgLegacyChar.nullable(false))
7393 .with_column("typcategory", SqlScalarType::PgLegacyChar.nullable(true))
7394 .with_column("typdelim", SqlScalarType::PgLegacyChar.nullable(false))
7395 .with_column("typrelid", SqlScalarType::Oid.nullable(false))
7396 .with_column("typelem", SqlScalarType::Oid.nullable(false))
7397 .with_column("typarray", SqlScalarType::Oid.nullable(false))
7398 .with_column("typinput", SqlScalarType::RegProc.nullable(true))
7399 .with_column("typreceive", SqlScalarType::Oid.nullable(false))
7400 .with_column("typnotnull", SqlScalarType::Bool.nullable(false))
7401 .with_column("typbasetype", SqlScalarType::Oid.nullable(false))
7402 .with_column("typtypmod", SqlScalarType::Int32.nullable(false))
7403 .with_column("typcollation", SqlScalarType::Oid.nullable(false))
7404 .with_column("typdefault", SqlScalarType::String.nullable(true))
7405 .finish(),
7406 column_comments: BTreeMap::new(),
7407 sql: "SELECT
7408 oid, typname, typnamespace, typowner, typlen, typtype, typcategory, typdelim, typrelid, typelem,
7409 typarray, typinput, typreceive, typnotnull, typbasetype, typtypmod, typcollation, typdefault
7410FROM mz_internal.pg_type_all_databases
7411WHERE database_name IS NULL OR database_name = pg_catalog.current_database();",
7412 access: vec![PUBLIC_SELECT],
7413});
7414
7415pub static PG_ATTRIBUTE_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
7421 BuiltinView {
7422 name: "pg_attribute_all_databases",
7423 schema: MZ_INTERNAL_SCHEMA,
7424 oid: oid::VIEW_PG_ATTRIBUTE_ALL_DATABASES_OID,
7425 desc: RelationDesc::builder()
7426 .with_column("attrelid", SqlScalarType::Oid.nullable(false))
7427 .with_column("attname", SqlScalarType::String.nullable(false))
7428 .with_column("atttypid", SqlScalarType::Oid.nullable(false))
7429 .with_column("attlen", SqlScalarType::Int16.nullable(true))
7430 .with_column("attnum", SqlScalarType::Int16.nullable(false))
7431 .with_column("atttypmod", SqlScalarType::Int32.nullable(false))
7432 .with_column("attnotnull", SqlScalarType::Bool.nullable(false))
7433 .with_column("atthasdef", SqlScalarType::Bool.nullable(false))
7434 .with_column("attidentity", SqlScalarType::PgLegacyChar.nullable(false))
7435 .with_column("attgenerated", SqlScalarType::PgLegacyChar.nullable(false))
7436 .with_column("attisdropped", SqlScalarType::Bool.nullable(false))
7437 .with_column("attcollation", SqlScalarType::Oid.nullable(false))
7438 .with_column("database_name", SqlScalarType::String.nullable(true))
7439 .with_column("pg_type_database_name", SqlScalarType::String.nullable(true))
7440 .finish(),
7441 column_comments: BTreeMap::new(),
7442 sql: "
7443SELECT
7444 class_objects.oid as attrelid,
7445 mz_columns.name as attname,
7446 mz_columns.type_oid AS atttypid,
7447 pg_type_all_databases.typlen AS attlen,
7448 position::int8::int2 as attnum,
7449 mz_columns.type_mod as atttypmod,
7450 NOT nullable as attnotnull,
7451 mz_columns.default IS NOT NULL as atthasdef,
7452 ''::pg_catalog.\"char\" as attidentity,
7453 -- MZ doesn't support generated columns so attgenerated is filled with ''
7454 ''::pg_catalog.\"char\" as attgenerated,
7455 FALSE as attisdropped,
7456 -- MZ doesn't support COLLATE so attcollation is filled with 0
7457 0::pg_catalog.oid as attcollation,
7458 -- Columns added because of the peeling. (Note that there are 2 of these here.)
7459 d.name as database_name,
7460 pg_type_all_databases.database_name as pg_type_database_name
7461FROM (
7462 -- pg_attribute catalogs columns on relations and indexes
7463 SELECT id, oid, schema_id, name, type FROM mz_catalog.mz_relations
7464 UNION ALL
7465 SELECT mz_indexes.id, mz_indexes.oid, mz_relations.schema_id, mz_indexes.name, 'index' AS type
7466 FROM mz_catalog.mz_indexes
7467 JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
7468) AS class_objects
7469JOIN mz_catalog.mz_columns ON class_objects.id = mz_columns.id
7470JOIN mz_internal.pg_type_all_databases ON pg_type_all_databases.oid = mz_columns.type_oid
7471JOIN mz_catalog.mz_schemas ON mz_schemas.id = class_objects.schema_id
7472LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id",
7473 access: vec![PUBLIC_SELECT],
7476 }
7477});
7478
7479pub const PG_ATTRIBUTE_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7480 name: "pg_attribute_all_databases_ind",
7481 schema: MZ_INTERNAL_SCHEMA,
7482 oid: oid::INDEX_PG_ATTRIBUTE_ALL_DATABASES_IND_OID,
7483 sql: "IN CLUSTER mz_catalog_server
7484ON mz_internal.pg_attribute_all_databases (
7485 attrelid, attname, atttypid, attlen, attnum, atttypmod, attnotnull, atthasdef, attidentity,
7486 attgenerated, attisdropped, attcollation, database_name, pg_type_database_name
7487)",
7488 is_retained_metrics_object: false,
7489};
7490
7491pub static PG_ATTRIBUTE: LazyLock<BuiltinView> = LazyLock::new(|| {
7492 BuiltinView {
7493 name: "pg_attribute",
7494 schema: PG_CATALOG_SCHEMA,
7495 oid: oid::VIEW_PG_ATTRIBUTE_OID,
7496 desc: RelationDesc::builder()
7497 .with_column("attrelid", SqlScalarType::Oid.nullable(false))
7498 .with_column("attname", SqlScalarType::String.nullable(false))
7499 .with_column("atttypid", SqlScalarType::Oid.nullable(false))
7500 .with_column("attlen", SqlScalarType::Int16.nullable(true))
7501 .with_column("attnum", SqlScalarType::Int16.nullable(false))
7502 .with_column("atttypmod", SqlScalarType::Int32.nullable(false))
7503 .with_column("attnotnull", SqlScalarType::Bool.nullable(false))
7504 .with_column("atthasdef", SqlScalarType::Bool.nullable(false))
7505 .with_column("attidentity", SqlScalarType::PgLegacyChar.nullable(false))
7506 .with_column("attgenerated", SqlScalarType::PgLegacyChar.nullable(false))
7507 .with_column("attisdropped", SqlScalarType::Bool.nullable(false))
7508 .with_column("attcollation", SqlScalarType::Oid.nullable(false))
7509 .finish(),
7510 column_comments: BTreeMap::new(),
7511 sql: "
7512SELECT
7513 attrelid, attname, atttypid, attlen, attnum, atttypmod, attnotnull, atthasdef, attidentity,
7514 attgenerated, attisdropped, attcollation
7515FROM mz_internal.pg_attribute_all_databases
7516WHERE
7517 (database_name IS NULL OR database_name = pg_catalog.current_database()) AND
7518 (pg_type_database_name IS NULL OR pg_type_database_name = pg_catalog.current_database());",
7519 access: vec![PUBLIC_SELECT],
7522 }
7523});
7524
7525pub static PG_PROC: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7526 name: "pg_proc",
7527 schema: PG_CATALOG_SCHEMA,
7528 oid: oid::VIEW_PG_PROC_OID,
7529 desc: RelationDesc::builder()
7530 .with_column("oid", SqlScalarType::Oid.nullable(false))
7531 .with_column("proname", SqlScalarType::String.nullable(false))
7532 .with_column("pronamespace", SqlScalarType::Oid.nullable(false))
7533 .with_column("proowner", SqlScalarType::Oid.nullable(false))
7534 .with_column("proargdefaults", SqlScalarType::String.nullable(true))
7535 .with_column("prorettype", SqlScalarType::Oid.nullable(false))
7536 .finish(),
7537 column_comments: BTreeMap::new(),
7538 sql: "SELECT
7539 mz_functions.oid,
7540 mz_functions.name AS proname,
7541 mz_schemas.oid AS pronamespace,
7542 role_owner.oid AS proowner,
7543 NULL::pg_catalog.text AS proargdefaults,
7544 ret_type.oid AS prorettype
7545FROM mz_catalog.mz_functions
7546JOIN mz_catalog.mz_schemas ON mz_functions.schema_id = mz_schemas.id
7547LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
7548JOIN mz_catalog.mz_types AS ret_type ON mz_functions.return_type_id = ret_type.id
7549JOIN mz_catalog.mz_roles role_owner ON role_owner.id = mz_functions.owner_id
7550WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()",
7551 access: vec![PUBLIC_SELECT],
7552});
7553
7554pub static PG_OPERATOR: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7555 name: "pg_operator",
7556 schema: PG_CATALOG_SCHEMA,
7557 oid: oid::VIEW_PG_OPERATOR_OID,
7558 desc: RelationDesc::builder()
7559 .with_column("oid", SqlScalarType::Oid.nullable(false))
7560 .with_column("oprname", SqlScalarType::String.nullable(false))
7561 .with_column("oprresult", SqlScalarType::Oid.nullable(false))
7562 .with_column("oprleft", SqlScalarType::Oid.nullable(false))
7563 .with_column("oprright", SqlScalarType::Oid.nullable(false))
7564 .with_key(vec![0, 1, 2, 3, 4])
7565 .finish(),
7566 column_comments: BTreeMap::new(),
7567 sql: "SELECT
7568 mz_operators.oid,
7569 mz_operators.name AS oprname,
7570 ret_type.oid AS oprresult,
7571 left_type.oid as oprleft,
7572 right_type.oid as oprright
7573FROM mz_catalog.mz_operators
7574JOIN mz_catalog.mz_types AS ret_type ON mz_operators.return_type_id = ret_type.id
7575JOIN mz_catalog.mz_types AS left_type ON mz_operators.argument_type_ids[1] = left_type.id
7576JOIN mz_catalog.mz_types AS right_type ON mz_operators.argument_type_ids[2] = right_type.id
7577WHERE array_length(mz_operators.argument_type_ids, 1) = 2
7578UNION SELECT
7579 mz_operators.oid,
7580 mz_operators.name AS oprname,
7581 ret_type.oid AS oprresult,
7582 0 as oprleft,
7583 right_type.oid as oprright
7584FROM mz_catalog.mz_operators
7585JOIN mz_catalog.mz_types AS ret_type ON mz_operators.return_type_id = ret_type.id
7586JOIN mz_catalog.mz_types AS right_type ON mz_operators.argument_type_ids[1] = right_type.id
7587WHERE array_length(mz_operators.argument_type_ids, 1) = 1",
7588 access: vec![PUBLIC_SELECT],
7589});
7590
7591pub static PG_RANGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7592 name: "pg_range",
7593 schema: PG_CATALOG_SCHEMA,
7594 oid: oid::VIEW_PG_RANGE_OID,
7595 desc: RelationDesc::builder()
7596 .with_column("rngtypid", SqlScalarType::Oid.nullable(false))
7597 .with_column("rngsubtype", SqlScalarType::Oid.nullable(false))
7598 .with_key(vec![])
7599 .finish(),
7600 column_comments: BTreeMap::new(),
7601 sql: "SELECT
7602 NULL::pg_catalog.oid AS rngtypid,
7603 NULL::pg_catalog.oid AS rngsubtype
7604WHERE false",
7605 access: vec![PUBLIC_SELECT],
7606});
7607
7608pub static PG_ENUM: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7609 name: "pg_enum",
7610 schema: PG_CATALOG_SCHEMA,
7611 oid: oid::VIEW_PG_ENUM_OID,
7612 desc: RelationDesc::builder()
7613 .with_column("oid", SqlScalarType::Oid.nullable(false))
7614 .with_column("enumtypid", SqlScalarType::Oid.nullable(false))
7615 .with_column("enumsortorder", SqlScalarType::Float32.nullable(false))
7616 .with_column("enumlabel", SqlScalarType::String.nullable(false))
7617 .with_key(vec![])
7618 .finish(),
7619 column_comments: BTreeMap::new(),
7620 sql: "SELECT
7621 NULL::pg_catalog.oid AS oid,
7622 NULL::pg_catalog.oid AS enumtypid,
7623 NULL::pg_catalog.float4 AS enumsortorder,
7624 NULL::pg_catalog.text AS enumlabel
7625WHERE false",
7626 access: vec![PUBLIC_SELECT],
7627});
7628
7629pub static PG_ATTRDEF_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7633 name: "pg_attrdef_all_databases",
7634 schema: MZ_INTERNAL_SCHEMA,
7635 oid: oid::VIEW_PG_ATTRDEF_ALL_DATABASES_OID,
7636 desc: RelationDesc::builder()
7637 .with_column("oid", SqlScalarType::Oid.nullable(true))
7638 .with_column("adrelid", SqlScalarType::Oid.nullable(false))
7639 .with_column("adnum", SqlScalarType::Int64.nullable(false))
7640 .with_column("adbin", SqlScalarType::String.nullable(false))
7641 .with_column("adsrc", SqlScalarType::String.nullable(false))
7642 .finish(),
7643 column_comments: BTreeMap::new(),
7644 sql: "
7645SELECT
7646 NULL::pg_catalog.oid AS oid,
7647 mz_objects.oid AS adrelid,
7648 mz_columns.position::int8 AS adnum,
7649 mz_columns.default AS adbin,
7650 mz_columns.default AS adsrc
7651FROM mz_catalog.mz_columns
7652 JOIN mz_catalog.mz_objects ON mz_columns.id = mz_objects.id
7653WHERE default IS NOT NULL",
7654 access: vec![PUBLIC_SELECT],
7655});
7656
7657pub const PG_ATTRDEF_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7658 name: "pg_attrdef_all_databases_ind",
7659 schema: MZ_INTERNAL_SCHEMA,
7660 oid: oid::INDEX_PG_ATTRDEF_ALL_DATABASES_IND_OID,
7661 sql: "IN CLUSTER mz_catalog_server
7662ON mz_internal.pg_attrdef_all_databases (oid, adrelid, adnum, adbin, adsrc)",
7663 is_retained_metrics_object: false,
7664};
7665
7666pub static PG_ATTRDEF: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7667 name: "pg_attrdef",
7668 schema: PG_CATALOG_SCHEMA,
7669 oid: oid::VIEW_PG_ATTRDEF_OID,
7670 desc: RelationDesc::builder()
7671 .with_column("oid", SqlScalarType::Oid.nullable(true))
7672 .with_column("adrelid", SqlScalarType::Oid.nullable(false))
7673 .with_column("adnum", SqlScalarType::Int64.nullable(false))
7674 .with_column("adbin", SqlScalarType::String.nullable(false))
7675 .with_column("adsrc", SqlScalarType::String.nullable(false))
7676 .finish(),
7677 column_comments: BTreeMap::new(),
7678 sql: "
7679SELECT
7680 pg_attrdef_all_databases.oid as oid,
7681 adrelid,
7682 adnum,
7683 adbin,
7684 adsrc
7685FROM mz_internal.pg_attrdef_all_databases
7686 JOIN mz_catalog.mz_databases d ON (d.id IS NULL OR d.name = pg_catalog.current_database());",
7687 access: vec![PUBLIC_SELECT],
7688});
7689
7690pub static PG_SETTINGS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7691 name: "pg_settings",
7692 schema: PG_CATALOG_SCHEMA,
7693 oid: oid::VIEW_PG_SETTINGS_OID,
7694 desc: RelationDesc::builder()
7695 .with_column("name", SqlScalarType::String.nullable(false))
7696 .with_column("setting", SqlScalarType::String.nullable(false))
7697 .with_key(vec![])
7698 .finish(),
7699 column_comments: BTreeMap::new(),
7700 sql: "SELECT
7701 name, setting
7702FROM (VALUES
7703 ('max_index_keys'::pg_catalog.text, '1000'::pg_catalog.text)
7704) AS _ (name, setting)",
7705 access: vec![PUBLIC_SELECT],
7706});
7707
7708pub static PG_AUTH_MEMBERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7709 name: "pg_auth_members",
7710 schema: PG_CATALOG_SCHEMA,
7711 oid: oid::VIEW_PG_AUTH_MEMBERS_OID,
7712 desc: RelationDesc::builder()
7713 .with_column("roleid", SqlScalarType::Oid.nullable(false))
7714 .with_column("member", SqlScalarType::Oid.nullable(false))
7715 .with_column("grantor", SqlScalarType::Oid.nullable(false))
7716 .with_column("admin_option", SqlScalarType::Bool.nullable(false))
7717 .finish(),
7718 column_comments: BTreeMap::new(),
7719 sql: "SELECT
7720 role.oid AS roleid,
7721 member.oid AS member,
7722 grantor.oid AS grantor,
7723 -- Materialize hasn't implemented admin_option.
7724 false as admin_option
7725FROM mz_catalog.mz_role_members membership
7726JOIN mz_catalog.mz_roles role ON membership.role_id = role.id
7727JOIN mz_catalog.mz_roles member ON membership.member = member.id
7728JOIN mz_catalog.mz_roles grantor ON membership.grantor = grantor.id",
7729 access: vec![PUBLIC_SELECT],
7730});
7731
7732pub static PG_EVENT_TRIGGER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7733 name: "pg_event_trigger",
7734 schema: PG_CATALOG_SCHEMA,
7735 oid: oid::VIEW_PG_EVENT_TRIGGER_OID,
7736 desc: RelationDesc::builder()
7737 .with_column("oid", SqlScalarType::Oid.nullable(false))
7738 .with_column("evtname", SqlScalarType::String.nullable(false))
7739 .with_column("evtevent", SqlScalarType::String.nullable(false))
7740 .with_column("evtowner", SqlScalarType::Oid.nullable(false))
7741 .with_column("evtfoid", SqlScalarType::Oid.nullable(false))
7742 .with_column("evtenabled", SqlScalarType::PgLegacyChar.nullable(false))
7743 .with_column(
7744 "evttags",
7745 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
7746 )
7747 .with_key(vec![])
7748 .finish(),
7749 column_comments: BTreeMap::new(),
7750 sql: "SELECT
7751 NULL::pg_catalog.oid AS oid,
7752 NULL::pg_catalog.text AS evtname,
7753 NULL::pg_catalog.text AS evtevent,
7754 NULL::pg_catalog.oid AS evtowner,
7755 NULL::pg_catalog.oid AS evtfoid,
7756 NULL::pg_catalog.char AS evtenabled,
7757 NULL::pg_catalog.text[] AS evttags
7758 WHERE false",
7759 access: vec![PUBLIC_SELECT],
7760});
7761
7762pub static PG_LANGUAGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7763 name: "pg_language",
7764 schema: PG_CATALOG_SCHEMA,
7765 oid: oid::VIEW_PG_LANGUAGE_OID,
7766 desc: RelationDesc::builder()
7767 .with_column("oid", SqlScalarType::Oid.nullable(false))
7768 .with_column("lanname", SqlScalarType::String.nullable(false))
7769 .with_column("lanowner", SqlScalarType::Oid.nullable(false))
7770 .with_column("lanispl", SqlScalarType::Bool.nullable(false))
7771 .with_column("lanpltrusted", SqlScalarType::Bool.nullable(false))
7772 .with_column("lanplcallfoid", SqlScalarType::Oid.nullable(false))
7773 .with_column("laninline", SqlScalarType::Oid.nullable(false))
7774 .with_column("lanvalidator", SqlScalarType::Oid.nullable(false))
7775 .with_column(
7776 "lanacl",
7777 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
7778 )
7779 .with_key(vec![])
7780 .finish(),
7781 column_comments: BTreeMap::new(),
7782 sql: "SELECT
7783 NULL::pg_catalog.oid AS oid,
7784 NULL::pg_catalog.text AS lanname,
7785 NULL::pg_catalog.oid AS lanowner,
7786 NULL::pg_catalog.bool AS lanispl,
7787 NULL::pg_catalog.bool AS lanpltrusted,
7788 NULL::pg_catalog.oid AS lanplcallfoid,
7789 NULL::pg_catalog.oid AS laninline,
7790 NULL::pg_catalog.oid AS lanvalidator,
7791 NULL::pg_catalog.text[] AS lanacl
7792 WHERE false",
7793 access: vec![PUBLIC_SELECT],
7794});
7795
7796pub static PG_SHDESCRIPTION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7797 name: "pg_shdescription",
7798 schema: PG_CATALOG_SCHEMA,
7799 oid: oid::VIEW_PG_SHDESCRIPTION_OID,
7800 desc: RelationDesc::builder()
7801 .with_column("objoid", SqlScalarType::Oid.nullable(false))
7802 .with_column("classoid", SqlScalarType::Oid.nullable(false))
7803 .with_column("description", SqlScalarType::String.nullable(false))
7804 .with_key(vec![])
7805 .finish(),
7806 column_comments: BTreeMap::new(),
7807 sql: "SELECT
7808 NULL::pg_catalog.oid AS objoid,
7809 NULL::pg_catalog.oid AS classoid,
7810 NULL::pg_catalog.text AS description
7811 WHERE false",
7812 access: vec![PUBLIC_SELECT],
7813});
7814
7815pub static PG_TIMEZONE_ABBREVS: LazyLock<BuiltinView> = LazyLock::new(|| {
7816 BuiltinView {
7817 name: "pg_timezone_abbrevs",
7818 schema: PG_CATALOG_SCHEMA,
7819 oid: oid::VIEW_PG_TIMEZONE_ABBREVS_OID,
7820 desc: RelationDesc::builder()
7821 .with_column("abbrev", SqlScalarType::String.nullable(false))
7822 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
7823 .with_column("is_dst", SqlScalarType::Bool.nullable(true))
7824 .with_key(vec![0])
7825 .finish(),
7826 column_comments: BTreeMap::new(),
7827 sql: "SELECT
7828 abbreviation AS abbrev,
7829 COALESCE(utc_offset, timezone_offset(timezone_name, now()).base_utc_offset + timezone_offset(timezone_name, now()).dst_offset)
7830 AS utc_offset,
7831 COALESCE(dst, timezone_offset(timezone_name, now()).dst_offset <> INTERVAL '0')
7832 AS is_dst
7833FROM mz_catalog.mz_timezone_abbreviations",
7834 access: vec![PUBLIC_SELECT],
7835 }
7836});
7837
7838pub static PG_TIMEZONE_NAMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7839 name: "pg_timezone_names",
7840 schema: PG_CATALOG_SCHEMA,
7841 oid: oid::VIEW_PG_TIMEZONE_NAMES_OID,
7842 desc: RelationDesc::builder()
7843 .with_column("name", SqlScalarType::String.nullable(false))
7844 .with_column("abbrev", SqlScalarType::String.nullable(true))
7845 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
7846 .with_column("is_dst", SqlScalarType::Bool.nullable(true))
7847 .with_key(vec![0])
7848 .finish(),
7849 column_comments: BTreeMap::new(),
7850 sql: "SELECT
7851 name,
7852 timezone_offset(name, now()).abbrev AS abbrev,
7853 timezone_offset(name, now()).base_utc_offset + timezone_offset(name, now()).dst_offset
7854 AS utc_offset,
7855 timezone_offset(name, now()).dst_offset <> INTERVAL '0'
7856 AS is_dst
7857FROM mz_catalog.mz_timezone_names",
7858 access: vec![PUBLIC_SELECT],
7859});
7860
7861pub static MZ_TIMEZONE_ABBREVIATIONS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7862 name: "mz_timezone_abbreviations",
7863 schema: MZ_CATALOG_SCHEMA,
7864 oid: oid::VIEW_MZ_TIMEZONE_ABBREVIATIONS_OID,
7865 desc: RelationDesc::builder()
7866 .with_column("abbreviation", SqlScalarType::String.nullable(false))
7867 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
7868 .with_column("dst", SqlScalarType::Bool.nullable(true))
7869 .with_column("timezone_name", SqlScalarType::String.nullable(true))
7870 .with_key(vec![0])
7871 .finish(),
7872 column_comments: BTreeMap::from_iter([
7873 ("abbreviation", "The timezone abbreviation."),
7874 (
7875 "utc_offset",
7876 "The UTC offset of the timezone or `NULL` if fixed.",
7877 ),
7878 (
7879 "dst",
7880 "Whether the timezone is in daylight savings or `NULL` if fixed.",
7881 ),
7882 (
7883 "timezone_name",
7884 "The full name of the non-fixed timezone or `NULL` if not fixed.",
7885 ),
7886 ]),
7887 sql: format!(
7888 "SELECT * FROM ({}) _ (abbreviation, utc_offset, dst, timezone_name)",
7889 mz_pgtz::abbrev::MZ_CATALOG_TIMEZONE_ABBREVIATIONS_SQL,
7890 )
7891 .leak(),
7892 access: vec![PUBLIC_SELECT],
7893});
7894
7895pub static MZ_TIMEZONE_NAMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7896 name: "mz_timezone_names",
7897 schema: MZ_CATALOG_SCHEMA,
7898 oid: oid::VIEW_MZ_TIMEZONE_NAMES_OID,
7899 desc: RelationDesc::builder()
7900 .with_column("name", SqlScalarType::String.nullable(false))
7901 .with_key(vec![0])
7902 .finish(),
7903 column_comments: BTreeMap::from_iter([("name", "The timezone name.")]),
7904 sql: format!(
7905 "SELECT * FROM ({}) _ (name)",
7906 mz_pgtz::timezone::MZ_CATALOG_TIMEZONE_NAMES_SQL,
7907 )
7908 .leak(),
7909 access: vec![PUBLIC_SELECT],
7910});
7911
7912pub static MZ_PEEK_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
7913 LazyLock::new(|| BuiltinView {
7914 name: "mz_peek_durations_histogram_per_worker",
7915 schema: MZ_INTROSPECTION_SCHEMA,
7916 oid: oid::VIEW_MZ_PEEK_DURATIONS_HISTOGRAM_PER_WORKER_OID,
7917 desc: RelationDesc::builder()
7918 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
7919 .with_column("type", SqlScalarType::String.nullable(false))
7920 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7921 .with_column("count", SqlScalarType::Int64.nullable(false))
7922 .with_key(vec![0, 1, 2])
7923 .finish(),
7924 column_comments: BTreeMap::new(),
7925 sql: "SELECT
7926 worker_id, type, duration_ns, pg_catalog.count(*) AS count
7927FROM
7928 mz_introspection.mz_peek_durations_histogram_raw
7929GROUP BY
7930 worker_id, type, duration_ns",
7931 access: vec![PUBLIC_SELECT],
7932 });
7933
7934pub static MZ_PEEK_DURATIONS_HISTOGRAM: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7935 name: "mz_peek_durations_histogram",
7936 schema: MZ_INTROSPECTION_SCHEMA,
7937 oid: oid::VIEW_MZ_PEEK_DURATIONS_HISTOGRAM_OID,
7938 desc: RelationDesc::builder()
7939 .with_column("type", SqlScalarType::String.nullable(false))
7940 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7941 .with_column(
7942 "count",
7943 SqlScalarType::Numeric {
7944 max_scale: Some(NumericMaxScale::ZERO),
7945 }
7946 .nullable(false),
7947 )
7948 .with_key(vec![0, 1])
7949 .finish(),
7950 column_comments: BTreeMap::from_iter([
7951 ("type", "The peek variant: `index` or `persist`."),
7952 (
7953 "duration_ns",
7954 "The upper bound of the bucket in nanoseconds.",
7955 ),
7956 (
7957 "count",
7958 "The (noncumulative) count of peeks in this bucket.",
7959 ),
7960 ]),
7961 sql: "
7962SELECT
7963 type, duration_ns,
7964 pg_catalog.sum(count) AS count
7965FROM mz_introspection.mz_peek_durations_histogram_per_worker
7966GROUP BY type, duration_ns",
7967 access: vec![PUBLIC_SELECT],
7968});
7969
7970pub static MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
7971 LazyLock::new(|| BuiltinView {
7972 name: "mz_dataflow_shutdown_durations_histogram_per_worker",
7973 schema: MZ_INTROSPECTION_SCHEMA,
7974 oid: oid::VIEW_MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_PER_WORKER_OID,
7975 desc: RelationDesc::builder()
7976 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
7977 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7978 .with_column("count", SqlScalarType::Int64.nullable(false))
7979 .with_key(vec![0, 1])
7980 .finish(),
7981 column_comments: BTreeMap::new(),
7982 sql: "SELECT
7983 worker_id, duration_ns, pg_catalog.count(*) AS count
7984FROM
7985 mz_introspection.mz_dataflow_shutdown_durations_histogram_raw
7986GROUP BY
7987 worker_id, duration_ns",
7988 access: vec![PUBLIC_SELECT],
7989 });
7990
7991pub static MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM: LazyLock<BuiltinView> =
7992 LazyLock::new(|| BuiltinView {
7993 name: "mz_dataflow_shutdown_durations_histogram",
7994 schema: MZ_INTROSPECTION_SCHEMA,
7995 oid: oid::VIEW_MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_OID,
7996 desc: RelationDesc::builder()
7997 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7998 .with_column(
7999 "count",
8000 SqlScalarType::Numeric {
8001 max_scale: Some(NumericMaxScale::ZERO),
8002 }
8003 .nullable(false),
8004 )
8005 .with_key(vec![0])
8006 .finish(),
8007 column_comments: BTreeMap::from_iter([
8008 (
8009 "duration_ns",
8010 "The upper bound of the bucket in nanoseconds.",
8011 ),
8012 (
8013 "count",
8014 "The (noncumulative) count of dataflows in this bucket.",
8015 ),
8016 ]),
8017 sql: "
8018SELECT
8019 duration_ns,
8020 pg_catalog.sum(count) AS count
8021FROM mz_introspection.mz_dataflow_shutdown_durations_histogram_per_worker
8022GROUP BY duration_ns",
8023 access: vec![PUBLIC_SELECT],
8024 });
8025
8026pub static MZ_SCHEDULING_ELAPSED_PER_WORKER: LazyLock<BuiltinView> =
8027 LazyLock::new(|| BuiltinView {
8028 name: "mz_scheduling_elapsed_per_worker",
8029 schema: MZ_INTROSPECTION_SCHEMA,
8030 oid: oid::VIEW_MZ_SCHEDULING_ELAPSED_PER_WORKER_OID,
8031 desc: RelationDesc::builder()
8032 .with_column("id", SqlScalarType::UInt64.nullable(false))
8033 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8034 .with_column("elapsed_ns", SqlScalarType::Int64.nullable(false))
8035 .with_key(vec![0, 1])
8036 .finish(),
8037 column_comments: BTreeMap::new(),
8038 sql: "SELECT
8039 id, worker_id, pg_catalog.count(*) AS elapsed_ns
8040FROM
8041 mz_introspection.mz_scheduling_elapsed_raw
8042GROUP BY
8043 id, worker_id",
8044 access: vec![PUBLIC_SELECT],
8045 });
8046
8047pub static MZ_SCHEDULING_ELAPSED: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8048 name: "mz_scheduling_elapsed",
8049 schema: MZ_INTROSPECTION_SCHEMA,
8050 oid: oid::VIEW_MZ_SCHEDULING_ELAPSED_OID,
8051 desc: RelationDesc::builder()
8052 .with_column("id", SqlScalarType::UInt64.nullable(false))
8053 .with_column(
8054 "elapsed_ns",
8055 SqlScalarType::Numeric {
8056 max_scale: Some(NumericMaxScale::ZERO),
8057 }
8058 .nullable(false),
8059 )
8060 .with_key(vec![0])
8061 .finish(),
8062 column_comments: BTreeMap::from_iter([
8063 (
8064 "id",
8065 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
8066 ),
8067 (
8068 "elapsed_ns",
8069 "The total elapsed time spent in the operator in nanoseconds.",
8070 ),
8071 ]),
8072 sql: "
8073SELECT
8074 id,
8075 pg_catalog.sum(elapsed_ns) AS elapsed_ns
8076FROM mz_introspection.mz_scheduling_elapsed_per_worker
8077GROUP BY id",
8078 access: vec![PUBLIC_SELECT],
8079});
8080
8081pub static MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
8082 LazyLock::new(|| BuiltinView {
8083 name: "mz_compute_operator_durations_histogram_per_worker",
8084 schema: MZ_INTROSPECTION_SCHEMA,
8085 oid: oid::VIEW_MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_PER_WORKER_OID,
8086 desc: RelationDesc::builder()
8087 .with_column("id", SqlScalarType::UInt64.nullable(false))
8088 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8089 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
8090 .with_column("count", SqlScalarType::Int64.nullable(false))
8091 .with_key(vec![0, 1, 2])
8092 .finish(),
8093 column_comments: BTreeMap::new(),
8094 sql: "SELECT
8095 id, worker_id, duration_ns, pg_catalog.count(*) AS count
8096FROM
8097 mz_introspection.mz_compute_operator_durations_histogram_raw
8098GROUP BY
8099 id, worker_id, duration_ns",
8100 access: vec![PUBLIC_SELECT],
8101 });
8102
8103pub static MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM: LazyLock<BuiltinView> =
8104 LazyLock::new(|| BuiltinView {
8105 name: "mz_compute_operator_durations_histogram",
8106 schema: MZ_INTROSPECTION_SCHEMA,
8107 oid: oid::VIEW_MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_OID,
8108 desc: RelationDesc::builder()
8109 .with_column("id", SqlScalarType::UInt64.nullable(false))
8110 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
8111 .with_column(
8112 "count",
8113 SqlScalarType::Numeric {
8114 max_scale: Some(NumericMaxScale::ZERO),
8115 }
8116 .nullable(false),
8117 )
8118 .with_key(vec![0, 1])
8119 .finish(),
8120 column_comments: BTreeMap::from_iter([
8121 (
8122 "id",
8123 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
8124 ),
8125 (
8126 "duration_ns",
8127 "The upper bound of the duration bucket in nanoseconds.",
8128 ),
8129 (
8130 "count",
8131 "The (noncumulative) count of invocations in the bucket.",
8132 ),
8133 ]),
8134 sql: "
8135SELECT
8136 id,
8137 duration_ns,
8138 pg_catalog.sum(count) AS count
8139FROM mz_introspection.mz_compute_operator_durations_histogram_per_worker
8140GROUP BY id, duration_ns",
8141 access: vec![PUBLIC_SELECT],
8142 });
8143
8144pub static MZ_SCHEDULING_PARKS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
8145 LazyLock::new(|| BuiltinView {
8146 name: "mz_scheduling_parks_histogram_per_worker",
8147 schema: MZ_INTROSPECTION_SCHEMA,
8148 oid: oid::VIEW_MZ_SCHEDULING_PARKS_HISTOGRAM_PER_WORKER_OID,
8149 desc: RelationDesc::builder()
8150 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8151 .with_column("slept_for_ns", SqlScalarType::UInt64.nullable(false))
8152 .with_column("requested_ns", SqlScalarType::UInt64.nullable(false))
8153 .with_column("count", SqlScalarType::Int64.nullable(false))
8154 .with_key(vec![0, 1, 2])
8155 .finish(),
8156 column_comments: BTreeMap::new(),
8157 sql: "SELECT
8158 worker_id, slept_for_ns, requested_ns, pg_catalog.count(*) AS count
8159FROM
8160 mz_introspection.mz_scheduling_parks_histogram_raw
8161GROUP BY
8162 worker_id, slept_for_ns, requested_ns",
8163 access: vec![PUBLIC_SELECT],
8164 });
8165
8166pub static MZ_SCHEDULING_PARKS_HISTOGRAM: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8167 name: "mz_scheduling_parks_histogram",
8168 schema: MZ_INTROSPECTION_SCHEMA,
8169 oid: oid::VIEW_MZ_SCHEDULING_PARKS_HISTOGRAM_OID,
8170 desc: RelationDesc::builder()
8171 .with_column("slept_for_ns", SqlScalarType::UInt64.nullable(false))
8172 .with_column("requested_ns", SqlScalarType::UInt64.nullable(false))
8173 .with_column(
8174 "count",
8175 SqlScalarType::Numeric {
8176 max_scale: Some(NumericMaxScale::ZERO),
8177 }
8178 .nullable(false),
8179 )
8180 .with_key(vec![0, 1])
8181 .finish(),
8182 column_comments: BTreeMap::from_iter([
8183 (
8184 "slept_for_ns",
8185 "The actual length of the park event in nanoseconds.",
8186 ),
8187 (
8188 "requested_ns",
8189 "The requested length of the park event in nanoseconds.",
8190 ),
8191 (
8192 "count",
8193 "The (noncumulative) count of park events in this bucket.",
8194 ),
8195 ]),
8196 sql: "
8197SELECT
8198 slept_for_ns,
8199 requested_ns,
8200 pg_catalog.sum(count) AS count
8201FROM mz_introspection.mz_scheduling_parks_histogram_per_worker
8202GROUP BY slept_for_ns, requested_ns",
8203 access: vec![PUBLIC_SELECT],
8204});
8205
8206pub static MZ_COMPUTE_ERROR_COUNTS_PER_WORKER: LazyLock<BuiltinView> =
8207 LazyLock::new(|| BuiltinView {
8208 name: "mz_compute_error_counts_per_worker",
8209 schema: MZ_INTROSPECTION_SCHEMA,
8210 oid: oid::VIEW_MZ_COMPUTE_ERROR_COUNTS_PER_WORKER_OID,
8211 desc: RelationDesc::builder()
8212 .with_column("export_id", SqlScalarType::String.nullable(false))
8213 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8214 .with_column("count", SqlScalarType::Int64.nullable(false))
8215 .with_key(vec![0, 1, 2])
8216 .finish(),
8217 column_comments: BTreeMap::new(),
8218 sql: "
8219WITH MUTUALLY RECURSIVE
8220 -- Indexes that reuse existing indexes rather than maintaining separate dataflows.
8221 -- For these we don't log error counts separately, so we need to forward the error counts from
8222 -- their dependencies instead.
8223 index_reuses(reuse_id text, index_id text) AS (
8224 SELECT d.object_id, d.dependency_id
8225 FROM mz_internal.mz_compute_dependencies d
8226 JOIN mz_introspection.mz_compute_exports e ON (e.export_id = d.object_id)
8227 WHERE NOT EXISTS (
8228 SELECT 1 FROM mz_introspection.mz_dataflows
8229 WHERE id = e.dataflow_id
8230 )
8231 ),
8232 -- Error counts that were directly logged on compute exports.
8233 direct_errors(export_id text, worker_id uint8, count int8) AS (
8234 SELECT export_id, worker_id, count
8235 FROM mz_introspection.mz_compute_error_counts_raw
8236 ),
8237 -- Error counts propagated to index reused.
8238 all_errors(export_id text, worker_id uint8, count int8) AS (
8239 SELECT * FROM direct_errors
8240 UNION
8241 SELECT r.reuse_id, e.worker_id, e.count
8242 FROM all_errors e
8243 JOIN index_reuses r ON (r.index_id = e.export_id)
8244 )
8245SELECT * FROM all_errors",
8246 access: vec![PUBLIC_SELECT],
8247 });
8248
8249pub static MZ_COMPUTE_ERROR_COUNTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8250 name: "mz_compute_error_counts",
8251 schema: MZ_INTROSPECTION_SCHEMA,
8252 oid: oid::VIEW_MZ_COMPUTE_ERROR_COUNTS_OID,
8253 desc: RelationDesc::builder()
8254 .with_column("export_id", SqlScalarType::String.nullable(false))
8255 .with_column(
8256 "count",
8257 SqlScalarType::Numeric {
8258 max_scale: Some(NumericMaxScale::ZERO),
8259 }
8260 .nullable(false),
8261 )
8262 .with_key(vec![0])
8263 .finish(),
8264 column_comments: BTreeMap::from_iter([
8265 (
8266 "export_id",
8267 "The ID of the dataflow export. Corresponds to `mz_compute_exports.export_id`.",
8268 ),
8269 (
8270 "count",
8271 "The count of errors present in this dataflow export.",
8272 ),
8273 ]),
8274 sql: "
8275SELECT
8276 export_id,
8277 pg_catalog.sum(count) AS count
8278FROM mz_introspection.mz_compute_error_counts_per_worker
8279GROUP BY export_id
8280HAVING pg_catalog.sum(count) != 0",
8281 access: vec![PUBLIC_SELECT],
8282});
8283
8284pub static MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED: LazyLock<BuiltinSource> =
8285 LazyLock::new(|| BuiltinSource {
8286 name: "mz_compute_error_counts_raw_unified",
8290 schema: MZ_INTERNAL_SCHEMA,
8291 oid: oid::SOURCE_MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED_OID,
8292 desc: RelationDesc::builder()
8293 .with_column("replica_id", SqlScalarType::String.nullable(false))
8294 .with_column("object_id", SqlScalarType::String.nullable(false))
8295 .with_column(
8296 "count",
8297 SqlScalarType::Numeric { max_scale: None }.nullable(false),
8298 )
8299 .finish(),
8300 data_source: IntrospectionType::ComputeErrorCounts,
8301 column_comments: BTreeMap::new(),
8302 is_retained_metrics_object: false,
8303 access: vec![PUBLIC_SELECT],
8304 });
8305
8306pub static MZ_COMPUTE_HYDRATION_TIMES: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
8307 name: "mz_compute_hydration_times",
8308 schema: MZ_INTERNAL_SCHEMA,
8309 oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_TIMES_OID,
8310 desc: RelationDesc::builder()
8311 .with_column("replica_id", SqlScalarType::String.nullable(false))
8312 .with_column("object_id", SqlScalarType::String.nullable(false))
8313 .with_column("time_ns", SqlScalarType::UInt64.nullable(true))
8314 .finish(),
8315 data_source: IntrospectionType::ComputeHydrationTimes,
8316 column_comments: BTreeMap::new(),
8317 is_retained_metrics_object: true,
8318 access: vec![PUBLIC_SELECT],
8319});
8320
8321pub static MZ_COMPUTE_HYDRATION_TIMES_IND: LazyLock<BuiltinIndex> =
8322 LazyLock::new(|| BuiltinIndex {
8323 name: "mz_compute_hydration_times_ind",
8324 schema: MZ_INTERNAL_SCHEMA,
8325 oid: oid::INDEX_MZ_COMPUTE_HYDRATION_TIMES_IND_OID,
8326 sql: "IN CLUSTER mz_catalog_server
8327 ON mz_internal.mz_compute_hydration_times (replica_id)",
8328 is_retained_metrics_object: true,
8329 });
8330
8331pub static MZ_COMPUTE_HYDRATION_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8332 name: "mz_compute_hydration_statuses",
8333 schema: MZ_INTERNAL_SCHEMA,
8334 oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_STATUSES_OID,
8335 desc: RelationDesc::builder()
8336 .with_column("object_id", SqlScalarType::String.nullable(false))
8337 .with_column("replica_id", SqlScalarType::String.nullable(false))
8338 .with_column("hydrated", SqlScalarType::Bool.nullable(false))
8339 .with_column("hydration_time", SqlScalarType::Interval.nullable(true))
8340 .finish(),
8341 column_comments: BTreeMap::from_iter([
8342 (
8343 "object_id",
8344 "The ID of a compute object. Corresponds to `mz_catalog.mz_indexes.id` or `mz_catalog.mz_materialized_views.id`",
8345 ),
8346 ("replica_id", "The ID of a cluster replica."),
8347 (
8348 "hydrated",
8349 "Whether the compute object is hydrated on the replica.",
8350 ),
8351 (
8352 "hydration_time",
8353 "The amount of time it took for the replica to hydrate the compute object.",
8354 ),
8355 ]),
8356 sql: "
8357WITH
8358 dataflows AS (
8359 SELECT
8360 object_id,
8361 replica_id,
8362 time_ns IS NOT NULL AS hydrated,
8363 ((time_ns / 1000) || 'microseconds')::interval AS hydration_time
8364 FROM mz_internal.mz_compute_hydration_times
8365 ),
8366 -- MVs that have advanced to the empty frontier don't have a dataflow installed anymore and
8367 -- therefore don't show up in `mz_compute_hydration_times`. We still want to show them here to
8368 -- avoid surprises for people joining `mz_materialized_views` against this relation (like the
8369 -- blue-green readiness query does), so we include them as 'hydrated'.
8370 complete_mvs AS (
8371 SELECT
8372 mv.id,
8373 f.replica_id,
8374 true AS hydrated,
8375 NULL::interval AS hydration_time
8376 FROM mz_materialized_views mv
8377 JOIN mz_catalog.mz_cluster_replica_frontiers f ON f.object_id = mv.id
8378 WHERE f.write_frontier IS NULL
8379 ),
8380 -- Ditto CTs
8381 complete_cts AS (
8382 SELECT
8383 ct.id,
8384 f.replica_id,
8385 true AS hydrated,
8386 NULL::interval AS hydration_time
8387 FROM mz_internal.mz_continual_tasks ct
8388 JOIN mz_catalog.mz_cluster_replica_frontiers f ON f.object_id = ct.id
8389 WHERE f.write_frontier IS NULL
8390 )
8391SELECT * FROM dataflows
8392UNION ALL
8393SELECT * FROM complete_mvs
8394UNION ALL
8395SELECT * FROM complete_cts",
8396 access: vec![PUBLIC_SELECT],
8397});
8398
8399pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES: LazyLock<BuiltinSource> = LazyLock::new(|| {
8400 BuiltinSource {
8401 name: "mz_compute_operator_hydration_statuses",
8402 schema: MZ_INTERNAL_SCHEMA,
8403 oid: oid::SOURCE_MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_OID,
8404 desc: RelationDesc::builder()
8405 .with_column("replica_id", SqlScalarType::String.nullable(false))
8406 .with_column("object_id", SqlScalarType::String.nullable(false))
8407 .with_column(
8408 "physical_plan_node_id",
8409 SqlScalarType::UInt64.nullable(false),
8410 )
8411 .with_column("hydrated", SqlScalarType::Bool.nullable(false))
8412 .with_key(vec![0, 1, 2])
8413 .finish(),
8414 data_source: IntrospectionType::ComputeOperatorHydrationStatus,
8415 column_comments: BTreeMap::from_iter([
8416 ("replica_id", "The ID of a cluster replica."),
8417 (
8418 "object_id",
8419 "The ID of a compute object. Corresponds to `mz_catalog.mz_indexes.id` or `mz_catalog.mz_materialized_views.id`.",
8420 ),
8421 (
8422 "physical_plan_node_id",
8423 "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)`.",
8424 ),
8425 ("hydrated", "Whether the node is hydrated on the replica."),
8426 ]),
8427 is_retained_metrics_object: false,
8428 access: vec![PUBLIC_SELECT],
8429 }
8430});
8431
8432pub static MZ_MESSAGE_COUNTS_PER_WORKER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8433 name: "mz_message_counts_per_worker",
8434 schema: MZ_INTROSPECTION_SCHEMA,
8435 oid: oid::VIEW_MZ_MESSAGE_COUNTS_PER_WORKER_OID,
8436 desc: RelationDesc::builder()
8437 .with_column("channel_id", SqlScalarType::UInt64.nullable(false))
8438 .with_column("from_worker_id", SqlScalarType::UInt64.nullable(false))
8439 .with_column("to_worker_id", SqlScalarType::UInt64.nullable(false))
8440 .with_column("sent", SqlScalarType::Int64.nullable(false))
8441 .with_column("received", SqlScalarType::Int64.nullable(false))
8442 .with_column("batch_sent", SqlScalarType::Int64.nullable(false))
8443 .with_column("batch_received", SqlScalarType::Int64.nullable(false))
8444 .with_key(vec![0, 1, 2])
8445 .finish(),
8446 column_comments: BTreeMap::new(),
8447 sql: "
8448WITH batch_sent_cte AS (
8449 SELECT
8450 channel_id,
8451 from_worker_id,
8452 to_worker_id,
8453 pg_catalog.count(*) AS sent
8454 FROM
8455 mz_introspection.mz_message_batch_counts_sent_raw
8456 GROUP BY
8457 channel_id, from_worker_id, to_worker_id
8458),
8459batch_received_cte AS (
8460 SELECT
8461 channel_id,
8462 from_worker_id,
8463 to_worker_id,
8464 pg_catalog.count(*) AS received
8465 FROM
8466 mz_introspection.mz_message_batch_counts_received_raw
8467 GROUP BY
8468 channel_id, from_worker_id, to_worker_id
8469),
8470sent_cte AS (
8471 SELECT
8472 channel_id,
8473 from_worker_id,
8474 to_worker_id,
8475 pg_catalog.count(*) AS sent
8476 FROM
8477 mz_introspection.mz_message_counts_sent_raw
8478 GROUP BY
8479 channel_id, from_worker_id, to_worker_id
8480),
8481received_cte AS (
8482 SELECT
8483 channel_id,
8484 from_worker_id,
8485 to_worker_id,
8486 pg_catalog.count(*) AS received
8487 FROM
8488 mz_introspection.mz_message_counts_received_raw
8489 GROUP BY
8490 channel_id, from_worker_id, to_worker_id
8491)
8492SELECT
8493 sent_cte.channel_id,
8494 sent_cte.from_worker_id,
8495 sent_cte.to_worker_id,
8496 sent_cte.sent,
8497 received_cte.received,
8498 batch_sent_cte.sent AS batch_sent,
8499 batch_received_cte.received AS batch_received
8500FROM sent_cte
8501JOIN received_cte USING (channel_id, from_worker_id, to_worker_id)
8502JOIN batch_sent_cte USING (channel_id, from_worker_id, to_worker_id)
8503JOIN batch_received_cte USING (channel_id, from_worker_id, to_worker_id)",
8504 access: vec![PUBLIC_SELECT],
8505});
8506
8507pub static MZ_MESSAGE_COUNTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8508 name: "mz_message_counts",
8509 schema: MZ_INTROSPECTION_SCHEMA,
8510 oid: oid::VIEW_MZ_MESSAGE_COUNTS_OID,
8511 desc: RelationDesc::builder()
8512 .with_column("channel_id", SqlScalarType::UInt64.nullable(false))
8513 .with_column(
8514 "sent",
8515 SqlScalarType::Numeric {
8516 max_scale: Some(NumericMaxScale::ZERO),
8517 }
8518 .nullable(false),
8519 )
8520 .with_column(
8521 "received",
8522 SqlScalarType::Numeric {
8523 max_scale: Some(NumericMaxScale::ZERO),
8524 }
8525 .nullable(false),
8526 )
8527 .with_column(
8528 "batch_sent",
8529 SqlScalarType::Numeric {
8530 max_scale: Some(NumericMaxScale::ZERO),
8531 }
8532 .nullable(false),
8533 )
8534 .with_column(
8535 "batch_received",
8536 SqlScalarType::Numeric {
8537 max_scale: Some(NumericMaxScale::ZERO),
8538 }
8539 .nullable(false),
8540 )
8541 .with_key(vec![0])
8542 .finish(),
8543 column_comments: BTreeMap::from_iter([
8544 (
8545 "channel_id",
8546 "The ID of the channel. Corresponds to `mz_dataflow_channels.id`.",
8547 ),
8548 ("sent", "The number of messages sent."),
8549 ("received", "The number of messages received."),
8550 ("batch_sent", "The number of batches sent."),
8551 ("batch_received", "The number of batches received."),
8552 ]),
8553 sql: "
8554SELECT
8555 channel_id,
8556 pg_catalog.sum(sent) AS sent,
8557 pg_catalog.sum(received) AS received,
8558 pg_catalog.sum(batch_sent) AS batch_sent,
8559 pg_catalog.sum(batch_received) AS batch_received
8560FROM mz_introspection.mz_message_counts_per_worker
8561GROUP BY channel_id",
8562 access: vec![PUBLIC_SELECT],
8563});
8564
8565pub static MZ_ACTIVE_PEEKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8566 name: "mz_active_peeks",
8567 schema: MZ_INTROSPECTION_SCHEMA,
8568 oid: oid::VIEW_MZ_ACTIVE_PEEKS_OID,
8569 desc: RelationDesc::builder()
8570 .with_column("id", SqlScalarType::Uuid.nullable(false))
8571 .with_column("object_id", SqlScalarType::String.nullable(false))
8572 .with_column("type", SqlScalarType::String.nullable(false))
8573 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
8574 .finish(),
8575 column_comments: BTreeMap::from_iter([
8576 ("id", "The ID of the peek request."),
8577 (
8578 "object_id",
8579 "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`.",
8580 ),
8581 (
8582 "type",
8583 "The type of the corresponding peek: `index` if targeting an index or temporary dataflow; `persist` for a source, materialized view, or table.",
8584 ),
8585 ("time", "The timestamp the peek has requested."),
8586 ]),
8587 sql: "
8588SELECT id, object_id, type, time
8589FROM mz_introspection.mz_active_peeks_per_worker
8590WHERE worker_id = 0",
8591 access: vec![PUBLIC_SELECT],
8592});
8593
8594pub static MZ_DATAFLOW_OPERATOR_REACHABILITY_PER_WORKER: LazyLock<BuiltinView> =
8595 LazyLock::new(|| BuiltinView {
8596 name: "mz_dataflow_operator_reachability_per_worker",
8597 schema: MZ_INTROSPECTION_SCHEMA,
8598 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_REACHABILITY_PER_WORKER_OID,
8599 desc: RelationDesc::builder()
8600 .with_column("id", SqlScalarType::UInt64.nullable(false))
8601 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8602 .with_column("port", SqlScalarType::UInt64.nullable(false))
8603 .with_column("update_type", SqlScalarType::String.nullable(false))
8604 .with_column("time", SqlScalarType::MzTimestamp.nullable(true))
8605 .with_column("count", SqlScalarType::Int64.nullable(false))
8606 .with_key(vec![0, 1, 2, 3, 4])
8607 .finish(),
8608 column_comments: BTreeMap::new(),
8609 sql: "SELECT
8610 addr2.id,
8611 reachability.worker_id,
8612 port,
8613 update_type,
8614 time,
8615 pg_catalog.count(*) as count
8616FROM
8617 mz_introspection.mz_dataflow_operator_reachability_raw reachability,
8618 mz_introspection.mz_dataflow_addresses_per_worker addr1,
8619 mz_introspection.mz_dataflow_addresses_per_worker addr2
8620WHERE
8621 addr2.address =
8622 CASE
8623 WHEN source = 0 THEN addr1.address
8624 ELSE addr1.address || reachability.source
8625 END
8626 AND addr1.id = reachability.id
8627 AND addr1.worker_id = reachability.worker_id
8628 AND addr2.worker_id = reachability.worker_id
8629GROUP BY addr2.id, reachability.worker_id, port, update_type, time",
8630 access: vec![PUBLIC_SELECT],
8631 });
8632
8633pub static MZ_DATAFLOW_OPERATOR_REACHABILITY: LazyLock<BuiltinView> =
8634 LazyLock::new(|| BuiltinView {
8635 name: "mz_dataflow_operator_reachability",
8636 schema: MZ_INTROSPECTION_SCHEMA,
8637 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_REACHABILITY_OID,
8638 desc: RelationDesc::builder()
8639 .with_column("id", SqlScalarType::UInt64.nullable(false))
8640 .with_column("port", SqlScalarType::UInt64.nullable(false))
8641 .with_column("update_type", SqlScalarType::String.nullable(false))
8642 .with_column("time", SqlScalarType::MzTimestamp.nullable(true))
8643 .with_column(
8644 "count",
8645 SqlScalarType::Numeric {
8646 max_scale: Some(NumericMaxScale::ZERO),
8647 }
8648 .nullable(false),
8649 )
8650 .with_key(vec![0, 1, 2, 3])
8651 .finish(),
8652 column_comments: BTreeMap::new(),
8653 sql: "
8654SELECT
8655 id,
8656 port,
8657 update_type,
8658 time,
8659 pg_catalog.sum(count) as count
8660FROM mz_introspection.mz_dataflow_operator_reachability_per_worker
8661GROUP BY id, port, update_type, time",
8662 access: vec![PUBLIC_SELECT],
8663 });
8664
8665pub static MZ_ARRANGEMENT_SIZES_PER_WORKER: LazyLock<BuiltinView> = LazyLock::new(|| {
8666 BuiltinView {
8667 name: "mz_arrangement_sizes_per_worker",
8668 schema: MZ_INTROSPECTION_SCHEMA,
8669 oid: oid::VIEW_MZ_ARRANGEMENT_SIZES_PER_WORKER_OID,
8670 desc: RelationDesc::builder()
8671 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8672 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8673 .with_column("records", SqlScalarType::Int64.nullable(true))
8674 .with_column("batches", SqlScalarType::Int64.nullable(true))
8675 .with_column("size", SqlScalarType::Int64.nullable(true))
8676 .with_column("capacity", SqlScalarType::Int64.nullable(true))
8677 .with_column("allocations", SqlScalarType::Int64.nullable(true))
8678 .finish(),
8679 column_comments: BTreeMap::new(),
8680 sql: "
8681WITH operators_per_worker_cte AS (
8682 SELECT
8683 id AS operator_id,
8684 worker_id
8685 FROM
8686 mz_introspection.mz_dataflow_operators_per_worker
8687),
8688batches_cte AS (
8689 SELECT
8690 operator_id,
8691 worker_id,
8692 COUNT(*) AS batches
8693 FROM
8694 mz_introspection.mz_arrangement_batches_raw
8695 GROUP BY
8696 operator_id, worker_id
8697),
8698records_cte AS (
8699 SELECT
8700 operator_id,
8701 worker_id,
8702 COUNT(*) AS records
8703 FROM
8704 mz_introspection.mz_arrangement_records_raw
8705 GROUP BY
8706 operator_id, worker_id
8707),
8708heap_size_cte AS (
8709 SELECT
8710 operator_id,
8711 worker_id,
8712 COUNT(*) AS size
8713 FROM
8714 mz_introspection.mz_arrangement_heap_size_raw
8715 GROUP BY
8716 operator_id, worker_id
8717),
8718heap_capacity_cte AS (
8719 SELECT
8720 operator_id,
8721 worker_id,
8722 COUNT(*) AS capacity
8723 FROM
8724 mz_introspection.mz_arrangement_heap_capacity_raw
8725 GROUP BY
8726 operator_id, worker_id
8727),
8728heap_allocations_cte AS (
8729 SELECT
8730 operator_id,
8731 worker_id,
8732 COUNT(*) AS allocations
8733 FROM
8734 mz_introspection.mz_arrangement_heap_allocations_raw
8735 GROUP BY
8736 operator_id, worker_id
8737),
8738batcher_records_cte AS (
8739 SELECT
8740 operator_id,
8741 worker_id,
8742 COUNT(*) AS records
8743 FROM
8744 mz_introspection.mz_arrangement_batcher_records_raw
8745 GROUP BY
8746 operator_id, worker_id
8747),
8748batcher_size_cte AS (
8749 SELECT
8750 operator_id,
8751 worker_id,
8752 COUNT(*) AS size
8753 FROM
8754 mz_introspection.mz_arrangement_batcher_size_raw
8755 GROUP BY
8756 operator_id, worker_id
8757),
8758batcher_capacity_cte AS (
8759 SELECT
8760 operator_id,
8761 worker_id,
8762 COUNT(*) AS capacity
8763 FROM
8764 mz_introspection.mz_arrangement_batcher_capacity_raw
8765 GROUP BY
8766 operator_id, worker_id
8767),
8768batcher_allocations_cte AS (
8769 SELECT
8770 operator_id,
8771 worker_id,
8772 COUNT(*) AS allocations
8773 FROM
8774 mz_introspection.mz_arrangement_batcher_allocations_raw
8775 GROUP BY
8776 operator_id, worker_id
8777),
8778combined AS (
8779 SELECT
8780 opw.operator_id,
8781 opw.worker_id,
8782 CASE
8783 WHEN records_cte.records IS NULL AND batcher_records_cte.records IS NULL THEN NULL
8784 ELSE COALESCE(records_cte.records, 0) + COALESCE(batcher_records_cte.records, 0)
8785 END AS records,
8786 batches_cte.batches AS batches,
8787 CASE
8788 WHEN heap_size_cte.size IS NULL AND batcher_size_cte.size IS NULL THEN NULL
8789 ELSE COALESCE(heap_size_cte.size, 0) + COALESCE(batcher_size_cte.size, 0)
8790 END AS size,
8791 CASE
8792 WHEN heap_capacity_cte.capacity IS NULL AND batcher_capacity_cte.capacity IS NULL THEN NULL
8793 ELSE COALESCE(heap_capacity_cte.capacity, 0) + COALESCE(batcher_capacity_cte.capacity, 0)
8794 END AS capacity,
8795 CASE
8796 WHEN heap_allocations_cte.allocations IS NULL AND batcher_allocations_cte.allocations IS NULL THEN NULL
8797 ELSE COALESCE(heap_allocations_cte.allocations, 0) + COALESCE(batcher_allocations_cte.allocations, 0)
8798 END AS allocations
8799 FROM
8800 operators_per_worker_cte opw
8801 LEFT OUTER JOIN batches_cte USING (operator_id, worker_id)
8802 LEFT OUTER JOIN records_cte USING (operator_id, worker_id)
8803 LEFT OUTER JOIN heap_size_cte USING (operator_id, worker_id)
8804 LEFT OUTER JOIN heap_capacity_cte USING (operator_id, worker_id)
8805 LEFT OUTER JOIN heap_allocations_cte USING (operator_id, worker_id)
8806 LEFT OUTER JOIN batcher_records_cte USING (operator_id, worker_id)
8807 LEFT OUTER JOIN batcher_size_cte USING (operator_id, worker_id)
8808 LEFT OUTER JOIN batcher_capacity_cte USING (operator_id, worker_id)
8809 LEFT OUTER JOIN batcher_allocations_cte USING (operator_id, worker_id)
8810)
8811SELECT
8812 operator_id, worker_id, records, batches, size, capacity, allocations
8813FROM combined
8814WHERE
8815 records IS NOT NULL
8816 OR batches IS NOT NULL
8817 OR size IS NOT NULL
8818 OR capacity IS NOT NULL
8819 OR allocations IS NOT NULL
8820",
8821 access: vec![PUBLIC_SELECT],
8822 }
8823});
8824
8825pub static MZ_ARRANGEMENT_SIZES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8826 name: "mz_arrangement_sizes",
8827 schema: MZ_INTROSPECTION_SCHEMA,
8828 oid: oid::VIEW_MZ_ARRANGEMENT_SIZES_OID,
8829 desc: RelationDesc::builder()
8830 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8831 .with_column("records", SqlScalarType::Int64.nullable(true))
8832 .with_column("batches", SqlScalarType::Int64.nullable(true))
8833 .with_column("size", SqlScalarType::Int64.nullable(true))
8834 .with_column("capacity", SqlScalarType::Int64.nullable(true))
8835 .with_column("allocations", SqlScalarType::Int64.nullable(true))
8836 .with_key(vec![0])
8837 .finish(),
8838 column_comments: BTreeMap::from_iter([
8839 (
8840 "operator_id",
8841 "The ID of the operator that created the arrangement. Corresponds to `mz_dataflow_operators.id`.",
8842 ),
8843 ("records", "The number of records in the arrangement."),
8844 ("batches", "The number of batches in the arrangement."),
8845 ("size", "The utilized size in bytes of the arrangement."),
8846 (
8847 "capacity",
8848 "The capacity in bytes of the arrangement. Can be larger than the size.",
8849 ),
8850 (
8851 "allocations",
8852 "The number of separate memory allocations backing the arrangement.",
8853 ),
8854 ]),
8855 sql: "
8856SELECT
8857 operator_id,
8858 SUM(records)::int8 AS records,
8859 SUM(batches)::int8 AS batches,
8860 SUM(size)::int8 AS size,
8861 SUM(capacity)::int8 AS capacity,
8862 SUM(allocations)::int8 AS allocations
8863FROM mz_introspection.mz_arrangement_sizes_per_worker
8864GROUP BY operator_id",
8865 access: vec![PUBLIC_SELECT],
8866});
8867
8868pub static MZ_ARRANGEMENT_SHARING_PER_WORKER: LazyLock<BuiltinView> =
8869 LazyLock::new(|| BuiltinView {
8870 name: "mz_arrangement_sharing_per_worker",
8871 schema: MZ_INTROSPECTION_SCHEMA,
8872 oid: oid::VIEW_MZ_ARRANGEMENT_SHARING_PER_WORKER_OID,
8873 desc: RelationDesc::builder()
8874 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8875 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8876 .with_column("count", SqlScalarType::Int64.nullable(false))
8877 .with_key(vec![0, 1])
8878 .finish(),
8879 column_comments: BTreeMap::new(),
8880 sql: "
8881SELECT
8882 operator_id,
8883 worker_id,
8884 pg_catalog.count(*) AS count
8885FROM mz_introspection.mz_arrangement_sharing_raw
8886GROUP BY operator_id, worker_id",
8887 access: vec![PUBLIC_SELECT],
8888 });
8889
8890pub static MZ_ARRANGEMENT_SHARING: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8891 name: "mz_arrangement_sharing",
8892 schema: MZ_INTROSPECTION_SCHEMA,
8893 oid: oid::VIEW_MZ_ARRANGEMENT_SHARING_OID,
8894 desc: RelationDesc::builder()
8895 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8896 .with_column("count", SqlScalarType::Int64.nullable(false))
8897 .finish(),
8898 column_comments: BTreeMap::from_iter([
8899 (
8900 "operator_id",
8901 "The ID of the operator that created the arrangement. Corresponds to `mz_dataflow_operators.id`.",
8902 ),
8903 (
8904 "count",
8905 "The number of operators that share the arrangement.",
8906 ),
8907 ]),
8908 sql: "
8909SELECT operator_id, count
8910FROM mz_introspection.mz_arrangement_sharing_per_worker
8911WHERE worker_id = 0",
8912 access: vec![PUBLIC_SELECT],
8913});
8914
8915pub static MZ_CLUSTER_REPLICA_UTILIZATION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8916 name: "mz_cluster_replica_utilization",
8917 schema: MZ_INTERNAL_SCHEMA,
8918 oid: oid::VIEW_MZ_CLUSTER_REPLICA_UTILIZATION_OID,
8919 desc: RelationDesc::builder()
8920 .with_column("replica_id", SqlScalarType::String.nullable(false))
8921 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
8922 .with_column("cpu_percent", SqlScalarType::Float64.nullable(true))
8923 .with_column("memory_percent", SqlScalarType::Float64.nullable(true))
8924 .with_column("disk_percent", SqlScalarType::Float64.nullable(true))
8925 .with_column("heap_percent", SqlScalarType::Float64.nullable(true))
8926 .finish(),
8927 column_comments: BTreeMap::from_iter([
8928 ("replica_id", "The ID of a cluster replica."),
8929 ("process_id", "The ID of a process within the replica."),
8930 (
8931 "cpu_percent",
8932 "Approximate CPU usage, in percent of the total allocation.",
8933 ),
8934 (
8935 "memory_percent",
8936 "Approximate RAM usage, in percent of the total allocation.",
8937 ),
8938 (
8939 "disk_percent",
8940 "Approximate disk usage, in percent of the total allocation.",
8941 ),
8942 (
8943 "heap_percent",
8944 "Approximate heap (RAM + swap) usage, in percent of the total allocation.",
8945 ),
8946 ]),
8947 sql: "
8948SELECT
8949 r.id AS replica_id,
8950 m.process_id,
8951 m.cpu_nano_cores::float8 / NULLIF(s.cpu_nano_cores, 0) * 100 AS cpu_percent,
8952 m.memory_bytes::float8 / NULLIF(s.memory_bytes, 0) * 100 AS memory_percent,
8953 m.disk_bytes::float8 / NULLIF(s.disk_bytes, 0) * 100 AS disk_percent,
8954 m.heap_bytes::float8 / NULLIF(m.heap_limit, 0) * 100 AS heap_percent
8955FROM
8956 mz_catalog.mz_cluster_replicas AS r
8957 JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size
8958 JOIN mz_internal.mz_cluster_replica_metrics AS m ON m.replica_id = r.id",
8959 access: vec![PUBLIC_SELECT],
8960});
8961
8962pub static MZ_CLUSTER_REPLICA_UTILIZATION_HISTORY: LazyLock<BuiltinView> =
8963 LazyLock::new(|| BuiltinView {
8964 name: "mz_cluster_replica_utilization_history",
8965 schema: MZ_INTERNAL_SCHEMA,
8966 oid: oid::VIEW_MZ_CLUSTER_REPLICA_UTILIZATION_HISTORY_OID,
8967 desc: RelationDesc::builder()
8968 .with_column("replica_id", SqlScalarType::String.nullable(false))
8969 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
8970 .with_column("cpu_percent", SqlScalarType::Float64.nullable(true))
8971 .with_column("memory_percent", SqlScalarType::Float64.nullable(true))
8972 .with_column("disk_percent", SqlScalarType::Float64.nullable(true))
8973 .with_column("heap_percent", SqlScalarType::Float64.nullable(true))
8974 .with_column(
8975 "occurred_at",
8976 SqlScalarType::TimestampTz { precision: None }.nullable(false),
8977 )
8978 .finish(),
8979 column_comments: BTreeMap::from_iter([
8980 ("replica_id", "The ID of a cluster replica."),
8981 ("process_id", "The ID of a process within the replica."),
8982 (
8983 "cpu_percent",
8984 "Approximate CPU usage, in percent of the total allocation.",
8985 ),
8986 (
8987 "memory_percent",
8988 "Approximate RAM usage, in percent of the total allocation.",
8989 ),
8990 (
8991 "disk_percent",
8992 "Approximate disk usage, in percent of the total allocation.",
8993 ),
8994 (
8995 "heap_percent",
8996 "Approximate heap (RAM + swap) usage, in percent of the total allocation.",
8997 ),
8998 (
8999 "occurred_at",
9000 "Wall-clock timestamp at which the event occurred.",
9001 ),
9002 ]),
9003 sql: "
9004SELECT
9005 r.id AS replica_id,
9006 m.process_id,
9007 m.cpu_nano_cores::float8 / NULLIF(s.cpu_nano_cores, 0) * 100 AS cpu_percent,
9008 m.memory_bytes::float8 / NULLIF(s.memory_bytes, 0) * 100 AS memory_percent,
9009 m.disk_bytes::float8 / NULLIF(s.disk_bytes, 0) * 100 AS disk_percent,
9010 m.heap_bytes::float8 / NULLIF(m.heap_limit, 0) * 100 AS heap_percent,
9011 m.occurred_at
9012FROM
9013 mz_catalog.mz_cluster_replicas AS r
9014 JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size
9015 JOIN mz_internal.mz_cluster_replica_metrics_history AS m ON m.replica_id = r.id",
9016 access: vec![PUBLIC_SELECT],
9017 });
9018
9019pub static MZ_DATAFLOW_OPERATOR_PARENTS_PER_WORKER: LazyLock<BuiltinView> =
9020 LazyLock::new(|| BuiltinView {
9021 name: "mz_dataflow_operator_parents_per_worker",
9022 schema: MZ_INTROSPECTION_SCHEMA,
9023 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_PARENTS_PER_WORKER_OID,
9024 desc: RelationDesc::builder()
9025 .with_column("id", SqlScalarType::UInt64.nullable(false))
9026 .with_column("parent_id", SqlScalarType::UInt64.nullable(false))
9027 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
9028 .finish(),
9029 column_comments: BTreeMap::new(),
9030 sql: "
9031WITH operator_addrs AS(
9032 SELECT
9033 id, address, worker_id
9034 FROM mz_introspection.mz_dataflow_addresses_per_worker
9035 INNER JOIN mz_introspection.mz_dataflow_operators_per_worker
9036 USING (id, worker_id)
9037),
9038parent_addrs AS (
9039 SELECT
9040 id,
9041 address[1:list_length(address) - 1] AS parent_address,
9042 worker_id
9043 FROM operator_addrs
9044)
9045SELECT pa.id, oa.id AS parent_id, pa.worker_id
9046FROM parent_addrs AS pa
9047 INNER JOIN operator_addrs AS oa
9048 ON pa.parent_address = oa.address
9049 AND pa.worker_id = oa.worker_id",
9050 access: vec![PUBLIC_SELECT],
9051 });
9052
9053pub static MZ_DATAFLOW_OPERATOR_PARENTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9054 name: "mz_dataflow_operator_parents",
9055 schema: MZ_INTROSPECTION_SCHEMA,
9056 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_PARENTS_OID,
9057 desc: RelationDesc::builder()
9058 .with_column("id", SqlScalarType::UInt64.nullable(false))
9059 .with_column("parent_id", SqlScalarType::UInt64.nullable(false))
9060 .finish(),
9061 column_comments: BTreeMap::from_iter([
9062 (
9063 "id",
9064 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
9065 ),
9066 (
9067 "parent_id",
9068 "The ID of the operator's parent operator. Corresponds to `mz_dataflow_operators.id`.",
9069 ),
9070 ]),
9071 sql: "
9072SELECT id, parent_id
9073FROM mz_introspection.mz_dataflow_operator_parents_per_worker
9074WHERE worker_id = 0",
9075 access: vec![PUBLIC_SELECT],
9076});
9077
9078pub static MZ_DATAFLOW_ARRANGEMENT_SIZES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9079 name: "mz_dataflow_arrangement_sizes",
9080 schema: MZ_INTROSPECTION_SCHEMA,
9081 oid: oid::VIEW_MZ_DATAFLOW_ARRANGEMENT_SIZES_OID,
9082 desc: RelationDesc::builder()
9083 .with_column("id", SqlScalarType::UInt64.nullable(false))
9084 .with_column("name", SqlScalarType::String.nullable(false))
9085 .with_column("records", SqlScalarType::Int64.nullable(true))
9086 .with_column("batches", SqlScalarType::Int64.nullable(true))
9087 .with_column("size", SqlScalarType::Int64.nullable(true))
9088 .with_column("capacity", SqlScalarType::Int64.nullable(true))
9089 .with_column("allocations", SqlScalarType::Int64.nullable(true))
9090 .with_key(vec![0, 1])
9091 .finish(),
9092 column_comments: BTreeMap::from_iter([
9093 (
9094 "id",
9095 "The ID of the [dataflow]. Corresponds to `mz_dataflows.id`.",
9096 ),
9097 ("name", "The name of the [dataflow]."),
9098 (
9099 "records",
9100 "The number of records in all arrangements in the dataflow.",
9101 ),
9102 (
9103 "batches",
9104 "The number of batches in all arrangements in the dataflow.",
9105 ),
9106 ("size", "The utilized size in bytes of the arrangements."),
9107 (
9108 "capacity",
9109 "The capacity in bytes of the arrangements. Can be larger than the size.",
9110 ),
9111 (
9112 "allocations",
9113 "The number of separate memory allocations backing the arrangements.",
9114 ),
9115 ]),
9116 sql: "
9117SELECT
9118 mdod.dataflow_id AS id,
9119 mdod.dataflow_name AS name,
9120 SUM(mas.records)::int8 AS records,
9121 SUM(mas.batches)::int8 AS batches,
9122 SUM(mas.size)::int8 AS size,
9123 SUM(mas.capacity)::int8 AS capacity,
9124 SUM(mas.allocations)::int8 AS allocations
9125FROM mz_introspection.mz_dataflow_operator_dataflows AS mdod
9126LEFT JOIN mz_introspection.mz_arrangement_sizes AS mas
9127 ON mdod.id = mas.operator_id
9128GROUP BY mdod.dataflow_id, mdod.dataflow_name",
9129 access: vec![PUBLIC_SELECT],
9130});
9131
9132pub static MZ_EXPECTED_GROUP_SIZE_ADVICE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9133 name: "mz_expected_group_size_advice",
9134 schema: MZ_INTROSPECTION_SCHEMA,
9135 oid: oid::VIEW_MZ_EXPECTED_GROUP_SIZE_ADVICE_OID,
9136 desc: RelationDesc::builder()
9137 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
9138 .with_column("dataflow_name", SqlScalarType::String.nullable(false))
9139 .with_column("region_id", SqlScalarType::UInt64.nullable(false))
9140 .with_column("region_name", SqlScalarType::String.nullable(false))
9141 .with_column("levels", SqlScalarType::Int64.nullable(false))
9142 .with_column("to_cut", SqlScalarType::Int64.nullable(false))
9143 .with_column(
9144 "savings",
9145 SqlScalarType::Numeric {
9146 max_scale: Some(NumericMaxScale::ZERO),
9147 }
9148 .nullable(true),
9149 )
9150 .with_column("hint", SqlScalarType::Float64.nullable(false))
9151 .finish(),
9152 column_comments: BTreeMap::from_iter([
9153 (
9154 "dataflow_id",
9155 "The ID of the [dataflow]. Corresponds to `mz_dataflows.id`.",
9156 ),
9157 (
9158 "dataflow_name",
9159 "The internal name of the dataflow hosting the min/max aggregation or Top K.",
9160 ),
9161 (
9162 "region_id",
9163 "The ID of the root operator scope. Corresponds to `mz_dataflow_operators.id`.",
9164 ),
9165 (
9166 "region_name",
9167 "The internal name of the root operator scope for the min/max aggregation or Top K.",
9168 ),
9169 (
9170 "levels",
9171 "The number of levels in the hierarchical scheme implemented by the region.",
9172 ),
9173 (
9174 "to_cut",
9175 "The number of levels that can be eliminated (cut) from the region's hierarchy.",
9176 ),
9177 (
9178 "savings",
9179 "A conservative estimate of the amount of memory in bytes to be saved by applying the hint.",
9180 ),
9181 (
9182 "hint",
9183 "The hint value that will eliminate `to_cut` levels from the region's hierarchy.",
9184 ),
9185 ]),
9186 sql: "
9187 -- The mz_expected_group_size_advice view provides tuning suggestions for the GROUP SIZE
9188 -- query hints. This tuning hint is effective for min/max/top-k patterns, where a stack
9189 -- of arrangements must be built. For each dataflow and region corresponding to one
9190 -- such pattern, we look for how many levels can be eliminated without hitting a level
9191 -- that actually substantially filters the input. The advice is constructed so that
9192 -- setting the hint for the affected region will eliminate these redundant levels of
9193 -- the hierarchical rendering.
9194 --
9195 -- A number of helper CTEs are used for the view definition. The first one, operators,
9196 -- looks for operator names that comprise arrangements of inputs to each level of a
9197 -- min/max/top-k hierarchy.
9198 WITH operators AS (
9199 SELECT
9200 dod.dataflow_id,
9201 dor.id AS region_id,
9202 dod.id,
9203 ars.records,
9204 ars.size
9205 FROM
9206 mz_introspection.mz_dataflow_operator_dataflows dod
9207 JOIN mz_introspection.mz_dataflow_addresses doa
9208 ON dod.id = doa.id
9209 JOIN mz_introspection.mz_dataflow_addresses dra
9210 ON dra.address = doa.address[:list_length(doa.address) - 1]
9211 JOIN mz_introspection.mz_dataflow_operators dor
9212 ON dor.id = dra.id
9213 JOIN mz_introspection.mz_arrangement_sizes ars
9214 ON ars.operator_id = dod.id
9215 WHERE
9216 dod.name = 'Arranged TopK input'
9217 OR dod.name = 'Arranged MinsMaxesHierarchical input'
9218 OR dod.name = 'Arrange ReduceMinsMaxes'
9219 ),
9220 -- The second CTE, levels, simply computes the heights of the min/max/top-k hierarchies
9221 -- identified in operators above.
9222 levels AS (
9223 SELECT o.dataflow_id, o.region_id, COUNT(*) AS levels
9224 FROM operators o
9225 GROUP BY o.dataflow_id, o.region_id
9226 ),
9227 -- The third CTE, pivot, determines for each min/max/top-k hierarchy, the first input
9228 -- operator. This operator is crucially important, as it records the number of records
9229 -- that was given as input to the gadget as a whole.
9230 pivot AS (
9231 SELECT
9232 o1.dataflow_id,
9233 o1.region_id,
9234 o1.id,
9235 o1.records
9236 FROM operators o1
9237 WHERE
9238 o1.id = (
9239 SELECT MIN(o2.id)
9240 FROM operators o2
9241 WHERE
9242 o2.dataflow_id = o1.dataflow_id
9243 AND o2.region_id = o1.region_id
9244 OPTIONS (AGGREGATE INPUT GROUP SIZE = 8)
9245 )
9246 ),
9247 -- The fourth CTE, candidates, will look for operators where the number of records
9248 -- maintained is not significantly different from the number at the pivot (excluding
9249 -- the pivot itself). These are the candidates for being cut from the dataflow region
9250 -- by adjusting the hint. The query includes a constant, heuristically tuned on TPC-H
9251 -- load generator data, to give some room for small deviations in number of records.
9252 -- The intuition for allowing for this deviation is that we are looking for a strongly
9253 -- reducing point in the hierarchy. To see why one such operator ought to exist in an
9254 -- untuned hierarchy, consider that at each level, we use hashing to distribute rows
9255 -- among groups where the min/max/top-k computation is (partially) applied. If the
9256 -- hierarchy has too many levels, the first-level (pivot) groups will be such that many
9257 -- groups might be empty or contain only one row. Each subsequent level will have a number
9258 -- of groups that is reduced exponentially. So at some point, we will find the level where
9259 -- we actually start having a few rows per group. That's where we will see the row counts
9260 -- significantly drop off.
9261 candidates AS (
9262 SELECT
9263 o.dataflow_id,
9264 o.region_id,
9265 o.id,
9266 o.records,
9267 o.size
9268 FROM
9269 operators o
9270 JOIN pivot p
9271 ON o.dataflow_id = p.dataflow_id
9272 AND o.region_id = p.region_id
9273 AND o.id <> p.id
9274 WHERE o.records >= p.records * (1 - 0.15)
9275 ),
9276 -- The fifth CTE, cuts, computes for each relevant dataflow region, the number of
9277 -- candidate levels that should be cut. We only return here dataflow regions where at
9278 -- least one level must be cut. Note that once we hit a point where the hierarchy starts
9279 -- to have a filtering effect, i.e., after the last candidate, it is dangerous to suggest
9280 -- cutting the height of the hierarchy further. This is because we will have way less
9281 -- groups in the next level, so there should be even further reduction happening or there
9282 -- is some substantial skew in the data. But if the latter is the case, then we should not
9283 -- tune the GROUP SIZE hints down anyway to avoid hurting latency upon updates directed
9284 -- at these unusually large groups. In addition to selecting the levels to cut, we also
9285 -- compute a conservative estimate of the memory savings in bytes that will result from
9286 -- cutting these levels from the hierarchy. The estimate is based on the sizes of the
9287 -- input arrangements for each level to be cut. These arrangements should dominate the
9288 -- size of each level that can be cut, since the reduction gadget internal to the level
9289 -- does not remove much data at these levels.
9290 cuts AS (
9291 SELECT c.dataflow_id, c.region_id, COUNT(*) AS to_cut, SUM(c.size) AS savings
9292 FROM candidates c
9293 GROUP BY c.dataflow_id, c.region_id
9294 HAVING COUNT(*) > 0
9295 )
9296 -- Finally, we compute the hint suggestion for each dataflow region based on the number of
9297 -- levels and the number of candidates to be cut. The hint is computed taking into account
9298 -- the fan-in used in rendering for the hash partitioning and reduction of the groups,
9299 -- currently equal to 16.
9300 SELECT
9301 dod.dataflow_id,
9302 dod.dataflow_name,
9303 dod.id AS region_id,
9304 dod.name AS region_name,
9305 l.levels,
9306 c.to_cut,
9307 c.savings,
9308 pow(16, l.levels - c.to_cut) - 1 AS hint
9309 FROM cuts c
9310 JOIN levels l
9311 ON c.dataflow_id = l.dataflow_id AND c.region_id = l.region_id
9312 JOIN mz_introspection.mz_dataflow_operator_dataflows dod
9313 ON dod.dataflow_id = c.dataflow_id AND dod.id = c.region_id",
9314 access: vec![PUBLIC_SELECT],
9315});
9316
9317pub static MZ_INDEX_ADVICE: LazyLock<BuiltinView> = LazyLock::new(|| {
9318 BuiltinView {
9319 name: "mz_index_advice",
9320 schema: MZ_INTERNAL_SCHEMA,
9321 oid: oid::VIEW_MZ_INDEX_ADVICE_OID,
9322 desc: RelationDesc::builder()
9323 .with_column("object_id", SqlScalarType::String.nullable(true))
9324 .with_column("hint", SqlScalarType::String.nullable(false))
9325 .with_column("details", SqlScalarType::String.nullable(false))
9326 .with_column("referenced_object_ids", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(true))
9327 .finish(),
9328 column_comments: BTreeMap::from_iter([
9329 ("object_id", "The ID of the object. Corresponds to mz_objects.id."),
9330 ("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."),
9331 ("details", "Additional details on why the `hint` was proposed based on the dependencies of the object."),
9332 ("referenced_object_ids", "The IDs of objects referenced by `details`. Corresponds to mz_objects.id."),
9333 ]),
9334 sql: "
9335-- To avoid confusion with sources and sinks in the materialize sense,
9336-- the following uses the terms leafs (instead of sinks) and roots (instead of sources)
9337-- when referring to the object dependency graph.
9338--
9339-- The basic idea is to walk up the dependency graph to propagate the transitive dependencies
9340-- of maintained objected upwards. The leaves of the dependency graph are maintained objects
9341-- that are not depended on by other maintained objects and have a justification why they must
9342-- be maintained (e.g. a materialized view that is depended on by a sink).
9343-- Starting from these leaves, the dependencies are propagated upwards towards the roots according
9344-- to the object dependencies. Whenever there is a node that is being depended on by multiple
9345-- downstream objects, that node is marked to be converted into a maintained object and this
9346-- node is then propagated further up. Once completed, the list of objects that are marked as
9347-- maintained is checked against all objects to generate appropriate recommendations.
9348--
9349-- Note that the recommendations only incorporate dependencies between objects.
9350-- This can lead to bad recommendations, e.g. filters can no longer be pushed into (or close to)
9351-- a sink if an index is added in between the sink and the filter. For very selective filters,
9352-- this can lead to redundant work: the index is computing stuff only to discarded by the selective
9353-- filter later on. But these kind of aspects cannot be understood by merely looking at the
9354-- dependencies.
9355WITH MUTUALLY RECURSIVE
9356 -- for all objects, understand if they have an index on them and on which cluster they are running
9357 -- this avoids having different cases for views with an index and materialized views later on
9358 objects(id text, type text, cluster_id text, indexes text list) AS (
9359 -- views and materialized views without an index
9360 SELECT
9361 o.id,
9362 o.type,
9363 o.cluster_id,
9364 '{}'::text list AS indexes
9365 FROM mz_catalog.mz_objects o
9366 WHERE o.id LIKE 'u%' AND o.type IN ('materialized-view', 'view') AND NOT EXISTS (
9367 SELECT FROM mz_internal.mz_object_dependencies d
9368 JOIN mz_catalog.mz_objects AS i
9369 ON (i.id = d.object_id AND i.type = 'index')
9370 WHERE (o.id = d.referenced_object_id)
9371 )
9372
9373 UNION ALL
9374
9375 -- views and materialized views with an index
9376 SELECT
9377 o.id,
9378 o.type,
9379 -- o.cluster_id is always NULL for views, so use the cluster of the index instead
9380 COALESCE(o.cluster_id, i.cluster_id) AS cluster_id,
9381 list_agg(i.id) AS indexes
9382 FROM mz_catalog.mz_objects o
9383 JOIN mz_internal.mz_object_dependencies AS d
9384 ON (o.id = d.referenced_object_id)
9385 JOIN mz_catalog.mz_objects AS i
9386 ON (i.id = d.object_id AND i.type = 'index')
9387 WHERE o.id LIKE 'u%' AND o.type IN ('materialized-view', 'view', 'source')
9388 GROUP BY o.id, o.type, o.cluster_id, i.cluster_id
9389 ),
9390
9391 -- maintained objects that are at the leafs of the dependency graph with respect to a specific cluster
9392 maintained_leafs(id text, justification text) AS (
9393 -- materialized views that are connected to a sink
9394 SELECT
9395 m.id,
9396 s.id AS justification
9397 FROM objects AS m
9398 JOIN mz_internal.mz_object_dependencies AS d
9399 ON (m.id = d.referenced_object_id)
9400 JOIN mz_catalog.mz_objects AS s
9401 ON (s.id = d.object_id AND s.type = 'sink')
9402 WHERE m.type = 'materialized-view'
9403
9404 UNION ALL
9405
9406 -- (materialized) views with an index that are not transitively depend on by maintained objects on the same cluster
9407 SELECT
9408 v.id,
9409 unnest(v.indexes) AS justification
9410 FROM objects AS v
9411 WHERE v.type IN ('view', 'materialized-view', 'source') AND NOT EXISTS (
9412 SELECT FROM mz_internal.mz_object_transitive_dependencies AS d
9413 INNER JOIN mz_catalog.mz_objects AS child
9414 ON (d.object_id = child.id)
9415 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]
9416 )
9417 ),
9418
9419 -- this is just a helper cte to union multiple lists as part of an aggregation, which is not directly possible in SQL
9420 agg_maintained_children(id text, maintained_children text list) AS (
9421 SELECT
9422 parent_id AS id,
9423 list_agg(maintained_child) AS maintained_leafs
9424 FROM (
9425 SELECT DISTINCT
9426 d.referenced_object_id AS parent_id,
9427 -- it's not possible to union lists in an aggregation, so we have to unnest the list first
9428 unnest(child.maintained_children) AS maintained_child
9429 FROM propagate_dependencies AS child
9430 INNER JOIN mz_internal.mz_object_dependencies AS d
9431 ON (child.id = d.object_id)
9432 )
9433 GROUP BY parent_id
9434 ),
9435
9436 -- propagate dependencies of maintained objects from the leafs to the roots of the dependency graph and
9437 -- record a justification when an object should be maintained, e.g. when it is depended on by more than one maintained object
9438 -- 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
9439 propagate_dependencies(id text, maintained_children text list, justification text list) AS (
9440 -- base case: start with the leafs
9441 SELECT DISTINCT
9442 id,
9443 LIST[id] AS maintained_children,
9444 list_agg(justification) AS justification
9445 FROM maintained_leafs
9446 GROUP BY id
9447
9448 UNION
9449
9450 -- recursive case: if there is a child with the same dependencies as the parent,
9451 -- the parent is only reused by a single child
9452 SELECT
9453 parent.id,
9454 child.maintained_children,
9455 NULL::text list AS justification
9456 FROM agg_maintained_children AS parent
9457 INNER JOIN mz_internal.mz_object_dependencies AS d
9458 ON (parent.id = d.referenced_object_id)
9459 INNER JOIN propagate_dependencies AS child
9460 ON (d.object_id = child.id)
9461 WHERE parent.maintained_children = child.maintained_children
9462
9463 UNION
9464
9465 -- recursive case: if there is NO child with the same dependencies as the parent,
9466 -- different children are reusing the parent so maintaining the object is justified by itself
9467 SELECT DISTINCT
9468 parent.id,
9469 LIST[parent.id] AS maintained_children,
9470 parent.maintained_children AS justification
9471 FROM agg_maintained_children AS parent
9472 WHERE NOT EXISTS (
9473 SELECT FROM mz_internal.mz_object_dependencies AS d
9474 INNER JOIN propagate_dependencies AS child
9475 ON (d.object_id = child.id AND d.referenced_object_id = parent.id)
9476 WHERE parent.maintained_children = child.maintained_children
9477 )
9478 ),
9479
9480 objects_with_justification(id text, type text, cluster_id text, maintained_children text list, justification text list, indexes text list) AS (
9481 SELECT
9482 p.id,
9483 o.type,
9484 o.cluster_id,
9485 p.maintained_children,
9486 p.justification,
9487 o.indexes
9488 FROM propagate_dependencies p
9489 JOIN objects AS o
9490 ON (p.id = o.id)
9491 ),
9492
9493 hints(id text, hint text, details text, justification text list) AS (
9494 -- materialized views that are not required
9495 SELECT
9496 id,
9497 'convert to a view' AS hint,
9498 'no dependencies from sinks nor from objects on different clusters' AS details,
9499 justification
9500 FROM objects_with_justification
9501 WHERE type = 'materialized-view' AND justification IS NULL
9502
9503 UNION ALL
9504
9505 -- materialized views that are required because a sink or a maintained object from a different cluster depends on them
9506 SELECT
9507 id,
9508 'keep' AS hint,
9509 'dependencies from sinks or objects on different clusters: ' AS details,
9510 justification
9511 FROM objects_with_justification AS m
9512 WHERE type = 'materialized-view' AND justification IS NOT NULL AND EXISTS (
9513 SELECT FROM unnest(justification) AS dependency
9514 JOIN mz_catalog.mz_objects s ON (s.type = 'sink' AND s.id = dependency)
9515
9516 UNION ALL
9517
9518 SELECT FROM unnest(justification) AS dependency
9519 JOIN mz_catalog.mz_objects AS d ON (d.id = dependency)
9520 WHERE d.cluster_id != m.cluster_id
9521 )
9522
9523 UNION ALL
9524
9525 -- 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
9526 SELECT
9527 id,
9528 'convert to a view with an index' AS hint,
9529 'no dependencies from sinks nor from objects on different clusters, but maintained dependencies on the same cluster: ' AS details,
9530 justification
9531 FROM objects_with_justification AS m
9532 WHERE type = 'materialized-view' AND justification IS NOT NULL AND NOT EXISTS (
9533 SELECT FROM unnest(justification) AS dependency
9534 JOIN mz_catalog.mz_objects s ON (s.type = 'sink' AND s.id = dependency)
9535
9536 UNION ALL
9537
9538 SELECT FROM unnest(justification) AS dependency
9539 JOIN mz_catalog.mz_objects AS d ON (d.id = dependency)
9540 WHERE d.cluster_id != m.cluster_id
9541 )
9542
9543 UNION ALL
9544
9545 -- views that have indexes on different clusters should be a materialized view
9546 SELECT
9547 o.id,
9548 'convert to materialized view' AS hint,
9549 'dependencies on multiple clusters: ' AS details,
9550 o.justification
9551 FROM objects_with_justification o,
9552 LATERAL unnest(o.justification) j
9553 LEFT JOIN mz_catalog.mz_objects AS m
9554 ON (m.id = j AND m.type IN ('index', 'materialized-view'))
9555 WHERE o.type = 'view' AND o.justification IS NOT NULL
9556 GROUP BY o.id, o.justification
9557 HAVING count(DISTINCT m.cluster_id) >= 2
9558
9559 UNION ALL
9560
9561 -- views without an index that should be maintained
9562 SELECT
9563 id,
9564 'add index' AS hint,
9565 'multiple downstream dependencies: ' AS details,
9566 justification
9567 FROM objects_with_justification
9568 WHERE type = 'view' AND justification IS NOT NULL AND indexes = '{}'::text list
9569
9570 UNION ALL
9571
9572 -- index inside the dependency graph (not a leaf)
9573 SELECT
9574 unnest(indexes) AS id,
9575 'drop unless queried directly' AS hint,
9576 'fewer than two downstream dependencies: ' AS details,
9577 maintained_children AS justification
9578 FROM objects_with_justification
9579 WHERE type = 'view' AND NOT indexes = '{}'::text list AND justification IS NULL
9580
9581 UNION ALL
9582
9583 -- index on a leaf of the dependency graph
9584 SELECT
9585 unnest(indexes) AS id,
9586 'drop unless queried directly' AS hint,
9587 'associated object does not have any dependencies (maintained or not maintained)' AS details,
9588 NULL::text list AS justification
9589 FROM objects_with_justification
9590 -- indexes can only be part of justification for leaf nodes
9591 WHERE type IN ('view', 'materialized-view') AND NOT indexes = '{}'::text list AND justification @> indexes
9592
9593 UNION ALL
9594
9595 -- index on a source
9596 SELECT
9597 unnest(indexes) AS id,
9598 'drop unless queried directly' AS hint,
9599 'sources do not transform data and can expose data directly' AS details,
9600 NULL::text list AS justification
9601 FROM objects_with_justification
9602 -- indexes can only be part of justification for leaf nodes
9603 WHERE type = 'source' AND NOT indexes = '{}'::text list
9604
9605 UNION ALL
9606
9607 -- indexes on views inside the dependency graph
9608 SELECT
9609 unnest(indexes) AS id,
9610 'keep' AS hint,
9611 'multiple downstream dependencies: ' AS details,
9612 justification
9613 FROM objects_with_justification
9614 -- indexes can only be part of justification for leaf nodes
9615 WHERE type = 'view' AND justification IS NOT NULL AND NOT indexes = '{}'::text list AND NOT justification @> indexes
9616 ),
9617
9618 hints_resolved_ids(id text, hint text, details text, justification text list) AS (
9619 SELECT
9620 h.id,
9621 h.hint,
9622 h.details || list_agg(o.name)::text AS details,
9623 h.justification
9624 FROM hints AS h,
9625 LATERAL unnest(h.justification) j
9626 JOIN mz_catalog.mz_objects AS o
9627 ON (o.id = j)
9628 GROUP BY h.id, h.hint, h.details, h.justification
9629
9630 UNION ALL
9631
9632 SELECT
9633 id,
9634 hint,
9635 details,
9636 justification
9637 FROM hints
9638 WHERE justification IS NULL
9639 )
9640
9641SELECT
9642 h.id AS object_id,
9643 h.hint AS hint,
9644 h.details,
9645 h.justification AS referenced_object_ids
9646FROM hints_resolved_ids AS h",
9647 access: vec![PUBLIC_SELECT],
9648 }
9649});
9650
9651pub static PG_CONSTRAINT: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9654 name: "pg_constraint",
9655 schema: PG_CATALOG_SCHEMA,
9656 oid: oid::VIEW_PG_CONSTRAINT_OID,
9657 desc: RelationDesc::builder()
9658 .with_column("oid", SqlScalarType::Oid.nullable(false))
9659 .with_column("conname", SqlScalarType::String.nullable(false))
9660 .with_column("connamespace", SqlScalarType::Oid.nullable(false))
9661 .with_column("contype", SqlScalarType::PgLegacyChar.nullable(false))
9662 .with_column("condeferrable", SqlScalarType::Bool.nullable(false))
9663 .with_column("condeferred", SqlScalarType::Bool.nullable(false))
9664 .with_column("convalidated", SqlScalarType::Bool.nullable(false))
9665 .with_column("conrelid", SqlScalarType::Oid.nullable(false))
9666 .with_column("contypid", SqlScalarType::Oid.nullable(false))
9667 .with_column("conindid", SqlScalarType::Oid.nullable(false))
9668 .with_column("conparentid", SqlScalarType::Oid.nullable(false))
9669 .with_column("confrelid", SqlScalarType::Oid.nullable(false))
9670 .with_column("confupdtype", SqlScalarType::PgLegacyChar.nullable(false))
9671 .with_column("confdeltype", SqlScalarType::PgLegacyChar.nullable(false))
9672 .with_column("confmatchtype", SqlScalarType::PgLegacyChar.nullable(false))
9673 .with_column("conislocal", SqlScalarType::Bool.nullable(false))
9674 .with_column("coninhcount", SqlScalarType::Int32.nullable(false))
9675 .with_column("connoinherit", SqlScalarType::Bool.nullable(false))
9676 .with_column(
9677 "conkey",
9678 SqlScalarType::Array(Box::new(SqlScalarType::Int16)).nullable(false),
9679 )
9680 .with_column(
9681 "confkey",
9682 SqlScalarType::Array(Box::new(SqlScalarType::Int16)).nullable(false),
9683 )
9684 .with_column(
9685 "conpfeqop",
9686 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9687 )
9688 .with_column(
9689 "conppeqop",
9690 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9691 )
9692 .with_column(
9693 "conffeqop",
9694 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9695 )
9696 .with_column(
9697 "conexclop",
9698 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9699 )
9700 .with_column("conbin", SqlScalarType::String.nullable(false))
9701 .with_key(vec![])
9702 .finish(),
9703 column_comments: BTreeMap::new(),
9704 sql: "SELECT
9705 NULL::pg_catalog.oid as oid,
9706 NULL::pg_catalog.text as conname,
9707 NULL::pg_catalog.oid as connamespace,
9708 NULL::pg_catalog.\"char\" as contype,
9709 NULL::pg_catalog.bool as condeferrable,
9710 NULL::pg_catalog.bool as condeferred,
9711 NULL::pg_catalog.bool as convalidated,
9712 NULL::pg_catalog.oid as conrelid,
9713 NULL::pg_catalog.oid as contypid,
9714 NULL::pg_catalog.oid as conindid,
9715 NULL::pg_catalog.oid as conparentid,
9716 NULL::pg_catalog.oid as confrelid,
9717 NULL::pg_catalog.\"char\" as confupdtype,
9718 NULL::pg_catalog.\"char\" as confdeltype,
9719 NULL::pg_catalog.\"char\" as confmatchtype,
9720 NULL::pg_catalog.bool as conislocal,
9721 NULL::pg_catalog.int4 as coninhcount,
9722 NULL::pg_catalog.bool as connoinherit,
9723 NULL::pg_catalog.int2[] as conkey,
9724 NULL::pg_catalog.int2[] as confkey,
9725 NULL::pg_catalog.oid[] as conpfeqop,
9726 NULL::pg_catalog.oid[] as conppeqop,
9727 NULL::pg_catalog.oid[] as conffeqop,
9728 NULL::pg_catalog.oid[] as conexclop,
9729 NULL::pg_catalog.text as conbin
9730WHERE false",
9731 access: vec![PUBLIC_SELECT],
9732});
9733
9734pub static PG_TABLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9735 name: "pg_tables",
9736 schema: PG_CATALOG_SCHEMA,
9737 oid: oid::VIEW_PG_TABLES_OID,
9738 desc: RelationDesc::builder()
9739 .with_column("schemaname", SqlScalarType::String.nullable(true))
9740 .with_column("tablename", SqlScalarType::String.nullable(false))
9741 .with_column("tableowner", SqlScalarType::String.nullable(false))
9742 .finish(),
9743 column_comments: BTreeMap::new(),
9744 sql: "
9745SELECT n.nspname AS schemaname,
9746 c.relname AS tablename,
9747 pg_catalog.pg_get_userbyid(c.relowner) AS tableowner
9748FROM pg_catalog.pg_class c
9749LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
9750WHERE c.relkind IN ('r', 'p')",
9751 access: vec![PUBLIC_SELECT],
9752});
9753
9754pub static PG_TABLESPACE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9755 name: "pg_tablespace",
9756 schema: PG_CATALOG_SCHEMA,
9757 oid: oid::VIEW_PG_TABLESPACE_OID,
9758 desc: RelationDesc::builder()
9759 .with_column("oid", SqlScalarType::Oid.nullable(false))
9760 .with_column("spcname", SqlScalarType::String.nullable(false))
9761 .with_column("spcowner", SqlScalarType::Oid.nullable(true))
9762 .with_column(
9763 "spcacl",
9764 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9765 )
9766 .with_column(
9767 "spcoptions",
9768 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9769 )
9770 .with_key(vec![])
9771 .finish(),
9772 column_comments: BTreeMap::new(),
9773 sql: "
9774 SELECT oid, spcname, spcowner, spcacl, spcoptions
9775 FROM (
9776 VALUES (
9777 --These are the same defaults CockroachDB uses.
9778 0::pg_catalog.oid,
9779 'pg_default'::pg_catalog.text,
9780 NULL::pg_catalog.oid,
9781 NULL::pg_catalog.text[],
9782 NULL::pg_catalog.text[]
9783 )
9784 ) AS _ (oid, spcname, spcowner, spcacl, spcoptions)
9785",
9786 access: vec![PUBLIC_SELECT],
9787});
9788
9789pub static PG_ACCESS_METHODS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9790 name: "pg_am",
9791 schema: PG_CATALOG_SCHEMA,
9792 oid: oid::VIEW_PG_AM_OID,
9793 desc: RelationDesc::builder()
9794 .with_column("oid", SqlScalarType::Oid.nullable(false))
9795 .with_column("amname", SqlScalarType::String.nullable(false))
9796 .with_column("amhandler", SqlScalarType::RegProc.nullable(false))
9797 .with_column("amtype", SqlScalarType::PgLegacyChar.nullable(false))
9798 .with_key(vec![])
9799 .finish(),
9800 column_comments: BTreeMap::new(),
9801 sql: "
9802SELECT NULL::pg_catalog.oid AS oid,
9803 NULL::pg_catalog.text AS amname,
9804 NULL::pg_catalog.regproc AS amhandler,
9805 NULL::pg_catalog.\"char\" AS amtype
9806WHERE false",
9807 access: vec![PUBLIC_SELECT],
9808});
9809
9810pub static PG_ROLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9811 name: "pg_roles",
9812 schema: PG_CATALOG_SCHEMA,
9813 oid: oid::VIEW_PG_ROLES_OID,
9814 desc: RelationDesc::builder()
9815 .with_column("rolname", SqlScalarType::String.nullable(false))
9816 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
9817 .with_column("rolinherit", SqlScalarType::Bool.nullable(false))
9818 .with_column("rolcreaterole", SqlScalarType::Bool.nullable(true))
9819 .with_column("rolcreatedb", SqlScalarType::Bool.nullable(true))
9820 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(false))
9821 .with_column("rolreplication", SqlScalarType::Bool.nullable(false))
9822 .with_column("rolconnlimit", SqlScalarType::Int32.nullable(false))
9823 .with_column("rolpassword", SqlScalarType::String.nullable(false))
9824 .with_column(
9825 "rolvaliduntil",
9826 SqlScalarType::TimestampTz { precision: None }.nullable(true),
9827 )
9828 .with_column("rolbypassrls", SqlScalarType::Bool.nullable(false))
9829 .with_column(
9830 "rolconfig",
9831 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9832 )
9833 .with_column("oid", SqlScalarType::Oid.nullable(false))
9834 .finish(),
9835 column_comments: BTreeMap::new(),
9836 sql: "SELECT
9837 rolname,
9838 rolsuper,
9839 rolinherit,
9840 rolcreaterole,
9841 rolcreatedb,
9842 COALESCE(rolcanlogin, false) AS rolcanlogin,
9843 rolreplication,
9844 rolconnlimit,
9845 '********' as rolpassword,
9846 rolvaliduntil,
9847 rolbypassrls,
9848 (
9849 SELECT array_agg(parameter_name || '=' || parameter_value)
9850 FROM mz_catalog.mz_role_parameters rp
9851 JOIN mz_catalog.mz_roles r ON r.id = rp.role_id
9852 WHERE ai.oid = r.oid
9853 ) AS rolconfig,
9854 oid
9855FROM pg_catalog.pg_authid ai",
9856 access: vec![PUBLIC_SELECT],
9857});
9858
9859pub static PG_USER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9860 name: "pg_user",
9861 schema: PG_CATALOG_SCHEMA,
9862 oid: oid::VIEW_PG_USER_OID,
9863 desc: RelationDesc::builder()
9864 .with_column("usename", SqlScalarType::String.nullable(false))
9865 .with_column("usesysid", SqlScalarType::Oid.nullable(false))
9866 .with_column("usecreatedb", SqlScalarType::Bool.nullable(true))
9867 .with_column("usesuper", SqlScalarType::Bool.nullable(true))
9868 .with_column("userepl", SqlScalarType::Bool.nullable(false))
9869 .with_column("usebypassrls", SqlScalarType::Bool.nullable(false))
9870 .with_column("passwd", SqlScalarType::String.nullable(true))
9871 .with_column(
9872 "valuntil",
9873 SqlScalarType::TimestampTz { precision: None }.nullable(true),
9874 )
9875 .with_column(
9876 "useconfig",
9877 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9878 )
9879 .finish(),
9880 column_comments: BTreeMap::new(),
9881 sql: "
9882SELECT
9883 rolname as usename,
9884 ai.oid as usesysid,
9885 rolcreatedb AS usecreatedb,
9886 rolsuper AS usesuper,
9887 rolreplication AS userepl,
9888 rolbypassrls AS usebypassrls,
9889 rolpassword as passwd,
9890 rolvaliduntil as valuntil,
9891 (
9892 SELECT array_agg(parameter_name || '=' || parameter_value)
9893 FROM mz_catalog.mz_role_parameters rp
9894 JOIN mz_catalog.mz_roles r ON r.id = rp.role_id
9895 WHERE ai.oid = r.oid
9896 ) AS useconfig
9897FROM pg_catalog.pg_authid ai
9898WHERE rolcanlogin",
9899 access: vec![PUBLIC_SELECT],
9900});
9901
9902pub static PG_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9903 name: "pg_views",
9904 schema: PG_CATALOG_SCHEMA,
9905 oid: oid::VIEW_PG_VIEWS_OID,
9906 desc: RelationDesc::builder()
9907 .with_column("schemaname", SqlScalarType::String.nullable(true))
9908 .with_column("viewname", SqlScalarType::String.nullable(false))
9909 .with_column("viewowner", SqlScalarType::Oid.nullable(false))
9910 .with_column("definition", SqlScalarType::String.nullable(false))
9911 .finish(),
9912 column_comments: BTreeMap::new(),
9913 sql: "SELECT
9914 s.name AS schemaname,
9915 v.name AS viewname,
9916 role_owner.oid AS viewowner,
9917 v.definition AS definition
9918FROM mz_catalog.mz_views v
9919LEFT JOIN mz_catalog.mz_schemas s ON s.id = v.schema_id
9920LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
9921JOIN mz_catalog.mz_roles role_owner ON role_owner.id = v.owner_id
9922WHERE s.database_id IS NULL OR d.name = current_database()",
9923 access: vec![PUBLIC_SELECT],
9924});
9925
9926pub static PG_MATVIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9927 name: "pg_matviews",
9928 schema: PG_CATALOG_SCHEMA,
9929 oid: oid::VIEW_PG_MATVIEWS_OID,
9930 desc: RelationDesc::builder()
9931 .with_column("schemaname", SqlScalarType::String.nullable(true))
9932 .with_column("matviewname", SqlScalarType::String.nullable(false))
9933 .with_column("matviewowner", SqlScalarType::Oid.nullable(false))
9934 .with_column("definition", SqlScalarType::String.nullable(false))
9935 .finish(),
9936 column_comments: BTreeMap::new(),
9937 sql: "SELECT
9938 s.name AS schemaname,
9939 m.name AS matviewname,
9940 role_owner.oid AS matviewowner,
9941 m.definition AS definition
9942FROM mz_catalog.mz_materialized_views m
9943LEFT JOIN mz_catalog.mz_schemas s ON s.id = m.schema_id
9944LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
9945JOIN mz_catalog.mz_roles role_owner ON role_owner.id = m.owner_id
9946WHERE s.database_id IS NULL OR d.name = current_database()",
9947 access: vec![PUBLIC_SELECT],
9948});
9949
9950pub static INFORMATION_SCHEMA_APPLICABLE_ROLES: LazyLock<BuiltinView> =
9951 LazyLock::new(|| BuiltinView {
9952 name: "applicable_roles",
9953 schema: INFORMATION_SCHEMA,
9954 oid: oid::VIEW_APPLICABLE_ROLES_OID,
9955 desc: RelationDesc::builder()
9956 .with_column("grantee", SqlScalarType::String.nullable(false))
9957 .with_column("role_name", SqlScalarType::String.nullable(false))
9958 .with_column("is_grantable", SqlScalarType::String.nullable(false))
9959 .finish(),
9960 column_comments: BTreeMap::new(),
9961 sql: "
9962SELECT
9963 member.name AS grantee,
9964 role.name AS role_name,
9965 -- ADMIN OPTION isn't implemented.
9966 'NO' AS is_grantable
9967FROM mz_catalog.mz_role_members membership
9968JOIN mz_catalog.mz_roles role ON membership.role_id = role.id
9969JOIN mz_catalog.mz_roles member ON membership.member = member.id
9970WHERE mz_catalog.mz_is_superuser() OR pg_has_role(current_role, member.oid, 'USAGE')",
9971 access: vec![PUBLIC_SELECT],
9972 });
9973
9974pub static INFORMATION_SCHEMA_COLUMNS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9975 name: "columns",
9976 schema: INFORMATION_SCHEMA,
9977 oid: oid::VIEW_COLUMNS_OID,
9978 desc: RelationDesc::builder()
9979 .with_column("table_catalog", SqlScalarType::String.nullable(false))
9980 .with_column("table_schema", SqlScalarType::String.nullable(false))
9981 .with_column("table_name", SqlScalarType::String.nullable(false))
9982 .with_column("column_name", SqlScalarType::String.nullable(false))
9983 .with_column("ordinal_position", SqlScalarType::Int64.nullable(false))
9984 .with_column("column_default", SqlScalarType::String.nullable(true))
9985 .with_column("is_nullable", SqlScalarType::String.nullable(false))
9986 .with_column("data_type", SqlScalarType::String.nullable(false))
9987 .with_column(
9988 "character_maximum_length",
9989 SqlScalarType::Int32.nullable(true),
9990 )
9991 .with_column("numeric_precision", SqlScalarType::Int32.nullable(true))
9992 .with_column("numeric_scale", SqlScalarType::Int32.nullable(true))
9993 .finish(),
9994 column_comments: BTreeMap::new(),
9995 sql: "
9996SELECT
9997 current_database() as table_catalog,
9998 s.name AS table_schema,
9999 o.name AS table_name,
10000 c.name AS column_name,
10001 c.position::int8 AS ordinal_position,
10002 c.default AS column_default,
10003 CASE WHEN c.nullable THEN 'YES' ELSE 'NO' END AS is_nullable,
10004 c.type AS data_type,
10005 NULL::pg_catalog.int4 AS character_maximum_length,
10006 NULL::pg_catalog.int4 AS numeric_precision,
10007 NULL::pg_catalog.int4 AS numeric_scale
10008FROM mz_catalog.mz_columns c
10009JOIN mz_catalog.mz_objects o ON o.id = c.id
10010JOIN mz_catalog.mz_schemas s ON s.id = o.schema_id
10011LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10012WHERE s.database_id IS NULL OR d.name = current_database()",
10013 access: vec![PUBLIC_SELECT],
10014});
10015
10016pub static INFORMATION_SCHEMA_ENABLED_ROLES: LazyLock<BuiltinView> =
10017 LazyLock::new(|| BuiltinView {
10018 name: "enabled_roles",
10019 schema: INFORMATION_SCHEMA,
10020 oid: oid::VIEW_ENABLED_ROLES_OID,
10021 desc: RelationDesc::builder()
10022 .with_column("role_name", SqlScalarType::String.nullable(false))
10023 .finish(),
10024 column_comments: BTreeMap::new(),
10025 sql: "
10026SELECT name AS role_name
10027FROM mz_catalog.mz_roles
10028WHERE mz_catalog.mz_is_superuser() OR pg_has_role(current_role, oid, 'USAGE')",
10029 access: vec![PUBLIC_SELECT],
10030 });
10031
10032pub static INFORMATION_SCHEMA_ROLE_TABLE_GRANTS: LazyLock<BuiltinView> = LazyLock::new(|| {
10033 BuiltinView {
10034 name: "role_table_grants",
10035 schema: INFORMATION_SCHEMA,
10036 oid: oid::VIEW_ROLE_TABLE_GRANTS_OID,
10037 desc: RelationDesc::builder()
10038 .with_column("grantor", SqlScalarType::String.nullable(false))
10039 .with_column("grantee", SqlScalarType::String.nullable(true))
10040 .with_column("table_catalog", SqlScalarType::String.nullable(true))
10041 .with_column("table_schema", SqlScalarType::String.nullable(false))
10042 .with_column("table_name", SqlScalarType::String.nullable(false))
10043 .with_column("privilege_type", SqlScalarType::String.nullable(true))
10044 .with_column("is_grantable", SqlScalarType::String.nullable(false))
10045 .with_column("with_hierarchy", SqlScalarType::String.nullable(false))
10046 .finish(),
10047 column_comments: BTreeMap::new(),
10048 sql: "
10049SELECT grantor, grantee, table_catalog, table_schema, table_name, privilege_type, is_grantable, with_hierarchy
10050FROM information_schema.table_privileges
10051WHERE
10052 grantor IN (SELECT role_name FROM information_schema.enabled_roles)
10053 OR grantee IN (SELECT role_name FROM information_schema.enabled_roles)",
10054 access: vec![PUBLIC_SELECT],
10055 }
10056});
10057
10058pub static INFORMATION_SCHEMA_KEY_COLUMN_USAGE: LazyLock<BuiltinView> =
10059 LazyLock::new(|| BuiltinView {
10060 name: "key_column_usage",
10061 schema: INFORMATION_SCHEMA,
10062 oid: oid::VIEW_KEY_COLUMN_USAGE_OID,
10063 desc: RelationDesc::builder()
10064 .with_column("constraint_catalog", SqlScalarType::String.nullable(false))
10065 .with_column("constraint_schema", SqlScalarType::String.nullable(false))
10066 .with_column("constraint_name", SqlScalarType::String.nullable(false))
10067 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10068 .with_column("table_schema", SqlScalarType::String.nullable(false))
10069 .with_column("table_name", SqlScalarType::String.nullable(false))
10070 .with_column("column_name", SqlScalarType::String.nullable(false))
10071 .with_column("ordinal_position", SqlScalarType::Int32.nullable(false))
10072 .with_column(
10073 "position_in_unique_constraint",
10074 SqlScalarType::Int32.nullable(false),
10075 )
10076 .with_key(vec![])
10077 .finish(),
10078 column_comments: BTreeMap::new(),
10079 sql: "SELECT
10080 NULL::text AS constraint_catalog,
10081 NULL::text AS constraint_schema,
10082 NULL::text AS constraint_name,
10083 NULL::text AS table_catalog,
10084 NULL::text AS table_schema,
10085 NULL::text AS table_name,
10086 NULL::text AS column_name,
10087 NULL::integer AS ordinal_position,
10088 NULL::integer AS position_in_unique_constraint
10089WHERE false",
10090 access: vec![PUBLIC_SELECT],
10091 });
10092
10093pub static INFORMATION_SCHEMA_REFERENTIAL_CONSTRAINTS: LazyLock<BuiltinView> =
10094 LazyLock::new(|| BuiltinView {
10095 name: "referential_constraints",
10096 schema: INFORMATION_SCHEMA,
10097 oid: oid::VIEW_REFERENTIAL_CONSTRAINTS_OID,
10098 desc: RelationDesc::builder()
10099 .with_column("constraint_catalog", SqlScalarType::String.nullable(false))
10100 .with_column("constraint_schema", SqlScalarType::String.nullable(false))
10101 .with_column("constraint_name", SqlScalarType::String.nullable(false))
10102 .with_column(
10103 "unique_constraint_catalog",
10104 SqlScalarType::String.nullable(false),
10105 )
10106 .with_column(
10107 "unique_constraint_schema",
10108 SqlScalarType::String.nullable(false),
10109 )
10110 .with_column(
10111 "unique_constraint_name",
10112 SqlScalarType::String.nullable(false),
10113 )
10114 .with_column("match_option", SqlScalarType::String.nullable(false))
10115 .with_column("update_rule", SqlScalarType::String.nullable(false))
10116 .with_column("delete_rule", SqlScalarType::String.nullable(false))
10117 .with_key(vec![])
10118 .finish(),
10119 column_comments: BTreeMap::new(),
10120 sql: "SELECT
10121 NULL::text AS constraint_catalog,
10122 NULL::text AS constraint_schema,
10123 NULL::text AS constraint_name,
10124 NULL::text AS unique_constraint_catalog,
10125 NULL::text AS unique_constraint_schema,
10126 NULL::text AS unique_constraint_name,
10127 NULL::text AS match_option,
10128 NULL::text AS update_rule,
10129 NULL::text AS delete_rule
10130WHERE false",
10131 access: vec![PUBLIC_SELECT],
10132 });
10133
10134pub static INFORMATION_SCHEMA_ROUTINES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10135 name: "routines",
10136 schema: INFORMATION_SCHEMA,
10137 oid: oid::VIEW_ROUTINES_OID,
10138 desc: RelationDesc::builder()
10139 .with_column("routine_catalog", SqlScalarType::String.nullable(false))
10140 .with_column("routine_schema", SqlScalarType::String.nullable(false))
10141 .with_column("routine_name", SqlScalarType::String.nullable(false))
10142 .with_column("routine_type", SqlScalarType::String.nullable(false))
10143 .with_column("routine_definition", SqlScalarType::String.nullable(true))
10144 .finish(),
10145 column_comments: BTreeMap::new(),
10146 sql: "SELECT
10147 current_database() as routine_catalog,
10148 s.name AS routine_schema,
10149 f.name AS routine_name,
10150 'FUNCTION' AS routine_type,
10151 NULL::text AS routine_definition
10152FROM mz_catalog.mz_functions f
10153JOIN mz_catalog.mz_schemas s ON s.id = f.schema_id
10154LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10155WHERE s.database_id IS NULL OR d.name = current_database()",
10156 access: vec![PUBLIC_SELECT],
10157});
10158
10159pub static INFORMATION_SCHEMA_SCHEMATA: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10160 name: "schemata",
10161 schema: INFORMATION_SCHEMA,
10162 oid: oid::VIEW_SCHEMATA_OID,
10163 desc: RelationDesc::builder()
10164 .with_column("catalog_name", SqlScalarType::String.nullable(false))
10165 .with_column("schema_name", SqlScalarType::String.nullable(false))
10166 .finish(),
10167 column_comments: BTreeMap::new(),
10168 sql: "
10169SELECT
10170 current_database() as catalog_name,
10171 s.name AS schema_name
10172FROM mz_catalog.mz_schemas s
10173LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10174WHERE s.database_id IS NULL OR d.name = current_database()",
10175 access: vec![PUBLIC_SELECT],
10176});
10177
10178pub static INFORMATION_SCHEMA_TABLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10179 name: "tables",
10180 schema: INFORMATION_SCHEMA,
10181 oid: oid::VIEW_TABLES_OID,
10182 desc: RelationDesc::builder()
10183 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10184 .with_column("table_schema", SqlScalarType::String.nullable(false))
10185 .with_column("table_name", SqlScalarType::String.nullable(false))
10186 .with_column("table_type", SqlScalarType::String.nullable(false))
10187 .finish(),
10188 column_comments: BTreeMap::new(),
10189 sql: "SELECT
10190 current_database() as table_catalog,
10191 s.name AS table_schema,
10192 r.name AS table_name,
10193 CASE r.type
10194 WHEN 'materialized-view' THEN 'MATERIALIZED VIEW'
10195 WHEN 'table' THEN 'BASE TABLE'
10196 ELSE pg_catalog.upper(r.type)
10197 END AS table_type
10198FROM mz_catalog.mz_relations r
10199JOIN mz_catalog.mz_schemas s ON s.id = r.schema_id
10200LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10201WHERE s.database_id IS NULL OR d.name = current_database()",
10202 access: vec![PUBLIC_SELECT],
10203});
10204
10205pub static INFORMATION_SCHEMA_TABLE_CONSTRAINTS: LazyLock<BuiltinView> =
10206 LazyLock::new(|| BuiltinView {
10207 name: "table_constraints",
10208 schema: INFORMATION_SCHEMA,
10209 oid: oid::VIEW_TABLE_CONSTRAINTS_OID,
10210 desc: RelationDesc::builder()
10211 .with_column("constraint_catalog", SqlScalarType::String.nullable(false))
10212 .with_column("constraint_schema", SqlScalarType::String.nullable(false))
10213 .with_column("constraint_name", SqlScalarType::String.nullable(false))
10214 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10215 .with_column("table_schema", SqlScalarType::String.nullable(false))
10216 .with_column("table_name", SqlScalarType::String.nullable(false))
10217 .with_column("constraint_type", SqlScalarType::String.nullable(false))
10218 .with_column("is_deferrable", SqlScalarType::String.nullable(false))
10219 .with_column("initially_deferred", SqlScalarType::String.nullable(false))
10220 .with_column("enforced", SqlScalarType::String.nullable(false))
10221 .with_column("nulls_distinct", SqlScalarType::String.nullable(false))
10222 .with_key(vec![])
10223 .finish(),
10224 column_comments: BTreeMap::new(),
10225 sql: "SELECT
10226 NULL::text AS constraint_catalog,
10227 NULL::text AS constraint_schema,
10228 NULL::text AS constraint_name,
10229 NULL::text AS table_catalog,
10230 NULL::text AS table_schema,
10231 NULL::text AS table_name,
10232 NULL::text AS constraint_type,
10233 NULL::text AS is_deferrable,
10234 NULL::text AS initially_deferred,
10235 NULL::text AS enforced,
10236 NULL::text AS nulls_distinct
10237WHERE false",
10238 access: vec![PUBLIC_SELECT],
10239 });
10240
10241pub static INFORMATION_SCHEMA_TABLE_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| {
10242 BuiltinView {
10243 name: "table_privileges",
10244 schema: INFORMATION_SCHEMA,
10245 oid: oid::VIEW_TABLE_PRIVILEGES_OID,
10246 desc: RelationDesc::builder()
10247 .with_column("grantor", SqlScalarType::String.nullable(false))
10248 .with_column("grantee", SqlScalarType::String.nullable(true))
10249 .with_column("table_catalog", SqlScalarType::String.nullable(true))
10250 .with_column("table_schema", SqlScalarType::String.nullable(false))
10251 .with_column("table_name", SqlScalarType::String.nullable(false))
10252 .with_column("privilege_type", SqlScalarType::String.nullable(true))
10253 .with_column("is_grantable", SqlScalarType::String.nullable(false))
10254 .with_column("with_hierarchy", SqlScalarType::String.nullable(false))
10255 .finish(),
10256 column_comments: BTreeMap::new(),
10257 sql: "
10258SELECT
10259 grantor,
10260 grantee,
10261 table_catalog,
10262 table_schema,
10263 table_name,
10264 privilege_type,
10265 is_grantable,
10266 CASE privilege_type
10267 WHEN 'SELECT' THEN 'YES'
10268 ELSE 'NO'
10269 END AS with_hierarchy
10270FROM
10271 (SELECT
10272 grantor.name AS grantor,
10273 CASE mz_internal.mz_aclitem_grantee(privileges)
10274 WHEN 'p' THEN 'PUBLIC'
10275 ELSE grantee.name
10276 END AS grantee,
10277 table_catalog,
10278 table_schema,
10279 table_name,
10280 unnest(mz_internal.mz_format_privileges(mz_internal.mz_aclitem_privileges(privileges))) AS privilege_type,
10281 -- ADMIN OPTION isn't implemented.
10282 'NO' AS is_grantable
10283 FROM
10284 (SELECT
10285 unnest(relations.privileges) AS privileges,
10286 CASE
10287 WHEN schemas.database_id IS NULL THEN current_database()
10288 ELSE databases.name
10289 END AS table_catalog,
10290 schemas.name AS table_schema,
10291 relations.name AS table_name
10292 FROM mz_catalog.mz_relations AS relations
10293 JOIN mz_catalog.mz_schemas AS schemas ON relations.schema_id = schemas.id
10294 LEFT JOIN mz_catalog.mz_databases AS databases ON schemas.database_id = databases.id
10295 WHERE schemas.database_id IS NULL OR databases.name = current_database())
10296 JOIN mz_catalog.mz_roles AS grantor ON mz_internal.mz_aclitem_grantor(privileges) = grantor.id
10297 LEFT JOIN mz_catalog.mz_roles AS grantee ON mz_internal.mz_aclitem_grantee(privileges) = grantee.id)
10298WHERE
10299 -- WHERE clause is not guaranteed to short-circuit and 'PUBLIC' will cause an error when passed
10300 -- to pg_has_role. Therefore we need to use a CASE statement.
10301 CASE
10302 WHEN grantee = 'PUBLIC' THEN true
10303 ELSE mz_catalog.mz_is_superuser()
10304 OR pg_has_role(current_role, grantee, 'USAGE')
10305 OR pg_has_role(current_role, grantor, 'USAGE')
10306 END",
10307 access: vec![PUBLIC_SELECT],
10308 }
10309});
10310
10311pub static INFORMATION_SCHEMA_TRIGGERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10312 name: "triggers",
10313 schema: INFORMATION_SCHEMA,
10314 oid: oid::VIEW_TRIGGERS_OID,
10315 desc: RelationDesc::builder()
10316 .with_column("trigger_catalog", SqlScalarType::String.nullable(false))
10317 .with_column("trigger_schema", SqlScalarType::String.nullable(false))
10318 .with_column("trigger_name", SqlScalarType::String.nullable(false))
10319 .with_column("event_manipulation", SqlScalarType::String.nullable(false))
10320 .with_column(
10321 "event_object_catalog",
10322 SqlScalarType::String.nullable(false),
10323 )
10324 .with_column("event_object_schema", SqlScalarType::String.nullable(false))
10325 .with_column("event_object_table", SqlScalarType::String.nullable(false))
10326 .with_column("action_order", SqlScalarType::Int32.nullable(false))
10327 .with_column("action_condition", SqlScalarType::String.nullable(false))
10328 .with_column("action_statement", SqlScalarType::String.nullable(false))
10329 .with_column("action_orientation", SqlScalarType::String.nullable(false))
10330 .with_column("action_timing", SqlScalarType::String.nullable(false))
10331 .with_column(
10332 "action_reference_old_table",
10333 SqlScalarType::String.nullable(false),
10334 )
10335 .with_column(
10336 "action_reference_new_table",
10337 SqlScalarType::String.nullable(false),
10338 )
10339 .with_key(vec![])
10340 .finish(),
10341 column_comments: BTreeMap::new(),
10342 sql: "SELECT
10343 NULL::text as trigger_catalog,
10344 NULL::text AS trigger_schema,
10345 NULL::text AS trigger_name,
10346 NULL::text AS event_manipulation,
10347 NULL::text AS event_object_catalog,
10348 NULL::text AS event_object_schema,
10349 NULL::text AS event_object_table,
10350 NULL::integer AS action_order,
10351 NULL::text AS action_condition,
10352 NULL::text AS action_statement,
10353 NULL::text AS action_orientation,
10354 NULL::text AS action_timing,
10355 NULL::text AS action_reference_old_table,
10356 NULL::text AS action_reference_new_table
10357WHERE FALSE",
10358 access: vec![PUBLIC_SELECT],
10359});
10360
10361pub static INFORMATION_SCHEMA_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10362 name: "views",
10363 schema: INFORMATION_SCHEMA,
10364 oid: oid::VIEW_VIEWS_OID,
10365 desc: RelationDesc::builder()
10366 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10367 .with_column("table_schema", SqlScalarType::String.nullable(false))
10368 .with_column("table_name", SqlScalarType::String.nullable(false))
10369 .with_column("view_definition", SqlScalarType::String.nullable(false))
10370 .finish(),
10371 column_comments: BTreeMap::new(),
10372 sql: "SELECT
10373 current_database() as table_catalog,
10374 s.name AS table_schema,
10375 v.name AS table_name,
10376 v.definition AS view_definition
10377FROM mz_catalog.mz_views v
10378JOIN mz_catalog.mz_schemas s ON s.id = v.schema_id
10379LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10380WHERE s.database_id IS NULL OR d.name = current_database()",
10381 access: vec![PUBLIC_SELECT],
10382});
10383
10384pub static INFORMATION_SCHEMA_CHARACTER_SETS: LazyLock<BuiltinView> =
10385 LazyLock::new(|| BuiltinView {
10386 name: "character_sets",
10387 schema: INFORMATION_SCHEMA,
10388 oid: oid::VIEW_CHARACTER_SETS_OID,
10389 desc: RelationDesc::builder()
10390 .with_column(
10391 "character_set_catalog",
10392 SqlScalarType::String.nullable(true),
10393 )
10394 .with_column("character_set_schema", SqlScalarType::String.nullable(true))
10395 .with_column("character_set_name", SqlScalarType::String.nullable(false))
10396 .with_column(
10397 "character_repertoire",
10398 SqlScalarType::String.nullable(false),
10399 )
10400 .with_column("form_of_use", SqlScalarType::String.nullable(false))
10401 .with_column(
10402 "default_collate_catalog",
10403 SqlScalarType::String.nullable(false),
10404 )
10405 .with_column(
10406 "default_collate_schema",
10407 SqlScalarType::String.nullable(false),
10408 )
10409 .with_column(
10410 "default_collate_name",
10411 SqlScalarType::String.nullable(false),
10412 )
10413 .with_key(vec![])
10414 .finish(),
10415 column_comments: BTreeMap::new(),
10416 sql: "SELECT
10417 NULL as character_set_catalog,
10418 NULL as character_set_schema,
10419 'UTF8' as character_set_name,
10420 'UCS' as character_repertoire,
10421 'UTF8' as form_of_use,
10422 current_database() as default_collate_catalog,
10423 'pg_catalog' as default_collate_schema,
10424 'en_US.utf8' as default_collate_name",
10425 access: vec![PUBLIC_SELECT],
10426 });
10427
10428pub static PG_COLLATION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10431 name: "pg_collation",
10432 schema: PG_CATALOG_SCHEMA,
10433 oid: oid::VIEW_PG_COLLATION_OID,
10434 desc: RelationDesc::builder()
10435 .with_column("oid", SqlScalarType::Oid.nullable(false))
10436 .with_column("collname", SqlScalarType::String.nullable(false))
10437 .with_column("collnamespace", SqlScalarType::Oid.nullable(false))
10438 .with_column("collowner", SqlScalarType::Oid.nullable(false))
10439 .with_column("collprovider", SqlScalarType::PgLegacyChar.nullable(false))
10440 .with_column("collisdeterministic", SqlScalarType::Bool.nullable(false))
10441 .with_column("collencoding", SqlScalarType::Int32.nullable(false))
10442 .with_column("collcollate", SqlScalarType::String.nullable(false))
10443 .with_column("collctype", SqlScalarType::String.nullable(false))
10444 .with_column("collversion", SqlScalarType::String.nullable(false))
10445 .with_key(vec![])
10446 .finish(),
10447 column_comments: BTreeMap::new(),
10448 sql: "
10449SELECT
10450 NULL::pg_catalog.oid AS oid,
10451 NULL::pg_catalog.text AS collname,
10452 NULL::pg_catalog.oid AS collnamespace,
10453 NULL::pg_catalog.oid AS collowner,
10454 NULL::pg_catalog.\"char\" AS collprovider,
10455 NULL::pg_catalog.bool AS collisdeterministic,
10456 NULL::pg_catalog.int4 AS collencoding,
10457 NULL::pg_catalog.text AS collcollate,
10458 NULL::pg_catalog.text AS collctype,
10459 NULL::pg_catalog.text AS collversion
10460WHERE false",
10461 access: vec![PUBLIC_SELECT],
10462});
10463
10464pub static PG_POLICY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10466 name: "pg_policy",
10467 schema: PG_CATALOG_SCHEMA,
10468 oid: oid::VIEW_PG_POLICY_OID,
10469 desc: RelationDesc::builder()
10470 .with_column("oid", SqlScalarType::Oid.nullable(false))
10471 .with_column("polname", SqlScalarType::String.nullable(false))
10472 .with_column("polrelid", SqlScalarType::Oid.nullable(false))
10473 .with_column("polcmd", SqlScalarType::PgLegacyChar.nullable(false))
10474 .with_column("polpermissive", SqlScalarType::Bool.nullable(false))
10475 .with_column(
10476 "polroles",
10477 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
10478 )
10479 .with_column("polqual", SqlScalarType::String.nullable(false))
10480 .with_column("polwithcheck", SqlScalarType::String.nullable(false))
10481 .with_key(vec![])
10482 .finish(),
10483 column_comments: BTreeMap::new(),
10484 sql: "
10485SELECT
10486 NULL::pg_catalog.oid AS oid,
10487 NULL::pg_catalog.text AS polname,
10488 NULL::pg_catalog.oid AS polrelid,
10489 NULL::pg_catalog.\"char\" AS polcmd,
10490 NULL::pg_catalog.bool AS polpermissive,
10491 NULL::pg_catalog.oid[] AS polroles,
10492 NULL::pg_catalog.text AS polqual,
10493 NULL::pg_catalog.text AS polwithcheck
10494WHERE false",
10495 access: vec![PUBLIC_SELECT],
10496});
10497
10498pub static PG_INHERITS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10500 name: "pg_inherits",
10501 schema: PG_CATALOG_SCHEMA,
10502 oid: oid::VIEW_PG_INHERITS_OID,
10503 desc: RelationDesc::builder()
10504 .with_column("inhrelid", SqlScalarType::Oid.nullable(false))
10505 .with_column("inhparent", SqlScalarType::Oid.nullable(false))
10506 .with_column("inhseqno", SqlScalarType::Int32.nullable(false))
10507 .with_column("inhdetachpending", SqlScalarType::Bool.nullable(false))
10508 .with_key(vec![])
10509 .finish(),
10510 column_comments: BTreeMap::new(),
10511 sql: "
10512SELECT
10513 NULL::pg_catalog.oid AS inhrelid,
10514 NULL::pg_catalog.oid AS inhparent,
10515 NULL::pg_catalog.int4 AS inhseqno,
10516 NULL::pg_catalog.bool AS inhdetachpending
10517WHERE false",
10518 access: vec![PUBLIC_SELECT],
10519});
10520
10521pub static PG_LOCKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10522 name: "pg_locks",
10523 schema: PG_CATALOG_SCHEMA,
10524 oid: oid::VIEW_PG_LOCKS_OID,
10525 desc: RelationDesc::builder()
10526 .with_column("locktype", SqlScalarType::String.nullable(false))
10527 .with_column("database", SqlScalarType::Oid.nullable(false))
10528 .with_column("relation", SqlScalarType::Oid.nullable(false))
10529 .with_column("page", SqlScalarType::Int32.nullable(false))
10530 .with_column("tuple", SqlScalarType::Int16.nullable(false))
10531 .with_column("virtualxid", SqlScalarType::String.nullable(false))
10532 .with_column("transactionid", SqlScalarType::String.nullable(false))
10533 .with_column("classid", SqlScalarType::Oid.nullable(false))
10534 .with_column("objid", SqlScalarType::Oid.nullable(false))
10535 .with_column("objsubid", SqlScalarType::Int16.nullable(false))
10536 .with_column("virtualtransaction", SqlScalarType::String.nullable(false))
10537 .with_column("pid", SqlScalarType::Int32.nullable(false))
10538 .with_column("mode", SqlScalarType::String.nullable(false))
10539 .with_column("granted", SqlScalarType::Bool.nullable(false))
10540 .with_column("fastpath", SqlScalarType::Bool.nullable(false))
10541 .with_column(
10542 "waitstart",
10543 SqlScalarType::TimestampTz { precision: None }.nullable(false),
10544 )
10545 .with_key(vec![])
10546 .finish(),
10547 column_comments: BTreeMap::new(),
10548 sql: "
10549SELECT
10550-- While there exist locks in Materialize, we don't expose them, so all of these fields are NULL.
10551 NULL::pg_catalog.text AS locktype,
10552 NULL::pg_catalog.oid AS database,
10553 NULL::pg_catalog.oid AS relation,
10554 NULL::pg_catalog.int4 AS page,
10555 NULL::pg_catalog.int2 AS tuple,
10556 NULL::pg_catalog.text AS virtualxid,
10557 NULL::pg_catalog.text AS transactionid,
10558 NULL::pg_catalog.oid AS classid,
10559 NULL::pg_catalog.oid AS objid,
10560 NULL::pg_catalog.int2 AS objsubid,
10561 NULL::pg_catalog.text AS virtualtransaction,
10562 NULL::pg_catalog.int4 AS pid,
10563 NULL::pg_catalog.text AS mode,
10564 NULL::pg_catalog.bool AS granted,
10565 NULL::pg_catalog.bool AS fastpath,
10566 NULL::pg_catalog.timestamptz AS waitstart
10567WHERE false",
10568 access: vec![PUBLIC_SELECT],
10569});
10570
10571pub static PG_AUTHID: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10572 name: "pg_authid",
10573 schema: PG_CATALOG_SCHEMA,
10574 oid: oid::VIEW_PG_AUTHID_OID,
10575 desc: RelationDesc::builder()
10576 .with_column("oid", SqlScalarType::Oid.nullable(false))
10577 .with_column("rolname", SqlScalarType::String.nullable(false))
10578 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
10579 .with_column("rolinherit", SqlScalarType::Bool.nullable(false))
10580 .with_column("rolcreaterole", SqlScalarType::Bool.nullable(true))
10581 .with_column("rolcreatedb", SqlScalarType::Bool.nullable(true))
10582 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(false))
10583 .with_column("rolreplication", SqlScalarType::Bool.nullable(false))
10584 .with_column("rolbypassrls", SqlScalarType::Bool.nullable(false))
10585 .with_column("rolconnlimit", SqlScalarType::Int32.nullable(false))
10586 .with_column("rolpassword", SqlScalarType::String.nullable(true))
10587 .with_column(
10588 "rolvaliduntil",
10589 SqlScalarType::TimestampTz { precision: None }.nullable(true),
10590 )
10591 .finish(),
10592 column_comments: BTreeMap::new(),
10593 sql: r#"
10594SELECT
10595 r.oid AS oid,
10596 r.name AS rolname,
10597 rolsuper,
10598 inherit AS rolinherit,
10599 mz_catalog.has_system_privilege(r.oid, 'CREATEROLE') AS rolcreaterole,
10600 mz_catalog.has_system_privilege(r.oid, 'CREATEDB') AS rolcreatedb,
10601 COALESCE(r.rolcanlogin, false) AS rolcanlogin,
10602 -- MZ doesn't support replication in the same way Postgres does
10603 false AS rolreplication,
10604 -- MZ doesn't how row level security
10605 false AS rolbypassrls,
10606 -- MZ doesn't have a connection limit
10607 -1 AS rolconnlimit,
10608 a.password_hash AS rolpassword,
10609 NULL::pg_catalog.timestamptz AS rolvaliduntil
10610FROM mz_catalog.mz_roles r
10611LEFT JOIN mz_catalog.mz_role_auth a ON r.oid = a.role_oid"#,
10612 access: vec![rbac::owner_privilege(ObjectType::Table, MZ_SYSTEM_ROLE_ID)],
10613});
10614
10615pub static PG_AGGREGATE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10616 name: "pg_aggregate",
10617 schema: PG_CATALOG_SCHEMA,
10618 oid: oid::VIEW_PG_AGGREGATE_OID,
10619 desc: RelationDesc::builder()
10620 .with_column("aggfnoid", SqlScalarType::Oid.nullable(false))
10621 .with_column("aggkind", SqlScalarType::String.nullable(false))
10622 .with_column("aggnumdirectargs", SqlScalarType::Int16.nullable(false))
10623 .with_column("aggtransfn", SqlScalarType::RegProc.nullable(true))
10624 .with_column("aggfinalfn", SqlScalarType::RegProc.nullable(false))
10625 .with_column("aggcombinefn", SqlScalarType::RegProc.nullable(false))
10626 .with_column("aggserialfn", SqlScalarType::RegProc.nullable(false))
10627 .with_column("aggdeserialfn", SqlScalarType::RegProc.nullable(false))
10628 .with_column("aggmtransfn", SqlScalarType::RegProc.nullable(false))
10629 .with_column("aggminvtransfn", SqlScalarType::RegProc.nullable(false))
10630 .with_column("aggmfinalfn", SqlScalarType::RegProc.nullable(false))
10631 .with_column("aggfinalextra", SqlScalarType::Bool.nullable(false))
10632 .with_column("aggmfinalextra", SqlScalarType::Bool.nullable(false))
10633 .with_column("aggfinalmodify", SqlScalarType::PgLegacyChar.nullable(true))
10634 .with_column(
10635 "aggmfinalmodify",
10636 SqlScalarType::PgLegacyChar.nullable(true),
10637 )
10638 .with_column("aggsortop", SqlScalarType::Oid.nullable(false))
10639 .with_column("aggtranstype", SqlScalarType::Oid.nullable(true))
10640 .with_column("aggtransspace", SqlScalarType::Int32.nullable(true))
10641 .with_column("aggmtranstype", SqlScalarType::Oid.nullable(false))
10642 .with_column("aggmtransspace", SqlScalarType::Int32.nullable(true))
10643 .with_column("agginitval", SqlScalarType::String.nullable(true))
10644 .with_column("aggminitval", SqlScalarType::String.nullable(true))
10645 .finish(),
10646 column_comments: BTreeMap::new(),
10647 sql: "SELECT
10648 a.oid as aggfnoid,
10649 -- Currently Materialize only support 'normal' aggregate functions.
10650 a.agg_kind as aggkind,
10651 a.agg_num_direct_args as aggnumdirectargs,
10652 -- Materialize doesn't support these fields.
10653 NULL::pg_catalog.regproc as aggtransfn,
10654 '0'::pg_catalog.regproc as aggfinalfn,
10655 '0'::pg_catalog.regproc as aggcombinefn,
10656 '0'::pg_catalog.regproc as aggserialfn,
10657 '0'::pg_catalog.regproc as aggdeserialfn,
10658 '0'::pg_catalog.regproc as aggmtransfn,
10659 '0'::pg_catalog.regproc as aggminvtransfn,
10660 '0'::pg_catalog.regproc as aggmfinalfn,
10661 false as aggfinalextra,
10662 false as aggmfinalextra,
10663 NULL::pg_catalog.\"char\" AS aggfinalmodify,
10664 NULL::pg_catalog.\"char\" AS aggmfinalmodify,
10665 '0'::pg_catalog.oid as aggsortop,
10666 NULL::pg_catalog.oid as aggtranstype,
10667 NULL::pg_catalog.int4 as aggtransspace,
10668 '0'::pg_catalog.oid as aggmtranstype,
10669 NULL::pg_catalog.int4 as aggmtransspace,
10670 NULL::pg_catalog.text as agginitval,
10671 NULL::pg_catalog.text as aggminitval
10672FROM mz_internal.mz_aggregates a",
10673 access: vec![PUBLIC_SELECT],
10674});
10675
10676pub static PG_TRIGGER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10677 name: "pg_trigger",
10678 schema: PG_CATALOG_SCHEMA,
10679 oid: oid::VIEW_PG_TRIGGER_OID,
10680 desc: RelationDesc::builder()
10681 .with_column("oid", SqlScalarType::Oid.nullable(false))
10682 .with_column("tgrelid", SqlScalarType::Oid.nullable(false))
10683 .with_column("tgparentid", SqlScalarType::Oid.nullable(false))
10684 .with_column("tgname", SqlScalarType::String.nullable(false))
10685 .with_column("tgfoid", SqlScalarType::Oid.nullable(false))
10686 .with_column("tgtype", SqlScalarType::Int16.nullable(false))
10687 .with_column("tgenabled", SqlScalarType::PgLegacyChar.nullable(false))
10688 .with_column("tgisinternal", SqlScalarType::Bool.nullable(false))
10689 .with_column("tgconstrrelid", SqlScalarType::Oid.nullable(false))
10690 .with_column("tgconstrindid", SqlScalarType::Oid.nullable(false))
10691 .with_column("tgconstraint", SqlScalarType::Oid.nullable(false))
10692 .with_column("tgdeferrable", SqlScalarType::Bool.nullable(false))
10693 .with_column("tginitdeferred", SqlScalarType::Bool.nullable(false))
10694 .with_column("tgnargs", SqlScalarType::Int16.nullable(false))
10695 .with_column("tgattr", SqlScalarType::Int2Vector.nullable(false))
10696 .with_column("tgargs", SqlScalarType::Bytes.nullable(false))
10697 .with_column("tgqual", SqlScalarType::String.nullable(false))
10698 .with_column("tgoldtable", SqlScalarType::String.nullable(false))
10699 .with_column("tgnewtable", SqlScalarType::String.nullable(false))
10700 .with_key(vec![])
10701 .finish(),
10702 column_comments: BTreeMap::new(),
10703 sql: "SELECT
10704 -- MZ doesn't support triggers so all of these fields are NULL.
10705 NULL::pg_catalog.oid AS oid,
10706 NULL::pg_catalog.oid AS tgrelid,
10707 NULL::pg_catalog.oid AS tgparentid,
10708 NULL::pg_catalog.text AS tgname,
10709 NULL::pg_catalog.oid AS tgfoid,
10710 NULL::pg_catalog.int2 AS tgtype,
10711 NULL::pg_catalog.\"char\" AS tgenabled,
10712 NULL::pg_catalog.bool AS tgisinternal,
10713 NULL::pg_catalog.oid AS tgconstrrelid,
10714 NULL::pg_catalog.oid AS tgconstrindid,
10715 NULL::pg_catalog.oid AS tgconstraint,
10716 NULL::pg_catalog.bool AS tgdeferrable,
10717 NULL::pg_catalog.bool AS tginitdeferred,
10718 NULL::pg_catalog.int2 AS tgnargs,
10719 NULL::pg_catalog.int2vector AS tgattr,
10720 NULL::pg_catalog.bytea AS tgargs,
10721 -- NOTE: The tgqual column is actually type `pg_node_tree` which we don't support. CockroachDB
10722 -- uses text as a placeholder, so we'll follow their lead here.
10723 NULL::pg_catalog.text AS tgqual,
10724 NULL::pg_catalog.text AS tgoldtable,
10725 NULL::pg_catalog.text AS tgnewtable
10726WHERE false
10727 ",
10728 access: vec![PUBLIC_SELECT],
10729});
10730
10731pub static PG_REWRITE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10732 name: "pg_rewrite",
10733 schema: PG_CATALOG_SCHEMA,
10734 oid: oid::VIEW_PG_REWRITE_OID,
10735 desc: RelationDesc::builder()
10736 .with_column("oid", SqlScalarType::Oid.nullable(false))
10737 .with_column("rulename", SqlScalarType::String.nullable(false))
10738 .with_column("ev_class", SqlScalarType::Oid.nullable(false))
10739 .with_column("ev_type", SqlScalarType::PgLegacyChar.nullable(false))
10740 .with_column("ev_enabled", SqlScalarType::PgLegacyChar.nullable(false))
10741 .with_column("is_instead", SqlScalarType::Bool.nullable(false))
10742 .with_column("ev_qual", SqlScalarType::String.nullable(false))
10743 .with_column("ev_action", SqlScalarType::String.nullable(false))
10744 .with_key(vec![])
10745 .finish(),
10746 column_comments: BTreeMap::new(),
10747 sql: "SELECT
10748 -- MZ doesn't support rewrite rules so all of these fields are NULL.
10749 NULL::pg_catalog.oid AS oid,
10750 NULL::pg_catalog.text AS rulename,
10751 NULL::pg_catalog.oid AS ev_class,
10752 NULL::pg_catalog.\"char\" AS ev_type,
10753 NULL::pg_catalog.\"char\" AS ev_enabled,
10754 NULL::pg_catalog.bool AS is_instead,
10755 -- NOTE: The ev_qual and ev_action columns are actually type `pg_node_tree` which we don't
10756 -- support. CockroachDB uses text as a placeholder, so we'll follow their lead here.
10757 NULL::pg_catalog.text AS ev_qual,
10758 NULL::pg_catalog.text AS ev_action
10759WHERE false
10760 ",
10761 access: vec![PUBLIC_SELECT],
10762});
10763
10764pub static PG_EXTENSION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10765 name: "pg_extension",
10766 schema: PG_CATALOG_SCHEMA,
10767 oid: oid::VIEW_PG_EXTENSION_OID,
10768 desc: RelationDesc::builder()
10769 .with_column("oid", SqlScalarType::Oid.nullable(false))
10770 .with_column("extname", SqlScalarType::String.nullable(false))
10771 .with_column("extowner", SqlScalarType::Oid.nullable(false))
10772 .with_column("extnamespace", SqlScalarType::Oid.nullable(false))
10773 .with_column("extrelocatable", SqlScalarType::Bool.nullable(false))
10774 .with_column("extversion", SqlScalarType::String.nullable(false))
10775 .with_column(
10776 "extconfig",
10777 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
10778 )
10779 .with_column(
10780 "extcondition",
10781 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
10782 )
10783 .with_key(vec![])
10784 .finish(),
10785 column_comments: BTreeMap::new(),
10786 sql: "SELECT
10787 -- MZ doesn't support extensions so all of these fields are NULL.
10788 NULL::pg_catalog.oid AS oid,
10789 NULL::pg_catalog.text AS extname,
10790 NULL::pg_catalog.oid AS extowner,
10791 NULL::pg_catalog.oid AS extnamespace,
10792 NULL::pg_catalog.bool AS extrelocatable,
10793 NULL::pg_catalog.text AS extversion,
10794 NULL::pg_catalog.oid[] AS extconfig,
10795 NULL::pg_catalog.text[] AS extcondition
10796WHERE false
10797 ",
10798 access: vec![PUBLIC_SELECT],
10799});
10800
10801pub static MZ_SHOW_ALL_OBJECTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10802 name: "mz_show_all_objects",
10803 schema: MZ_INTERNAL_SCHEMA,
10804 oid: oid::VIEW_MZ_SHOW_ALL_OBJECTS_OID,
10805 desc: RelationDesc::builder()
10806 .with_column("schema_id", SqlScalarType::String.nullable(false))
10807 .with_column("name", SqlScalarType::String.nullable(false))
10808 .with_column("type", SqlScalarType::String.nullable(false))
10809 .with_column("comment", SqlScalarType::String.nullable(false))
10810 .finish(),
10811 column_comments: BTreeMap::new(),
10812 sql: "WITH comments AS (
10813 SELECT id, object_type, comment
10814 FROM mz_internal.mz_comments
10815 WHERE object_sub_id IS NULL
10816 )
10817 SELECT schema_id, name, type, COALESCE(comment, '') AS comment
10818 FROM mz_catalog.mz_objects AS objs
10819 LEFT JOIN comments ON objs.id = comments.id
10820 WHERE (comments.object_type = objs.type OR comments.object_type IS NULL)",
10821 access: vec![PUBLIC_SELECT],
10822});
10823
10824pub static MZ_SHOW_CLUSTERS: LazyLock<BuiltinView> = LazyLock::new(|| {
10825 BuiltinView {
10826 name: "mz_show_clusters",
10827 schema: MZ_INTERNAL_SCHEMA,
10828 oid: oid::VIEW_MZ_SHOW_CLUSTERS_OID,
10829 desc: RelationDesc::builder()
10830 .with_column("name", SqlScalarType::String.nullable(false))
10831 .with_column("replicas", SqlScalarType::String.nullable(true))
10832 .with_column("comment", SqlScalarType::String.nullable(false))
10833 .finish(),
10834 column_comments: BTreeMap::new(),
10835 sql: "
10836 WITH clusters AS (
10837 SELECT
10838 mc.id,
10839 mc.name,
10840 pg_catalog.string_agg(mcr.name || ' (' || mcr.size || ')', ', ' ORDER BY mcr.name) AS replicas
10841 FROM mz_catalog.mz_clusters mc
10842 LEFT JOIN mz_catalog.mz_cluster_replicas mcr
10843 ON mc.id = mcr.cluster_id
10844 GROUP BY mc.id, mc.name
10845 ),
10846 comments AS (
10847 SELECT id, comment
10848 FROM mz_internal.mz_comments
10849 WHERE object_type = 'cluster' AND object_sub_id IS NULL
10850 )
10851 SELECT name, replicas, COALESCE(comment, '') as comment
10852 FROM clusters
10853 LEFT JOIN comments ON clusters.id = comments.id",
10854 access: vec![PUBLIC_SELECT],
10855}
10856});
10857
10858pub static MZ_SHOW_SECRETS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10859 name: "mz_show_secrets",
10860 schema: MZ_INTERNAL_SCHEMA,
10861 oid: oid::VIEW_MZ_SHOW_SECRETS_OID,
10862 desc: RelationDesc::builder()
10863 .with_column("schema_id", SqlScalarType::String.nullable(false))
10864 .with_column("name", SqlScalarType::String.nullable(false))
10865 .with_column("comment", SqlScalarType::String.nullable(false))
10866 .finish(),
10867 column_comments: BTreeMap::new(),
10868 sql: "WITH comments AS (
10869 SELECT id, comment
10870 FROM mz_internal.mz_comments
10871 WHERE object_type = 'secret' AND object_sub_id IS NULL
10872 )
10873 SELECT schema_id, name, COALESCE(comment, '') as comment
10874 FROM mz_catalog.mz_secrets secrets
10875 LEFT JOIN comments ON secrets.id = comments.id",
10876 access: vec![PUBLIC_SELECT],
10877});
10878
10879pub static MZ_SHOW_COLUMNS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10880 name: "mz_show_columns",
10881 schema: MZ_INTERNAL_SCHEMA,
10882 oid: oid::VIEW_MZ_SHOW_COLUMNS_OID,
10883 desc: RelationDesc::builder()
10884 .with_column("id", SqlScalarType::String.nullable(false))
10885 .with_column("name", SqlScalarType::String.nullable(false))
10886 .with_column("nullable", SqlScalarType::Bool.nullable(false))
10887 .with_column("type", SqlScalarType::String.nullable(false))
10888 .with_column("position", SqlScalarType::UInt64.nullable(false))
10889 .with_column("comment", SqlScalarType::String.nullable(false))
10890 .finish(),
10891 column_comments: BTreeMap::new(),
10892 sql: "
10893 SELECT columns.id, name, nullable, type, position, COALESCE(comment, '') as comment
10894 FROM mz_catalog.mz_columns columns
10895 LEFT JOIN mz_internal.mz_comments comments
10896 ON columns.id = comments.id AND columns.position = comments.object_sub_id",
10897 access: vec![PUBLIC_SELECT],
10898});
10899
10900pub static MZ_SHOW_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10901 name: "mz_show_databases",
10902 schema: MZ_INTERNAL_SCHEMA,
10903 oid: oid::VIEW_MZ_SHOW_DATABASES_OID,
10904 desc: RelationDesc::builder()
10905 .with_column("name", SqlScalarType::String.nullable(false))
10906 .with_column("comment", SqlScalarType::String.nullable(false))
10907 .finish(),
10908 column_comments: BTreeMap::new(),
10909 sql: "WITH comments AS (
10910 SELECT id, comment
10911 FROM mz_internal.mz_comments
10912 WHERE object_type = 'database' AND object_sub_id IS NULL
10913 )
10914 SELECT name, COALESCE(comment, '') as comment
10915 FROM mz_catalog.mz_databases databases
10916 LEFT JOIN comments ON databases.id = comments.id",
10917 access: vec![PUBLIC_SELECT],
10918});
10919
10920pub static MZ_SHOW_SCHEMAS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10921 name: "mz_show_schemas",
10922 schema: MZ_INTERNAL_SCHEMA,
10923 oid: oid::VIEW_MZ_SHOW_SCHEMAS_OID,
10924 desc: RelationDesc::builder()
10925 .with_column("database_id", SqlScalarType::String.nullable(true))
10926 .with_column("name", SqlScalarType::String.nullable(false))
10927 .with_column("comment", SqlScalarType::String.nullable(false))
10928 .finish(),
10929 column_comments: BTreeMap::new(),
10930 sql: "WITH comments AS (
10931 SELECT id, comment
10932 FROM mz_internal.mz_comments
10933 WHERE object_type = 'schema' AND object_sub_id IS NULL
10934 )
10935 SELECT database_id, name, COALESCE(comment, '') as comment
10936 FROM mz_catalog.mz_schemas schemas
10937 LEFT JOIN comments ON schemas.id = comments.id",
10938 access: vec![PUBLIC_SELECT],
10939});
10940
10941pub static MZ_SHOW_ROLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10942 name: "mz_show_roles",
10943 schema: MZ_INTERNAL_SCHEMA,
10944 oid: oid::VIEW_MZ_SHOW_ROLES_OID,
10945 desc: RelationDesc::builder()
10946 .with_column("name", SqlScalarType::String.nullable(false))
10947 .with_column("comment", SqlScalarType::String.nullable(false))
10948 .finish(),
10949 column_comments: BTreeMap::new(),
10950 sql: "WITH comments AS (
10951 SELECT id, comment
10952 FROM mz_internal.mz_comments
10953 WHERE object_type = 'role' AND object_sub_id IS NULL
10954 )
10955 SELECT name, COALESCE(comment, '') as comment
10956 FROM mz_catalog.mz_roles roles
10957 LEFT JOIN comments ON roles.id = comments.id
10958 WHERE roles.id NOT LIKE 's%'
10959 AND roles.id NOT LIKE 'g%'",
10960 access: vec![PUBLIC_SELECT],
10961});
10962
10963pub static MZ_SHOW_TABLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10964 name: "mz_show_tables",
10965 schema: MZ_INTERNAL_SCHEMA,
10966 oid: oid::VIEW_MZ_SHOW_TABLES_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 .with_column("source_id", SqlScalarType::String.nullable(true))
10972 .finish(),
10973 column_comments: BTreeMap::new(),
10974 sql: "WITH comments AS (
10975 SELECT id, comment
10976 FROM mz_internal.mz_comments
10977 WHERE object_type = 'table' AND object_sub_id IS NULL
10978 )
10979 SELECT schema_id, name, COALESCE(comment, '') as comment, source_id
10980 FROM mz_catalog.mz_tables tables
10981 LEFT JOIN comments ON tables.id = comments.id",
10982 access: vec![PUBLIC_SELECT],
10983});
10984
10985pub static MZ_SHOW_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10986 name: "mz_show_views",
10987 schema: MZ_INTERNAL_SCHEMA,
10988 oid: oid::VIEW_MZ_SHOW_VIEWS_OID,
10989 desc: RelationDesc::builder()
10990 .with_column("schema_id", SqlScalarType::String.nullable(false))
10991 .with_column("name", 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 = 'view' AND object_sub_id IS NULL
10999 )
11000 SELECT schema_id, name, COALESCE(comment, '') as comment
11001 FROM mz_catalog.mz_views views
11002 LEFT JOIN comments ON views.id = comments.id",
11003 access: vec![PUBLIC_SELECT],
11004});
11005
11006pub static MZ_SHOW_TYPES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11007 name: "mz_show_types",
11008 schema: MZ_INTERNAL_SCHEMA,
11009 oid: oid::VIEW_MZ_SHOW_TYPES_OID,
11010 desc: RelationDesc::builder()
11011 .with_column("schema_id", SqlScalarType::String.nullable(false))
11012 .with_column("name", SqlScalarType::String.nullable(false))
11013 .with_column("comment", SqlScalarType::String.nullable(false))
11014 .finish(),
11015 column_comments: BTreeMap::new(),
11016 sql: "WITH comments AS (
11017 SELECT id, comment
11018 FROM mz_internal.mz_comments
11019 WHERE object_type = 'type' AND object_sub_id IS NULL
11020 )
11021 SELECT schema_id, name, COALESCE(comment, '') as comment
11022 FROM mz_catalog.mz_types types
11023 LEFT JOIN comments ON types.id = comments.id",
11024 access: vec![PUBLIC_SELECT],
11025});
11026
11027pub static MZ_SHOW_CONNECTIONS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11028 name: "mz_show_connections",
11029 schema: MZ_INTERNAL_SCHEMA,
11030 oid: oid::VIEW_MZ_SHOW_CONNECTIONS_OID,
11031 desc: RelationDesc::builder()
11032 .with_column("schema_id", SqlScalarType::String.nullable(false))
11033 .with_column("name", SqlScalarType::String.nullable(false))
11034 .with_column("type", SqlScalarType::String.nullable(false))
11035 .with_column("comment", SqlScalarType::String.nullable(false))
11036 .finish(),
11037 column_comments: BTreeMap::new(),
11038 sql: "WITH comments AS (
11039 SELECT id, comment
11040 FROM mz_internal.mz_comments
11041 WHERE object_type = 'connection' AND object_sub_id IS NULL
11042 )
11043 SELECT schema_id, name, type, COALESCE(comment, '') as comment
11044 FROM mz_catalog.mz_connections connections
11045 LEFT JOIN comments ON connections.id = comments.id",
11046 access: vec![PUBLIC_SELECT],
11047});
11048
11049pub static MZ_SHOW_SOURCES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11050 name: "mz_show_sources",
11051 schema: MZ_INTERNAL_SCHEMA,
11052 oid: oid::VIEW_MZ_SHOW_SOURCES_OID,
11053 desc: RelationDesc::builder()
11054 .with_column("id", SqlScalarType::String.nullable(false))
11055 .with_column("name", SqlScalarType::String.nullable(false))
11056 .with_column("type", SqlScalarType::String.nullable(false))
11057 .with_column("cluster", SqlScalarType::String.nullable(true))
11058 .with_column("schema_id", SqlScalarType::String.nullable(false))
11059 .with_column("cluster_id", SqlScalarType::String.nullable(true))
11060 .with_column("comment", SqlScalarType::String.nullable(false))
11061 .finish(),
11062 column_comments: BTreeMap::new(),
11063 sql: "
11064WITH comments AS (
11065 SELECT id, comment
11066 FROM mz_internal.mz_comments
11067 WHERE object_type = 'source' AND object_sub_id IS NULL
11068)
11069SELECT
11070 sources.id,
11071 sources.name,
11072 sources.type,
11073 clusters.name AS cluster,
11074 schema_id,
11075 cluster_id,
11076 COALESCE(comments.comment, '') as comment
11077FROM
11078 mz_catalog.mz_sources AS sources
11079 LEFT JOIN
11080 mz_catalog.mz_clusters AS clusters
11081 ON clusters.id = sources.cluster_id
11082 LEFT JOIN comments ON sources.id = comments.id",
11083 access: vec![PUBLIC_SELECT],
11084});
11085
11086pub static MZ_SHOW_SINKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11087 name: "mz_show_sinks",
11088 schema: MZ_INTERNAL_SCHEMA,
11089 oid: oid::VIEW_MZ_SHOW_SINKS_OID,
11090 desc: RelationDesc::builder()
11091 .with_column("id", SqlScalarType::String.nullable(false))
11092 .with_column("name", SqlScalarType::String.nullable(false))
11093 .with_column("type", SqlScalarType::String.nullable(false))
11094 .with_column("cluster", SqlScalarType::String.nullable(false))
11095 .with_column("schema_id", SqlScalarType::String.nullable(false))
11096 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11097 .with_column("comment", SqlScalarType::String.nullable(false))
11098 .finish(),
11099 column_comments: BTreeMap::new(),
11100 sql: "
11101WITH comments AS (
11102 SELECT id, comment
11103 FROM mz_internal.mz_comments
11104 WHERE object_type = 'sink' AND object_sub_id IS NULL
11105)
11106SELECT
11107 sinks.id,
11108 sinks.name,
11109 sinks.type,
11110 clusters.name AS cluster,
11111 schema_id,
11112 cluster_id,
11113 COALESCE(comments.comment, '') as comment
11114FROM
11115 mz_catalog.mz_sinks AS sinks
11116 JOIN
11117 mz_catalog.mz_clusters AS clusters
11118 ON clusters.id = sinks.cluster_id
11119 LEFT JOIN comments ON sinks.id = comments.id",
11120 access: vec![PUBLIC_SELECT],
11121});
11122
11123pub static MZ_SHOW_MATERIALIZED_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11124 name: "mz_show_materialized_views",
11125 schema: MZ_INTERNAL_SCHEMA,
11126 oid: oid::VIEW_MZ_SHOW_MATERIALIZED_VIEWS_OID,
11127 desc: RelationDesc::builder()
11128 .with_column("id", SqlScalarType::String.nullable(false))
11129 .with_column("name", SqlScalarType::String.nullable(false))
11130 .with_column("cluster", SqlScalarType::String.nullable(false))
11131 .with_column("schema_id", SqlScalarType::String.nullable(false))
11132 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11133 .with_column("comment", SqlScalarType::String.nullable(false))
11134 .finish(),
11135 column_comments: BTreeMap::new(),
11136 sql: "
11137WITH comments AS (
11138 SELECT id, comment
11139 FROM mz_internal.mz_comments
11140 WHERE object_type = 'materialized-view' AND object_sub_id IS NULL
11141)
11142SELECT
11143 mviews.id as id,
11144 mviews.name,
11145 clusters.name AS cluster,
11146 schema_id,
11147 cluster_id,
11148 COALESCE(comments.comment, '') as comment
11149FROM
11150 mz_catalog.mz_materialized_views AS mviews
11151 JOIN mz_catalog.mz_clusters AS clusters ON clusters.id = mviews.cluster_id
11152 LEFT JOIN comments ON mviews.id = comments.id",
11153 access: vec![PUBLIC_SELECT],
11154});
11155
11156pub static MZ_SHOW_INDEXES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11157 name: "mz_show_indexes",
11158 schema: MZ_INTERNAL_SCHEMA,
11159 oid: oid::VIEW_MZ_SHOW_INDEXES_OID,
11160 desc: RelationDesc::builder()
11161 .with_column("id", SqlScalarType::String.nullable(false))
11162 .with_column("name", SqlScalarType::String.nullable(false))
11163 .with_column("on", SqlScalarType::String.nullable(false))
11164 .with_column("cluster", SqlScalarType::String.nullable(false))
11165 .with_column(
11166 "key",
11167 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
11168 )
11169 .with_column("on_id", SqlScalarType::String.nullable(false))
11170 .with_column("schema_id", SqlScalarType::String.nullable(false))
11171 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11172 .with_column("comment", SqlScalarType::String.nullable(false))
11173 .finish(),
11174 column_comments: BTreeMap::new(),
11175 sql: "
11176WITH comments AS (
11177 SELECT id, comment
11178 FROM mz_internal.mz_comments
11179 WHERE object_type = 'index' AND object_sub_id IS NULL
11180)
11181SELECT
11182 idxs.id AS id,
11183 idxs.name AS name,
11184 objs.name AS on,
11185 clusters.name AS cluster,
11186 COALESCE(keys.key, '{}'::_text) AS key,
11187 idxs.on_id AS on_id,
11188 objs.schema_id AS schema_id,
11189 clusters.id AS cluster_id,
11190 COALESCE(comments.comment, '') as comment
11191FROM
11192 mz_catalog.mz_indexes AS idxs
11193 JOIN mz_catalog.mz_objects AS objs ON idxs.on_id = objs.id
11194 JOIN mz_catalog.mz_clusters AS clusters ON clusters.id = idxs.cluster_id
11195 LEFT JOIN
11196 (SELECT
11197 idxs.id,
11198 ARRAY_AGG(
11199 CASE
11200 WHEN idx_cols.on_expression IS NULL THEN obj_cols.name
11201 ELSE idx_cols.on_expression
11202 END
11203 ORDER BY idx_cols.index_position ASC
11204 ) AS key
11205 FROM
11206 mz_catalog.mz_indexes AS idxs
11207 JOIN mz_catalog.mz_index_columns idx_cols ON idxs.id = idx_cols.index_id
11208 LEFT JOIN mz_catalog.mz_columns obj_cols ON
11209 idxs.on_id = obj_cols.id AND idx_cols.on_position = obj_cols.position
11210 GROUP BY idxs.id) AS keys
11211 ON idxs.id = keys.id
11212 LEFT JOIN comments ON idxs.id = comments.id",
11213 access: vec![PUBLIC_SELECT],
11214});
11215
11216pub static MZ_SHOW_CLUSTER_REPLICAS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11217 name: "mz_show_cluster_replicas",
11218 schema: MZ_INTERNAL_SCHEMA,
11219 oid: oid::VIEW_MZ_SHOW_CLUSTER_REPLICAS_OID,
11220 desc: RelationDesc::builder()
11221 .with_column("cluster", SqlScalarType::String.nullable(false))
11222 .with_column("replica", SqlScalarType::String.nullable(false))
11223 .with_column("replica_id", SqlScalarType::String.nullable(false))
11224 .with_column("size", SqlScalarType::String.nullable(true))
11225 .with_column("ready", SqlScalarType::Bool.nullable(false))
11226 .with_column("comment", SqlScalarType::String.nullable(false))
11227 .finish(),
11228 column_comments: BTreeMap::new(),
11229 sql: r#"SELECT
11230 mz_catalog.mz_clusters.name AS cluster,
11231 mz_catalog.mz_cluster_replicas.name AS replica,
11232 mz_catalog.mz_cluster_replicas.id as replica_id,
11233 mz_catalog.mz_cluster_replicas.size AS size,
11234 coalesce(statuses.ready, FALSE) AS ready,
11235 coalesce(comments.comment, '') as comment
11236FROM
11237 mz_catalog.mz_cluster_replicas
11238 JOIN mz_catalog.mz_clusters
11239 ON mz_catalog.mz_cluster_replicas.cluster_id = mz_catalog.mz_clusters.id
11240 LEFT JOIN
11241 (
11242 SELECT
11243 replica_id,
11244 bool_and(hydrated) AS ready
11245 FROM mz_internal.mz_hydration_statuses
11246 WHERE replica_id is not null
11247 GROUP BY replica_id
11248 ) AS statuses
11249 ON mz_catalog.mz_cluster_replicas.id = statuses.replica_id
11250 LEFT JOIN mz_internal.mz_comments comments
11251 ON mz_catalog.mz_cluster_replicas.id = comments.id
11252WHERE (comments.object_type = 'cluster-replica' OR comments.object_type IS NULL)
11253ORDER BY 1, 2"#,
11254 access: vec![PUBLIC_SELECT],
11255});
11256
11257pub static MZ_SHOW_CONTINUAL_TASKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11258 name: "mz_show_continual_tasks",
11259 schema: MZ_INTERNAL_SCHEMA,
11260 oid: oid::VIEW_MZ_SHOW_CONTINUAL_TASKS_OID,
11261 desc: RelationDesc::builder()
11262 .with_column("id", SqlScalarType::String.nullable(false))
11263 .with_column("name", SqlScalarType::String.nullable(false))
11264 .with_column("cluster", SqlScalarType::String.nullable(false))
11265 .with_column("schema_id", SqlScalarType::String.nullable(false))
11266 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11267 .with_column("comment", SqlScalarType::String.nullable(false))
11268 .finish(),
11269 column_comments: BTreeMap::new(),
11270 sql: "
11271WITH comments AS (
11272 SELECT id, comment
11273 FROM mz_internal.mz_comments
11274 WHERE object_type = 'continual-task' AND object_sub_id IS NULL
11275)
11276SELECT
11277 cts.id as id,
11278 cts.name,
11279 clusters.name AS cluster,
11280 schema_id,
11281 cluster_id,
11282 COALESCE(comments.comment, '') as comment
11283FROM
11284 mz_internal.mz_continual_tasks AS cts
11285 JOIN mz_catalog.mz_clusters AS clusters ON clusters.id = cts.cluster_id
11286 LEFT JOIN comments ON cts.id = comments.id",
11287 access: vec![PUBLIC_SELECT],
11288});
11289
11290pub static MZ_SHOW_ROLE_MEMBERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11291 name: "mz_show_role_members",
11292 schema: MZ_INTERNAL_SCHEMA,
11293 oid: oid::VIEW_MZ_SHOW_ROLE_MEMBERS_OID,
11294 desc: RelationDesc::builder()
11295 .with_column("role", SqlScalarType::String.nullable(false))
11296 .with_column("member", SqlScalarType::String.nullable(false))
11297 .with_column("grantor", SqlScalarType::String.nullable(false))
11298 .finish(),
11299 column_comments: BTreeMap::from_iter([
11300 ("role", "The role that `member` is a member of."),
11301 ("member", "The role that is a member of `role`."),
11302 (
11303 "grantor",
11304 "The role that granted membership of `member` to `role`.",
11305 ),
11306 ]),
11307 sql: r#"SELECT
11308 r1.name AS role,
11309 r2.name AS member,
11310 r3.name AS grantor
11311FROM mz_catalog.mz_role_members rm
11312JOIN mz_catalog.mz_roles r1 ON r1.id = rm.role_id
11313JOIN mz_catalog.mz_roles r2 ON r2.id = rm.member
11314JOIN mz_catalog.mz_roles r3 ON r3.id = rm.grantor
11315ORDER BY role"#,
11316 access: vec![PUBLIC_SELECT],
11317});
11318
11319pub static MZ_SHOW_MY_ROLE_MEMBERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11320 name: "mz_show_my_role_members",
11321 schema: MZ_INTERNAL_SCHEMA,
11322 oid: oid::VIEW_MZ_SHOW_MY_ROLE_MEMBERS_OID,
11323 desc: RelationDesc::builder()
11324 .with_column("role", SqlScalarType::String.nullable(false))
11325 .with_column("member", SqlScalarType::String.nullable(false))
11326 .with_column("grantor", SqlScalarType::String.nullable(false))
11327 .finish(),
11328 column_comments: BTreeMap::from_iter([
11329 ("role", "The role that `member` is a member of."),
11330 ("member", "The role that is a member of `role`."),
11331 (
11332 "grantor",
11333 "The role that granted membership of `member` to `role`.",
11334 ),
11335 ]),
11336 sql: r#"SELECT role, member, grantor
11337FROM mz_internal.mz_show_role_members
11338WHERE pg_has_role(member, 'USAGE')"#,
11339 access: vec![PUBLIC_SELECT],
11340});
11341
11342pub static MZ_SHOW_SYSTEM_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11343 name: "mz_show_system_privileges",
11344 schema: MZ_INTERNAL_SCHEMA,
11345 oid: oid::VIEW_MZ_SHOW_SYSTEM_PRIVILEGES_OID,
11346 desc: RelationDesc::builder()
11347 .with_column("grantor", SqlScalarType::String.nullable(true))
11348 .with_column("grantee", SqlScalarType::String.nullable(true))
11349 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11350 .finish(),
11351 column_comments: BTreeMap::from_iter([
11352 ("grantor", "The role that granted the privilege."),
11353 ("grantee", "The role that the privilege was granted to."),
11354 ("privilege_type", "They type of privilege granted."),
11355 ]),
11356 sql: r#"SELECT
11357 grantor.name AS grantor,
11358 CASE privileges.grantee
11359 WHEN 'p' THEN 'PUBLIC'
11360 ELSE grantee.name
11361 END AS grantee,
11362 privileges.privilege_type AS privilege_type
11363FROM
11364 (SELECT mz_internal.mz_aclexplode(ARRAY[privileges]).*
11365 FROM mz_catalog.mz_system_privileges) AS privileges
11366LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11367LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11368WHERE privileges.grantee NOT LIKE 's%'"#,
11369 access: vec![PUBLIC_SELECT],
11370});
11371
11372pub static MZ_SHOW_MY_SYSTEM_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11373 name: "mz_show_my_system_privileges",
11374 schema: MZ_INTERNAL_SCHEMA,
11375 oid: oid::VIEW_MZ_SHOW_MY_SYSTEM_PRIVILEGES_OID,
11376 desc: RelationDesc::builder()
11377 .with_column("grantor", SqlScalarType::String.nullable(true))
11378 .with_column("grantee", SqlScalarType::String.nullable(true))
11379 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11380 .finish(),
11381 column_comments: BTreeMap::from_iter([
11382 ("grantor", "The role that granted the privilege."),
11383 ("grantee", "The role that the privilege was granted to."),
11384 ("privilege_type", "They type of privilege granted."),
11385 ]),
11386 sql: r#"SELECT grantor, grantee, privilege_type
11387FROM mz_internal.mz_show_system_privileges
11388WHERE
11389 CASE
11390 WHEN grantee = 'PUBLIC' THEN true
11391 ELSE pg_has_role(grantee, 'USAGE')
11392 END"#,
11393 access: vec![PUBLIC_SELECT],
11394});
11395
11396pub static MZ_SHOW_CLUSTER_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11397 name: "mz_show_cluster_privileges",
11398 schema: MZ_INTERNAL_SCHEMA,
11399 oid: oid::VIEW_MZ_SHOW_CLUSTER_PRIVILEGES_OID,
11400 desc: RelationDesc::builder()
11401 .with_column("grantor", SqlScalarType::String.nullable(true))
11402 .with_column("grantee", SqlScalarType::String.nullable(true))
11403 .with_column("name", SqlScalarType::String.nullable(false))
11404 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11405 .finish(),
11406 column_comments: BTreeMap::from_iter([
11407 ("grantor", "The role that granted the privilege."),
11408 ("grantee", "The role that the privilege was granted to."),
11409 ("name", "The name of the cluster."),
11410 ("privilege_type", "They type of privilege granted."),
11411 ]),
11412 sql: r#"SELECT
11413 grantor.name AS grantor,
11414 CASE privileges.grantee
11415 WHEN 'p' THEN 'PUBLIC'
11416 ELSE grantee.name
11417 END AS grantee,
11418 privileges.name AS name,
11419 privileges.privilege_type AS privilege_type
11420FROM
11421 (SELECT mz_internal.mz_aclexplode(privileges).*, name
11422 FROM mz_catalog.mz_clusters
11423 WHERE id NOT LIKE 's%') AS privileges
11424LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11425LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11426WHERE privileges.grantee NOT LIKE 's%'"#,
11427 access: vec![PUBLIC_SELECT],
11428});
11429
11430pub static MZ_SHOW_MY_CLUSTER_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11431 name: "mz_show_my_cluster_privileges",
11432 schema: MZ_INTERNAL_SCHEMA,
11433 oid: oid::VIEW_MZ_SHOW_MY_CLUSTER_PRIVILEGES_OID,
11434 desc: RelationDesc::builder()
11435 .with_column("grantor", SqlScalarType::String.nullable(true))
11436 .with_column("grantee", SqlScalarType::String.nullable(true))
11437 .with_column("name", SqlScalarType::String.nullable(false))
11438 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11439 .finish(),
11440 column_comments: BTreeMap::from_iter([
11441 ("grantor", "The role that granted the privilege."),
11442 ("grantee", "The role that the privilege was granted to."),
11443 ("name", "The name of the cluster."),
11444 ("privilege_type", "They type of privilege granted."),
11445 ]),
11446 sql: r#"SELECT grantor, grantee, name, privilege_type
11447FROM mz_internal.mz_show_cluster_privileges
11448WHERE
11449 CASE
11450 WHEN grantee = 'PUBLIC' THEN true
11451 ELSE pg_has_role(grantee, 'USAGE')
11452 END"#,
11453 access: vec![PUBLIC_SELECT],
11454});
11455
11456pub static MZ_SHOW_DATABASE_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11457 name: "mz_show_database_privileges",
11458 schema: MZ_INTERNAL_SCHEMA,
11459 oid: oid::VIEW_MZ_SHOW_DATABASE_PRIVILEGES_OID,
11460 desc: RelationDesc::builder()
11461 .with_column("grantor", SqlScalarType::String.nullable(true))
11462 .with_column("grantee", SqlScalarType::String.nullable(true))
11463 .with_column("name", SqlScalarType::String.nullable(false))
11464 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11465 .finish(),
11466 column_comments: BTreeMap::from_iter([
11467 ("grantor", "The role that granted the privilege."),
11468 ("grantee", "The role that the privilege was granted to."),
11469 ("name", "The name of the database."),
11470 ("privilege_type", "They type of privilege granted."),
11471 ]),
11472 sql: r#"SELECT
11473 grantor.name AS grantor,
11474 CASE privileges.grantee
11475 WHEN 'p' THEN 'PUBLIC'
11476 ELSE grantee.name
11477 END AS grantee,
11478 privileges.name AS name,
11479 privileges.privilege_type AS privilege_type
11480FROM
11481 (SELECT mz_internal.mz_aclexplode(privileges).*, name
11482 FROM mz_catalog.mz_databases
11483 WHERE id NOT LIKE 's%') AS privileges
11484LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11485LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11486WHERE privileges.grantee NOT LIKE 's%'"#,
11487 access: vec![PUBLIC_SELECT],
11488});
11489
11490pub static MZ_SHOW_MY_DATABASE_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11491 name: "mz_show_my_database_privileges",
11492 schema: MZ_INTERNAL_SCHEMA,
11493 oid: oid::VIEW_MZ_SHOW_MY_DATABASE_PRIVILEGES_OID,
11494 desc: RelationDesc::builder()
11495 .with_column("grantor", SqlScalarType::String.nullable(true))
11496 .with_column("grantee", SqlScalarType::String.nullable(true))
11497 .with_column("name", SqlScalarType::String.nullable(false))
11498 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11499 .finish(),
11500 column_comments: BTreeMap::from_iter([
11501 ("grantor", "The role that granted the privilege."),
11502 ("grantee", "The role that the privilege was granted to."),
11503 ("name", "The name of the cluster."),
11504 ("privilege_type", "They type of privilege granted."),
11505 ]),
11506 sql: r#"SELECT grantor, grantee, name, privilege_type
11507FROM mz_internal.mz_show_database_privileges
11508WHERE
11509 CASE
11510 WHEN grantee = 'PUBLIC' THEN true
11511 ELSE pg_has_role(grantee, 'USAGE')
11512 END"#,
11513 access: vec![PUBLIC_SELECT],
11514});
11515
11516pub static MZ_SHOW_SCHEMA_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11517 name: "mz_show_schema_privileges",
11518 schema: MZ_INTERNAL_SCHEMA,
11519 oid: oid::VIEW_MZ_SHOW_SCHEMA_PRIVILEGES_OID,
11520 desc: RelationDesc::builder()
11521 .with_column("grantor", SqlScalarType::String.nullable(true))
11522 .with_column("grantee", SqlScalarType::String.nullable(true))
11523 .with_column("database", SqlScalarType::String.nullable(true))
11524 .with_column("name", SqlScalarType::String.nullable(false))
11525 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11526 .finish(),
11527 column_comments: BTreeMap::from_iter([
11528 ("grantor", "The role that granted the privilege."),
11529 ("grantee", "The role that the privilege was granted to."),
11530 (
11531 "database",
11532 "The name of the database containing the schema.",
11533 ),
11534 ("name", "The name of the schema."),
11535 ("privilege_type", "They type of privilege granted."),
11536 ]),
11537 sql: r#"SELECT
11538 grantor.name AS grantor,
11539 CASE privileges.grantee
11540 WHEN 'p' THEN 'PUBLIC'
11541 ELSE grantee.name
11542 END AS grantee,
11543 databases.name AS database,
11544 privileges.name AS name,
11545 privileges.privilege_type AS privilege_type
11546FROM
11547 (SELECT mz_internal.mz_aclexplode(privileges).*, database_id, name
11548 FROM mz_catalog.mz_schemas
11549 WHERE id NOT LIKE 's%') AS privileges
11550LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11551LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11552LEFT JOIN mz_catalog.mz_databases databases ON privileges.database_id = databases.id
11553WHERE privileges.grantee NOT LIKE 's%'"#,
11554 access: vec![PUBLIC_SELECT],
11555});
11556
11557pub static MZ_SHOW_MY_SCHEMA_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11558 name: "mz_show_my_schema_privileges",
11559 schema: MZ_INTERNAL_SCHEMA,
11560 oid: oid::VIEW_MZ_SHOW_MY_SCHEMA_PRIVILEGES_OID,
11561 desc: RelationDesc::builder()
11562 .with_column("grantor", SqlScalarType::String.nullable(true))
11563 .with_column("grantee", SqlScalarType::String.nullable(true))
11564 .with_column("database", SqlScalarType::String.nullable(true))
11565 .with_column("name", SqlScalarType::String.nullable(false))
11566 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11567 .finish(),
11568 column_comments: BTreeMap::from_iter([
11569 ("grantor", "The role that granted the privilege."),
11570 ("grantee", "The role that the privilege was granted to."),
11571 (
11572 "database",
11573 "The name of the database containing the schema.",
11574 ),
11575 ("name", "The name of the schema."),
11576 ("privilege_type", "They type of privilege granted."),
11577 ]),
11578 sql: r#"SELECT grantor, grantee, database, name, privilege_type
11579FROM mz_internal.mz_show_schema_privileges
11580WHERE
11581 CASE
11582 WHEN grantee = 'PUBLIC' THEN true
11583 ELSE pg_has_role(grantee, 'USAGE')
11584 END"#,
11585 access: vec![PUBLIC_SELECT],
11586});
11587
11588pub static MZ_SHOW_OBJECT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11589 name: "mz_show_object_privileges",
11590 schema: MZ_INTERNAL_SCHEMA,
11591 oid: oid::VIEW_MZ_SHOW_OBJECT_PRIVILEGES_OID,
11592 desc: RelationDesc::builder()
11593 .with_column("grantor", SqlScalarType::String.nullable(true))
11594 .with_column("grantee", SqlScalarType::String.nullable(true))
11595 .with_column("database", SqlScalarType::String.nullable(true))
11596 .with_column("schema", SqlScalarType::String.nullable(true))
11597 .with_column("name", SqlScalarType::String.nullable(false))
11598 .with_column("object_type", SqlScalarType::String.nullable(false))
11599 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11600 .finish(),
11601 column_comments: BTreeMap::from_iter([
11602 ("grantor", "The role that granted the privilege."),
11603 ("grantee", "The role that the privilege was granted to."),
11604 (
11605 "database",
11606 "The name of the database containing the object.",
11607 ),
11608 ("schema", "The name of the schema containing the object."),
11609 ("name", "The name of the object."),
11610 (
11611 "object_type",
11612 "The type of object the privilege is granted on.",
11613 ),
11614 ("privilege_type", "They type of privilege granted."),
11615 ]),
11616 sql: r#"SELECT
11617 grantor.name AS grantor,
11618 CASE privileges.grantee
11619 WHEN 'p' THEN 'PUBLIC'
11620 ELSE grantee.name
11621 END AS grantee,
11622 databases.name AS database,
11623 schemas.name AS schema,
11624 privileges.name AS name,
11625 privileges.type AS object_type,
11626 privileges.privilege_type AS privilege_type
11627FROM
11628 (SELECT mz_internal.mz_aclexplode(privileges).*, schema_id, name, type
11629 FROM mz_catalog.mz_objects
11630 WHERE id NOT LIKE 's%') AS privileges
11631LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11632LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11633LEFT JOIN mz_catalog.mz_schemas schemas ON privileges.schema_id = schemas.id
11634LEFT JOIN mz_catalog.mz_databases databases ON schemas.database_id = databases.id
11635WHERE privileges.grantee NOT LIKE 's%'"#,
11636 access: vec![PUBLIC_SELECT],
11637});
11638
11639pub static MZ_SHOW_MY_OBJECT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11640 name: "mz_show_my_object_privileges",
11641 schema: MZ_INTERNAL_SCHEMA,
11642 oid: oid::VIEW_MZ_SHOW_MY_OBJECT_PRIVILEGES_OID,
11643 desc: RelationDesc::builder()
11644 .with_column("grantor", SqlScalarType::String.nullable(true))
11645 .with_column("grantee", SqlScalarType::String.nullable(true))
11646 .with_column("database", SqlScalarType::String.nullable(true))
11647 .with_column("schema", SqlScalarType::String.nullable(true))
11648 .with_column("name", SqlScalarType::String.nullable(false))
11649 .with_column("object_type", SqlScalarType::String.nullable(false))
11650 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11651 .finish(),
11652 column_comments: BTreeMap::from_iter([
11653 ("grantor", "The role that granted the privilege."),
11654 ("grantee", "The role that the privilege was granted to."),
11655 (
11656 "database",
11657 "The name of the database containing the object.",
11658 ),
11659 ("schema", "The name of the schema containing the object."),
11660 ("name", "The name of the object."),
11661 (
11662 "object_type",
11663 "The type of object the privilege is granted on.",
11664 ),
11665 ("privilege_type", "They type of privilege granted."),
11666 ]),
11667 sql: r#"SELECT grantor, grantee, database, schema, name, object_type, privilege_type
11668FROM mz_internal.mz_show_object_privileges
11669WHERE
11670 CASE
11671 WHEN grantee = 'PUBLIC' THEN true
11672 ELSE pg_has_role(grantee, 'USAGE')
11673 END"#,
11674 access: vec![PUBLIC_SELECT],
11675});
11676
11677pub static MZ_SHOW_ALL_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11678 name: "mz_show_all_privileges",
11679 schema: MZ_INTERNAL_SCHEMA,
11680 oid: oid::VIEW_MZ_SHOW_ALL_PRIVILEGES_OID,
11681 desc: RelationDesc::builder()
11682 .with_column("grantor", SqlScalarType::String.nullable(true))
11683 .with_column("grantee", SqlScalarType::String.nullable(true))
11684 .with_column("database", SqlScalarType::String.nullable(true))
11685 .with_column("schema", SqlScalarType::String.nullable(true))
11686 .with_column("name", SqlScalarType::String.nullable(true))
11687 .with_column("object_type", SqlScalarType::String.nullable(false))
11688 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11689 .finish(),
11690 column_comments: BTreeMap::from_iter([
11691 ("grantor", "The role that granted the privilege."),
11692 ("grantee", "The role that the privilege was granted to."),
11693 (
11694 "database",
11695 "The name of the database containing the object.",
11696 ),
11697 ("schema", "The name of the schema containing the object."),
11698 ("name", "The name of the privilege target."),
11699 (
11700 "object_type",
11701 "The type of object the privilege is granted on.",
11702 ),
11703 ("privilege_type", "They type of privilege granted."),
11704 ]),
11705 sql: r#"SELECT grantor, grantee, NULL AS database, NULL AS schema, NULL AS name, 'system' AS object_type, privilege_type
11706FROM mz_internal.mz_show_system_privileges
11707UNION ALL
11708SELECT grantor, grantee, NULL AS database, NULL AS schema, name, 'cluster' AS object_type, privilege_type
11709FROM mz_internal.mz_show_cluster_privileges
11710UNION ALL
11711SELECT grantor, grantee, NULL AS database, NULL AS schema, name, 'database' AS object_type, privilege_type
11712FROM mz_internal.mz_show_database_privileges
11713UNION ALL
11714SELECT grantor, grantee, database, NULL AS schema, name, 'schema' AS object_type, privilege_type
11715FROM mz_internal.mz_show_schema_privileges
11716UNION ALL
11717SELECT grantor, grantee, database, schema, name, object_type, privilege_type
11718FROM mz_internal.mz_show_object_privileges"#,
11719 access: vec![PUBLIC_SELECT],
11720});
11721
11722pub static MZ_SHOW_ALL_MY_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11723 name: "mz_show_all_my_privileges",
11724 schema: MZ_INTERNAL_SCHEMA,
11725 oid: oid::VIEW_MZ_SHOW_ALL_MY_PRIVILEGES_OID,
11726 desc: RelationDesc::builder()
11727 .with_column("grantor", SqlScalarType::String.nullable(true))
11728 .with_column("grantee", SqlScalarType::String.nullable(true))
11729 .with_column("database", SqlScalarType::String.nullable(true))
11730 .with_column("schema", SqlScalarType::String.nullable(true))
11731 .with_column("name", SqlScalarType::String.nullable(true))
11732 .with_column("object_type", SqlScalarType::String.nullable(false))
11733 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11734 .finish(),
11735 column_comments: BTreeMap::from_iter([
11736 ("grantor", "The role that granted the privilege."),
11737 ("grantee", "The role that the privilege was granted to."),
11738 (
11739 "database",
11740 "The name of the database containing the object.",
11741 ),
11742 ("schema", "The name of the schema containing the object."),
11743 ("name", "The name of the privilege target."),
11744 (
11745 "object_type",
11746 "The type of object the privilege is granted on.",
11747 ),
11748 ("privilege_type", "They type of privilege granted."),
11749 ]),
11750 sql: r#"SELECT grantor, grantee, database, schema, name, object_type, privilege_type
11751FROM mz_internal.mz_show_all_privileges
11752WHERE
11753 CASE
11754 WHEN grantee = 'PUBLIC' THEN true
11755 ELSE pg_has_role(grantee, 'USAGE')
11756 END"#,
11757 access: vec![PUBLIC_SELECT],
11758});
11759
11760pub static MZ_SHOW_DEFAULT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11761 name: "mz_show_default_privileges",
11762 schema: MZ_INTERNAL_SCHEMA,
11763 oid: oid::VIEW_MZ_SHOW_DEFAULT_PRIVILEGES_OID,
11764 desc: RelationDesc::builder()
11765 .with_column("object_owner", SqlScalarType::String.nullable(true))
11766 .with_column("database", SqlScalarType::String.nullable(true))
11767 .with_column("schema", SqlScalarType::String.nullable(true))
11768 .with_column("object_type", SqlScalarType::String.nullable(false))
11769 .with_column("grantee", SqlScalarType::String.nullable(true))
11770 .with_column("privilege_type", SqlScalarType::String.nullable(true))
11771 .finish(),
11772 column_comments: BTreeMap::from_iter([
11773 (
11774 "object_owner",
11775 "Privileges described in this row will be granted on objects created by `object_owner`.",
11776 ),
11777 (
11778 "database",
11779 "Privileges described in this row will be granted only on objects created in `database` if non-null.",
11780 ),
11781 (
11782 "schema",
11783 "Privileges described in this row will be granted only on objects created in `schema` if non-null.",
11784 ),
11785 (
11786 "object_type",
11787 "Privileges described in this row will be granted only on objects of type `object_type`.",
11788 ),
11789 (
11790 "grantee",
11791 "Privileges described in this row will be granted to `grantee`.",
11792 ),
11793 ("privilege_type", "They type of privilege to be granted."),
11794 ]),
11795 sql: r#"SELECT
11796 CASE defaults.role_id
11797 WHEN 'p' THEN 'PUBLIC'
11798 ELSE object_owner.name
11799 END AS object_owner,
11800 databases.name AS database,
11801 schemas.name AS schema,
11802 object_type,
11803 CASE defaults.grantee
11804 WHEN 'p' THEN 'PUBLIC'
11805 ELSE grantee.name
11806 END AS grantee,
11807 unnest(mz_internal.mz_format_privileges(defaults.privileges)) AS privilege_type
11808FROM mz_catalog.mz_default_privileges defaults
11809LEFT JOIN mz_catalog.mz_roles AS object_owner ON defaults.role_id = object_owner.id
11810LEFT JOIN mz_catalog.mz_roles AS grantee ON defaults.grantee = grantee.id
11811LEFT JOIN mz_catalog.mz_databases AS databases ON defaults.database_id = databases.id
11812LEFT JOIN mz_catalog.mz_schemas AS schemas ON defaults.schema_id = schemas.id
11813WHERE defaults.grantee NOT LIKE 's%'
11814 AND defaults.database_id IS NULL OR defaults.database_id NOT LIKE 's%'
11815 AND defaults.schema_id IS NULL OR defaults.schema_id NOT LIKE 's%'"#,
11816 access: vec![PUBLIC_SELECT],
11817});
11818
11819pub static MZ_SHOW_MY_DEFAULT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11820 name: "mz_show_my_default_privileges",
11821 schema: MZ_INTERNAL_SCHEMA,
11822 oid: oid::VIEW_MZ_SHOW_MY_DEFAULT_PRIVILEGES_OID,
11823 desc: RelationDesc::builder()
11824 .with_column("object_owner", SqlScalarType::String.nullable(true))
11825 .with_column("database", SqlScalarType::String.nullable(true))
11826 .with_column("schema", SqlScalarType::String.nullable(true))
11827 .with_column("object_type", SqlScalarType::String.nullable(false))
11828 .with_column("grantee", SqlScalarType::String.nullable(true))
11829 .with_column("privilege_type", SqlScalarType::String.nullable(true))
11830 .finish(),
11831 column_comments: BTreeMap::from_iter([
11832 (
11833 "object_owner",
11834 "Privileges described in this row will be granted on objects created by `object_owner`.",
11835 ),
11836 (
11837 "database",
11838 "Privileges described in this row will be granted only on objects created in `database` if non-null.",
11839 ),
11840 (
11841 "schema",
11842 "Privileges described in this row will be granted only on objects created in `schema` if non-null.",
11843 ),
11844 (
11845 "object_type",
11846 "Privileges described in this row will be granted only on objects of type `object_type`.",
11847 ),
11848 (
11849 "grantee",
11850 "Privileges described in this row will be granted to `grantee`.",
11851 ),
11852 ("privilege_type", "They type of privilege to be granted."),
11853 ]),
11854 sql: r#"SELECT object_owner, database, schema, object_type, grantee, privilege_type
11855FROM mz_internal.mz_show_default_privileges
11856WHERE
11857 CASE
11858 WHEN grantee = 'PUBLIC' THEN true
11859 ELSE pg_has_role(grantee, 'USAGE')
11860 END"#,
11861 access: vec![PUBLIC_SELECT],
11862});
11863
11864pub static MZ_SHOW_NETWORK_POLICIES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11865 name: "mz_show_network_policies",
11866 schema: MZ_INTERNAL_SCHEMA,
11867 oid: oid::VIEW_MZ_SHOW_NETWORK_POLICIES_OID,
11868 desc: RelationDesc::builder()
11869 .with_column("name", SqlScalarType::String.nullable(false))
11870 .with_column("rules", SqlScalarType::String.nullable(true))
11871 .with_column("comment", SqlScalarType::String.nullable(false))
11872 .finish(),
11873 column_comments: BTreeMap::new(),
11874 sql: "
11875WITH comments AS (
11876 SELECT id, comment
11877 FROM mz_internal.mz_comments
11878 WHERE object_type = 'network-policy' AND object_sub_id IS NULL
11879)
11880SELECT
11881 policy.name,
11882 pg_catalog.string_agg(rule.name,',' ORDER BY rule.name) as rules,
11883 COALESCE(comment, '') as comment
11884FROM
11885 mz_internal.mz_network_policies as policy
11886LEFT JOIN
11887 mz_internal.mz_network_policy_rules as rule ON policy.id = rule.policy_id
11888LEFT JOIN
11889 comments ON policy.id = comments.id
11890WHERE
11891 policy.id NOT LIKE 's%'
11892AND
11893 policy.id NOT LIKE 'g%'
11894GROUP BY policy.name, comments.comment;",
11895 access: vec![PUBLIC_SELECT],
11896});
11897
11898pub static MZ_CLUSTER_REPLICA_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11899 name: "mz_cluster_replica_history",
11900 schema: MZ_INTERNAL_SCHEMA,
11901 oid: oid::VIEW_MZ_CLUSTER_REPLICA_HISTORY_OID,
11902 desc: RelationDesc::builder()
11903 .with_column("replica_id", SqlScalarType::String.nullable(true))
11904 .with_column("size", SqlScalarType::String.nullable(true))
11905 .with_column("cluster_id", SqlScalarType::String.nullable(true))
11906 .with_column("cluster_name", SqlScalarType::String.nullable(true))
11907 .with_column("replica_name", SqlScalarType::String.nullable(true))
11908 .with_column(
11909 "created_at",
11910 SqlScalarType::TimestampTz { precision: None }.nullable(false),
11911 )
11912 .with_column(
11913 "dropped_at",
11914 SqlScalarType::TimestampTz { precision: None }.nullable(true),
11915 )
11916 .with_column(
11917 "credits_per_hour",
11918 SqlScalarType::Numeric { max_scale: None }.nullable(true),
11919 )
11920 .finish(),
11921 column_comments: BTreeMap::from_iter([
11922 ("replica_id", "The ID of a cluster replica."),
11923 (
11924 "size",
11925 "The size of the cluster replica. Corresponds to `mz_cluster_replica_sizes.size`.",
11926 ),
11927 (
11928 "cluster_id",
11929 "The ID of the cluster associated with the replica.",
11930 ),
11931 (
11932 "cluster_name",
11933 "The name of the cluster associated with the replica.",
11934 ),
11935 ("replica_name", "The name of the replica."),
11936 ("created_at", "The time at which the replica was created."),
11937 (
11938 "dropped_at",
11939 "The time at which the replica was dropped, or `NULL` if it still exists.",
11940 ),
11941 (
11942 "credits_per_hour",
11943 "The number of compute credits consumed per hour. Corresponds to `mz_cluster_replica_sizes.credits_per_hour`.",
11944 ),
11945 ]),
11946 sql: r#"
11947 WITH
11948 creates AS
11949 (
11950 SELECT
11951 details ->> 'logical_size' AS size,
11952 details ->> 'replica_id' AS replica_id,
11953 details ->> 'replica_name' AS replica_name,
11954 details ->> 'cluster_name' AS cluster_name,
11955 details ->> 'cluster_id' AS cluster_id,
11956 occurred_at
11957 FROM mz_catalog.mz_audit_events
11958 WHERE
11959 object_type = 'cluster-replica' AND event_type = 'create'
11960 AND
11961 details ->> 'replica_id' IS NOT NULL
11962 AND
11963 details ->> 'cluster_id' !~~ 's%'
11964 ),
11965 drops AS
11966 (
11967 SELECT details ->> 'replica_id' AS replica_id, occurred_at
11968 FROM mz_catalog.mz_audit_events
11969 WHERE object_type = 'cluster-replica' AND event_type = 'drop'
11970 )
11971 SELECT
11972 creates.replica_id,
11973 creates.size,
11974 creates.cluster_id,
11975 creates.cluster_name,
11976 creates.replica_name,
11977 creates.occurred_at AS created_at,
11978 drops.occurred_at AS dropped_at,
11979 mz_cluster_replica_sizes.credits_per_hour as credits_per_hour
11980 FROM
11981 creates
11982 LEFT JOIN drops ON creates.replica_id = drops.replica_id
11983 LEFT JOIN
11984 mz_catalog.mz_cluster_replica_sizes
11985 ON mz_cluster_replica_sizes.size = creates.size"#,
11986 access: vec![PUBLIC_SELECT],
11987});
11988
11989pub static MZ_CLUSTER_REPLICA_NAME_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11990 name: "mz_cluster_replica_name_history",
11991 schema: MZ_INTERNAL_SCHEMA,
11992 oid: oid::VIEW_MZ_CLUSTER_REPLICA_NAME_HISTORY_OID,
11993 desc: RelationDesc::builder()
11994 .with_column(
11995 "occurred_at",
11996 SqlScalarType::TimestampTz { precision: None }.nullable(true),
11997 )
11998 .with_column("id", SqlScalarType::String.nullable(true))
11999 .with_column("previous_name", SqlScalarType::String.nullable(true))
12000 .with_column("new_name", SqlScalarType::String.nullable(true))
12001 .finish(),
12002 column_comments: BTreeMap::from_iter([
12003 (
12004 "occurred_at",
12005 "The time at which the cluster replica was created or renamed. `NULL` if it's a built in system cluster replica.",
12006 ),
12007 ("id", "The ID of the cluster replica."),
12008 (
12009 "previous_name",
12010 "The previous name of the cluster replica. `NULL` if there was no previous name.",
12011 ),
12012 ("new_name", "The new name of the cluster replica."),
12013 ]),
12014 sql: r#"WITH user_replica_alter_history AS (
12015 SELECT occurred_at,
12016 audit_events.details->>'replica_id' AS id,
12017 audit_events.details->>'old_name' AS previous_name,
12018 audit_events.details->>'new_name' AS new_name
12019 FROM mz_catalog.mz_audit_events AS audit_events
12020 WHERE object_type = 'cluster-replica'
12021 AND audit_events.event_type = 'alter'
12022 AND audit_events.details->>'replica_id' like 'u%'
12023),
12024user_replica_create_history AS (
12025 SELECT occurred_at,
12026 audit_events.details->>'replica_id' AS id,
12027 NULL AS previous_name,
12028 audit_events.details->>'replica_name' AS new_name
12029 FROM mz_catalog.mz_audit_events AS audit_events
12030 WHERE object_type = 'cluster-replica'
12031 AND audit_events.event_type = 'create'
12032 AND audit_events.details->>'replica_id' like 'u%'
12033),
12034-- Because built in system cluster replicas don't have audit events, we need to manually add them
12035system_replicas AS (
12036 -- We assume that the system cluster replicas were created at the beginning of time
12037 SELECT NULL::timestamptz AS occurred_at,
12038 id,
12039 NULL AS previous_name,
12040 name AS new_name
12041 FROM mz_catalog.mz_cluster_replicas
12042 WHERE id LIKE 's%'
12043)
12044SELECT *
12045FROM user_replica_alter_history
12046UNION ALL
12047SELECT *
12048FROM user_replica_create_history
12049UNION ALL
12050SELECT *
12051FROM system_replicas"#,
12052 access: vec![PUBLIC_SELECT],
12053});
12054
12055pub static MZ_HYDRATION_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12056 name: "mz_hydration_statuses",
12057 schema: MZ_INTERNAL_SCHEMA,
12058 oid: oid::VIEW_MZ_HYDRATION_STATUSES_OID,
12059 desc: RelationDesc::builder()
12060 .with_column("object_id", SqlScalarType::String.nullable(false))
12061 .with_column("replica_id", SqlScalarType::String.nullable(true))
12062 .with_column("hydrated", SqlScalarType::Bool.nullable(true))
12063 .finish(),
12064 column_comments: BTreeMap::from_iter([
12065 (
12066 "object_id",
12067 "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`.",
12068 ),
12069 ("replica_id", "The ID of a cluster replica."),
12070 ("hydrated", "Whether the object is hydrated on the replica."),
12071 ]),
12072 sql: r#"WITH
12073-- Joining against the linearizable catalog tables ensures that this view
12074-- always contains the set of installed objects, even when it depends
12075-- on introspection relations that may received delayed updates.
12076--
12077-- Note that this view only includes objects that are maintained by dataflows.
12078-- In particular, some source types (webhook, introspection, ...) are not and
12079-- are therefore omitted.
12080indexes AS (
12081 SELECT
12082 i.id AS object_id,
12083 h.replica_id,
12084 COALESCE(h.hydrated, false) AS hydrated
12085 FROM mz_catalog.mz_indexes i
12086 LEFT JOIN mz_internal.mz_compute_hydration_statuses h
12087 ON (h.object_id = i.id)
12088),
12089materialized_views AS (
12090 SELECT
12091 i.id AS object_id,
12092 h.replica_id,
12093 COALESCE(h.hydrated, false) AS hydrated
12094 FROM mz_catalog.mz_materialized_views i
12095 LEFT JOIN mz_internal.mz_compute_hydration_statuses h
12096 ON (h.object_id = i.id)
12097),
12098continual_tasks AS (
12099 SELECT
12100 i.id AS object_id,
12101 h.replica_id,
12102 COALESCE(h.hydrated, false) AS hydrated
12103 FROM mz_internal.mz_continual_tasks i
12104 LEFT JOIN mz_internal.mz_compute_hydration_statuses h
12105 ON (h.object_id = i.id)
12106),
12107-- Hydration is a dataflow concept and not all sources are maintained by
12108-- dataflows, so we need to find the ones that are. Generally, sources that
12109-- have a cluster ID are maintained by a dataflow running on that cluster.
12110-- Webhook sources are an exception to this rule.
12111sources_with_clusters AS (
12112 SELECT id, cluster_id
12113 FROM mz_catalog.mz_sources
12114 WHERE cluster_id IS NOT NULL AND type != 'webhook'
12115),
12116sources AS (
12117 SELECT
12118 s.id AS object_id,
12119 ss.replica_id AS replica_id,
12120 ss.rehydration_latency IS NOT NULL AS hydrated
12121 FROM sources_with_clusters s
12122 LEFT JOIN mz_internal.mz_source_statistics ss USING (id)
12123),
12124-- We don't yet report sink hydration status (database-issues#8331), so we do a best effort attempt here and
12125-- define a sink as hydrated when it's both "running" and has a frontier greater than the minimum.
12126-- There is likely still a possibility of FPs.
12127sinks AS (
12128 SELECT
12129 s.id AS object_id,
12130 r.id AS replica_id,
12131 ss.status = 'running' AND COALESCE(f.write_frontier, 0) > 0 AS hydrated
12132 FROM mz_catalog.mz_sinks s
12133 LEFT JOIN mz_internal.mz_sink_statuses ss USING (id)
12134 JOIN mz_catalog.mz_cluster_replicas r
12135 ON (r.cluster_id = s.cluster_id)
12136 LEFT JOIN mz_catalog.mz_cluster_replica_frontiers f
12137 ON (f.object_id = s.id AND f.replica_id = r.id)
12138)
12139SELECT * FROM indexes
12140UNION ALL
12141SELECT * FROM materialized_views
12142UNION ALL
12143SELECT * FROM continual_tasks
12144UNION ALL
12145SELECT * FROM sources
12146UNION ALL
12147SELECT * FROM sinks"#,
12148 access: vec![PUBLIC_SELECT],
12149});
12150
12151pub static MZ_MATERIALIZATION_DEPENDENCIES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12152 name: "mz_materialization_dependencies",
12153 schema: MZ_INTERNAL_SCHEMA,
12154 oid: oid::VIEW_MZ_MATERIALIZATION_DEPENDENCIES_OID,
12155 desc: RelationDesc::builder()
12156 .with_column("object_id", SqlScalarType::String.nullable(false))
12157 .with_column("dependency_id", SqlScalarType::String.nullable(false))
12158 .finish(),
12159 column_comments: BTreeMap::from_iter([
12160 (
12161 "object_id",
12162 "The ID of a materialization. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, or `mz_catalog.mz_sinks.id`.",
12163 ),
12164 (
12165 "dependency_id",
12166 "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`.",
12167 ),
12168 ]),
12169 sql: "
12170SELECT object_id, dependency_id
12171FROM mz_internal.mz_compute_dependencies
12172UNION ALL
12173SELECT s.id, d.referenced_object_id AS dependency_id
12174FROM mz_internal.mz_object_dependencies d
12175JOIN mz_catalog.mz_sinks s ON (s.id = d.object_id)
12176JOIN mz_catalog.mz_relations r ON (r.id = d.referenced_object_id)",
12177 access: vec![PUBLIC_SELECT],
12178});
12179
12180pub static MZ_MATERIALIZATION_LAG: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12181 name: "mz_materialization_lag",
12182 schema: MZ_INTERNAL_SCHEMA,
12183 oid: oid::VIEW_MZ_MATERIALIZATION_LAG_OID,
12184 desc: RelationDesc::builder()
12185 .with_column("object_id", SqlScalarType::String.nullable(false))
12186 .with_column("local_lag", SqlScalarType::Interval.nullable(true))
12187 .with_column("global_lag", SqlScalarType::Interval.nullable(true))
12188 .with_column(
12189 "slowest_local_input_id",
12190 SqlScalarType::String.nullable(false),
12191 )
12192 .with_column(
12193 "slowest_global_input_id",
12194 SqlScalarType::String.nullable(false),
12195 )
12196 .finish(),
12197 column_comments: BTreeMap::from_iter([
12198 (
12199 "object_id",
12200 "The ID of the materialized view, index, or sink.",
12201 ),
12202 (
12203 "local_lag",
12204 "The amount of time the materialization lags behind its direct inputs.",
12205 ),
12206 (
12207 "global_lag",
12208 "The amount of time the materialization lags behind its root inputs (sources and tables).",
12209 ),
12210 (
12211 "slowest_local_input_id",
12212 "The ID of the slowest direct input.",
12213 ),
12214 (
12215 "slowest_global_input_id",
12216 "The ID of the slowest root input.",
12217 ),
12218 ]),
12219 sql: "
12220WITH MUTUALLY RECURSIVE
12221 -- IDs of objects for which we want to know the lag.
12222 materializations (id text) AS (
12223 SELECT id FROM mz_catalog.mz_indexes
12224 UNION ALL
12225 SELECT id FROM mz_catalog.mz_materialized_views
12226 UNION ALL
12227 SELECT id FROM mz_internal.mz_continual_tasks
12228 UNION ALL
12229 SELECT id FROM mz_catalog.mz_sinks
12230 ),
12231 -- Direct dependencies of materializations.
12232 direct_dependencies (id text, dep_id text) AS (
12233 SELECT m.id, d.dependency_id
12234 FROM materializations m
12235 JOIN mz_internal.mz_materialization_dependencies d ON (m.id = d.object_id)
12236 ),
12237 -- All transitive dependencies of materializations.
12238 transitive_dependencies (id text, dep_id text) AS (
12239 SELECT id, dep_id FROM direct_dependencies
12240 UNION
12241 SELECT td.id, dd.dep_id
12242 FROM transitive_dependencies td
12243 JOIN direct_dependencies dd ON (dd.id = td.dep_id)
12244 ),
12245 -- Root dependencies of materializations (sources and tables).
12246 root_dependencies (id text, dep_id text) AS (
12247 SELECT *
12248 FROM transitive_dependencies td
12249 WHERE NOT EXISTS (
12250 SELECT 1
12251 FROM direct_dependencies dd
12252 WHERE dd.id = td.dep_id
12253 )
12254 ),
12255 -- Write progress times of materializations.
12256 materialization_times (id text, time timestamptz) AS (
12257 SELECT m.id, to_timestamp(f.write_frontier::text::double / 1000)
12258 FROM materializations m
12259 JOIN mz_internal.mz_frontiers f ON (m.id = f.object_id)
12260 ),
12261 -- Write progress times of direct dependencies of materializations.
12262 input_times (id text, slowest_dep text, time timestamptz) AS (
12263 SELECT DISTINCT ON (d.id)
12264 d.id,
12265 d.dep_id,
12266 to_timestamp(f.write_frontier::text::double / 1000)
12267 FROM direct_dependencies d
12268 JOIN mz_internal.mz_frontiers f ON (d.dep_id = f.object_id)
12269 ORDER BY d.id, f.write_frontier ASC
12270 ),
12271 -- Write progress times of root dependencies of materializations.
12272 root_times (id text, slowest_dep text, time timestamptz) AS (
12273 SELECT DISTINCT ON (d.id)
12274 d.id,
12275 d.dep_id,
12276 to_timestamp(f.write_frontier::text::double / 1000)
12277 FROM root_dependencies d
12278 JOIN mz_internal.mz_frontiers f ON (d.dep_id = f.object_id)
12279 ORDER BY d.id, f.write_frontier ASC
12280 )
12281SELECT
12282 id AS object_id,
12283 -- Ensure that lag values are always NULL for materializations that have reached the empty
12284 -- frontier, as those have processed all their input data.
12285 -- Also make sure that lag values are never negative, even when input frontiers are before
12286 -- output frontiers (as can happen during hydration).
12287 CASE
12288 WHEN m.time IS NULL THEN INTERVAL '0'
12289 WHEN i.time IS NULL THEN NULL
12290 ELSE greatest(i.time - m.time, INTERVAL '0')
12291 END AS local_lag,
12292 CASE
12293 WHEN m.time IS NULL THEN INTERVAL '0'
12294 WHEN r.time IS NULL THEN NULL
12295 ELSE greatest(r.time - m.time, INTERVAL '0')
12296 END AS global_lag,
12297 i.slowest_dep AS slowest_local_input_id,
12298 r.slowest_dep AS slowest_global_input_id
12299FROM materialization_times m
12300JOIN input_times i USING (id)
12301JOIN root_times r USING (id)",
12302 access: vec![PUBLIC_SELECT],
12303});
12304
12305pub static MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW: LazyLock<BuiltinView> = LazyLock::new(|| {
12311 BuiltinView {
12312 name: "mz_console_cluster_utilization_overview",
12313 schema: MZ_INTERNAL_SCHEMA,
12314 oid: oid::VIEW_MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_OID,
12315 desc: RelationDesc::builder()
12316 .with_column(
12317 "bucket_start",
12318 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12319 )
12320 .with_column("replica_id", SqlScalarType::String.nullable(false))
12321 .with_column("memory_percent", SqlScalarType::Float64.nullable(true))
12322 .with_column(
12323 "max_memory_at",
12324 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12325 )
12326 .with_column("disk_percent", SqlScalarType::Float64.nullable(true))
12327 .with_column(
12328 "max_disk_at",
12329 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12330 )
12331 .with_column(
12332 "memory_and_disk_percent",
12333 SqlScalarType::Float64.nullable(true),
12334 )
12335 .with_column(
12336 "max_memory_and_disk_memory_percent",
12337 SqlScalarType::Float64.nullable(true),
12338 )
12339 .with_column(
12340 "max_memory_and_disk_disk_percent",
12341 SqlScalarType::Float64.nullable(true),
12342 )
12343 .with_column(
12344 "max_memory_and_disk_at",
12345 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12346 )
12347 .with_column("heap_percent", SqlScalarType::Float64.nullable(true))
12348 .with_column(
12349 "max_heap_at",
12350 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12351 )
12352 .with_column("max_cpu_percent", SqlScalarType::Float64.nullable(true))
12353 .with_column(
12354 "max_cpu_at",
12355 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12356 )
12357 .with_column("offline_events", SqlScalarType::Jsonb.nullable(true))
12358 .with_column(
12359 "bucket_end",
12360 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12361 )
12362 .with_column("name", SqlScalarType::String.nullable(true))
12363 .with_column("cluster_id", SqlScalarType::String.nullable(true))
12364 .with_column("size", SqlScalarType::String.nullable(true))
12365 .finish(),
12366 column_comments: BTreeMap::new(),
12367 sql: r#"WITH replica_history AS (
12368 SELECT replica_id,
12369 size,
12370 cluster_id
12371 FROM mz_internal.mz_cluster_replica_history
12372 UNION
12373 -- We need to union the current set of cluster replicas since mz_cluster_replica_history doesn't include system clusters
12374 SELECT id AS replica_id,
12375 size,
12376 cluster_id
12377 FROM mz_catalog.mz_cluster_replicas
12378),
12379replica_metrics_history AS (
12380 SELECT
12381 m.occurred_at,
12382 m.replica_id,
12383 r.size,
12384 (SUM(m.cpu_nano_cores::float8) / NULLIF(s.cpu_nano_cores, 0)) / s.processes AS cpu_percent,
12385 (SUM(m.memory_bytes::float8) / NULLIF(s.memory_bytes, 0)) / s.processes AS memory_percent,
12386 (SUM(m.disk_bytes::float8) / NULLIF(s.disk_bytes, 0)) / s.processes AS disk_percent,
12387 (SUM(m.heap_bytes::float8) / NULLIF(m.heap_limit, 0)) / s.processes AS heap_percent,
12388 SUM(m.disk_bytes::float8) AS disk_bytes,
12389 SUM(m.memory_bytes::float8) AS memory_bytes,
12390 s.disk_bytes::numeric * s.processes AS total_disk_bytes,
12391 s.memory_bytes::numeric * s.processes AS total_memory_bytes
12392 FROM
12393 replica_history AS r
12394 INNER JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size
12395 INNER JOIN mz_internal.mz_cluster_replica_metrics_history AS m ON m.replica_id = r.replica_id
12396 GROUP BY
12397 m.occurred_at,
12398 m.replica_id,
12399 r.size,
12400 s.cpu_nano_cores,
12401 s.memory_bytes,
12402 s.disk_bytes,
12403 m.heap_limit,
12404 s.processes
12405),
12406replica_utilization_history_binned AS (
12407 SELECT m.occurred_at,
12408 m.replica_id,
12409 m.cpu_percent,
12410 m.memory_percent,
12411 m.memory_bytes,
12412 m.disk_percent,
12413 m.disk_bytes,
12414 m.heap_percent,
12415 m.total_disk_bytes,
12416 m.total_memory_bytes,
12417 m.size,
12418 date_bin(
12419 '8 HOURS',
12420 occurred_at,
12421 '1970-01-01'::timestamp
12422 ) AS bucket_start
12423 FROM replica_history AS r
12424 JOIN replica_metrics_history AS m ON m.replica_id = r.replica_id
12425 WHERE mz_now() <= date_bin(
12426 '8 HOURS',
12427 occurred_at,
12428 '1970-01-01'::timestamp
12429 ) + INTERVAL '14 DAYS'
12430),
12431-- For each (replica, bucket), take the (replica, bucket) with the highest memory
12432max_memory AS (
12433 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12434 replica_id,
12435 memory_percent,
12436 occurred_at
12437 FROM replica_utilization_history_binned
12438 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12439 ORDER BY bucket_start,
12440 replica_id,
12441 COALESCE(memory_bytes, 0) DESC
12442),
12443max_disk AS (
12444 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12445 replica_id,
12446 disk_percent,
12447 occurred_at
12448 FROM replica_utilization_history_binned
12449 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12450 ORDER BY bucket_start,
12451 replica_id,
12452 COALESCE(disk_bytes, 0) DESC
12453),
12454max_cpu AS (
12455 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12456 replica_id,
12457 cpu_percent,
12458 occurred_at
12459 FROM replica_utilization_history_binned
12460 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12461 ORDER BY bucket_start,
12462 replica_id,
12463 COALESCE(cpu_percent, 0) DESC
12464),
12465/*
12466 This is different
12467 from adding max_memory
12468 and max_disk per bucket because both
12469 values may not occur at the same time if the bucket interval is large.
12470 */
12471max_memory_and_disk AS (
12472 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12473 replica_id,
12474 memory_percent,
12475 disk_percent,
12476 memory_and_disk_percent,
12477 occurred_at
12478 FROM (
12479 SELECT *,
12480 CASE
12481 WHEN disk_bytes IS NULL
12482 AND memory_bytes IS NULL THEN NULL
12483 ELSE (COALESCE(disk_bytes, 0) + COALESCE(memory_bytes, 0))
12484 / (total_disk_bytes::numeric + total_memory_bytes::numeric)
12485 END AS memory_and_disk_percent
12486 FROM replica_utilization_history_binned
12487 ) AS max_memory_and_disk_inner
12488 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12489 ORDER BY bucket_start,
12490 replica_id,
12491 COALESCE(memory_and_disk_percent, 0) DESC
12492),
12493max_heap AS (
12494 SELECT DISTINCT ON (bucket_start, replica_id)
12495 bucket_start,
12496 replica_id,
12497 heap_percent,
12498 occurred_at
12499 FROM replica_utilization_history_binned
12500 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12501 ORDER BY bucket_start, replica_id, COALESCE(heap_percent, 0) DESC
12502),
12503-- For each (replica, bucket), get its offline events at that time
12504replica_offline_event_history AS (
12505 SELECT date_bin(
12506 '8 HOURS',
12507 occurred_at,
12508 '1970-01-01'::timestamp
12509 ) AS bucket_start,
12510 replica_id,
12511 jsonb_agg(
12512 jsonb_build_object(
12513 'replicaId',
12514 rsh.replica_id,
12515 'occurredAt',
12516 rsh.occurred_at,
12517 'status',
12518 rsh.status,
12519 'reason',
12520 rsh.reason
12521 )
12522 ) AS offline_events
12523 FROM mz_internal.mz_cluster_replica_status_history AS rsh -- We assume the statuses for process 0 are the same as all processes
12524 WHERE process_id = '0'
12525 AND status = 'offline'
12526 AND mz_now() <= date_bin(
12527 '8 HOURS',
12528 occurred_at,
12529 '1970-01-01'::timestamp
12530 ) + INTERVAL '14 DAYS'
12531 GROUP BY bucket_start,
12532 replica_id
12533)
12534SELECT
12535 bucket_start,
12536 replica_id,
12537 max_memory.memory_percent,
12538 max_memory.occurred_at as max_memory_at,
12539 max_disk.disk_percent,
12540 max_disk.occurred_at as max_disk_at,
12541 max_memory_and_disk.memory_and_disk_percent as memory_and_disk_percent,
12542 max_memory_and_disk.memory_percent as max_memory_and_disk_memory_percent,
12543 max_memory_and_disk.disk_percent as max_memory_and_disk_disk_percent,
12544 max_memory_and_disk.occurred_at as max_memory_and_disk_at,
12545 max_heap.heap_percent,
12546 max_heap.occurred_at as max_heap_at,
12547 max_cpu.cpu_percent as max_cpu_percent,
12548 max_cpu.occurred_at as max_cpu_at,
12549 replica_offline_event_history.offline_events,
12550 bucket_start + INTERVAL '8 HOURS' as bucket_end,
12551 replica_name_history.new_name AS name,
12552 replica_history.cluster_id,
12553 replica_history.size
12554FROM max_memory
12555JOIN max_disk USING (bucket_start, replica_id)
12556JOIN max_cpu USING (bucket_start, replica_id)
12557JOIN max_memory_and_disk USING (bucket_start, replica_id)
12558JOIN max_heap USING (bucket_start, replica_id)
12559JOIN replica_history USING (replica_id)
12560CROSS JOIN LATERAL (
12561 SELECT new_name
12562 FROM mz_internal.mz_cluster_replica_name_history as replica_name_history
12563 WHERE replica_id = replica_name_history.id -- We treat NULLs as the beginning of time
12564 AND bucket_start + INTERVAL '8 HOURS' >= COALESCE(
12565 replica_name_history.occurred_at,
12566 '1970-01-01'::timestamp
12567 )
12568 ORDER BY replica_name_history.occurred_at DESC
12569 LIMIT '1'
12570) AS replica_name_history
12571LEFT JOIN replica_offline_event_history USING (bucket_start, replica_id)"#,
12572 access: vec![PUBLIC_SELECT],
12573 }
12574});
12575
12576pub static MZ_CLUSTER_DEPLOYMENT_LINEAGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12599 name: "mz_cluster_deployment_lineage",
12600 schema: MZ_INTERNAL_SCHEMA,
12601 oid: oid::VIEW_MZ_CLUSTER_DEPLOYMENT_LINEAGE_OID,
12602 desc: RelationDesc::builder()
12603 .with_column("cluster_id", SqlScalarType::String.nullable(true))
12604 .with_column(
12605 "current_deployment_cluster_id",
12606 SqlScalarType::String.nullable(false),
12607 )
12608 .with_column("cluster_name", SqlScalarType::String.nullable(false))
12609 .with_key(vec![0, 1, 2])
12610 .finish(),
12611 column_comments: BTreeMap::from_iter([
12612 (
12613 "cluster_id",
12614 "The ID of the cluster. Corresponds to `mz_clusters.id` (though the cluster may no longer exist).",
12615 ),
12616 (
12617 "current_deployment_cluster_id",
12618 "The cluster ID of the last cluster in `cluster_id`'s blue/green lineage (the cluster is guaranteed to exist).",
12619 ),
12620 ("cluster_name", "The name of the cluster"),
12621 ]),
12622 sql: r#"WITH MUTUALLY RECURSIVE cluster_events (
12623 cluster_id text,
12624 cluster_name text,
12625 event_type text,
12626 occurred_at timestamptz
12627) AS (
12628 SELECT coalesce(details->>'id', details->>'cluster_id') AS cluster_id,
12629 coalesce(details->>'name', details->>'new_name') AS cluster_name,
12630 event_type,
12631 occurred_at
12632 FROM mz_audit_events
12633 WHERE (
12634 event_type IN ('create', 'drop')
12635 OR (
12636 event_type = 'alter'
12637 AND details ? 'new_name'
12638 )
12639 )
12640 AND object_type = 'cluster'
12641 AND mz_now() < occurred_at + INTERVAL '30 days'
12642),
12643mz_cluster_deployment_lineage (
12644 cluster_id text,
12645 current_deployment_cluster_id text,
12646 cluster_name text
12647) AS (
12648 SELECT c.id,
12649 c.id,
12650 c.name
12651 FROM mz_clusters c
12652 WHERE c.id LIKE 'u%'
12653 UNION
12654 SELECT *
12655 FROM dropped_clusters
12656),
12657-- Closest create or rename event based on the current clusters in the result set
12658most_recent_create_or_rename (
12659 cluster_id text,
12660 current_deployment_cluster_id text,
12661 cluster_name text,
12662 occurred_at timestamptz
12663) AS (
12664 SELECT DISTINCT ON (e.cluster_id) e.cluster_id,
12665 c.current_deployment_cluster_id,
12666 e.cluster_name,
12667 e.occurred_at
12668 FROM mz_cluster_deployment_lineage c
12669 JOIN cluster_events e ON c.cluster_id = e.cluster_id
12670 AND c.cluster_name = e.cluster_name
12671 WHERE e.event_type <> 'drop'
12672 ORDER BY e.cluster_id,
12673 e.occurred_at DESC
12674),
12675-- Clusters that were dropped most recently within 1 minute of most_recent_create_or_rename
12676dropped_clusters (
12677 cluster_id text,
12678 current_deployment_cluster_id text,
12679 cluster_name text
12680) AS (
12681 SELECT DISTINCT ON (cr.cluster_id) e.cluster_id,
12682 cr.current_deployment_cluster_id,
12683 cr.cluster_name
12684 FROM most_recent_create_or_rename cr
12685 JOIN cluster_events e ON e.occurred_at BETWEEN cr.occurred_at - interval '1 minute'
12686 AND cr.occurred_at + interval '1 minute'
12687 AND (
12688 e.cluster_name = cr.cluster_name
12689 OR e.cluster_name = cr.cluster_name || '_dbt_deploy'
12690 )
12691 WHERE e.event_type = 'drop'
12692 ORDER BY cr.cluster_id,
12693 abs(
12694 extract(
12695 epoch
12696 FROM cr.occurred_at - e.occurred_at
12697 )
12698 )
12699)
12700SELECT *
12701FROM mz_cluster_deployment_lineage"#,
12702 access: vec![PUBLIC_SELECT],
12703});
12704
12705pub const MZ_SHOW_DATABASES_IND: BuiltinIndex = BuiltinIndex {
12706 name: "mz_show_databases_ind",
12707 schema: MZ_INTERNAL_SCHEMA,
12708 oid: oid::INDEX_MZ_SHOW_DATABASES_IND_OID,
12709 sql: "IN CLUSTER mz_catalog_server
12710ON mz_internal.mz_show_databases (name)",
12711 is_retained_metrics_object: false,
12712};
12713
12714pub const MZ_SHOW_SCHEMAS_IND: BuiltinIndex = BuiltinIndex {
12715 name: "mz_show_schemas_ind",
12716 schema: MZ_INTERNAL_SCHEMA,
12717 oid: oid::INDEX_MZ_SHOW_SCHEMAS_IND_OID,
12718 sql: "IN CLUSTER mz_catalog_server
12719ON mz_internal.mz_show_schemas (database_id)",
12720 is_retained_metrics_object: false,
12721};
12722
12723pub const MZ_SHOW_CONNECTIONS_IND: BuiltinIndex = BuiltinIndex {
12724 name: "mz_show_connections_ind",
12725 schema: MZ_INTERNAL_SCHEMA,
12726 oid: oid::INDEX_MZ_SHOW_CONNECTIONS_IND_OID,
12727 sql: "IN CLUSTER mz_catalog_server
12728ON mz_internal.mz_show_connections (schema_id)",
12729 is_retained_metrics_object: false,
12730};
12731
12732pub const MZ_SHOW_TABLES_IND: BuiltinIndex = BuiltinIndex {
12733 name: "mz_show_tables_ind",
12734 schema: MZ_INTERNAL_SCHEMA,
12735 oid: oid::INDEX_MZ_SHOW_TABLES_IND_OID,
12736 sql: "IN CLUSTER mz_catalog_server
12737ON mz_internal.mz_show_tables (schema_id)",
12738 is_retained_metrics_object: false,
12739};
12740
12741pub const MZ_SHOW_SOURCES_IND: BuiltinIndex = BuiltinIndex {
12742 name: "mz_show_sources_ind",
12743 schema: MZ_INTERNAL_SCHEMA,
12744 oid: oid::INDEX_MZ_SHOW_SOURCES_IND_OID,
12745 sql: "IN CLUSTER mz_catalog_server
12746ON mz_internal.mz_show_sources (schema_id)",
12747 is_retained_metrics_object: false,
12748};
12749
12750pub const MZ_SHOW_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12751 name: "mz_show_views_ind",
12752 schema: MZ_INTERNAL_SCHEMA,
12753 oid: oid::INDEX_MZ_SHOW_VIEWS_IND_OID,
12754 sql: "IN CLUSTER mz_catalog_server
12755ON mz_internal.mz_show_views (schema_id)",
12756 is_retained_metrics_object: false,
12757};
12758
12759pub const MZ_SHOW_MATERIALIZED_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12760 name: "mz_show_materialized_views_ind",
12761 schema: MZ_INTERNAL_SCHEMA,
12762 oid: oid::INDEX_MZ_SHOW_MATERIALIZED_VIEWS_IND_OID,
12763 sql: "IN CLUSTER mz_catalog_server
12764ON mz_internal.mz_show_materialized_views (schema_id)",
12765 is_retained_metrics_object: false,
12766};
12767
12768pub const MZ_SHOW_SINKS_IND: BuiltinIndex = BuiltinIndex {
12769 name: "mz_show_sinks_ind",
12770 schema: MZ_INTERNAL_SCHEMA,
12771 oid: oid::INDEX_MZ_SHOW_SINKS_IND_OID,
12772 sql: "IN CLUSTER mz_catalog_server
12773ON mz_internal.mz_show_sinks (schema_id)",
12774 is_retained_metrics_object: false,
12775};
12776
12777pub const MZ_SHOW_TYPES_IND: BuiltinIndex = BuiltinIndex {
12778 name: "mz_show_types_ind",
12779 schema: MZ_INTERNAL_SCHEMA,
12780 oid: oid::INDEX_MZ_SHOW_TYPES_IND_OID,
12781 sql: "IN CLUSTER mz_catalog_server
12782ON mz_internal.mz_show_types (schema_id)",
12783 is_retained_metrics_object: false,
12784};
12785
12786pub const MZ_SHOW_ROLES_IND: BuiltinIndex = BuiltinIndex {
12787 name: "mz_show_roles_ind",
12788 schema: MZ_INTERNAL_SCHEMA,
12789 oid: oid::INDEX_MZ_SHOW_ROLES_IND_OID,
12790 sql: "IN CLUSTER mz_catalog_server
12791ON mz_internal.mz_show_roles (name)",
12792 is_retained_metrics_object: false,
12793};
12794
12795pub const MZ_SHOW_ALL_OBJECTS_IND: BuiltinIndex = BuiltinIndex {
12796 name: "mz_show_all_objects_ind",
12797 schema: MZ_INTERNAL_SCHEMA,
12798 oid: oid::INDEX_MZ_SHOW_ALL_OBJECTS_IND_OID,
12799 sql: "IN CLUSTER mz_catalog_server
12800ON mz_internal.mz_show_all_objects (schema_id)",
12801 is_retained_metrics_object: false,
12802};
12803
12804pub const MZ_SHOW_INDEXES_IND: BuiltinIndex = BuiltinIndex {
12805 name: "mz_show_indexes_ind",
12806 schema: MZ_INTERNAL_SCHEMA,
12807 oid: oid::INDEX_MZ_SHOW_INDEXES_IND_OID,
12808 sql: "IN CLUSTER mz_catalog_server
12809ON mz_internal.mz_show_indexes (schema_id)",
12810 is_retained_metrics_object: false,
12811};
12812
12813pub const MZ_SHOW_COLUMNS_IND: BuiltinIndex = BuiltinIndex {
12814 name: "mz_show_columns_ind",
12815 schema: MZ_INTERNAL_SCHEMA,
12816 oid: oid::INDEX_MZ_SHOW_COLUMNS_IND_OID,
12817 sql: "IN CLUSTER mz_catalog_server
12818ON mz_internal.mz_show_columns (id)",
12819 is_retained_metrics_object: false,
12820};
12821
12822pub const MZ_SHOW_CLUSTERS_IND: BuiltinIndex = BuiltinIndex {
12823 name: "mz_show_clusters_ind",
12824 schema: MZ_INTERNAL_SCHEMA,
12825 oid: oid::INDEX_MZ_SHOW_CLUSTERS_IND_OID,
12826 sql: "IN CLUSTER mz_catalog_server
12827ON mz_internal.mz_show_clusters (name)",
12828 is_retained_metrics_object: false,
12829};
12830
12831pub const MZ_SHOW_CLUSTER_REPLICAS_IND: BuiltinIndex = BuiltinIndex {
12832 name: "mz_show_cluster_replicas_ind",
12833 schema: MZ_INTERNAL_SCHEMA,
12834 oid: oid::INDEX_MZ_SHOW_CLUSTER_REPLICAS_IND_OID,
12835 sql: "IN CLUSTER mz_catalog_server
12836ON mz_internal.mz_show_cluster_replicas (cluster)",
12837 is_retained_metrics_object: false,
12838};
12839
12840pub const MZ_SHOW_SECRETS_IND: BuiltinIndex = BuiltinIndex {
12841 name: "mz_show_secrets_ind",
12842 schema: MZ_INTERNAL_SCHEMA,
12843 oid: oid::INDEX_MZ_SHOW_SECRETS_IND_OID,
12844 sql: "IN CLUSTER mz_catalog_server
12845ON mz_internal.mz_show_secrets (schema_id)",
12846 is_retained_metrics_object: false,
12847};
12848
12849pub const MZ_DATABASES_IND: BuiltinIndex = BuiltinIndex {
12850 name: "mz_databases_ind",
12851 schema: MZ_CATALOG_SCHEMA,
12852 oid: oid::INDEX_MZ_DATABASES_IND_OID,
12853 sql: "IN CLUSTER mz_catalog_server
12854ON mz_catalog.mz_databases (name)",
12855 is_retained_metrics_object: false,
12856};
12857
12858pub const MZ_SCHEMAS_IND: BuiltinIndex = BuiltinIndex {
12859 name: "mz_schemas_ind",
12860 schema: MZ_CATALOG_SCHEMA,
12861 oid: oid::INDEX_MZ_SCHEMAS_IND_OID,
12862 sql: "IN CLUSTER mz_catalog_server
12863ON mz_catalog.mz_schemas (database_id)",
12864 is_retained_metrics_object: false,
12865};
12866
12867pub const MZ_CONNECTIONS_IND: BuiltinIndex = BuiltinIndex {
12868 name: "mz_connections_ind",
12869 schema: MZ_CATALOG_SCHEMA,
12870 oid: oid::INDEX_MZ_CONNECTIONS_IND_OID,
12871 sql: "IN CLUSTER mz_catalog_server
12872ON mz_catalog.mz_connections (schema_id)",
12873 is_retained_metrics_object: false,
12874};
12875
12876pub const MZ_TABLES_IND: BuiltinIndex = BuiltinIndex {
12877 name: "mz_tables_ind",
12878 schema: MZ_CATALOG_SCHEMA,
12879 oid: oid::INDEX_MZ_TABLES_IND_OID,
12880 sql: "IN CLUSTER mz_catalog_server
12881ON mz_catalog.mz_tables (schema_id)",
12882 is_retained_metrics_object: false,
12883};
12884
12885pub const MZ_TYPES_IND: BuiltinIndex = BuiltinIndex {
12886 name: "mz_types_ind",
12887 schema: MZ_CATALOG_SCHEMA,
12888 oid: oid::INDEX_MZ_TYPES_IND_OID,
12889 sql: "IN CLUSTER mz_catalog_server
12890ON mz_catalog.mz_types (schema_id)",
12891 is_retained_metrics_object: false,
12892};
12893
12894pub const MZ_OBJECTS_IND: BuiltinIndex = BuiltinIndex {
12895 name: "mz_objects_ind",
12896 schema: MZ_CATALOG_SCHEMA,
12897 oid: oid::INDEX_MZ_OBJECTS_IND_OID,
12898 sql: "IN CLUSTER mz_catalog_server
12899ON mz_catalog.mz_objects (schema_id)",
12900 is_retained_metrics_object: false,
12901};
12902
12903pub const MZ_COLUMNS_IND: BuiltinIndex = BuiltinIndex {
12904 name: "mz_columns_ind",
12905 schema: MZ_CATALOG_SCHEMA,
12906 oid: oid::INDEX_MZ_COLUMNS_IND_OID,
12907 sql: "IN CLUSTER mz_catalog_server
12908ON mz_catalog.mz_columns (name)",
12909 is_retained_metrics_object: false,
12910};
12911
12912pub const MZ_SECRETS_IND: BuiltinIndex = BuiltinIndex {
12913 name: "mz_secrets_ind",
12914 schema: MZ_CATALOG_SCHEMA,
12915 oid: oid::INDEX_MZ_SECRETS_IND_OID,
12916 sql: "IN CLUSTER mz_catalog_server
12917ON mz_catalog.mz_secrets (name)",
12918 is_retained_metrics_object: false,
12919};
12920
12921pub const MZ_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12922 name: "mz_views_ind",
12923 schema: MZ_CATALOG_SCHEMA,
12924 oid: oid::INDEX_MZ_VIEWS_IND_OID,
12925 sql: "IN CLUSTER mz_catalog_server
12926ON mz_catalog.mz_views (schema_id)",
12927 is_retained_metrics_object: false,
12928};
12929
12930pub const MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_IND: BuiltinIndex = BuiltinIndex {
12931 name: "mz_console_cluster_utilization_overview_ind",
12932 schema: MZ_INTERNAL_SCHEMA,
12933 oid: oid::INDEX_MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_IND_OID,
12934 sql: "IN CLUSTER mz_catalog_server
12935ON mz_internal.mz_console_cluster_utilization_overview (cluster_id)",
12936 is_retained_metrics_object: false,
12937};
12938
12939pub const MZ_CLUSTER_DEPLOYMENT_LINEAGE_IND: BuiltinIndex = BuiltinIndex {
12940 name: "mz_cluster_deployment_lineage_ind",
12941 schema: MZ_INTERNAL_SCHEMA,
12942 oid: oid::INDEX_MZ_CLUSTER_DEPLOYMENT_LINEAGE_IND_OID,
12943 sql: "IN CLUSTER mz_catalog_server
12944ON mz_internal.mz_cluster_deployment_lineage (cluster_id)",
12945 is_retained_metrics_object: false,
12946};
12947
12948pub const MZ_CLUSTERS_IND: BuiltinIndex = BuiltinIndex {
12949 name: "mz_clusters_ind",
12950 schema: MZ_CATALOG_SCHEMA,
12951 oid: oid::INDEX_MZ_CLUSTERS_IND_OID,
12952 sql: "IN CLUSTER mz_catalog_server
12953ON mz_catalog.mz_clusters (id)",
12954 is_retained_metrics_object: false,
12955};
12956
12957pub const MZ_INDEXES_IND: BuiltinIndex = BuiltinIndex {
12958 name: "mz_indexes_ind",
12959 schema: MZ_CATALOG_SCHEMA,
12960 oid: oid::INDEX_MZ_INDEXES_IND_OID,
12961 sql: "IN CLUSTER mz_catalog_server
12962ON mz_catalog.mz_indexes (id)",
12963 is_retained_metrics_object: false,
12964};
12965
12966pub const MZ_ROLES_IND: BuiltinIndex = BuiltinIndex {
12967 name: "mz_roles_ind",
12968 schema: MZ_CATALOG_SCHEMA,
12969 oid: oid::INDEX_MZ_ROLES_IND_OID,
12970 sql: "IN CLUSTER mz_catalog_server
12971ON mz_catalog.mz_roles (id)",
12972 is_retained_metrics_object: false,
12973};
12974
12975pub const MZ_SOURCES_IND: BuiltinIndex = BuiltinIndex {
12976 name: "mz_sources_ind",
12977 schema: MZ_CATALOG_SCHEMA,
12978 oid: oid::INDEX_MZ_SOURCES_IND_OID,
12979 sql: "IN CLUSTER mz_catalog_server
12980ON mz_catalog.mz_sources (id)",
12981 is_retained_metrics_object: true,
12982};
12983
12984pub const MZ_SINKS_IND: BuiltinIndex = BuiltinIndex {
12985 name: "mz_sinks_ind",
12986 schema: MZ_CATALOG_SCHEMA,
12987 oid: oid::INDEX_MZ_SINKS_IND_OID,
12988 sql: "IN CLUSTER mz_catalog_server
12989ON mz_catalog.mz_sinks (id)",
12990 is_retained_metrics_object: true,
12991};
12992
12993pub const MZ_MATERIALIZED_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12994 name: "mz_materialized_views_ind",
12995 schema: MZ_CATALOG_SCHEMA,
12996 oid: oid::INDEX_MZ_MATERIALIZED_VIEWS_IND_OID,
12997 sql: "IN CLUSTER mz_catalog_server
12998ON mz_catalog.mz_materialized_views (id)",
12999 is_retained_metrics_object: false,
13000};
13001
13002pub const MZ_CONTINUAL_TASKS_IND: BuiltinIndex = BuiltinIndex {
13003 name: "mz_continual_tasks_ind",
13004 schema: MZ_INTERNAL_SCHEMA,
13005 oid: oid::INDEX_MZ_CONTINUAL_TASKS_IND_OID,
13006 sql: "IN CLUSTER mz_catalog_server
13007ON mz_internal.mz_continual_tasks (id)",
13008 is_retained_metrics_object: false,
13009};
13010
13011pub const MZ_SOURCE_STATUSES_IND: BuiltinIndex = BuiltinIndex {
13012 name: "mz_source_statuses_ind",
13013 schema: MZ_INTERNAL_SCHEMA,
13014 oid: oid::INDEX_MZ_SOURCE_STATUSES_IND_OID,
13015 sql: "IN CLUSTER mz_catalog_server
13016ON mz_internal.mz_source_statuses (id)",
13017 is_retained_metrics_object: false,
13018};
13019
13020pub const MZ_SINK_STATUSES_IND: BuiltinIndex = BuiltinIndex {
13021 name: "mz_sink_statuses_ind",
13022 schema: MZ_INTERNAL_SCHEMA,
13023 oid: oid::INDEX_MZ_SINK_STATUSES_IND_OID,
13024 sql: "IN CLUSTER mz_catalog_server
13025ON mz_internal.mz_sink_statuses (id)",
13026 is_retained_metrics_object: false,
13027};
13028
13029pub const MZ_SOURCE_STATUS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13030 name: "mz_source_status_history_ind",
13031 schema: MZ_INTERNAL_SCHEMA,
13032 oid: oid::INDEX_MZ_SOURCE_STATUS_HISTORY_IND_OID,
13033 sql: "IN CLUSTER mz_catalog_server
13034ON mz_internal.mz_source_status_history (source_id)",
13035 is_retained_metrics_object: false,
13036};
13037
13038pub const MZ_SINK_STATUS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13039 name: "mz_sink_status_history_ind",
13040 schema: MZ_INTERNAL_SCHEMA,
13041 oid: oid::INDEX_MZ_SINK_STATUS_HISTORY_IND_OID,
13042 sql: "IN CLUSTER mz_catalog_server
13043ON mz_internal.mz_sink_status_history (sink_id)",
13044 is_retained_metrics_object: false,
13045};
13046
13047pub const MZ_SHOW_CONTINUAL_TASKS_IND: BuiltinIndex = BuiltinIndex {
13048 name: "mz_show_continual_tasks_ind",
13049 schema: MZ_INTERNAL_SCHEMA,
13050 oid: oid::INDEX_MZ_SHOW_CONTINUAL_TASKS_OID,
13051 sql: "IN CLUSTER mz_catalog_server
13052ON mz_internal.mz_show_continual_tasks (id)",
13053 is_retained_metrics_object: false,
13054};
13055
13056pub static MZ_SOURCE_STATISTICS_WITH_HISTORY: LazyLock<BuiltinView> =
13069 LazyLock::new(|| BuiltinView {
13070 name: "mz_source_statistics_with_history",
13071 schema: MZ_INTERNAL_SCHEMA,
13072 oid: oid::VIEW_MZ_SOURCE_STATISTICS_WITH_HISTORY_OID,
13073 desc: RelationDesc::builder()
13074 .with_column("id", SqlScalarType::String.nullable(false))
13075 .with_column("replica_id", SqlScalarType::String.nullable(true))
13076 .with_column("messages_received", SqlScalarType::UInt64.nullable(false))
13077 .with_column("bytes_received", SqlScalarType::UInt64.nullable(false))
13078 .with_column("updates_staged", SqlScalarType::UInt64.nullable(false))
13079 .with_column("updates_committed", SqlScalarType::UInt64.nullable(false))
13080 .with_column("records_indexed", SqlScalarType::UInt64.nullable(false))
13081 .with_column("bytes_indexed", SqlScalarType::UInt64.nullable(false))
13082 .with_column(
13083 "rehydration_latency",
13084 SqlScalarType::Interval.nullable(true),
13085 )
13086 .with_column(
13087 "snapshot_records_known",
13088 SqlScalarType::UInt64.nullable(true),
13089 )
13090 .with_column(
13091 "snapshot_records_staged",
13092 SqlScalarType::UInt64.nullable(true),
13093 )
13094 .with_column("snapshot_committed", SqlScalarType::Bool.nullable(false))
13095 .with_column("offset_known", SqlScalarType::UInt64.nullable(true))
13096 .with_column("offset_committed", SqlScalarType::UInt64.nullable(true))
13097 .with_key(vec![0, 1])
13098 .finish(),
13099 column_comments: BTreeMap::new(),
13100 sql: "
13101WITH
13102 -- For each subsource, statistics are reported as its parent source
13103 subsource_to_parent AS
13104 (
13105 SELECT subsource.id AS id, parent.id AS report_id
13106 FROM mz_catalog.mz_sources AS subsource
13107 JOIN mz_internal.mz_object_dependencies AS dep ON subsource.id = dep.object_id
13108 JOIN mz_catalog.mz_sources AS parent ON parent.id = dep.referenced_object_id
13109 WHERE subsource.type = 'subsource'
13110 ),
13111 -- For each table from source, statistics are reported as its parent source
13112 table_to_parent AS
13113 (
13114 SELECT id, source_id AS report_id
13115 FROM mz_catalog.mz_tables
13116 WHERE source_id IS NOT NULL
13117 ),
13118 -- For each source and subsource, statistics are reported as itself
13119 source_refl AS
13120 (
13121 SELECT id, id AS report_id
13122 FROM mz_catalog.mz_sources
13123 WHERE type NOT IN ('progress', 'log')
13124 ),
13125 -- For each table from source, statistics are reported as itself
13126 table_refl AS
13127 (
13128 SELECT id, id AS report_id
13129 FROM mz_catalog.mz_tables
13130 WHERE source_id IS NOT NULL
13131 ),
13132 report_paths AS
13133 (
13134 SELECT id, report_id FROM subsource_to_parent
13135 UNION ALL SELECT id, report_id FROM table_to_parent
13136 UNION ALL SELECT id, report_id FROM source_refl
13137 UNION ALL SELECT id, report_id FROM table_refl
13138 )
13139SELECT
13140 report_paths.report_id AS id,
13141 replica_id,
13142 -- Counters
13143 SUM(messages_received)::uint8 AS messages_received,
13144 SUM(bytes_received)::uint8 AS bytes_received,
13145 SUM(updates_staged)::uint8 AS updates_staged,
13146 SUM(updates_committed)::uint8 AS updates_committed,
13147 -- Resetting Gauges
13148 SUM(records_indexed)::uint8 AS records_indexed,
13149 SUM(bytes_indexed)::uint8 AS bytes_indexed,
13150 -- Ensure we aggregate to NULL when not all workers are done rehydrating.
13151 CASE
13152 WHEN bool_or(rehydration_latency IS NULL) THEN NULL
13153 ELSE MAX(rehydration_latency)::interval
13154 END AS rehydration_latency,
13155 SUM(snapshot_records_known)::uint8 AS snapshot_records_known,
13156 SUM(snapshot_records_staged)::uint8 AS snapshot_records_staged,
13157 bool_and(snapshot_committed) as snapshot_committed,
13158 -- Gauges
13159 MAX(offset_known)::uint8 AS offset_known,
13160 MIN(offset_committed)::uint8 AS offset_committed
13161FROM mz_internal.mz_source_statistics_raw
13162 JOIN report_paths USING (id)
13163GROUP BY report_paths.report_id, replica_id",
13164 access: vec![PUBLIC_SELECT],
13165 });
13166
13167pub const MZ_SOURCE_STATISTICS_WITH_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13168 name: "mz_source_statistics_with_history_ind",
13169 schema: MZ_INTERNAL_SCHEMA,
13170 oid: oid::INDEX_MZ_SOURCE_STATISTICS_WITH_HISTORY_IND_OID,
13171 sql: "IN CLUSTER mz_catalog_server
13172ON mz_internal.mz_source_statistics_with_history (id, replica_id)",
13173 is_retained_metrics_object: true,
13174};
13175
13176pub static MZ_SOURCE_STATISTICS: LazyLock<BuiltinView> = LazyLock::new(|| {
13179 BuiltinView {
13180 name: "mz_source_statistics",
13181 schema: MZ_INTERNAL_SCHEMA,
13182 oid: oid::VIEW_MZ_SOURCE_STATISTICS_OID,
13183 desc: RelationDesc::builder()
13185 .with_column("id", SqlScalarType::String.nullable(false))
13186 .with_column("replica_id", SqlScalarType::String.nullable(true))
13187 .with_column("messages_received", SqlScalarType::UInt64.nullable(false))
13188 .with_column("bytes_received", SqlScalarType::UInt64.nullable(false))
13189 .with_column("updates_staged", SqlScalarType::UInt64.nullable(false))
13190 .with_column("updates_committed", SqlScalarType::UInt64.nullable(false))
13191 .with_column("records_indexed", SqlScalarType::UInt64.nullable(false))
13192 .with_column("bytes_indexed", SqlScalarType::UInt64.nullable(false))
13193 .with_column(
13194 "rehydration_latency",
13195 SqlScalarType::Interval.nullable(true),
13196 )
13197 .with_column(
13198 "snapshot_records_known",
13199 SqlScalarType::UInt64.nullable(true),
13200 )
13201 .with_column(
13202 "snapshot_records_staged",
13203 SqlScalarType::UInt64.nullable(true),
13204 )
13205 .with_column("snapshot_committed", SqlScalarType::Bool.nullable(false))
13206 .with_column("offset_known", SqlScalarType::UInt64.nullable(true))
13207 .with_column("offset_committed", SqlScalarType::UInt64.nullable(true))
13208 .with_key(vec![0, 1])
13209 .finish(),
13210 column_comments: BTreeMap::from_iter([
13211 (
13212 "id",
13213 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
13214 ),
13215 (
13216 "replica_id",
13217 "The ID of a replica running the source. Corresponds to `mz_catalog.mz_cluster_replicas.id`.",
13218 ),
13219 (
13220 "messages_received",
13221 "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.",
13222 ),
13223 (
13224 "bytes_received",
13225 "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.",
13226 ),
13227 (
13228 "updates_staged",
13229 "The number of updates (insertions plus deletions) the source has written but not yet committed to the storage layer.",
13230 ),
13231 (
13232 "updates_committed",
13233 "The number of updates (insertions plus deletions) the source has committed to the storage layer.",
13234 ),
13235 (
13236 "records_indexed",
13237 "The number of individual records indexed in the source envelope state.",
13238 ),
13239 (
13240 "bytes_indexed",
13241 "The number of bytes stored in the source's internal index, if any.",
13242 ),
13243 (
13244 "rehydration_latency",
13245 "The amount of time it took for the source to rehydrate its internal index, if any, after the source last restarted.",
13246 ),
13247 (
13248 "snapshot_records_known",
13249 "The size of the source's snapshot, measured in number of records. See below to learn what constitutes a record.",
13250 ),
13251 (
13252 "snapshot_records_staged",
13253 "The number of records in the source's snapshot that Materialize has read. See below to learn what constitutes a record.",
13254 ),
13255 (
13256 "snapshot_committed",
13257 "Whether the source has committed the initial snapshot for a source.",
13258 ),
13259 (
13260 "offset_known",
13261 "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.",
13262 ),
13263 (
13264 "offset_committed",
13265 "The offset of the the data that Materialize has durably ingested. See below to learn what constitutes an offset.",
13266 ),
13267 ]),
13268 sql: "SELECT * FROM mz_internal.mz_source_statistics_with_history WHERE length(id) > 0",
13269 access: vec![PUBLIC_SELECT],
13270 }
13271});
13272
13273pub const MZ_SOURCE_STATISTICS_IND: BuiltinIndex = BuiltinIndex {
13274 name: "mz_source_statistics_ind",
13275 schema: MZ_INTERNAL_SCHEMA,
13276 oid: oid::INDEX_MZ_SOURCE_STATISTICS_IND_OID,
13277 sql: "IN CLUSTER mz_catalog_server
13278ON mz_internal.mz_source_statistics (id, replica_id)",
13279 is_retained_metrics_object: false,
13280};
13281
13282pub static MZ_SINK_STATISTICS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
13283 name: "mz_sink_statistics",
13284 schema: MZ_INTERNAL_SCHEMA,
13285 oid: oid::VIEW_MZ_SINK_STATISTICS_OID,
13286 desc: RelationDesc::builder()
13287 .with_column("id", SqlScalarType::String.nullable(false))
13288 .with_column("replica_id", SqlScalarType::String.nullable(true))
13289 .with_column("messages_staged", SqlScalarType::UInt64.nullable(false))
13290 .with_column("messages_committed", SqlScalarType::UInt64.nullable(false))
13291 .with_column("bytes_staged", SqlScalarType::UInt64.nullable(false))
13292 .with_column("bytes_committed", SqlScalarType::UInt64.nullable(false))
13293 .with_key(vec![0, 1])
13294 .finish(),
13295 column_comments: BTreeMap::from_iter([
13296 (
13297 "id",
13298 "The ID of the sink. Corresponds to `mz_catalog.mz_sources.id`.",
13299 ),
13300 (
13301 "replica_id",
13302 "The ID of a replica running the sink. Corresponds to `mz_catalog.mz_cluster_replicas.id`.",
13303 ),
13304 (
13305 "messages_staged",
13306 "The number of messages staged but possibly not committed to the sink.",
13307 ),
13308 (
13309 "messages_committed",
13310 "The number of messages committed to the sink.",
13311 ),
13312 (
13313 "bytes_staged",
13314 "The number of bytes staged but possibly not committed to the sink. This counts both keys and values, if applicable.",
13315 ),
13316 (
13317 "bytes_committed",
13318 "The number of bytes committed to the sink. This counts both keys and values, if applicable.",
13319 ),
13320 ]),
13321 sql: "
13322SELECT
13323 id,
13324 replica_id,
13325 SUM(messages_staged)::uint8 AS messages_staged,
13326 SUM(messages_committed)::uint8 AS messages_committed,
13327 SUM(bytes_staged)::uint8 AS bytes_staged,
13328 SUM(bytes_committed)::uint8 AS bytes_committed
13329FROM mz_internal.mz_sink_statistics_raw
13330GROUP BY id, replica_id",
13331 access: vec![PUBLIC_SELECT],
13332});
13333
13334pub const MZ_SINK_STATISTICS_IND: BuiltinIndex = BuiltinIndex {
13335 name: "mz_sink_statistics_ind",
13336 schema: MZ_INTERNAL_SCHEMA,
13337 oid: oid::INDEX_MZ_SINK_STATISTICS_IND_OID,
13338 sql: "IN CLUSTER mz_catalog_server
13339ON mz_internal.mz_sink_statistics (id, replica_id)",
13340 is_retained_metrics_object: true,
13341};
13342
13343pub const MZ_CLUSTER_REPLICAS_IND: BuiltinIndex = BuiltinIndex {
13344 name: "mz_cluster_replicas_ind",
13345 schema: MZ_CATALOG_SCHEMA,
13346 oid: oid::INDEX_MZ_CLUSTER_REPLICAS_IND_OID,
13347 sql: "IN CLUSTER mz_catalog_server
13348ON mz_catalog.mz_cluster_replicas (id)",
13349 is_retained_metrics_object: true,
13350};
13351
13352pub const MZ_CLUSTER_REPLICA_SIZES_IND: BuiltinIndex = BuiltinIndex {
13353 name: "mz_cluster_replica_sizes_ind",
13354 schema: MZ_CATALOG_SCHEMA,
13355 oid: oid::INDEX_MZ_CLUSTER_REPLICA_SIZES_IND_OID,
13356 sql: "IN CLUSTER mz_catalog_server
13357ON mz_catalog.mz_cluster_replica_sizes (size)",
13358 is_retained_metrics_object: true,
13359};
13360
13361pub const MZ_CLUSTER_REPLICA_STATUSES_IND: BuiltinIndex = BuiltinIndex {
13362 name: "mz_cluster_replica_statuses_ind",
13363 schema: MZ_INTERNAL_SCHEMA,
13364 oid: oid::INDEX_MZ_CLUSTER_REPLICA_STATUSES_IND_OID,
13365 sql: "IN CLUSTER mz_catalog_server
13366ON mz_internal.mz_cluster_replica_statuses (replica_id)",
13367 is_retained_metrics_object: false,
13368};
13369
13370pub const MZ_CLUSTER_REPLICA_STATUS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13371 name: "mz_cluster_replica_status_history_ind",
13372 schema: MZ_INTERNAL_SCHEMA,
13373 oid: oid::INDEX_MZ_CLUSTER_REPLICA_STATUS_HISTORY_IND_OID,
13374 sql: "IN CLUSTER mz_catalog_server
13375ON mz_internal.mz_cluster_replica_status_history (replica_id)",
13376 is_retained_metrics_object: false,
13377};
13378
13379pub const MZ_CLUSTER_REPLICA_METRICS_IND: BuiltinIndex = BuiltinIndex {
13380 name: "mz_cluster_replica_metrics_ind",
13381 schema: MZ_INTERNAL_SCHEMA,
13382 oid: oid::INDEX_MZ_CLUSTER_REPLICA_METRICS_IND_OID,
13383 sql: "IN CLUSTER mz_catalog_server
13384ON mz_internal.mz_cluster_replica_metrics (replica_id)",
13385 is_retained_metrics_object: false,
13386};
13387
13388pub const MZ_CLUSTER_REPLICA_METRICS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13389 name: "mz_cluster_replica_metrics_history_ind",
13390 schema: MZ_INTERNAL_SCHEMA,
13391 oid: oid::INDEX_MZ_CLUSTER_REPLICA_METRICS_HISTORY_IND_OID,
13392 sql: "IN CLUSTER mz_catalog_server
13393ON mz_internal.mz_cluster_replica_metrics_history (replica_id)",
13394 is_retained_metrics_object: false,
13395};
13396
13397pub const MZ_CLUSTER_REPLICA_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13398 name: "mz_cluster_replica_history_ind",
13399 schema: MZ_INTERNAL_SCHEMA,
13400 oid: oid::INDEX_MZ_CLUSTER_REPLICA_HISTORY_IND_OID,
13401 sql: "IN CLUSTER mz_catalog_server
13402ON mz_internal.mz_cluster_replica_history (dropped_at)",
13403 is_retained_metrics_object: true,
13404};
13405
13406pub const MZ_CLUSTER_REPLICA_NAME_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13407 name: "mz_cluster_replica_name_history_ind",
13408 schema: MZ_INTERNAL_SCHEMA,
13409 oid: oid::INDEX_MZ_CLUSTER_REPLICA_NAME_HISTORY_IND_OID,
13410 sql: "IN CLUSTER mz_catalog_server
13411ON mz_internal.mz_cluster_replica_name_history (id)",
13412 is_retained_metrics_object: false,
13413};
13414
13415pub const MZ_OBJECT_LIFETIMES_IND: BuiltinIndex = BuiltinIndex {
13416 name: "mz_object_lifetimes_ind",
13417 schema: MZ_INTERNAL_SCHEMA,
13418 oid: oid::INDEX_MZ_OBJECT_LIFETIMES_IND_OID,
13419 sql: "IN CLUSTER mz_catalog_server
13420ON mz_internal.mz_object_lifetimes (id)",
13421 is_retained_metrics_object: false,
13422};
13423
13424pub const MZ_OBJECT_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13425 name: "mz_object_history_ind",
13426 schema: MZ_INTERNAL_SCHEMA,
13427 oid: oid::INDEX_MZ_OBJECT_HISTORY_IND_OID,
13428 sql: "IN CLUSTER mz_catalog_server
13429ON mz_internal.mz_object_history (id)",
13430 is_retained_metrics_object: false,
13431};
13432
13433pub const MZ_OBJECT_DEPENDENCIES_IND: BuiltinIndex = BuiltinIndex {
13434 name: "mz_object_dependencies_ind",
13435 schema: MZ_INTERNAL_SCHEMA,
13436 oid: oid::INDEX_MZ_OBJECT_DEPENDENCIES_IND_OID,
13437 sql: "IN CLUSTER mz_catalog_server
13438ON mz_internal.mz_object_dependencies (object_id)",
13439 is_retained_metrics_object: true,
13440};
13441
13442pub const MZ_COMPUTE_DEPENDENCIES_IND: BuiltinIndex = BuiltinIndex {
13443 name: "mz_compute_dependencies_ind",
13444 schema: MZ_INTERNAL_SCHEMA,
13445 oid: oid::INDEX_MZ_COMPUTE_DEPENDENCIES_IND_OID,
13446 sql: "IN CLUSTER mz_catalog_server
13447ON mz_internal.mz_compute_dependencies (dependency_id)",
13448 is_retained_metrics_object: false,
13449};
13450
13451pub const MZ_OBJECT_TRANSITIVE_DEPENDENCIES_IND: BuiltinIndex = BuiltinIndex {
13452 name: "mz_object_transitive_dependencies_ind",
13453 schema: MZ_INTERNAL_SCHEMA,
13454 oid: oid::INDEX_MZ_OBJECT_TRANSITIVE_DEPENDENCIES_IND_OID,
13455 sql: "IN CLUSTER mz_catalog_server
13456ON mz_internal.mz_object_transitive_dependencies (object_id)",
13457 is_retained_metrics_object: false,
13458};
13459
13460pub const MZ_FRONTIERS_IND: BuiltinIndex = BuiltinIndex {
13461 name: "mz_frontiers_ind",
13462 schema: MZ_INTERNAL_SCHEMA,
13463 oid: oid::INDEX_MZ_FRONTIERS_IND_OID,
13464 sql: "IN CLUSTER mz_catalog_server
13465ON mz_internal.mz_frontiers (object_id)",
13466 is_retained_metrics_object: false,
13467};
13468
13469pub const MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13470 name: "mz_wallclock_global_lag_recent_history_ind",
13471 schema: MZ_INTERNAL_SCHEMA,
13472 oid: oid::INDEX_MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_IND_OID,
13473 sql: "IN CLUSTER mz_catalog_server
13474ON mz_internal.mz_wallclock_global_lag_recent_history (object_id)",
13475 is_retained_metrics_object: false,
13476};
13477
13478pub const MZ_RECENT_ACTIVITY_LOG_THINNED_IND: BuiltinIndex = BuiltinIndex {
13479 name: "mz_recent_activity_log_thinned_ind",
13480 schema: MZ_INTERNAL_SCHEMA,
13481 oid: oid::INDEX_MZ_RECENT_ACTIVITY_LOG_THINNED_IND_OID,
13482 sql: "IN CLUSTER mz_catalog_server
13483-- sql_hash because we plan to join
13484-- this against mz_internal.mz_sql_text
13485ON mz_internal.mz_recent_activity_log_thinned (sql_hash)",
13486 is_retained_metrics_object: false,
13487};
13488
13489pub const MZ_KAFKA_SOURCES_IND: BuiltinIndex = BuiltinIndex {
13490 name: "mz_kafka_sources_ind",
13491 schema: MZ_CATALOG_SCHEMA,
13492 oid: oid::INDEX_MZ_KAFKA_SOURCES_IND_OID,
13493 sql: "IN CLUSTER mz_catalog_server
13494ON mz_catalog.mz_kafka_sources (id)",
13495 is_retained_metrics_object: true,
13496};
13497
13498pub const MZ_WEBHOOK_SOURCES_IND: BuiltinIndex = BuiltinIndex {
13499 name: "mz_webhook_sources_ind",
13500 schema: MZ_INTERNAL_SCHEMA,
13501 oid: oid::INDEX_MZ_WEBHOOK_SOURCES_IND_OID,
13502 sql: "IN CLUSTER mz_catalog_server
13503ON mz_internal.mz_webhook_sources (id)",
13504 is_retained_metrics_object: true,
13505};
13506
13507pub const MZ_COMMENTS_IND: BuiltinIndex = BuiltinIndex {
13508 name: "mz_comments_ind",
13509 schema: MZ_INTERNAL_SCHEMA,
13510 oid: oid::INDEX_MZ_COMMENTS_IND_OID,
13511 sql: "IN CLUSTER mz_catalog_server
13512ON mz_internal.mz_comments (id)",
13513 is_retained_metrics_object: true,
13514};
13515
13516pub static MZ_ANALYTICS: BuiltinConnection = BuiltinConnection {
13517 name: "mz_analytics",
13518 schema: MZ_INTERNAL_SCHEMA,
13519 oid: oid::CONNECTION_MZ_ANALYTICS_OID,
13520 sql: "CREATE CONNECTION mz_internal.mz_analytics TO AWS (ASSUME ROLE ARN = '')",
13521 access: &[MzAclItem {
13522 grantee: MZ_SYSTEM_ROLE_ID,
13523 grantor: MZ_ANALYTICS_ROLE_ID,
13524 acl_mode: rbac::all_object_privileges(SystemObjectType::Object(ObjectType::Connection)),
13525 }],
13526 owner_id: &MZ_ANALYTICS_ROLE_ID,
13527 runtime_alterable: true,
13528};
13529
13530pub const MZ_SYSTEM_ROLE: BuiltinRole = BuiltinRole {
13531 id: MZ_SYSTEM_ROLE_ID,
13532 name: SYSTEM_USER_NAME,
13533 oid: oid::ROLE_MZ_SYSTEM_OID,
13534 attributes: RoleAttributesRaw::new().with_all(),
13535};
13536
13537pub const MZ_SUPPORT_ROLE: BuiltinRole = BuiltinRole {
13538 id: MZ_SUPPORT_ROLE_ID,
13539 name: SUPPORT_USER_NAME,
13540 oid: oid::ROLE_MZ_SUPPORT_OID,
13541 attributes: RoleAttributesRaw::new(),
13542};
13543
13544pub const MZ_ANALYTICS_ROLE: BuiltinRole = BuiltinRole {
13545 id: MZ_ANALYTICS_ROLE_ID,
13546 name: ANALYTICS_USER_NAME,
13547 oid: oid::ROLE_MZ_ANALYTICS_OID,
13548 attributes: RoleAttributesRaw::new(),
13549};
13550
13551pub const MZ_MONITOR_ROLE: BuiltinRole = BuiltinRole {
13554 id: MZ_MONITOR_ROLE_ID,
13555 name: "mz_monitor",
13556 oid: oid::ROLE_MZ_MONITOR_OID,
13557 attributes: RoleAttributesRaw::new(),
13558};
13559
13560pub const MZ_MONITOR_REDACTED: BuiltinRole = BuiltinRole {
13563 id: MZ_MONITOR_REDACTED_ROLE_ID,
13564 name: "mz_monitor_redacted",
13565 oid: oid::ROLE_MZ_MONITOR_REDACTED_OID,
13566 attributes: RoleAttributesRaw::new(),
13567};
13568
13569pub const MZ_SYSTEM_CLUSTER: BuiltinCluster = BuiltinCluster {
13570 name: SYSTEM_USER_NAME,
13571 owner_id: &MZ_SYSTEM_ROLE_ID,
13572 privileges: &[
13573 MzAclItem {
13574 grantee: MZ_SUPPORT_ROLE_ID,
13575 grantor: MZ_SYSTEM_ROLE_ID,
13576 acl_mode: AclMode::USAGE,
13577 },
13578 rbac::owner_privilege(ObjectType::Cluster, MZ_SYSTEM_ROLE_ID),
13579 ],
13580};
13581
13582pub const MZ_SYSTEM_CLUSTER_REPLICA: BuiltinClusterReplica = BuiltinClusterReplica {
13583 name: BUILTIN_CLUSTER_REPLICA_NAME,
13584 cluster_name: MZ_SYSTEM_CLUSTER.name,
13585};
13586
13587pub const MZ_CATALOG_SERVER_CLUSTER: BuiltinCluster = BuiltinCluster {
13588 name: "mz_catalog_server",
13589 owner_id: &MZ_SYSTEM_ROLE_ID,
13590 privileges: &[
13591 MzAclItem {
13592 grantee: RoleId::Public,
13593 grantor: MZ_SYSTEM_ROLE_ID,
13594 acl_mode: AclMode::USAGE,
13595 },
13596 MzAclItem {
13597 grantee: MZ_SUPPORT_ROLE_ID,
13598 grantor: MZ_SYSTEM_ROLE_ID,
13599 acl_mode: AclMode::USAGE.union(AclMode::CREATE),
13600 },
13601 rbac::owner_privilege(ObjectType::Cluster, MZ_SYSTEM_ROLE_ID),
13602 ],
13603};
13604
13605pub const MZ_CATALOG_SERVER_CLUSTER_REPLICA: BuiltinClusterReplica = BuiltinClusterReplica {
13606 name: BUILTIN_CLUSTER_REPLICA_NAME,
13607 cluster_name: MZ_CATALOG_SERVER_CLUSTER.name,
13608};
13609
13610pub const MZ_PROBE_CLUSTER: BuiltinCluster = BuiltinCluster {
13611 name: "mz_probe",
13612 owner_id: &MZ_SYSTEM_ROLE_ID,
13613 privileges: &[
13614 MzAclItem {
13615 grantee: MZ_SUPPORT_ROLE_ID,
13616 grantor: MZ_SYSTEM_ROLE_ID,
13617 acl_mode: AclMode::USAGE,
13618 },
13619 MzAclItem {
13620 grantee: MZ_MONITOR_ROLE_ID,
13621 grantor: MZ_SYSTEM_ROLE_ID,
13622 acl_mode: AclMode::USAGE,
13623 },
13624 rbac::owner_privilege(ObjectType::Cluster, MZ_SYSTEM_ROLE_ID),
13625 ],
13626};
13627pub const MZ_PROBE_CLUSTER_REPLICA: BuiltinClusterReplica = BuiltinClusterReplica {
13628 name: BUILTIN_CLUSTER_REPLICA_NAME,
13629 cluster_name: MZ_PROBE_CLUSTER.name,
13630};
13631
13632pub const MZ_SUPPORT_CLUSTER: BuiltinCluster = BuiltinCluster {
13633 name: "mz_support",
13634 owner_id: &MZ_SUPPORT_ROLE_ID,
13635 privileges: &[
13636 MzAclItem {
13637 grantee: MZ_SYSTEM_ROLE_ID,
13638 grantor: MZ_SUPPORT_ROLE_ID,
13639 acl_mode: rbac::all_object_privileges(SystemObjectType::Object(ObjectType::Cluster)),
13640 },
13641 rbac::owner_privilege(ObjectType::Cluster, MZ_SUPPORT_ROLE_ID),
13642 ],
13643};
13644
13645pub const MZ_ANALYTICS_CLUSTER: BuiltinCluster = BuiltinCluster {
13646 name: "mz_analytics",
13647 owner_id: &MZ_ANALYTICS_ROLE_ID,
13648 privileges: &[
13649 MzAclItem {
13650 grantee: MZ_SYSTEM_ROLE_ID,
13651 grantor: MZ_ANALYTICS_ROLE_ID,
13652 acl_mode: rbac::all_object_privileges(SystemObjectType::Object(ObjectType::Cluster)),
13653 },
13654 rbac::owner_privilege(ObjectType::Cluster, MZ_ANALYTICS_ROLE_ID),
13655 ],
13656};
13657
13658pub static BUILTINS_STATIC: LazyLock<Vec<Builtin<NameReference>>> = LazyLock::new(|| {
13660 let mut builtins = vec![
13661 Builtin::Type(&TYPE_ANY),
13662 Builtin::Type(&TYPE_ANYARRAY),
13663 Builtin::Type(&TYPE_ANYELEMENT),
13664 Builtin::Type(&TYPE_ANYNONARRAY),
13665 Builtin::Type(&TYPE_ANYRANGE),
13666 Builtin::Type(&TYPE_BOOL),
13667 Builtin::Type(&TYPE_BOOL_ARRAY),
13668 Builtin::Type(&TYPE_BYTEA),
13669 Builtin::Type(&TYPE_BYTEA_ARRAY),
13670 Builtin::Type(&TYPE_BPCHAR),
13671 Builtin::Type(&TYPE_BPCHAR_ARRAY),
13672 Builtin::Type(&TYPE_CHAR),
13673 Builtin::Type(&TYPE_CHAR_ARRAY),
13674 Builtin::Type(&TYPE_DATE),
13675 Builtin::Type(&TYPE_DATE_ARRAY),
13676 Builtin::Type(&TYPE_FLOAT4),
13677 Builtin::Type(&TYPE_FLOAT4_ARRAY),
13678 Builtin::Type(&TYPE_FLOAT8),
13679 Builtin::Type(&TYPE_FLOAT8_ARRAY),
13680 Builtin::Type(&TYPE_INT4),
13681 Builtin::Type(&TYPE_INT4_ARRAY),
13682 Builtin::Type(&TYPE_INT8),
13683 Builtin::Type(&TYPE_INT8_ARRAY),
13684 Builtin::Type(&TYPE_INTERVAL),
13685 Builtin::Type(&TYPE_INTERVAL_ARRAY),
13686 Builtin::Type(&TYPE_JSONB),
13687 Builtin::Type(&TYPE_JSONB_ARRAY),
13688 Builtin::Type(&TYPE_LIST),
13689 Builtin::Type(&TYPE_MAP),
13690 Builtin::Type(&TYPE_NAME),
13691 Builtin::Type(&TYPE_NAME_ARRAY),
13692 Builtin::Type(&TYPE_NUMERIC),
13693 Builtin::Type(&TYPE_NUMERIC_ARRAY),
13694 Builtin::Type(&TYPE_OID),
13695 Builtin::Type(&TYPE_OID_ARRAY),
13696 Builtin::Type(&TYPE_RECORD),
13697 Builtin::Type(&TYPE_RECORD_ARRAY),
13698 Builtin::Type(&TYPE_REGCLASS),
13699 Builtin::Type(&TYPE_REGCLASS_ARRAY),
13700 Builtin::Type(&TYPE_REGPROC),
13701 Builtin::Type(&TYPE_REGPROC_ARRAY),
13702 Builtin::Type(&TYPE_REGTYPE),
13703 Builtin::Type(&TYPE_REGTYPE_ARRAY),
13704 Builtin::Type(&TYPE_INT2),
13705 Builtin::Type(&TYPE_INT2_ARRAY),
13706 Builtin::Type(&TYPE_TEXT),
13707 Builtin::Type(&TYPE_TEXT_ARRAY),
13708 Builtin::Type(&TYPE_TIME),
13709 Builtin::Type(&TYPE_TIME_ARRAY),
13710 Builtin::Type(&TYPE_TIMESTAMP),
13711 Builtin::Type(&TYPE_TIMESTAMP_ARRAY),
13712 Builtin::Type(&TYPE_TIMESTAMPTZ),
13713 Builtin::Type(&TYPE_TIMESTAMPTZ_ARRAY),
13714 Builtin::Type(&TYPE_UUID),
13715 Builtin::Type(&TYPE_UUID_ARRAY),
13716 Builtin::Type(&TYPE_VARCHAR),
13717 Builtin::Type(&TYPE_VARCHAR_ARRAY),
13718 Builtin::Type(&TYPE_INT2_VECTOR),
13719 Builtin::Type(&TYPE_INT2_VECTOR_ARRAY),
13720 Builtin::Type(&TYPE_ANYCOMPATIBLE),
13721 Builtin::Type(&TYPE_ANYCOMPATIBLEARRAY),
13722 Builtin::Type(&TYPE_ANYCOMPATIBLENONARRAY),
13723 Builtin::Type(&TYPE_ANYCOMPATIBLELIST),
13724 Builtin::Type(&TYPE_ANYCOMPATIBLEMAP),
13725 Builtin::Type(&TYPE_ANYCOMPATIBLERANGE),
13726 Builtin::Type(&TYPE_UINT2),
13727 Builtin::Type(&TYPE_UINT2_ARRAY),
13728 Builtin::Type(&TYPE_UINT4),
13729 Builtin::Type(&TYPE_UINT4_ARRAY),
13730 Builtin::Type(&TYPE_UINT8),
13731 Builtin::Type(&TYPE_UINT8_ARRAY),
13732 Builtin::Type(&TYPE_MZ_TIMESTAMP),
13733 Builtin::Type(&TYPE_MZ_TIMESTAMP_ARRAY),
13734 Builtin::Type(&TYPE_INT4_RANGE),
13735 Builtin::Type(&TYPE_INT4_RANGE_ARRAY),
13736 Builtin::Type(&TYPE_INT8_RANGE),
13737 Builtin::Type(&TYPE_INT8_RANGE_ARRAY),
13738 Builtin::Type(&TYPE_DATE_RANGE),
13739 Builtin::Type(&TYPE_DATE_RANGE_ARRAY),
13740 Builtin::Type(&TYPE_NUM_RANGE),
13741 Builtin::Type(&TYPE_NUM_RANGE_ARRAY),
13742 Builtin::Type(&TYPE_TS_RANGE),
13743 Builtin::Type(&TYPE_TS_RANGE_ARRAY),
13744 Builtin::Type(&TYPE_TSTZ_RANGE),
13745 Builtin::Type(&TYPE_TSTZ_RANGE_ARRAY),
13746 Builtin::Type(&TYPE_MZ_ACL_ITEM),
13747 Builtin::Type(&TYPE_MZ_ACL_ITEM_ARRAY),
13748 Builtin::Type(&TYPE_ACL_ITEM),
13749 Builtin::Type(&TYPE_ACL_ITEM_ARRAY),
13750 Builtin::Type(&TYPE_INTERNAL),
13751 ];
13752 for (schema, funcs) in &[
13753 (PG_CATALOG_SCHEMA, &*mz_sql::func::PG_CATALOG_BUILTINS),
13754 (
13755 INFORMATION_SCHEMA,
13756 &*mz_sql::func::INFORMATION_SCHEMA_BUILTINS,
13757 ),
13758 (MZ_CATALOG_SCHEMA, &*mz_sql::func::MZ_CATALOG_BUILTINS),
13759 (MZ_INTERNAL_SCHEMA, &*mz_sql::func::MZ_INTERNAL_BUILTINS),
13760 (MZ_UNSAFE_SCHEMA, &*mz_sql::func::MZ_UNSAFE_BUILTINS),
13761 ] {
13762 for (name, func) in funcs.iter() {
13763 builtins.push(Builtin::Func(BuiltinFunc {
13764 name,
13765 schema,
13766 inner: func,
13767 }));
13768 }
13769 }
13770 builtins.append(&mut vec![
13771 Builtin::Log(&MZ_ARRANGEMENT_SHARING_RAW),
13772 Builtin::Log(&MZ_ARRANGEMENT_BATCHES_RAW),
13773 Builtin::Log(&MZ_ARRANGEMENT_RECORDS_RAW),
13774 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_RECORDS_RAW),
13775 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_SIZE_RAW),
13776 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_CAPACITY_RAW),
13777 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_ALLOCATIONS_RAW),
13778 Builtin::Log(&MZ_DATAFLOW_CHANNELS_PER_WORKER),
13779 Builtin::Log(&MZ_DATAFLOW_OPERATORS_PER_WORKER),
13780 Builtin::Log(&MZ_DATAFLOW_ADDRESSES_PER_WORKER),
13781 Builtin::Log(&MZ_DATAFLOW_OPERATOR_REACHABILITY_RAW),
13782 Builtin::Log(&MZ_COMPUTE_EXPORTS_PER_WORKER),
13783 Builtin::Log(&MZ_COMPUTE_DATAFLOW_GLOBAL_IDS_PER_WORKER),
13784 Builtin::Log(&MZ_MESSAGE_COUNTS_RECEIVED_RAW),
13785 Builtin::Log(&MZ_MESSAGE_COUNTS_SENT_RAW),
13786 Builtin::Log(&MZ_MESSAGE_BATCH_COUNTS_RECEIVED_RAW),
13787 Builtin::Log(&MZ_MESSAGE_BATCH_COUNTS_SENT_RAW),
13788 Builtin::Log(&MZ_ACTIVE_PEEKS_PER_WORKER),
13789 Builtin::Log(&MZ_PEEK_DURATIONS_HISTOGRAM_RAW),
13790 Builtin::Log(&MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_RAW),
13791 Builtin::Log(&MZ_ARRANGEMENT_HEAP_CAPACITY_RAW),
13792 Builtin::Log(&MZ_ARRANGEMENT_HEAP_ALLOCATIONS_RAW),
13793 Builtin::Log(&MZ_ARRANGEMENT_HEAP_SIZE_RAW),
13794 Builtin::Log(&MZ_SCHEDULING_ELAPSED_RAW),
13795 Builtin::Log(&MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_RAW),
13796 Builtin::Log(&MZ_SCHEDULING_PARKS_HISTOGRAM_RAW),
13797 Builtin::Log(&MZ_COMPUTE_FRONTIERS_PER_WORKER),
13798 Builtin::Log(&MZ_COMPUTE_IMPORT_FRONTIERS_PER_WORKER),
13799 Builtin::Log(&MZ_COMPUTE_ERROR_COUNTS_RAW),
13800 Builtin::Log(&MZ_COMPUTE_HYDRATION_TIMES_PER_WORKER),
13801 Builtin::Log(&MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_PER_WORKER),
13802 Builtin::Table(&MZ_KAFKA_SINKS),
13803 Builtin::Table(&MZ_KAFKA_CONNECTIONS),
13804 Builtin::Table(&MZ_KAFKA_SOURCES),
13805 Builtin::Table(&MZ_OBJECT_DEPENDENCIES),
13806 Builtin::Table(&MZ_ICEBERG_SINKS),
13807 Builtin::Table(&MZ_DATABASES),
13808 Builtin::Table(&MZ_SCHEMAS),
13809 Builtin::Table(&MZ_COLUMNS),
13810 Builtin::Table(&MZ_INDEXES),
13811 Builtin::Table(&MZ_INDEX_COLUMNS),
13812 Builtin::Table(&MZ_TABLES),
13813 Builtin::Table(&MZ_SOURCES),
13814 Builtin::Table(&MZ_SOURCE_REFERENCES),
13815 Builtin::Table(&MZ_POSTGRES_SOURCES),
13816 Builtin::Table(&MZ_POSTGRES_SOURCE_TABLES),
13817 Builtin::Table(&MZ_MYSQL_SOURCE_TABLES),
13818 Builtin::Table(&MZ_SQL_SERVER_SOURCE_TABLES),
13819 Builtin::Table(&MZ_KAFKA_SOURCE_TABLES),
13820 Builtin::Table(&MZ_SINKS),
13821 Builtin::Table(&MZ_VIEWS),
13822 Builtin::Table(&MZ_MATERIALIZED_VIEWS),
13823 Builtin::Table(&MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES),
13824 Builtin::Table(&MZ_TYPES),
13825 Builtin::Table(&MZ_TYPE_PG_METADATA),
13826 Builtin::Table(&MZ_ARRAY_TYPES),
13827 Builtin::Table(&MZ_BASE_TYPES),
13828 Builtin::Table(&MZ_LIST_TYPES),
13829 Builtin::Table(&MZ_MAP_TYPES),
13830 Builtin::Table(&MZ_ROLES),
13831 Builtin::Table(&MZ_ROLE_AUTH),
13832 Builtin::Table(&MZ_ROLE_MEMBERS),
13833 Builtin::Table(&MZ_ROLE_PARAMETERS),
13834 Builtin::Table(&MZ_PSEUDO_TYPES),
13835 Builtin::Table(&MZ_FUNCTIONS),
13836 Builtin::Table(&MZ_OPERATORS),
13837 Builtin::Table(&MZ_AGGREGATES),
13838 Builtin::Table(&MZ_CLUSTERS),
13839 Builtin::Table(&MZ_CLUSTER_WORKLOAD_CLASSES),
13840 Builtin::Table(&MZ_CLUSTER_SCHEDULES),
13841 Builtin::Table(&MZ_SECRETS),
13842 Builtin::Table(&MZ_CONNECTIONS),
13843 Builtin::Table(&MZ_SSH_TUNNEL_CONNECTIONS),
13844 Builtin::Table(&MZ_CLUSTER_REPLICAS),
13845 Builtin::Source(&MZ_CLUSTER_REPLICA_METRICS_HISTORY),
13846 Builtin::View(&MZ_CLUSTER_REPLICA_METRICS),
13847 Builtin::Table(&MZ_CLUSTER_REPLICA_SIZES),
13848 Builtin::Source(&MZ_CLUSTER_REPLICA_STATUS_HISTORY),
13849 Builtin::View(&MZ_CLUSTER_REPLICA_STATUSES),
13850 Builtin::Table(&MZ_INTERNAL_CLUSTER_REPLICAS),
13851 Builtin::Table(&MZ_PENDING_CLUSTER_REPLICAS),
13852 Builtin::Table(&MZ_AUDIT_EVENTS),
13853 Builtin::Table(&MZ_STORAGE_USAGE_BY_SHARD),
13854 Builtin::Table(&MZ_EGRESS_IPS),
13855 Builtin::Table(&MZ_AWS_PRIVATELINK_CONNECTIONS),
13856 Builtin::Table(&MZ_AWS_CONNECTIONS),
13857 Builtin::Table(&MZ_SUBSCRIPTIONS),
13858 Builtin::Table(&MZ_SESSIONS),
13859 Builtin::Table(&MZ_DEFAULT_PRIVILEGES),
13860 Builtin::Table(&MZ_SYSTEM_PRIVILEGES),
13861 Builtin::Table(&MZ_COMMENTS),
13862 Builtin::Table(&MZ_WEBHOOKS_SOURCES),
13863 Builtin::Table(&MZ_HISTORY_RETENTION_STRATEGIES),
13864 Builtin::Table(&MZ_CONTINUAL_TASKS),
13865 Builtin::Table(&MZ_NETWORK_POLICIES),
13866 Builtin::Table(&MZ_NETWORK_POLICY_RULES),
13867 Builtin::Table(&MZ_LICENSE_KEYS),
13868 Builtin::View(&MZ_RELATIONS),
13869 Builtin::View(&MZ_OBJECT_OID_ALIAS),
13870 Builtin::View(&MZ_OBJECTS),
13871 Builtin::View(&MZ_OBJECT_FULLY_QUALIFIED_NAMES),
13872 Builtin::View(&MZ_OBJECTS_ID_NAMESPACE_TYPES),
13873 Builtin::View(&MZ_OBJECT_HISTORY),
13874 Builtin::View(&MZ_OBJECT_LIFETIMES),
13875 Builtin::View(&MZ_ARRANGEMENT_SHARING_PER_WORKER),
13876 Builtin::View(&MZ_ARRANGEMENT_SHARING),
13877 Builtin::View(&MZ_ARRANGEMENT_SIZES_PER_WORKER),
13878 Builtin::View(&MZ_ARRANGEMENT_SIZES),
13879 Builtin::View(&MZ_DATAFLOWS_PER_WORKER),
13880 Builtin::View(&MZ_DATAFLOWS),
13881 Builtin::View(&MZ_DATAFLOW_ADDRESSES),
13882 Builtin::View(&MZ_DATAFLOW_CHANNELS),
13883 Builtin::View(&MZ_DATAFLOW_OPERATORS),
13884 Builtin::View(&MZ_DATAFLOW_GLOBAL_IDS),
13885 Builtin::View(&MZ_MAPPABLE_OBJECTS),
13886 Builtin::View(&MZ_DATAFLOW_OPERATOR_DATAFLOWS_PER_WORKER),
13887 Builtin::View(&MZ_DATAFLOW_OPERATOR_DATAFLOWS),
13888 Builtin::View(&MZ_OBJECT_TRANSITIVE_DEPENDENCIES),
13889 Builtin::View(&MZ_DATAFLOW_OPERATOR_REACHABILITY_PER_WORKER),
13890 Builtin::View(&MZ_DATAFLOW_OPERATOR_REACHABILITY),
13891 Builtin::View(&MZ_CLUSTER_REPLICA_UTILIZATION),
13892 Builtin::View(&MZ_CLUSTER_REPLICA_UTILIZATION_HISTORY),
13893 Builtin::View(&MZ_DATAFLOW_OPERATOR_PARENTS_PER_WORKER),
13894 Builtin::View(&MZ_DATAFLOW_OPERATOR_PARENTS),
13895 Builtin::View(&MZ_COMPUTE_EXPORTS),
13896 Builtin::View(&MZ_DATAFLOW_ARRANGEMENT_SIZES),
13897 Builtin::View(&MZ_EXPECTED_GROUP_SIZE_ADVICE),
13898 Builtin::View(&MZ_COMPUTE_FRONTIERS),
13899 Builtin::View(&MZ_DATAFLOW_CHANNEL_OPERATORS_PER_WORKER),
13900 Builtin::View(&MZ_DATAFLOW_CHANNEL_OPERATORS),
13901 Builtin::View(&MZ_COMPUTE_IMPORT_FRONTIERS),
13902 Builtin::View(&MZ_MESSAGE_COUNTS_PER_WORKER),
13903 Builtin::View(&MZ_MESSAGE_COUNTS),
13904 Builtin::View(&MZ_ACTIVE_PEEKS),
13905 Builtin::View(&MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_PER_WORKER),
13906 Builtin::View(&MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM),
13907 Builtin::View(&MZ_RECORDS_PER_DATAFLOW_OPERATOR_PER_WORKER),
13908 Builtin::View(&MZ_RECORDS_PER_DATAFLOW_OPERATOR),
13909 Builtin::View(&MZ_RECORDS_PER_DATAFLOW_PER_WORKER),
13910 Builtin::View(&MZ_RECORDS_PER_DATAFLOW),
13911 Builtin::View(&MZ_PEEK_DURATIONS_HISTOGRAM_PER_WORKER),
13912 Builtin::View(&MZ_PEEK_DURATIONS_HISTOGRAM),
13913 Builtin::View(&MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_PER_WORKER),
13914 Builtin::View(&MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM),
13915 Builtin::View(&MZ_SCHEDULING_ELAPSED_PER_WORKER),
13916 Builtin::View(&MZ_SCHEDULING_ELAPSED),
13917 Builtin::View(&MZ_SCHEDULING_PARKS_HISTOGRAM_PER_WORKER),
13918 Builtin::View(&MZ_SCHEDULING_PARKS_HISTOGRAM),
13919 Builtin::View(&MZ_SHOW_ALL_OBJECTS),
13920 Builtin::View(&MZ_SHOW_COLUMNS),
13921 Builtin::View(&MZ_SHOW_CLUSTERS),
13922 Builtin::View(&MZ_SHOW_SECRETS),
13923 Builtin::View(&MZ_SHOW_DATABASES),
13924 Builtin::View(&MZ_SHOW_SCHEMAS),
13925 Builtin::View(&MZ_SHOW_TABLES),
13926 Builtin::View(&MZ_SHOW_VIEWS),
13927 Builtin::View(&MZ_SHOW_TYPES),
13928 Builtin::View(&MZ_SHOW_ROLES),
13929 Builtin::View(&MZ_SHOW_CONNECTIONS),
13930 Builtin::View(&MZ_SHOW_SOURCES),
13931 Builtin::View(&MZ_SHOW_SINKS),
13932 Builtin::View(&MZ_SHOW_MATERIALIZED_VIEWS),
13933 Builtin::View(&MZ_SHOW_INDEXES),
13934 Builtin::View(&MZ_SHOW_CONTINUAL_TASKS),
13935 Builtin::View(&MZ_CLUSTER_REPLICA_HISTORY),
13936 Builtin::View(&MZ_CLUSTER_REPLICA_NAME_HISTORY),
13937 Builtin::View(&MZ_TIMEZONE_NAMES),
13938 Builtin::View(&MZ_TIMEZONE_ABBREVIATIONS),
13939 Builtin::View(&PG_NAMESPACE_ALL_DATABASES),
13940 Builtin::Index(&PG_NAMESPACE_ALL_DATABASES_IND),
13941 Builtin::View(&PG_NAMESPACE),
13942 Builtin::View(&PG_CLASS_ALL_DATABASES),
13943 Builtin::Index(&PG_CLASS_ALL_DATABASES_IND),
13944 Builtin::View(&PG_CLASS),
13945 Builtin::View(&PG_DEPEND),
13946 Builtin::View(&PG_DATABASE),
13947 Builtin::View(&PG_INDEX),
13948 Builtin::View(&PG_TYPE_ALL_DATABASES),
13949 Builtin::Index(&PG_TYPE_ALL_DATABASES_IND),
13950 Builtin::View(&PG_TYPE),
13951 Builtin::View(&PG_DESCRIPTION_ALL_DATABASES),
13952 Builtin::Index(&PG_DESCRIPTION_ALL_DATABASES_IND),
13953 Builtin::View(&PG_DESCRIPTION),
13954 Builtin::View(&PG_ATTRIBUTE_ALL_DATABASES),
13955 Builtin::Index(&PG_ATTRIBUTE_ALL_DATABASES_IND),
13956 Builtin::View(&PG_ATTRIBUTE),
13957 Builtin::View(&PG_PROC),
13958 Builtin::View(&PG_OPERATOR),
13959 Builtin::View(&PG_RANGE),
13960 Builtin::View(&PG_ENUM),
13961 Builtin::View(&PG_ATTRDEF_ALL_DATABASES),
13962 Builtin::Index(&PG_ATTRDEF_ALL_DATABASES_IND),
13963 Builtin::View(&PG_ATTRDEF),
13964 Builtin::View(&PG_SETTINGS),
13965 Builtin::View(&PG_AUTH_MEMBERS),
13966 Builtin::View(&PG_CONSTRAINT),
13967 Builtin::View(&PG_TABLES),
13968 Builtin::View(&PG_TABLESPACE),
13969 Builtin::View(&PG_ACCESS_METHODS),
13970 Builtin::View(&PG_LOCKS),
13971 Builtin::View(&PG_AUTHID),
13972 Builtin::View(&PG_ROLES),
13973 Builtin::View(&PG_USER),
13974 Builtin::View(&PG_VIEWS),
13975 Builtin::View(&PG_MATVIEWS),
13976 Builtin::View(&PG_COLLATION),
13977 Builtin::View(&PG_POLICY),
13978 Builtin::View(&PG_INHERITS),
13979 Builtin::View(&PG_AGGREGATE),
13980 Builtin::View(&PG_TRIGGER),
13981 Builtin::View(&PG_REWRITE),
13982 Builtin::View(&PG_EXTENSION),
13983 Builtin::View(&PG_EVENT_TRIGGER),
13984 Builtin::View(&PG_LANGUAGE),
13985 Builtin::View(&PG_SHDESCRIPTION),
13986 Builtin::View(&PG_INDEXES),
13987 Builtin::View(&PG_TIMEZONE_ABBREVS),
13988 Builtin::View(&PG_TIMEZONE_NAMES),
13989 Builtin::View(&INFORMATION_SCHEMA_APPLICABLE_ROLES),
13990 Builtin::View(&INFORMATION_SCHEMA_COLUMNS),
13991 Builtin::View(&INFORMATION_SCHEMA_ENABLED_ROLES),
13992 Builtin::View(&INFORMATION_SCHEMA_KEY_COLUMN_USAGE),
13993 Builtin::View(&INFORMATION_SCHEMA_REFERENTIAL_CONSTRAINTS),
13994 Builtin::View(&INFORMATION_SCHEMA_ROUTINES),
13995 Builtin::View(&INFORMATION_SCHEMA_SCHEMATA),
13996 Builtin::View(&INFORMATION_SCHEMA_TABLES),
13997 Builtin::View(&INFORMATION_SCHEMA_TABLE_CONSTRAINTS),
13998 Builtin::View(&INFORMATION_SCHEMA_TABLE_PRIVILEGES),
13999 Builtin::View(&INFORMATION_SCHEMA_ROLE_TABLE_GRANTS),
14000 Builtin::View(&INFORMATION_SCHEMA_TRIGGERS),
14001 Builtin::View(&INFORMATION_SCHEMA_VIEWS),
14002 Builtin::View(&INFORMATION_SCHEMA_CHARACTER_SETS),
14003 Builtin::View(&MZ_SHOW_ROLE_MEMBERS),
14004 Builtin::View(&MZ_SHOW_MY_ROLE_MEMBERS),
14005 Builtin::View(&MZ_SHOW_SYSTEM_PRIVILEGES),
14006 Builtin::View(&MZ_SHOW_MY_SYSTEM_PRIVILEGES),
14007 Builtin::View(&MZ_SHOW_CLUSTER_PRIVILEGES),
14008 Builtin::View(&MZ_SHOW_MY_CLUSTER_PRIVILEGES),
14009 Builtin::View(&MZ_SHOW_DATABASE_PRIVILEGES),
14010 Builtin::View(&MZ_SHOW_MY_DATABASE_PRIVILEGES),
14011 Builtin::View(&MZ_SHOW_SCHEMA_PRIVILEGES),
14012 Builtin::View(&MZ_SHOW_MY_SCHEMA_PRIVILEGES),
14013 Builtin::View(&MZ_SHOW_OBJECT_PRIVILEGES),
14014 Builtin::View(&MZ_SHOW_MY_OBJECT_PRIVILEGES),
14015 Builtin::View(&MZ_SHOW_ALL_PRIVILEGES),
14016 Builtin::View(&MZ_SHOW_ALL_MY_PRIVILEGES),
14017 Builtin::View(&MZ_SHOW_DEFAULT_PRIVILEGES),
14018 Builtin::View(&MZ_SHOW_MY_DEFAULT_PRIVILEGES),
14019 Builtin::Source(&MZ_SINK_STATUS_HISTORY),
14020 Builtin::View(&MZ_SINK_STATUSES),
14021 Builtin::Source(&MZ_SOURCE_STATUS_HISTORY),
14022 Builtin::Source(&MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY),
14023 Builtin::View(&MZ_AWS_PRIVATELINK_CONNECTION_STATUSES),
14024 Builtin::Source(&MZ_STATEMENT_EXECUTION_HISTORY),
14025 Builtin::View(&MZ_STATEMENT_EXECUTION_HISTORY_REDACTED),
14026 Builtin::Source(&MZ_PREPARED_STATEMENT_HISTORY),
14027 Builtin::Source(&MZ_SESSION_HISTORY),
14028 Builtin::Source(&MZ_SQL_TEXT),
14029 Builtin::View(&MZ_SQL_TEXT_REDACTED),
14030 Builtin::View(&MZ_RECENT_SQL_TEXT),
14031 Builtin::View(&MZ_RECENT_SQL_TEXT_REDACTED),
14032 Builtin::Index(&MZ_RECENT_SQL_TEXT_IND),
14033 Builtin::View(&MZ_ACTIVITY_LOG_THINNED),
14034 Builtin::View(&MZ_RECENT_ACTIVITY_LOG_THINNED),
14035 Builtin::View(&MZ_RECENT_ACTIVITY_LOG),
14036 Builtin::View(&MZ_RECENT_ACTIVITY_LOG_REDACTED),
14037 Builtin::Index(&MZ_RECENT_ACTIVITY_LOG_THINNED_IND),
14038 Builtin::View(&MZ_SOURCE_STATUSES),
14039 Builtin::Source(&MZ_STATEMENT_LIFECYCLE_HISTORY),
14040 Builtin::Source(&MZ_STORAGE_SHARDS),
14041 Builtin::Source(&MZ_SOURCE_STATISTICS_RAW),
14042 Builtin::Source(&MZ_SINK_STATISTICS_RAW),
14043 Builtin::View(&MZ_SOURCE_STATISTICS_WITH_HISTORY),
14044 Builtin::Index(&MZ_SOURCE_STATISTICS_WITH_HISTORY_IND),
14045 Builtin::View(&MZ_SOURCE_STATISTICS),
14046 Builtin::Index(&MZ_SOURCE_STATISTICS_IND),
14047 Builtin::View(&MZ_SINK_STATISTICS),
14048 Builtin::Index(&MZ_SINK_STATISTICS_IND),
14049 Builtin::View(&MZ_STORAGE_USAGE),
14050 Builtin::Source(&MZ_FRONTIERS),
14051 Builtin::View(&MZ_GLOBAL_FRONTIERS),
14052 Builtin::Source(&MZ_WALLCLOCK_LAG_HISTORY),
14053 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG_HISTORY),
14054 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY),
14055 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG),
14056 Builtin::Source(&MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW),
14057 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM),
14058 Builtin::Source(&MZ_MATERIALIZED_VIEW_REFRESHES),
14059 Builtin::Source(&MZ_COMPUTE_DEPENDENCIES),
14060 Builtin::View(&MZ_MATERIALIZATION_DEPENDENCIES),
14061 Builtin::View(&MZ_MATERIALIZATION_LAG),
14062 Builtin::View(&MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW),
14063 Builtin::View(&MZ_COMPUTE_ERROR_COUNTS_PER_WORKER),
14064 Builtin::View(&MZ_COMPUTE_ERROR_COUNTS),
14065 Builtin::Source(&MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED),
14066 Builtin::Source(&MZ_COMPUTE_HYDRATION_TIMES),
14067 Builtin::Log(&MZ_COMPUTE_LIR_MAPPING_PER_WORKER),
14068 Builtin::View(&MZ_LIR_MAPPING),
14069 Builtin::Source(&MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES),
14070 Builtin::Source(&MZ_CLUSTER_REPLICA_FRONTIERS),
14071 Builtin::View(&MZ_COMPUTE_HYDRATION_STATUSES),
14072 Builtin::View(&MZ_HYDRATION_STATUSES),
14073 Builtin::View(&MZ_SHOW_CLUSTER_REPLICAS),
14074 Builtin::View(&MZ_SHOW_NETWORK_POLICIES),
14075 Builtin::View(&MZ_CLUSTER_DEPLOYMENT_LINEAGE),
14076 Builtin::Index(&MZ_SHOW_DATABASES_IND),
14077 Builtin::Index(&MZ_SHOW_SCHEMAS_IND),
14078 Builtin::Index(&MZ_SHOW_CONNECTIONS_IND),
14079 Builtin::Index(&MZ_SHOW_TABLES_IND),
14080 Builtin::Index(&MZ_SHOW_SOURCES_IND),
14081 Builtin::Index(&MZ_SHOW_VIEWS_IND),
14082 Builtin::Index(&MZ_SHOW_MATERIALIZED_VIEWS_IND),
14083 Builtin::Index(&MZ_SHOW_SINKS_IND),
14084 Builtin::Index(&MZ_SHOW_TYPES_IND),
14085 Builtin::Index(&MZ_SHOW_ALL_OBJECTS_IND),
14086 Builtin::Index(&MZ_SHOW_INDEXES_IND),
14087 Builtin::Index(&MZ_SHOW_COLUMNS_IND),
14088 Builtin::Index(&MZ_SHOW_CLUSTERS_IND),
14089 Builtin::Index(&MZ_SHOW_CLUSTER_REPLICAS_IND),
14090 Builtin::Index(&MZ_SHOW_SECRETS_IND),
14091 Builtin::Index(&MZ_SHOW_ROLES_IND),
14092 Builtin::Index(&MZ_CLUSTERS_IND),
14093 Builtin::Index(&MZ_INDEXES_IND),
14094 Builtin::Index(&MZ_ROLES_IND),
14095 Builtin::Index(&MZ_SOURCES_IND),
14096 Builtin::Index(&MZ_SINKS_IND),
14097 Builtin::Index(&MZ_MATERIALIZED_VIEWS_IND),
14098 Builtin::Index(&MZ_CONTINUAL_TASKS_IND),
14099 Builtin::Index(&MZ_SOURCE_STATUSES_IND),
14100 Builtin::Index(&MZ_SOURCE_STATUS_HISTORY_IND),
14101 Builtin::Index(&MZ_SINK_STATUSES_IND),
14102 Builtin::Index(&MZ_SINK_STATUS_HISTORY_IND),
14103 Builtin::Index(&MZ_CLUSTER_REPLICAS_IND),
14104 Builtin::Index(&MZ_CLUSTER_REPLICA_SIZES_IND),
14105 Builtin::Index(&MZ_CLUSTER_REPLICA_STATUSES_IND),
14106 Builtin::Index(&MZ_CLUSTER_REPLICA_STATUS_HISTORY_IND),
14107 Builtin::Index(&MZ_CLUSTER_REPLICA_METRICS_IND),
14108 Builtin::Index(&MZ_CLUSTER_REPLICA_METRICS_HISTORY_IND),
14109 Builtin::Index(&MZ_CLUSTER_REPLICA_HISTORY_IND),
14110 Builtin::Index(&MZ_CLUSTER_REPLICA_NAME_HISTORY_IND),
14111 Builtin::Index(&MZ_OBJECT_LIFETIMES_IND),
14112 Builtin::Index(&MZ_OBJECT_HISTORY_IND),
14113 Builtin::Index(&MZ_OBJECT_DEPENDENCIES_IND),
14114 Builtin::Index(&MZ_COMPUTE_DEPENDENCIES_IND),
14115 Builtin::Index(&MZ_OBJECT_TRANSITIVE_DEPENDENCIES_IND),
14116 Builtin::Index(&MZ_FRONTIERS_IND),
14117 Builtin::Index(&MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_IND),
14118 Builtin::Index(&MZ_KAFKA_SOURCES_IND),
14119 Builtin::Index(&MZ_WEBHOOK_SOURCES_IND),
14120 Builtin::Index(&MZ_COMMENTS_IND),
14121 Builtin::Index(&MZ_DATABASES_IND),
14122 Builtin::Index(&MZ_SCHEMAS_IND),
14123 Builtin::Index(&MZ_CONNECTIONS_IND),
14124 Builtin::Index(&MZ_TABLES_IND),
14125 Builtin::Index(&MZ_TYPES_IND),
14126 Builtin::Index(&MZ_OBJECTS_IND),
14127 Builtin::Index(&MZ_COLUMNS_IND),
14128 Builtin::Index(&MZ_SECRETS_IND),
14129 Builtin::Index(&MZ_VIEWS_IND),
14130 Builtin::Index(&MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_IND),
14131 Builtin::Index(&MZ_CLUSTER_DEPLOYMENT_LINEAGE_IND),
14132 Builtin::Index(&MZ_CLUSTER_REPLICA_FRONTIERS_IND),
14133 Builtin::Index(&MZ_COMPUTE_HYDRATION_TIMES_IND),
14134 Builtin::View(&MZ_RECENT_STORAGE_USAGE),
14135 Builtin::Index(&MZ_RECENT_STORAGE_USAGE_IND),
14136 Builtin::Connection(&MZ_ANALYTICS),
14137 Builtin::ContinualTask(&MZ_CLUSTER_REPLICA_METRICS_HISTORY_CT),
14138 Builtin::ContinualTask(&MZ_CLUSTER_REPLICA_STATUS_HISTORY_CT),
14139 Builtin::ContinualTask(&MZ_WALLCLOCK_LAG_HISTORY_CT),
14140 Builtin::View(&MZ_INDEX_ADVICE),
14141 ]);
14142
14143 builtins.extend(notice::builtins());
14144
14145 builtins
14146});
14147pub const BUILTIN_ROLES: &[&BuiltinRole] = &[
14148 &MZ_SYSTEM_ROLE,
14149 &MZ_SUPPORT_ROLE,
14150 &MZ_ANALYTICS_ROLE,
14151 &MZ_MONITOR_ROLE,
14152 &MZ_MONITOR_REDACTED,
14153];
14154pub const BUILTIN_CLUSTERS: &[&BuiltinCluster] = &[
14155 &MZ_SYSTEM_CLUSTER,
14156 &MZ_CATALOG_SERVER_CLUSTER,
14157 &MZ_PROBE_CLUSTER,
14158 &MZ_SUPPORT_CLUSTER,
14159 &MZ_ANALYTICS_CLUSTER,
14160];
14161pub const BUILTIN_CLUSTER_REPLICAS: &[&BuiltinClusterReplica] = &[
14162 &MZ_SYSTEM_CLUSTER_REPLICA,
14163 &MZ_CATALOG_SERVER_CLUSTER_REPLICA,
14164 &MZ_PROBE_CLUSTER_REPLICA,
14165];
14166
14167#[allow(non_snake_case)]
14168pub mod BUILTINS {
14169 use mz_sql::catalog::BuiltinsConfig;
14170
14171 use super::*;
14172
14173 pub fn logs() -> impl Iterator<Item = &'static BuiltinLog> {
14174 BUILTINS_STATIC.iter().filter_map(|b| match b {
14175 Builtin::Log(log) => Some(*log),
14176 _ => None,
14177 })
14178 }
14179
14180 pub fn types() -> impl Iterator<Item = &'static BuiltinType<NameReference>> {
14181 BUILTINS_STATIC.iter().filter_map(|b| match b {
14182 Builtin::Type(typ) => Some(*typ),
14183 _ => None,
14184 })
14185 }
14186
14187 pub fn views() -> impl Iterator<Item = &'static BuiltinView> {
14188 BUILTINS_STATIC.iter().filter_map(|b| match b {
14189 Builtin::View(view) => Some(*view),
14190 _ => None,
14191 })
14192 }
14193
14194 pub fn funcs() -> impl Iterator<Item = &'static BuiltinFunc> {
14195 BUILTINS_STATIC.iter().filter_map(|b| match b {
14196 Builtin::Func(func) => Some(func),
14197 _ => None,
14198 })
14199 }
14200
14201 pub fn iter(cfg: &BuiltinsConfig) -> impl Iterator<Item = &'static Builtin<NameReference>> {
14202 let include_continual_tasks = cfg.include_continual_tasks;
14203 BUILTINS_STATIC.iter().filter(move |x| match x {
14204 Builtin::ContinualTask(_) if !include_continual_tasks => false,
14205 _ => true,
14206 })
14207 }
14208}
14209
14210pub static BUILTIN_LOG_LOOKUP: LazyLock<HashMap<&'static str, &'static BuiltinLog>> =
14211 LazyLock::new(|| BUILTINS::logs().map(|log| (log.name, log)).collect());
14212pub static BUILTIN_LOOKUP: LazyLock<
14215 HashMap<SystemObjectDescription, (usize, &'static Builtin<NameReference>)>,
14216> = LazyLock::new(|| {
14217 BUILTINS_STATIC
14222 .iter()
14223 .enumerate()
14224 .map(|(idx, builtin)| {
14225 (
14226 SystemObjectDescription {
14227 schema_name: builtin.schema().to_string(),
14228 object_type: builtin.catalog_item_type(),
14229 object_name: builtin.name().to_string(),
14230 },
14231 (idx, builtin),
14232 )
14233 })
14234 .collect()
14235});
14236
14237#[mz_ore::test]
14238#[cfg_attr(miri, ignore)] fn test_builtin_type_schema() {
14240 use mz_pgrepr::oid::FIRST_MATERIALIZE_OID;
14241
14242 for typ in BUILTINS::types() {
14243 if typ.oid < FIRST_MATERIALIZE_OID {
14244 assert_eq!(
14245 typ.schema, PG_CATALOG_SCHEMA,
14246 "{typ:?} should be in {PG_CATALOG_SCHEMA} schema"
14247 );
14248 } else {
14249 assert_eq!(
14252 typ.schema, MZ_CATALOG_SCHEMA,
14253 "{typ:?} should be in {MZ_CATALOG_SCHEMA} schema"
14254 );
14255 }
14256 }
14257}