1pub mod notice;
26
27use std::collections::BTreeMap;
28use std::hash::Hash;
29use std::string::ToString;
30use std::sync::LazyLock;
31
32use mz_compute_client::logging::{ComputeLog, DifferentialLog, LogVariant, TimelyLog};
33use mz_ore::collections::HashMap;
34use mz_pgrepr::oid;
35use mz_repr::adt::mz_acl_item::{AclMode, MzAclItem};
36use mz_repr::adt::numeric::NumericMaxScale;
37use mz_repr::namespaces::{
38 INFORMATION_SCHEMA, MZ_CATALOG_SCHEMA, MZ_INTERNAL_SCHEMA, MZ_INTROSPECTION_SCHEMA,
39 MZ_UNSAFE_SCHEMA, PG_CATALOG_SCHEMA,
40};
41use mz_repr::role_id::RoleId;
42use mz_repr::{RelationDesc, SqlRelationType, SqlScalarType};
43use mz_sql::catalog::RoleAttributesRaw;
44use mz_sql::catalog::{
45 CatalogItemType, CatalogType, CatalogTypeDetails, CatalogTypePgMetadata, NameReference,
46 ObjectType, SystemObjectType, TypeReference,
47};
48use mz_sql::rbac;
49use mz_sql::session::user::{
50 ANALYTICS_USER_NAME, MZ_ANALYTICS_ROLE_ID, MZ_MONITOR_REDACTED_ROLE_ID, MZ_MONITOR_ROLE_ID,
51 MZ_SUPPORT_ROLE_ID, MZ_SYSTEM_ROLE_ID, SUPPORT_USER_NAME, SYSTEM_USER_NAME,
52};
53use mz_storage_client::controller::IntrospectionType;
54use mz_storage_client::healthcheck::WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW_DESC;
55use mz_storage_client::healthcheck::{
56 MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_DESC, MZ_PREPARED_STATEMENT_HISTORY_DESC,
57 MZ_SESSION_HISTORY_DESC, MZ_SINK_STATUS_HISTORY_DESC, MZ_SOURCE_STATUS_HISTORY_DESC,
58 MZ_SQL_TEXT_DESC, MZ_STATEMENT_EXECUTION_HISTORY_DESC, REPLICA_METRICS_HISTORY_DESC,
59 REPLICA_STATUS_HISTORY_DESC, WALLCLOCK_LAG_HISTORY_DESC,
60};
61use mz_storage_client::statistics::{MZ_SINK_STATISTICS_RAW_DESC, MZ_SOURCE_STATISTICS_RAW_DESC};
62use serde::Serialize;
63
64use crate::durable::objects::SystemObjectDescription;
65
66pub const BUILTIN_PREFIXES: &[&str] = &["mz_", "pg_", "external_"];
67const BUILTIN_CLUSTER_REPLICA_NAME: &str = "r1";
68
69pub const RUNTIME_ALTERABLE_FINGERPRINT_SENTINEL: &str = "<RUNTIME-ALTERABLE>";
85
86#[derive(Clone, Debug)]
87pub enum Builtin<T: 'static + TypeReference> {
88 Log(&'static BuiltinLog),
89 Table(&'static BuiltinTable),
90 View(&'static BuiltinView),
91 Type(&'static BuiltinType<T>),
92 Func(BuiltinFunc),
93 Source(&'static BuiltinSource),
94 ContinualTask(&'static BuiltinContinualTask),
95 Index(&'static BuiltinIndex),
96 Connection(&'static BuiltinConnection),
97}
98
99impl<T: TypeReference> Builtin<T> {
100 pub fn name(&self) -> &'static str {
101 match self {
102 Builtin::Log(log) => log.name,
103 Builtin::Table(table) => table.name,
104 Builtin::View(view) => view.name,
105 Builtin::Type(typ) => typ.name,
106 Builtin::Func(func) => func.name,
107 Builtin::Source(coll) => coll.name,
108 Builtin::ContinualTask(ct) => ct.name,
109 Builtin::Index(index) => index.name,
110 Builtin::Connection(connection) => connection.name,
111 }
112 }
113
114 pub fn schema(&self) -> &'static str {
115 match self {
116 Builtin::Log(log) => log.schema,
117 Builtin::Table(table) => table.schema,
118 Builtin::View(view) => view.schema,
119 Builtin::Type(typ) => typ.schema,
120 Builtin::Func(func) => func.schema,
121 Builtin::Source(coll) => coll.schema,
122 Builtin::ContinualTask(ct) => ct.schema,
123 Builtin::Index(index) => index.schema,
124 Builtin::Connection(connection) => connection.schema,
125 }
126 }
127
128 pub fn catalog_item_type(&self) -> CatalogItemType {
129 match self {
130 Builtin::Log(_) => CatalogItemType::Source,
131 Builtin::Source(_) => CatalogItemType::Source,
132 Builtin::ContinualTask(_) => CatalogItemType::ContinualTask,
133 Builtin::Table(_) => CatalogItemType::Table,
134 Builtin::View(_) => CatalogItemType::View,
135 Builtin::Type(_) => CatalogItemType::Type,
136 Builtin::Func(_) => CatalogItemType::Func,
137 Builtin::Index(_) => CatalogItemType::Index,
138 Builtin::Connection(_) => CatalogItemType::Connection,
139 }
140 }
141
142 pub fn runtime_alterable(&self) -> bool {
144 match self {
145 Builtin::Connection(c) => c.runtime_alterable,
146 _ => false,
147 }
148 }
149}
150
151#[derive(Clone, Debug, Hash, Serialize)]
152pub struct BuiltinLog {
153 pub variant: LogVariant,
154 pub name: &'static str,
155 pub schema: &'static str,
156 pub oid: u32,
157 pub access: Vec<MzAclItem>,
159}
160
161#[derive(Clone, Hash, Debug, PartialEq, Eq)]
162pub struct BuiltinTable {
163 pub name: &'static str,
164 pub schema: &'static str,
165 pub oid: u32,
166 pub desc: RelationDesc,
167 pub column_comments: BTreeMap<&'static str, &'static str>,
168 pub is_retained_metrics_object: bool,
171 pub access: Vec<MzAclItem>,
173}
174
175#[derive(Clone, Debug, Hash, Serialize)]
176pub struct BuiltinSource {
177 pub name: &'static str,
178 pub schema: &'static str,
179 pub oid: u32,
180 pub desc: RelationDesc,
181 pub column_comments: BTreeMap<&'static str, &'static str>,
182 pub data_source: IntrospectionType,
183 pub is_retained_metrics_object: bool,
186 pub access: Vec<MzAclItem>,
188}
189
190#[derive(Hash, Debug, PartialEq, Eq)]
191pub struct BuiltinContinualTask {
192 pub name: &'static str,
193 pub schema: &'static str,
194 pub oid: u32,
195 pub desc: RelationDesc,
196 pub sql: &'static str,
197 pub access: Vec<MzAclItem>,
199}
200
201#[derive(Hash, Debug)]
202pub struct BuiltinView {
203 pub name: &'static str,
204 pub schema: &'static str,
205 pub oid: u32,
206 pub desc: RelationDesc,
207 pub column_comments: BTreeMap<&'static str, &'static str>,
208 pub sql: &'static str,
209 pub access: Vec<MzAclItem>,
211}
212
213impl BuiltinView {
214 pub fn create_sql(&self) -> String {
215 format!("CREATE VIEW {}.{} AS {}", self.schema, self.name, self.sql)
216 }
217}
218
219#[derive(Debug)]
220pub struct BuiltinType<T: TypeReference> {
221 pub name: &'static str,
222 pub schema: &'static str,
223 pub oid: u32,
224 pub details: CatalogTypeDetails<T>,
225}
226
227#[derive(Clone, Debug)]
228pub struct BuiltinFunc {
229 pub schema: &'static str,
230 pub name: &'static str,
231 pub inner: &'static mz_sql::func::Func,
232}
233
234#[derive(Debug)]
240pub struct BuiltinIndex {
241 pub name: &'static str,
242 pub schema: &'static str,
243 pub oid: u32,
244 pub sql: &'static str,
248 pub is_retained_metrics_object: bool,
249}
250
251impl BuiltinIndex {
252 pub fn create_sql(&self) -> String {
253 format!("CREATE INDEX {}\n{}", self.name, self.sql)
254 }
255}
256
257impl BuiltinContinualTask {
258 pub fn create_sql(&self) -> String {
259 format!(
260 "CREATE CONTINUAL TASK {}.{}\n{}",
261 self.schema, self.name, self.sql
262 )
263 }
264}
265
266#[derive(Hash, Debug)]
267pub struct BuiltinConnection {
268 pub name: &'static str,
269 pub schema: &'static str,
270 pub oid: u32,
271 pub sql: &'static str,
272 pub access: &'static [MzAclItem],
273 pub owner_id: &'static RoleId,
274 pub runtime_alterable: bool,
279}
280
281#[derive(Clone, Debug)]
282pub struct BuiltinRole {
283 pub id: RoleId,
284 pub name: &'static str,
288 pub oid: u32,
289 pub attributes: RoleAttributesRaw,
290}
291
292#[derive(Clone, Debug)]
293pub struct BuiltinCluster {
294 pub name: &'static str,
298 pub privileges: &'static [MzAclItem],
299 pub owner_id: &'static RoleId,
300}
301
302#[derive(Clone, Debug, PartialEq, Eq)]
303pub struct BuiltinClusterReplica {
304 pub name: &'static str,
306 pub cluster_name: &'static str,
308}
309
310pub trait Fingerprint {
312 fn fingerprint(&self) -> String;
313}
314
315impl<T: TypeReference> Fingerprint for &Builtin<T> {
316 fn fingerprint(&self) -> String {
317 match self {
318 Builtin::Log(log) => log.fingerprint(),
319 Builtin::Table(table) => table.fingerprint(),
320 Builtin::View(view) => view.fingerprint(),
321 Builtin::Type(typ) => typ.fingerprint(),
322 Builtin::Func(func) => func.fingerprint(),
323 Builtin::Source(coll) => coll.fingerprint(),
324 Builtin::ContinualTask(ct) => ct.fingerprint(),
325 Builtin::Index(index) => index.fingerprint(),
326 Builtin::Connection(connection) => connection.fingerprint(),
327 }
328 }
329}
330
331impl<T: TypeReference> Fingerprint for &BuiltinType<T> {
333 fn fingerprint(&self) -> String {
334 "".to_string()
335 }
336}
337
338impl Fingerprint for &BuiltinFunc {
339 fn fingerprint(&self) -> String {
340 "".to_string()
341 }
342}
343
344impl Fingerprint for &BuiltinLog {
345 fn fingerprint(&self) -> String {
346 self.variant.desc().fingerprint()
347 }
348}
349
350impl Fingerprint for &BuiltinTable {
351 fn fingerprint(&self) -> String {
352 self.desc.fingerprint()
353 }
354}
355
356impl Fingerprint for &BuiltinView {
357 fn fingerprint(&self) -> String {
358 self.sql.to_string()
359 }
360}
361
362impl Fingerprint for &BuiltinSource {
363 fn fingerprint(&self) -> String {
364 self.desc.fingerprint()
365 }
366}
367
368impl Fingerprint for &BuiltinContinualTask {
369 fn fingerprint(&self) -> String {
370 self.create_sql()
371 }
372}
373
374impl Fingerprint for &BuiltinIndex {
375 fn fingerprint(&self) -> String {
376 self.create_sql()
377 }
378}
379
380impl Fingerprint for &BuiltinConnection {
381 fn fingerprint(&self) -> String {
382 self.sql.to_string()
383 }
384}
385
386impl Fingerprint for RelationDesc {
387 fn fingerprint(&self) -> String {
388 self.typ().fingerprint()
389 }
390}
391
392impl Fingerprint for SqlRelationType {
393 fn fingerprint(&self) -> String {
394 serde_json::to_string(self).expect("serialization cannot fail")
395 }
396}
397
398pub const TYPE_BOOL: BuiltinType<NameReference> = BuiltinType {
418 name: "bool",
419 schema: PG_CATALOG_SCHEMA,
420 oid: oid::TYPE_BOOL_OID,
421 details: CatalogTypeDetails {
422 typ: CatalogType::Bool,
423 array_id: None,
424 pg_metadata: Some(CatalogTypePgMetadata {
425 typinput_oid: 1242,
426 typreceive_oid: 2436,
427 }),
428 },
429};
430
431pub const TYPE_BYTEA: BuiltinType<NameReference> = BuiltinType {
432 name: "bytea",
433 schema: PG_CATALOG_SCHEMA,
434 oid: oid::TYPE_BYTEA_OID,
435 details: CatalogTypeDetails {
436 typ: CatalogType::Bytes,
437 array_id: None,
438 pg_metadata: Some(CatalogTypePgMetadata {
439 typinput_oid: 1244,
440 typreceive_oid: 2412,
441 }),
442 },
443};
444
445pub const TYPE_INT8: BuiltinType<NameReference> = BuiltinType {
446 name: "int8",
447 schema: PG_CATALOG_SCHEMA,
448 oid: oid::TYPE_INT8_OID,
449 details: CatalogTypeDetails {
450 typ: CatalogType::Int64,
451 array_id: None,
452 pg_metadata: Some(CatalogTypePgMetadata {
453 typinput_oid: 460,
454 typreceive_oid: 2408,
455 }),
456 },
457};
458
459pub const TYPE_INT4: BuiltinType<NameReference> = BuiltinType {
460 name: "int4",
461 schema: PG_CATALOG_SCHEMA,
462 oid: oid::TYPE_INT4_OID,
463 details: CatalogTypeDetails {
464 typ: CatalogType::Int32,
465 array_id: None,
466 pg_metadata: Some(CatalogTypePgMetadata {
467 typinput_oid: 42,
468 typreceive_oid: 2406,
469 }),
470 },
471};
472
473pub const TYPE_TEXT: BuiltinType<NameReference> = BuiltinType {
474 name: "text",
475 schema: PG_CATALOG_SCHEMA,
476 oid: oid::TYPE_TEXT_OID,
477 details: CatalogTypeDetails {
478 typ: CatalogType::String,
479 array_id: None,
480 pg_metadata: Some(CatalogTypePgMetadata {
481 typinput_oid: 46,
482 typreceive_oid: 2414,
483 }),
484 },
485};
486
487pub const TYPE_OID: BuiltinType<NameReference> = BuiltinType {
488 name: "oid",
489 schema: PG_CATALOG_SCHEMA,
490 oid: oid::TYPE_OID_OID,
491 details: CatalogTypeDetails {
492 typ: CatalogType::Oid,
493 array_id: None,
494 pg_metadata: Some(CatalogTypePgMetadata {
495 typinput_oid: 1798,
496 typreceive_oid: 2418,
497 }),
498 },
499};
500
501pub const TYPE_FLOAT4: BuiltinType<NameReference> = BuiltinType {
502 name: "float4",
503 schema: PG_CATALOG_SCHEMA,
504 oid: oid::TYPE_FLOAT4_OID,
505 details: CatalogTypeDetails {
506 typ: CatalogType::Float32,
507 array_id: None,
508 pg_metadata: Some(CatalogTypePgMetadata {
509 typinput_oid: 200,
510 typreceive_oid: 2424,
511 }),
512 },
513};
514
515pub const TYPE_FLOAT8: BuiltinType<NameReference> = BuiltinType {
516 name: "float8",
517 schema: PG_CATALOG_SCHEMA,
518 oid: oid::TYPE_FLOAT8_OID,
519 details: CatalogTypeDetails {
520 typ: CatalogType::Float64,
521 array_id: None,
522 pg_metadata: Some(CatalogTypePgMetadata {
523 typinput_oid: 214,
524 typreceive_oid: 2426,
525 }),
526 },
527};
528
529pub const TYPE_BOOL_ARRAY: BuiltinType<NameReference> = BuiltinType {
530 name: "_bool",
531 schema: PG_CATALOG_SCHEMA,
532 oid: oid::TYPE_BOOL_ARRAY_OID,
533 details: CatalogTypeDetails {
534 typ: CatalogType::Array {
535 element_reference: TYPE_BOOL.name,
536 },
537 array_id: None,
538 pg_metadata: Some(CatalogTypePgMetadata {
539 typinput_oid: 750,
540 typreceive_oid: 2400,
541 }),
542 },
543};
544
545pub const TYPE_BYTEA_ARRAY: BuiltinType<NameReference> = BuiltinType {
546 name: "_bytea",
547 schema: PG_CATALOG_SCHEMA,
548 oid: oid::TYPE_BYTEA_ARRAY_OID,
549 details: CatalogTypeDetails {
550 typ: CatalogType::Array {
551 element_reference: TYPE_BYTEA.name,
552 },
553 array_id: None,
554 pg_metadata: Some(CatalogTypePgMetadata {
555 typinput_oid: 750,
556 typreceive_oid: 2400,
557 }),
558 },
559};
560
561pub const TYPE_INT4_ARRAY: BuiltinType<NameReference> = BuiltinType {
562 name: "_int4",
563 schema: PG_CATALOG_SCHEMA,
564 oid: oid::TYPE_INT4_ARRAY_OID,
565 details: CatalogTypeDetails {
566 typ: CatalogType::Array {
567 element_reference: TYPE_INT4.name,
568 },
569 array_id: None,
570 pg_metadata: Some(CatalogTypePgMetadata {
571 typinput_oid: 750,
572 typreceive_oid: 2400,
573 }),
574 },
575};
576
577pub const TYPE_TEXT_ARRAY: BuiltinType<NameReference> = BuiltinType {
578 name: "_text",
579 schema: PG_CATALOG_SCHEMA,
580 oid: oid::TYPE_TEXT_ARRAY_OID,
581 details: CatalogTypeDetails {
582 typ: CatalogType::Array {
583 element_reference: TYPE_TEXT.name,
584 },
585 array_id: None,
586 pg_metadata: Some(CatalogTypePgMetadata {
587 typinput_oid: 750,
588 typreceive_oid: 2400,
589 }),
590 },
591};
592
593pub const TYPE_INT8_ARRAY: BuiltinType<NameReference> = BuiltinType {
594 name: "_int8",
595 schema: PG_CATALOG_SCHEMA,
596 oid: oid::TYPE_INT8_ARRAY_OID,
597 details: CatalogTypeDetails {
598 typ: CatalogType::Array {
599 element_reference: TYPE_INT8.name,
600 },
601 array_id: None,
602 pg_metadata: Some(CatalogTypePgMetadata {
603 typinput_oid: 750,
604 typreceive_oid: 2400,
605 }),
606 },
607};
608
609pub const TYPE_FLOAT4_ARRAY: BuiltinType<NameReference> = BuiltinType {
610 name: "_float4",
611 schema: PG_CATALOG_SCHEMA,
612 oid: oid::TYPE_FLOAT4_ARRAY_OID,
613 details: CatalogTypeDetails {
614 typ: CatalogType::Array {
615 element_reference: TYPE_FLOAT4.name,
616 },
617 array_id: None,
618 pg_metadata: Some(CatalogTypePgMetadata {
619 typinput_oid: 750,
620 typreceive_oid: 2400,
621 }),
622 },
623};
624
625pub const TYPE_FLOAT8_ARRAY: BuiltinType<NameReference> = BuiltinType {
626 name: "_float8",
627 schema: PG_CATALOG_SCHEMA,
628 oid: oid::TYPE_FLOAT8_ARRAY_OID,
629 details: CatalogTypeDetails {
630 typ: CatalogType::Array {
631 element_reference: TYPE_FLOAT8.name,
632 },
633 array_id: None,
634 pg_metadata: Some(CatalogTypePgMetadata {
635 typinput_oid: 750,
636 typreceive_oid: 2400,
637 }),
638 },
639};
640
641pub const TYPE_OID_ARRAY: BuiltinType<NameReference> = BuiltinType {
642 name: "_oid",
643 schema: PG_CATALOG_SCHEMA,
644 oid: oid::TYPE_OID_ARRAY_OID,
645 details: CatalogTypeDetails {
646 typ: CatalogType::Array {
647 element_reference: TYPE_OID.name,
648 },
649 array_id: None,
650 pg_metadata: Some(CatalogTypePgMetadata {
651 typinput_oid: 750,
652 typreceive_oid: 2400,
653 }),
654 },
655};
656
657pub const TYPE_DATE: BuiltinType<NameReference> = BuiltinType {
658 name: "date",
659 schema: PG_CATALOG_SCHEMA,
660 oid: oid::TYPE_DATE_OID,
661 details: CatalogTypeDetails {
662 typ: CatalogType::Date,
663 array_id: None,
664 pg_metadata: Some(CatalogTypePgMetadata {
665 typinput_oid: 1084,
666 typreceive_oid: 2468,
667 }),
668 },
669};
670
671pub const TYPE_TIME: BuiltinType<NameReference> = BuiltinType {
672 name: "time",
673 schema: PG_CATALOG_SCHEMA,
674 oid: oid::TYPE_TIME_OID,
675 details: CatalogTypeDetails {
676 typ: CatalogType::Time,
677 array_id: None,
678 pg_metadata: Some(CatalogTypePgMetadata {
679 typinput_oid: 1143,
680 typreceive_oid: 2470,
681 }),
682 },
683};
684
685pub const TYPE_TIMESTAMP: BuiltinType<NameReference> = BuiltinType {
686 name: "timestamp",
687 schema: PG_CATALOG_SCHEMA,
688 oid: oid::TYPE_TIMESTAMP_OID,
689 details: CatalogTypeDetails {
690 typ: CatalogType::Timestamp,
691 array_id: None,
692 pg_metadata: Some(CatalogTypePgMetadata {
693 typinput_oid: 1312,
694 typreceive_oid: 2474,
695 }),
696 },
697};
698
699pub const TYPE_TIMESTAMP_ARRAY: BuiltinType<NameReference> = BuiltinType {
700 name: "_timestamp",
701 schema: PG_CATALOG_SCHEMA,
702 oid: oid::TYPE_TIMESTAMP_ARRAY_OID,
703 details: CatalogTypeDetails {
704 typ: CatalogType::Array {
705 element_reference: TYPE_TIMESTAMP.name,
706 },
707 array_id: None,
708 pg_metadata: Some(CatalogTypePgMetadata {
709 typinput_oid: 750,
710 typreceive_oid: 2400,
711 }),
712 },
713};
714
715pub const TYPE_DATE_ARRAY: BuiltinType<NameReference> = BuiltinType {
716 name: "_date",
717 schema: PG_CATALOG_SCHEMA,
718 oid: oid::TYPE_DATE_ARRAY_OID,
719 details: CatalogTypeDetails {
720 typ: CatalogType::Array {
721 element_reference: TYPE_DATE.name,
722 },
723 array_id: None,
724 pg_metadata: Some(CatalogTypePgMetadata {
725 typinput_oid: 750,
726 typreceive_oid: 2400,
727 }),
728 },
729};
730
731pub const TYPE_TIME_ARRAY: BuiltinType<NameReference> = BuiltinType {
732 name: "_time",
733 schema: PG_CATALOG_SCHEMA,
734 oid: oid::TYPE_TIME_ARRAY_OID,
735 details: CatalogTypeDetails {
736 typ: CatalogType::Array {
737 element_reference: TYPE_TIME.name,
738 },
739 array_id: None,
740 pg_metadata: Some(CatalogTypePgMetadata {
741 typinput_oid: 750,
742 typreceive_oid: 2400,
743 }),
744 },
745};
746
747pub const TYPE_TIMESTAMPTZ: BuiltinType<NameReference> = BuiltinType {
748 name: "timestamptz",
749 schema: PG_CATALOG_SCHEMA,
750 oid: oid::TYPE_TIMESTAMPTZ_OID,
751 details: CatalogTypeDetails {
752 typ: CatalogType::TimestampTz,
753 array_id: None,
754 pg_metadata: Some(CatalogTypePgMetadata {
755 typinput_oid: 1150,
756 typreceive_oid: 2476,
757 }),
758 },
759};
760
761pub const TYPE_TIMESTAMPTZ_ARRAY: BuiltinType<NameReference> = BuiltinType {
762 name: "_timestamptz",
763 schema: PG_CATALOG_SCHEMA,
764 oid: oid::TYPE_TIMESTAMPTZ_ARRAY_OID,
765 details: CatalogTypeDetails {
766 typ: CatalogType::Array {
767 element_reference: TYPE_TIMESTAMPTZ.name,
768 },
769 array_id: None,
770 pg_metadata: Some(CatalogTypePgMetadata {
771 typinput_oid: 750,
772 typreceive_oid: 2400,
773 }),
774 },
775};
776
777pub const TYPE_INTERVAL: BuiltinType<NameReference> = BuiltinType {
778 name: "interval",
779 schema: PG_CATALOG_SCHEMA,
780 oid: oid::TYPE_INTERVAL_OID,
781 details: CatalogTypeDetails {
782 typ: CatalogType::Interval,
783 array_id: None,
784 pg_metadata: Some(CatalogTypePgMetadata {
785 typinput_oid: 1160,
786 typreceive_oid: 2478,
787 }),
788 },
789};
790
791pub const TYPE_INTERVAL_ARRAY: BuiltinType<NameReference> = BuiltinType {
792 name: "_interval",
793 schema: PG_CATALOG_SCHEMA,
794 oid: oid::TYPE_INTERVAL_ARRAY_OID,
795 details: CatalogTypeDetails {
796 typ: CatalogType::Array {
797 element_reference: TYPE_INTERVAL.name,
798 },
799 array_id: None,
800 pg_metadata: Some(CatalogTypePgMetadata {
801 typinput_oid: 750,
802 typreceive_oid: 2400,
803 }),
804 },
805};
806
807pub const TYPE_NAME: BuiltinType<NameReference> = BuiltinType {
808 name: "name",
809 schema: PG_CATALOG_SCHEMA,
810 oid: oid::TYPE_NAME_OID,
811 details: CatalogTypeDetails {
812 typ: CatalogType::PgLegacyName,
813 array_id: None,
814 pg_metadata: Some(CatalogTypePgMetadata {
815 typinput_oid: 34,
816 typreceive_oid: 2422,
817 }),
818 },
819};
820
821pub const TYPE_NAME_ARRAY: BuiltinType<NameReference> = BuiltinType {
822 name: "_name",
823 schema: PG_CATALOG_SCHEMA,
824 oid: oid::TYPE_NAME_ARRAY_OID,
825 details: CatalogTypeDetails {
826 typ: CatalogType::Array {
827 element_reference: TYPE_NAME.name,
828 },
829 array_id: None,
830 pg_metadata: Some(CatalogTypePgMetadata {
831 typinput_oid: 750,
832 typreceive_oid: 2400,
833 }),
834 },
835};
836
837pub const TYPE_NUMERIC: BuiltinType<NameReference> = BuiltinType {
838 name: "numeric",
839 schema: PG_CATALOG_SCHEMA,
840 oid: oid::TYPE_NUMERIC_OID,
841 details: CatalogTypeDetails {
842 typ: CatalogType::Numeric,
843 array_id: None,
844 pg_metadata: Some(CatalogTypePgMetadata {
845 typinput_oid: 1701,
846 typreceive_oid: 2460,
847 }),
848 },
849};
850
851pub const TYPE_NUMERIC_ARRAY: BuiltinType<NameReference> = BuiltinType {
852 name: "_numeric",
853 schema: PG_CATALOG_SCHEMA,
854 oid: oid::TYPE_NUMERIC_ARRAY_OID,
855 details: CatalogTypeDetails {
856 typ: CatalogType::Array {
857 element_reference: TYPE_NUMERIC.name,
858 },
859 array_id: None,
860 pg_metadata: Some(CatalogTypePgMetadata {
861 typinput_oid: 750,
862 typreceive_oid: 2400,
863 }),
864 },
865};
866
867pub const TYPE_RECORD: BuiltinType<NameReference> = BuiltinType {
868 name: "record",
869 schema: PG_CATALOG_SCHEMA,
870 oid: oid::TYPE_RECORD_OID,
871 details: CatalogTypeDetails {
872 typ: CatalogType::Pseudo,
873 array_id: None,
874 pg_metadata: Some(CatalogTypePgMetadata {
875 typinput_oid: 2290,
876 typreceive_oid: 2402,
877 }),
878 },
879};
880
881pub const TYPE_RECORD_ARRAY: BuiltinType<NameReference> = BuiltinType {
882 name: "_record",
883 schema: PG_CATALOG_SCHEMA,
884 oid: oid::TYPE_RECORD_ARRAY_OID,
885 details: CatalogTypeDetails {
886 typ: CatalogType::Array {
887 element_reference: TYPE_RECORD.name,
888 },
889 array_id: None,
890 pg_metadata: Some(CatalogTypePgMetadata {
891 typinput_oid: 750,
892 typreceive_oid: 2400,
893 }),
894 },
895};
896
897pub const TYPE_UUID: BuiltinType<NameReference> = BuiltinType {
898 name: "uuid",
899 schema: PG_CATALOG_SCHEMA,
900 oid: oid::TYPE_UUID_OID,
901 details: CatalogTypeDetails {
902 typ: CatalogType::Uuid,
903 array_id: None,
904 pg_metadata: Some(CatalogTypePgMetadata {
905 typinput_oid: 2952,
906 typreceive_oid: 2961,
907 }),
908 },
909};
910
911pub const TYPE_UUID_ARRAY: BuiltinType<NameReference> = BuiltinType {
912 name: "_uuid",
913 schema: PG_CATALOG_SCHEMA,
914 oid: oid::TYPE_UUID_ARRAY_OID,
915 details: CatalogTypeDetails {
916 typ: CatalogType::Array {
917 element_reference: TYPE_UUID.name,
918 },
919 array_id: None,
920 pg_metadata: Some(CatalogTypePgMetadata {
921 typinput_oid: 750,
922 typreceive_oid: 2400,
923 }),
924 },
925};
926
927pub const TYPE_JSONB: BuiltinType<NameReference> = BuiltinType {
928 name: "jsonb",
929 schema: PG_CATALOG_SCHEMA,
930 oid: oid::TYPE_JSONB_OID,
931 details: CatalogTypeDetails {
932 typ: CatalogType::Jsonb,
933 array_id: None,
934 pg_metadata: Some(CatalogTypePgMetadata {
935 typinput_oid: 3806,
936 typreceive_oid: 3805,
937 }),
938 },
939};
940
941pub const TYPE_JSONB_ARRAY: BuiltinType<NameReference> = BuiltinType {
942 name: "_jsonb",
943 schema: PG_CATALOG_SCHEMA,
944 oid: oid::TYPE_JSONB_ARRAY_OID,
945 details: CatalogTypeDetails {
946 typ: CatalogType::Array {
947 element_reference: TYPE_JSONB.name,
948 },
949 array_id: None,
950 pg_metadata: Some(CatalogTypePgMetadata {
951 typinput_oid: 750,
952 typreceive_oid: 2400,
953 }),
954 },
955};
956
957pub const TYPE_ANY: BuiltinType<NameReference> = BuiltinType {
958 name: "any",
959 schema: PG_CATALOG_SCHEMA,
960 oid: oid::TYPE_ANY_OID,
961 details: CatalogTypeDetails {
962 typ: CatalogType::Pseudo,
963 array_id: None,
964 pg_metadata: Some(CatalogTypePgMetadata {
965 typinput_oid: 2294,
966 typreceive_oid: 0,
967 }),
968 },
969};
970
971pub const TYPE_ANYARRAY: BuiltinType<NameReference> = BuiltinType {
972 name: "anyarray",
973 schema: PG_CATALOG_SCHEMA,
974 oid: oid::TYPE_ANYARRAY_OID,
975 details: CatalogTypeDetails {
976 typ: CatalogType::Pseudo,
977 array_id: None,
978 pg_metadata: Some(CatalogTypePgMetadata {
979 typinput_oid: 2296,
980 typreceive_oid: 2502,
981 }),
982 },
983};
984
985pub const TYPE_ANYELEMENT: BuiltinType<NameReference> = BuiltinType {
986 name: "anyelement",
987 schema: PG_CATALOG_SCHEMA,
988 oid: oid::TYPE_ANYELEMENT_OID,
989 details: CatalogTypeDetails {
990 typ: CatalogType::Pseudo,
991 array_id: None,
992 pg_metadata: Some(CatalogTypePgMetadata {
993 typinput_oid: 2312,
994 typreceive_oid: 0,
995 }),
996 },
997};
998
999pub const TYPE_ANYNONARRAY: BuiltinType<NameReference> = BuiltinType {
1000 name: "anynonarray",
1001 schema: PG_CATALOG_SCHEMA,
1002 oid: oid::TYPE_ANYNONARRAY_OID,
1003 details: CatalogTypeDetails {
1004 typ: CatalogType::Pseudo,
1005 array_id: None,
1006 pg_metadata: Some(CatalogTypePgMetadata {
1007 typinput_oid: 2777,
1008 typreceive_oid: 0,
1009 }),
1010 },
1011};
1012
1013pub const TYPE_ANYRANGE: BuiltinType<NameReference> = BuiltinType {
1014 name: "anyrange",
1015 schema: PG_CATALOG_SCHEMA,
1016 oid: oid::TYPE_ANYRANGE_OID,
1017 details: CatalogTypeDetails {
1018 typ: CatalogType::Pseudo,
1019 array_id: None,
1020 pg_metadata: Some(CatalogTypePgMetadata {
1021 typinput_oid: 3832,
1022 typreceive_oid: 0,
1023 }),
1024 },
1025};
1026
1027pub const TYPE_CHAR: BuiltinType<NameReference> = BuiltinType {
1028 name: "char",
1029 schema: PG_CATALOG_SCHEMA,
1030 oid: oid::TYPE_CHAR_OID,
1031 details: CatalogTypeDetails {
1032 typ: CatalogType::PgLegacyChar,
1033 array_id: None,
1034 pg_metadata: Some(CatalogTypePgMetadata {
1035 typinput_oid: 1245,
1036 typreceive_oid: 2434,
1037 }),
1038 },
1039};
1040
1041pub const TYPE_VARCHAR: BuiltinType<NameReference> = BuiltinType {
1042 name: "varchar",
1043 schema: PG_CATALOG_SCHEMA,
1044 oid: oid::TYPE_VARCHAR_OID,
1045 details: CatalogTypeDetails {
1046 typ: CatalogType::VarChar,
1047 array_id: None,
1048 pg_metadata: Some(CatalogTypePgMetadata {
1049 typinput_oid: 1046,
1050 typreceive_oid: 2432,
1051 }),
1052 },
1053};
1054
1055pub const TYPE_INT2: BuiltinType<NameReference> = BuiltinType {
1056 name: "int2",
1057 schema: PG_CATALOG_SCHEMA,
1058 oid: oid::TYPE_INT2_OID,
1059 details: CatalogTypeDetails {
1060 typ: CatalogType::Int16,
1061 array_id: None,
1062 pg_metadata: Some(CatalogTypePgMetadata {
1063 typinput_oid: 38,
1064 typreceive_oid: 2404,
1065 }),
1066 },
1067};
1068
1069pub const TYPE_INT2_ARRAY: BuiltinType<NameReference> = BuiltinType {
1070 name: "_int2",
1071 schema: PG_CATALOG_SCHEMA,
1072 oid: oid::TYPE_INT2_ARRAY_OID,
1073 details: CatalogTypeDetails {
1074 typ: CatalogType::Array {
1075 element_reference: TYPE_INT2.name,
1076 },
1077 array_id: None,
1078 pg_metadata: Some(CatalogTypePgMetadata {
1079 typinput_oid: 750,
1080 typreceive_oid: 2400,
1081 }),
1082 },
1083};
1084
1085pub const TYPE_BPCHAR: BuiltinType<NameReference> = BuiltinType {
1086 name: "bpchar",
1087 schema: PG_CATALOG_SCHEMA,
1088 oid: oid::TYPE_BPCHAR_OID,
1089 details: CatalogTypeDetails {
1090 typ: CatalogType::Char,
1091 array_id: None,
1092 pg_metadata: Some(CatalogTypePgMetadata {
1093 typinput_oid: 1044,
1094 typreceive_oid: 2430,
1095 }),
1096 },
1097};
1098
1099pub const TYPE_CHAR_ARRAY: BuiltinType<NameReference> = BuiltinType {
1100 name: "_char",
1101 schema: PG_CATALOG_SCHEMA,
1102 oid: oid::TYPE_CHAR_ARRAY_OID,
1103 details: CatalogTypeDetails {
1104 typ: CatalogType::Array {
1105 element_reference: TYPE_CHAR.name,
1106 },
1107 array_id: None,
1108 pg_metadata: Some(CatalogTypePgMetadata {
1109 typinput_oid: 750,
1110 typreceive_oid: 2400,
1111 }),
1112 },
1113};
1114
1115pub const TYPE_VARCHAR_ARRAY: BuiltinType<NameReference> = BuiltinType {
1116 name: "_varchar",
1117 schema: PG_CATALOG_SCHEMA,
1118 oid: oid::TYPE_VARCHAR_ARRAY_OID,
1119 details: CatalogTypeDetails {
1120 typ: CatalogType::Array {
1121 element_reference: TYPE_VARCHAR.name,
1122 },
1123 array_id: None,
1124 pg_metadata: Some(CatalogTypePgMetadata {
1125 typinput_oid: 750,
1126 typreceive_oid: 2400,
1127 }),
1128 },
1129};
1130
1131pub const TYPE_BPCHAR_ARRAY: BuiltinType<NameReference> = BuiltinType {
1132 name: "_bpchar",
1133 schema: PG_CATALOG_SCHEMA,
1134 oid: oid::TYPE_BPCHAR_ARRAY_OID,
1135 details: CatalogTypeDetails {
1136 typ: CatalogType::Array {
1137 element_reference: TYPE_BPCHAR.name,
1138 },
1139 array_id: None,
1140 pg_metadata: Some(CatalogTypePgMetadata {
1141 typinput_oid: 750,
1142 typreceive_oid: 2400,
1143 }),
1144 },
1145};
1146
1147pub const TYPE_REGPROC: BuiltinType<NameReference> = BuiltinType {
1148 name: "regproc",
1149 schema: PG_CATALOG_SCHEMA,
1150 oid: oid::TYPE_REGPROC_OID,
1151 details: CatalogTypeDetails {
1152 typ: CatalogType::RegProc,
1153 array_id: None,
1154 pg_metadata: Some(CatalogTypePgMetadata {
1155 typinput_oid: 44,
1156 typreceive_oid: 2444,
1157 }),
1158 },
1159};
1160
1161pub const TYPE_REGPROC_ARRAY: BuiltinType<NameReference> = BuiltinType {
1162 name: "_regproc",
1163 schema: PG_CATALOG_SCHEMA,
1164 oid: oid::TYPE_REGPROC_ARRAY_OID,
1165 details: CatalogTypeDetails {
1166 typ: CatalogType::Array {
1167 element_reference: TYPE_REGPROC.name,
1168 },
1169 array_id: None,
1170 pg_metadata: Some(CatalogTypePgMetadata {
1171 typinput_oid: 750,
1172 typreceive_oid: 2400,
1173 }),
1174 },
1175};
1176
1177pub const TYPE_REGTYPE: BuiltinType<NameReference> = BuiltinType {
1178 name: "regtype",
1179 schema: PG_CATALOG_SCHEMA,
1180 oid: oid::TYPE_REGTYPE_OID,
1181 details: CatalogTypeDetails {
1182 typ: CatalogType::RegType,
1183 array_id: None,
1184 pg_metadata: Some(CatalogTypePgMetadata {
1185 typinput_oid: 2220,
1186 typreceive_oid: 2454,
1187 }),
1188 },
1189};
1190
1191pub const TYPE_REGTYPE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1192 name: "_regtype",
1193 schema: PG_CATALOG_SCHEMA,
1194 oid: oid::TYPE_REGTYPE_ARRAY_OID,
1195 details: CatalogTypeDetails {
1196 typ: CatalogType::Array {
1197 element_reference: TYPE_REGTYPE.name,
1198 },
1199 array_id: None,
1200 pg_metadata: Some(CatalogTypePgMetadata {
1201 typinput_oid: 750,
1202 typreceive_oid: 2400,
1203 }),
1204 },
1205};
1206
1207pub const TYPE_REGCLASS: BuiltinType<NameReference> = BuiltinType {
1208 name: "regclass",
1209 schema: PG_CATALOG_SCHEMA,
1210 oid: oid::TYPE_REGCLASS_OID,
1211 details: CatalogTypeDetails {
1212 typ: CatalogType::RegClass,
1213 array_id: None,
1214 pg_metadata: Some(CatalogTypePgMetadata {
1215 typinput_oid: 2218,
1216 typreceive_oid: 2452,
1217 }),
1218 },
1219};
1220
1221pub const TYPE_REGCLASS_ARRAY: BuiltinType<NameReference> = BuiltinType {
1222 name: "_regclass",
1223 schema: PG_CATALOG_SCHEMA,
1224 oid: oid::TYPE_REGCLASS_ARRAY_OID,
1225 details: CatalogTypeDetails {
1226 typ: CatalogType::Array {
1227 element_reference: TYPE_REGCLASS.name,
1228 },
1229 array_id: None,
1230 pg_metadata: Some(CatalogTypePgMetadata {
1231 typinput_oid: 750,
1232 typreceive_oid: 2400,
1233 }),
1234 },
1235};
1236
1237pub const TYPE_INT2_VECTOR: BuiltinType<NameReference> = BuiltinType {
1238 name: "int2vector",
1239 schema: PG_CATALOG_SCHEMA,
1240 oid: oid::TYPE_INT2_VECTOR_OID,
1241 details: CatalogTypeDetails {
1242 typ: CatalogType::Int2Vector,
1243 array_id: None,
1244 pg_metadata: Some(CatalogTypePgMetadata {
1245 typinput_oid: 40,
1246 typreceive_oid: 2410,
1247 }),
1248 },
1249};
1250
1251pub const TYPE_INT2_VECTOR_ARRAY: BuiltinType<NameReference> = BuiltinType {
1252 name: "_int2vector",
1253 schema: PG_CATALOG_SCHEMA,
1254 oid: oid::TYPE_INT2_VECTOR_ARRAY_OID,
1255 details: CatalogTypeDetails {
1256 typ: CatalogType::Array {
1257 element_reference: TYPE_INT2_VECTOR.name,
1258 },
1259 array_id: None,
1260 pg_metadata: Some(CatalogTypePgMetadata {
1261 typinput_oid: 750,
1262 typreceive_oid: 2400,
1263 }),
1264 },
1265};
1266
1267pub const TYPE_ANYCOMPATIBLE: BuiltinType<NameReference> = BuiltinType {
1268 name: "anycompatible",
1269 schema: PG_CATALOG_SCHEMA,
1270 oid: oid::TYPE_ANYCOMPATIBLE_OID,
1271 details: CatalogTypeDetails {
1272 typ: CatalogType::Pseudo,
1273 array_id: None,
1274 pg_metadata: Some(CatalogTypePgMetadata {
1275 typinput_oid: 5086,
1276 typreceive_oid: 0,
1277 }),
1278 },
1279};
1280
1281pub const TYPE_ANYCOMPATIBLEARRAY: BuiltinType<NameReference> = BuiltinType {
1282 name: "anycompatiblearray",
1283 schema: PG_CATALOG_SCHEMA,
1284 oid: oid::TYPE_ANYCOMPATIBLEARRAY_OID,
1285 details: CatalogTypeDetails {
1286 typ: CatalogType::Pseudo,
1287 array_id: None,
1288 pg_metadata: Some(CatalogTypePgMetadata {
1289 typinput_oid: 5088,
1290 typreceive_oid: 5090,
1291 }),
1292 },
1293};
1294
1295pub const TYPE_ANYCOMPATIBLENONARRAY: BuiltinType<NameReference> = BuiltinType {
1296 name: "anycompatiblenonarray",
1297 schema: PG_CATALOG_SCHEMA,
1298 oid: oid::TYPE_ANYCOMPATIBLENONARRAY_OID,
1299 details: CatalogTypeDetails {
1300 typ: CatalogType::Pseudo,
1301 array_id: None,
1302 pg_metadata: Some(CatalogTypePgMetadata {
1303 typinput_oid: 5092,
1304 typreceive_oid: 0,
1305 }),
1306 },
1307};
1308
1309pub const TYPE_ANYCOMPATIBLERANGE: BuiltinType<NameReference> = BuiltinType {
1310 name: "anycompatiblerange",
1311 schema: PG_CATALOG_SCHEMA,
1312 oid: oid::TYPE_ANYCOMPATIBLERANGE_OID,
1313 details: CatalogTypeDetails {
1314 typ: CatalogType::Pseudo,
1315 array_id: None,
1316 pg_metadata: Some(CatalogTypePgMetadata {
1317 typinput_oid: 5094,
1318 typreceive_oid: 0,
1319 }),
1320 },
1321};
1322
1323pub const TYPE_LIST: BuiltinType<NameReference> = BuiltinType {
1324 name: "list",
1325 schema: MZ_CATALOG_SCHEMA,
1326 oid: mz_pgrepr::oid::TYPE_LIST_OID,
1327 details: CatalogTypeDetails {
1328 typ: CatalogType::Pseudo,
1329 array_id: None,
1330 pg_metadata: None,
1331 },
1332};
1333
1334pub const TYPE_MAP: BuiltinType<NameReference> = BuiltinType {
1335 name: "map",
1336 schema: MZ_CATALOG_SCHEMA,
1337 oid: mz_pgrepr::oid::TYPE_MAP_OID,
1338 details: CatalogTypeDetails {
1339 typ: CatalogType::Pseudo,
1340 array_id: None,
1341 pg_metadata: None,
1342 },
1343};
1344
1345pub const TYPE_ANYCOMPATIBLELIST: BuiltinType<NameReference> = BuiltinType {
1346 name: "anycompatiblelist",
1347 schema: MZ_CATALOG_SCHEMA,
1348 oid: mz_pgrepr::oid::TYPE_ANYCOMPATIBLELIST_OID,
1349 details: CatalogTypeDetails {
1350 typ: CatalogType::Pseudo,
1351 array_id: None,
1352 pg_metadata: None,
1353 },
1354};
1355
1356pub const TYPE_ANYCOMPATIBLEMAP: BuiltinType<NameReference> = BuiltinType {
1357 name: "anycompatiblemap",
1358 schema: MZ_CATALOG_SCHEMA,
1359 oid: mz_pgrepr::oid::TYPE_ANYCOMPATIBLEMAP_OID,
1360 details: CatalogTypeDetails {
1361 typ: CatalogType::Pseudo,
1362 array_id: None,
1363 pg_metadata: None,
1364 },
1365};
1366
1367pub const TYPE_UINT2: BuiltinType<NameReference> = BuiltinType {
1368 name: "uint2",
1369 schema: MZ_CATALOG_SCHEMA,
1370 oid: mz_pgrepr::oid::TYPE_UINT2_OID,
1371 details: CatalogTypeDetails {
1372 typ: CatalogType::UInt16,
1373 array_id: None,
1374 pg_metadata: None,
1375 },
1376};
1377
1378pub const TYPE_UINT2_ARRAY: BuiltinType<NameReference> = BuiltinType {
1379 name: "_uint2",
1380 schema: MZ_CATALOG_SCHEMA,
1381 oid: mz_pgrepr::oid::TYPE_UINT2_ARRAY_OID,
1382 details: CatalogTypeDetails {
1383 typ: CatalogType::Array {
1384 element_reference: TYPE_UINT2.name,
1385 },
1386 array_id: None,
1387 pg_metadata: None,
1388 },
1389};
1390
1391pub const TYPE_UINT4: BuiltinType<NameReference> = BuiltinType {
1392 name: "uint4",
1393 schema: MZ_CATALOG_SCHEMA,
1394 oid: mz_pgrepr::oid::TYPE_UINT4_OID,
1395 details: CatalogTypeDetails {
1396 typ: CatalogType::UInt32,
1397 array_id: None,
1398 pg_metadata: None,
1399 },
1400};
1401
1402pub const TYPE_UINT4_ARRAY: BuiltinType<NameReference> = BuiltinType {
1403 name: "_uint4",
1404 schema: MZ_CATALOG_SCHEMA,
1405 oid: mz_pgrepr::oid::TYPE_UINT4_ARRAY_OID,
1406 details: CatalogTypeDetails {
1407 typ: CatalogType::Array {
1408 element_reference: TYPE_UINT4.name,
1409 },
1410 array_id: None,
1411 pg_metadata: None,
1412 },
1413};
1414
1415pub const TYPE_UINT8: BuiltinType<NameReference> = BuiltinType {
1416 name: "uint8",
1417 schema: MZ_CATALOG_SCHEMA,
1418 oid: mz_pgrepr::oid::TYPE_UINT8_OID,
1419 details: CatalogTypeDetails {
1420 typ: CatalogType::UInt64,
1421 array_id: None,
1422 pg_metadata: None,
1423 },
1424};
1425
1426pub const TYPE_UINT8_ARRAY: BuiltinType<NameReference> = BuiltinType {
1427 name: "_uint8",
1428 schema: MZ_CATALOG_SCHEMA,
1429 oid: mz_pgrepr::oid::TYPE_UINT8_ARRAY_OID,
1430 details: CatalogTypeDetails {
1431 typ: CatalogType::Array {
1432 element_reference: TYPE_UINT8.name,
1433 },
1434 array_id: None,
1435 pg_metadata: None,
1436 },
1437};
1438
1439pub const TYPE_MZ_TIMESTAMP: BuiltinType<NameReference> = BuiltinType {
1440 name: "mz_timestamp",
1441 schema: MZ_CATALOG_SCHEMA,
1442 oid: mz_pgrepr::oid::TYPE_MZ_TIMESTAMP_OID,
1443 details: CatalogTypeDetails {
1444 typ: CatalogType::MzTimestamp,
1445 array_id: None,
1446 pg_metadata: None,
1447 },
1448};
1449
1450pub const TYPE_MZ_TIMESTAMP_ARRAY: BuiltinType<NameReference> = BuiltinType {
1451 name: "_mz_timestamp",
1452 schema: MZ_CATALOG_SCHEMA,
1453 oid: mz_pgrepr::oid::TYPE_MZ_TIMESTAMP_ARRAY_OID,
1454 details: CatalogTypeDetails {
1455 typ: CatalogType::Array {
1456 element_reference: TYPE_MZ_TIMESTAMP.name,
1457 },
1458 array_id: None,
1459 pg_metadata: None,
1460 },
1461};
1462
1463pub const TYPE_INT4_RANGE: BuiltinType<NameReference> = BuiltinType {
1464 name: "int4range",
1465 schema: PG_CATALOG_SCHEMA,
1466 oid: mz_pgrepr::oid::TYPE_INT4RANGE_OID,
1467 details: CatalogTypeDetails {
1468 typ: CatalogType::Range {
1469 element_reference: TYPE_INT4.name,
1470 },
1471 array_id: None,
1472 pg_metadata: Some(CatalogTypePgMetadata {
1473 typinput_oid: 3834,
1474 typreceive_oid: 3836,
1475 }),
1476 },
1477};
1478
1479pub const TYPE_INT4_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1480 name: "_int4range",
1481 schema: PG_CATALOG_SCHEMA,
1482 oid: mz_pgrepr::oid::TYPE_INT4RANGE_ARRAY_OID,
1483 details: CatalogTypeDetails {
1484 typ: CatalogType::Array {
1485 element_reference: TYPE_INT4_RANGE.name,
1486 },
1487 array_id: None,
1488 pg_metadata: Some(CatalogTypePgMetadata {
1489 typinput_oid: 750,
1490 typreceive_oid: 2400,
1491 }),
1492 },
1493};
1494
1495pub const TYPE_INT8_RANGE: BuiltinType<NameReference> = BuiltinType {
1496 name: "int8range",
1497 schema: PG_CATALOG_SCHEMA,
1498 oid: mz_pgrepr::oid::TYPE_INT8RANGE_OID,
1499 details: CatalogTypeDetails {
1500 typ: CatalogType::Range {
1501 element_reference: TYPE_INT8.name,
1502 },
1503 array_id: None,
1504 pg_metadata: Some(CatalogTypePgMetadata {
1505 typinput_oid: 3834,
1506 typreceive_oid: 3836,
1507 }),
1508 },
1509};
1510
1511pub const TYPE_INT8_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1512 name: "_int8range",
1513 schema: PG_CATALOG_SCHEMA,
1514 oid: mz_pgrepr::oid::TYPE_INT8RANGE_ARRAY_OID,
1515 details: CatalogTypeDetails {
1516 typ: CatalogType::Array {
1517 element_reference: TYPE_INT8_RANGE.name,
1518 },
1519 array_id: None,
1520 pg_metadata: Some(CatalogTypePgMetadata {
1521 typinput_oid: 750,
1522 typreceive_oid: 2400,
1523 }),
1524 },
1525};
1526
1527pub const TYPE_DATE_RANGE: BuiltinType<NameReference> = BuiltinType {
1528 name: "daterange",
1529 schema: PG_CATALOG_SCHEMA,
1530 oid: mz_pgrepr::oid::TYPE_DATERANGE_OID,
1531 details: CatalogTypeDetails {
1532 typ: CatalogType::Range {
1533 element_reference: TYPE_DATE.name,
1534 },
1535 array_id: None,
1536 pg_metadata: Some(CatalogTypePgMetadata {
1537 typinput_oid: 3834,
1538 typreceive_oid: 3836,
1539 }),
1540 },
1541};
1542
1543pub const TYPE_DATE_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1544 name: "_daterange",
1545 schema: PG_CATALOG_SCHEMA,
1546 oid: mz_pgrepr::oid::TYPE_DATERANGE_ARRAY_OID,
1547 details: CatalogTypeDetails {
1548 typ: CatalogType::Array {
1549 element_reference: TYPE_DATE_RANGE.name,
1550 },
1551 array_id: None,
1552 pg_metadata: Some(CatalogTypePgMetadata {
1553 typinput_oid: 750,
1554 typreceive_oid: 2400,
1555 }),
1556 },
1557};
1558
1559pub const TYPE_NUM_RANGE: BuiltinType<NameReference> = BuiltinType {
1560 name: "numrange",
1561 schema: PG_CATALOG_SCHEMA,
1562 oid: mz_pgrepr::oid::TYPE_NUMRANGE_OID,
1563 details: CatalogTypeDetails {
1564 typ: CatalogType::Range {
1565 element_reference: TYPE_NUMERIC.name,
1566 },
1567 array_id: None,
1568 pg_metadata: Some(CatalogTypePgMetadata {
1569 typinput_oid: 3834,
1570 typreceive_oid: 3836,
1571 }),
1572 },
1573};
1574
1575pub const TYPE_NUM_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1576 name: "_numrange",
1577 schema: PG_CATALOG_SCHEMA,
1578 oid: mz_pgrepr::oid::TYPE_NUMRANGE_ARRAY_OID,
1579 details: CatalogTypeDetails {
1580 typ: CatalogType::Array {
1581 element_reference: TYPE_NUM_RANGE.name,
1582 },
1583 array_id: None,
1584 pg_metadata: Some(CatalogTypePgMetadata {
1585 typinput_oid: 750,
1586 typreceive_oid: 2400,
1587 }),
1588 },
1589};
1590
1591pub const TYPE_TS_RANGE: BuiltinType<NameReference> = BuiltinType {
1592 name: "tsrange",
1593 schema: PG_CATALOG_SCHEMA,
1594 oid: mz_pgrepr::oid::TYPE_TSRANGE_OID,
1595 details: CatalogTypeDetails {
1596 typ: CatalogType::Range {
1597 element_reference: TYPE_TIMESTAMP.name,
1598 },
1599 array_id: None,
1600 pg_metadata: Some(CatalogTypePgMetadata {
1601 typinput_oid: 3834,
1602 typreceive_oid: 3836,
1603 }),
1604 },
1605};
1606
1607pub const TYPE_TS_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1608 name: "_tsrange",
1609 schema: PG_CATALOG_SCHEMA,
1610 oid: mz_pgrepr::oid::TYPE_TSRANGE_ARRAY_OID,
1611 details: CatalogTypeDetails {
1612 typ: CatalogType::Array {
1613 element_reference: TYPE_TS_RANGE.name,
1614 },
1615 array_id: None,
1616 pg_metadata: Some(CatalogTypePgMetadata {
1617 typinput_oid: 750,
1618 typreceive_oid: 2400,
1619 }),
1620 },
1621};
1622
1623pub const TYPE_TSTZ_RANGE: BuiltinType<NameReference> = BuiltinType {
1624 name: "tstzrange",
1625 schema: PG_CATALOG_SCHEMA,
1626 oid: mz_pgrepr::oid::TYPE_TSTZRANGE_OID,
1627 details: CatalogTypeDetails {
1628 typ: CatalogType::Range {
1629 element_reference: TYPE_TIMESTAMPTZ.name,
1630 },
1631 array_id: None,
1632 pg_metadata: Some(CatalogTypePgMetadata {
1633 typinput_oid: 3834,
1634 typreceive_oid: 3836,
1635 }),
1636 },
1637};
1638
1639pub const TYPE_TSTZ_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1640 name: "_tstzrange",
1641 schema: PG_CATALOG_SCHEMA,
1642 oid: mz_pgrepr::oid::TYPE_TSTZRANGE_ARRAY_OID,
1643 details: CatalogTypeDetails {
1644 typ: CatalogType::Array {
1645 element_reference: TYPE_TSTZ_RANGE.name,
1646 },
1647 array_id: None,
1648 pg_metadata: Some(CatalogTypePgMetadata {
1649 typinput_oid: 750,
1650 typreceive_oid: 2400,
1651 }),
1652 },
1653};
1654
1655pub const TYPE_MZ_ACL_ITEM: BuiltinType<NameReference> = BuiltinType {
1656 name: "mz_aclitem",
1657 schema: MZ_CATALOG_SCHEMA,
1658 oid: mz_pgrepr::oid::TYPE_MZ_ACL_ITEM_OID,
1659 details: CatalogTypeDetails {
1660 typ: CatalogType::MzAclItem,
1661 array_id: None,
1662 pg_metadata: None,
1663 },
1664};
1665
1666pub const TYPE_MZ_ACL_ITEM_ARRAY: BuiltinType<NameReference> = BuiltinType {
1667 name: "_mz_aclitem",
1668 schema: MZ_CATALOG_SCHEMA,
1669 oid: mz_pgrepr::oid::TYPE_MZ_ACL_ITEM_ARRAY_OID,
1670 details: CatalogTypeDetails {
1671 typ: CatalogType::Array {
1672 element_reference: TYPE_MZ_ACL_ITEM.name,
1673 },
1674 array_id: None,
1675 pg_metadata: Some(CatalogTypePgMetadata {
1676 typinput_oid: 750,
1677 typreceive_oid: 2400,
1678 }),
1679 },
1680};
1681
1682pub const TYPE_ACL_ITEM: BuiltinType<NameReference> = BuiltinType {
1683 name: "aclitem",
1684 schema: PG_CATALOG_SCHEMA,
1685 oid: 1033,
1686 details: CatalogTypeDetails {
1687 typ: CatalogType::AclItem,
1688 array_id: None,
1689 pg_metadata: Some(CatalogTypePgMetadata {
1690 typinput_oid: 1031,
1691 typreceive_oid: 0,
1692 }),
1693 },
1694};
1695
1696pub const TYPE_ACL_ITEM_ARRAY: BuiltinType<NameReference> = BuiltinType {
1697 name: "_aclitem",
1698 schema: PG_CATALOG_SCHEMA,
1699 oid: 1034,
1700 details: CatalogTypeDetails {
1701 typ: CatalogType::Array {
1702 element_reference: TYPE_ACL_ITEM.name,
1703 },
1704 array_id: None,
1705 pg_metadata: Some(CatalogTypePgMetadata {
1706 typinput_oid: 750,
1707 typreceive_oid: 2400,
1708 }),
1709 },
1710};
1711
1712pub const TYPE_INTERNAL: BuiltinType<NameReference> = BuiltinType {
1713 name: "internal",
1714 schema: PG_CATALOG_SCHEMA,
1715 oid: 2281,
1716 details: CatalogTypeDetails {
1717 typ: CatalogType::Pseudo,
1718 array_id: None,
1719 pg_metadata: Some(CatalogTypePgMetadata {
1720 typinput_oid: 2304,
1721 typreceive_oid: 0,
1722 }),
1723 },
1724};
1725
1726const PUBLIC_SELECT: MzAclItem = MzAclItem {
1727 grantee: RoleId::Public,
1728 grantor: MZ_SYSTEM_ROLE_ID,
1729 acl_mode: AclMode::SELECT,
1730};
1731
1732const SUPPORT_SELECT: MzAclItem = MzAclItem {
1733 grantee: MZ_SUPPORT_ROLE_ID,
1734 grantor: MZ_SYSTEM_ROLE_ID,
1735 acl_mode: AclMode::SELECT,
1736};
1737
1738const ANALYTICS_SELECT: MzAclItem = MzAclItem {
1739 grantee: MZ_ANALYTICS_ROLE_ID,
1740 grantor: MZ_SYSTEM_ROLE_ID,
1741 acl_mode: AclMode::SELECT,
1742};
1743
1744const MONITOR_SELECT: MzAclItem = MzAclItem {
1745 grantee: MZ_MONITOR_ROLE_ID,
1746 grantor: MZ_SYSTEM_ROLE_ID,
1747 acl_mode: AclMode::SELECT,
1748};
1749
1750const MONITOR_REDACTED_SELECT: MzAclItem = MzAclItem {
1751 grantee: MZ_MONITOR_REDACTED_ROLE_ID,
1752 grantor: MZ_SYSTEM_ROLE_ID,
1753 acl_mode: AclMode::SELECT,
1754};
1755
1756pub static MZ_DATAFLOW_OPERATORS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1757 name: "mz_dataflow_operators_per_worker",
1758 schema: MZ_INTROSPECTION_SCHEMA,
1759 oid: oid::LOG_MZ_DATAFLOW_OPERATORS_PER_WORKER_OID,
1760 variant: LogVariant::Timely(TimelyLog::Operates),
1761 access: vec![PUBLIC_SELECT],
1762});
1763
1764pub static MZ_DATAFLOW_ADDRESSES_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1765 name: "mz_dataflow_addresses_per_worker",
1766 schema: MZ_INTROSPECTION_SCHEMA,
1767 oid: oid::LOG_MZ_DATAFLOW_ADDRESSES_PER_WORKER_OID,
1768 variant: LogVariant::Timely(TimelyLog::Addresses),
1769 access: vec![PUBLIC_SELECT],
1770});
1771
1772pub static MZ_DATAFLOW_CHANNELS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1773 name: "mz_dataflow_channels_per_worker",
1774 schema: MZ_INTROSPECTION_SCHEMA,
1775 oid: oid::LOG_MZ_DATAFLOW_CHANNELS_PER_WORKER_OID,
1776 variant: LogVariant::Timely(TimelyLog::Channels),
1777 access: vec![PUBLIC_SELECT],
1778});
1779
1780pub static MZ_SCHEDULING_ELAPSED_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1781 name: "mz_scheduling_elapsed_raw",
1782 schema: MZ_INTROSPECTION_SCHEMA,
1783 oid: oid::LOG_MZ_SCHEDULING_ELAPSED_RAW_OID,
1784 variant: LogVariant::Timely(TimelyLog::Elapsed),
1785 access: vec![PUBLIC_SELECT],
1786});
1787
1788pub static MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_RAW: LazyLock<BuiltinLog> =
1789 LazyLock::new(|| BuiltinLog {
1790 name: "mz_compute_operator_durations_histogram_raw",
1791 schema: MZ_INTROSPECTION_SCHEMA,
1792 oid: oid::LOG_MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_RAW_OID,
1793 variant: LogVariant::Timely(TimelyLog::Histogram),
1794 access: vec![PUBLIC_SELECT],
1795 });
1796
1797pub static MZ_SCHEDULING_PARKS_HISTOGRAM_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1798 name: "mz_scheduling_parks_histogram_raw",
1799 schema: MZ_INTROSPECTION_SCHEMA,
1800 oid: oid::LOG_MZ_SCHEDULING_PARKS_HISTOGRAM_RAW_OID,
1801 variant: LogVariant::Timely(TimelyLog::Parks),
1802 access: vec![PUBLIC_SELECT],
1803});
1804
1805pub static MZ_ARRANGEMENT_RECORDS_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1806 name: "mz_arrangement_records_raw",
1807 schema: MZ_INTROSPECTION_SCHEMA,
1808 oid: oid::LOG_MZ_ARRANGEMENT_RECORDS_RAW_OID,
1809 variant: LogVariant::Differential(DifferentialLog::ArrangementRecords),
1810 access: vec![PUBLIC_SELECT],
1811});
1812
1813pub static MZ_ARRANGEMENT_BATCHES_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1814 name: "mz_arrangement_batches_raw",
1815 schema: MZ_INTROSPECTION_SCHEMA,
1816 oid: oid::LOG_MZ_ARRANGEMENT_BATCHES_RAW_OID,
1817 variant: LogVariant::Differential(DifferentialLog::ArrangementBatches),
1818 access: vec![PUBLIC_SELECT],
1819});
1820
1821pub static MZ_ARRANGEMENT_SHARING_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1822 name: "mz_arrangement_sharing_raw",
1823 schema: MZ_INTROSPECTION_SCHEMA,
1824 oid: oid::LOG_MZ_ARRANGEMENT_SHARING_RAW_OID,
1825 variant: LogVariant::Differential(DifferentialLog::Sharing),
1826 access: vec![PUBLIC_SELECT],
1827});
1828
1829pub static MZ_ARRANGEMENT_BATCHER_RECORDS_RAW: LazyLock<BuiltinLog> =
1830 LazyLock::new(|| BuiltinLog {
1831 name: "mz_arrangement_batcher_records_raw",
1832 schema: MZ_INTROSPECTION_SCHEMA,
1833 oid: oid::LOG_MZ_ARRANGEMENT_BATCHER_RECORDS_RAW_OID,
1834 variant: LogVariant::Differential(DifferentialLog::BatcherRecords),
1835 access: vec![PUBLIC_SELECT],
1836 });
1837
1838pub static MZ_ARRANGEMENT_BATCHER_SIZE_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1839 name: "mz_arrangement_batcher_size_raw",
1840 schema: MZ_INTROSPECTION_SCHEMA,
1841 oid: oid::LOG_MZ_ARRANGEMENT_BATCHER_SIZE_RAW_OID,
1842 variant: LogVariant::Differential(DifferentialLog::BatcherSize),
1843 access: vec![PUBLIC_SELECT],
1844});
1845
1846pub static MZ_ARRANGEMENT_BATCHER_CAPACITY_RAW: LazyLock<BuiltinLog> =
1847 LazyLock::new(|| BuiltinLog {
1848 name: "mz_arrangement_batcher_capacity_raw",
1849 schema: MZ_INTROSPECTION_SCHEMA,
1850 oid: oid::LOG_MZ_ARRANGEMENT_BATCHER_CAPACITY_RAW_OID,
1851 variant: LogVariant::Differential(DifferentialLog::BatcherCapacity),
1852 access: vec![PUBLIC_SELECT],
1853 });
1854
1855pub static MZ_ARRANGEMENT_BATCHER_ALLOCATIONS_RAW: LazyLock<BuiltinLog> =
1856 LazyLock::new(|| BuiltinLog {
1857 name: "mz_arrangement_batcher_allocations_raw",
1858 schema: MZ_INTROSPECTION_SCHEMA,
1859 oid: oid::LOG_MZ_ARRANGEMENT_BATCHER_ALLOCATIONS_RAW_OID,
1860 variant: LogVariant::Differential(DifferentialLog::BatcherAllocations),
1861 access: vec![PUBLIC_SELECT],
1862 });
1863
1864pub static MZ_COMPUTE_EXPORTS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1865 name: "mz_compute_exports_per_worker",
1866 schema: MZ_INTROSPECTION_SCHEMA,
1867 oid: oid::LOG_MZ_COMPUTE_EXPORTS_PER_WORKER_OID,
1868 variant: LogVariant::Compute(ComputeLog::DataflowCurrent),
1869 access: vec![PUBLIC_SELECT],
1870});
1871
1872pub static MZ_COMPUTE_DATAFLOW_GLOBAL_IDS_PER_WORKER: LazyLock<BuiltinLog> =
1873 LazyLock::new(|| BuiltinLog {
1874 name: "mz_compute_dataflow_global_ids_per_worker",
1875 schema: MZ_INTROSPECTION_SCHEMA,
1876 oid: oid::LOG_MZ_COMPUTE_DATAFLOW_GLOBAL_IDS_PER_WORKER_OID,
1877 variant: LogVariant::Compute(ComputeLog::DataflowGlobal),
1878 access: vec![PUBLIC_SELECT],
1879 });
1880
1881pub static MZ_COMPUTE_FRONTIERS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1882 name: "mz_compute_frontiers_per_worker",
1883 schema: MZ_INTROSPECTION_SCHEMA,
1884 oid: oid::LOG_MZ_COMPUTE_FRONTIERS_PER_WORKER_OID,
1885 variant: LogVariant::Compute(ComputeLog::FrontierCurrent),
1886 access: vec![PUBLIC_SELECT],
1887});
1888
1889pub static MZ_COMPUTE_IMPORT_FRONTIERS_PER_WORKER: LazyLock<BuiltinLog> =
1890 LazyLock::new(|| BuiltinLog {
1891 name: "mz_compute_import_frontiers_per_worker",
1892 schema: MZ_INTROSPECTION_SCHEMA,
1893 oid: oid::LOG_MZ_COMPUTE_IMPORT_FRONTIERS_PER_WORKER_OID,
1894 variant: LogVariant::Compute(ComputeLog::ImportFrontierCurrent),
1895 access: vec![PUBLIC_SELECT],
1896 });
1897
1898pub static MZ_COMPUTE_ERROR_COUNTS_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1899 name: "mz_compute_error_counts_raw",
1900 schema: MZ_INTROSPECTION_SCHEMA,
1901 oid: oid::LOG_MZ_COMPUTE_ERROR_COUNTS_RAW_OID,
1902 variant: LogVariant::Compute(ComputeLog::ErrorCount),
1903 access: vec![PUBLIC_SELECT],
1904});
1905
1906pub static MZ_COMPUTE_HYDRATION_TIMES_PER_WORKER: LazyLock<BuiltinLog> =
1907 LazyLock::new(|| BuiltinLog {
1908 name: "mz_compute_hydration_times_per_worker",
1909 schema: MZ_INTROSPECTION_SCHEMA,
1910 oid: oid::LOG_MZ_COMPUTE_HYDRATION_TIMES_PER_WORKER_OID,
1911 variant: LogVariant::Compute(ComputeLog::HydrationTime),
1912 access: vec![PUBLIC_SELECT],
1913 });
1914
1915pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_PER_WORKER: LazyLock<BuiltinLog> =
1916 LazyLock::new(|| BuiltinLog {
1917 name: "mz_compute_operator_hydration_statuses_per_worker",
1918 schema: MZ_INTROSPECTION_SCHEMA,
1919 oid: oid::LOG_MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_PER_WORKER_OID,
1920 variant: LogVariant::Compute(ComputeLog::OperatorHydrationStatus),
1921 access: vec![PUBLIC_SELECT],
1922 });
1923
1924pub static MZ_ACTIVE_PEEKS_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1925 name: "mz_active_peeks_per_worker",
1926 schema: MZ_INTROSPECTION_SCHEMA,
1927 oid: oid::LOG_MZ_ACTIVE_PEEKS_PER_WORKER_OID,
1928 variant: LogVariant::Compute(ComputeLog::PeekCurrent),
1929 access: vec![PUBLIC_SELECT],
1930});
1931
1932pub static MZ_COMPUTE_LIR_MAPPING_PER_WORKER: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1933 name: "mz_compute_lir_mapping_per_worker",
1934 schema: MZ_INTROSPECTION_SCHEMA,
1935 oid: oid::LOG_MZ_COMPUTE_LIR_MAPPING_PER_WORKER_OID,
1936 variant: LogVariant::Compute(ComputeLog::LirMapping),
1937 access: vec![PUBLIC_SELECT],
1938});
1939
1940pub static MZ_PEEK_DURATIONS_HISTOGRAM_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1941 name: "mz_peek_durations_histogram_raw",
1942 schema: MZ_INTROSPECTION_SCHEMA,
1943 oid: oid::LOG_MZ_PEEK_DURATIONS_HISTOGRAM_RAW_OID,
1944 variant: LogVariant::Compute(ComputeLog::PeekDuration),
1945 access: vec![PUBLIC_SELECT],
1946});
1947
1948pub static MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_RAW: LazyLock<BuiltinLog> =
1949 LazyLock::new(|| BuiltinLog {
1950 name: "mz_dataflow_shutdown_durations_histogram_raw",
1951 schema: MZ_INTROSPECTION_SCHEMA,
1952 oid: oid::LOG_MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_RAW_OID,
1953 variant: LogVariant::Compute(ComputeLog::ShutdownDuration),
1954 access: vec![PUBLIC_SELECT],
1955 });
1956
1957pub static MZ_ARRANGEMENT_HEAP_SIZE_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1958 name: "mz_arrangement_heap_size_raw",
1959 schema: MZ_INTROSPECTION_SCHEMA,
1960 oid: oid::LOG_MZ_ARRANGEMENT_HEAP_SIZE_RAW_OID,
1961 variant: LogVariant::Compute(ComputeLog::ArrangementHeapSize),
1962 access: vec![PUBLIC_SELECT],
1963});
1964
1965pub static MZ_ARRANGEMENT_HEAP_CAPACITY_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1966 name: "mz_arrangement_heap_capacity_raw",
1967 schema: MZ_INTROSPECTION_SCHEMA,
1968 oid: oid::LOG_MZ_ARRANGEMENT_HEAP_CAPACITY_RAW_OID,
1969 variant: LogVariant::Compute(ComputeLog::ArrangementHeapCapacity),
1970 access: vec![PUBLIC_SELECT],
1971});
1972
1973pub static MZ_ARRANGEMENT_HEAP_ALLOCATIONS_RAW: LazyLock<BuiltinLog> =
1974 LazyLock::new(|| BuiltinLog {
1975 name: "mz_arrangement_heap_allocations_raw",
1976 schema: MZ_INTROSPECTION_SCHEMA,
1977 oid: oid::LOG_MZ_ARRANGEMENT_HEAP_ALLOCATIONS_RAW_OID,
1978 variant: LogVariant::Compute(ComputeLog::ArrangementHeapAllocations),
1979 access: vec![PUBLIC_SELECT],
1980 });
1981
1982pub static MZ_MESSAGE_BATCH_COUNTS_RECEIVED_RAW: LazyLock<BuiltinLog> =
1983 LazyLock::new(|| BuiltinLog {
1984 name: "mz_message_batch_counts_received_raw",
1985 schema: MZ_INTROSPECTION_SCHEMA,
1986 oid: oid::LOG_MZ_MESSAGE_BATCH_COUNTS_RECEIVED_RAW_OID,
1987 variant: LogVariant::Timely(TimelyLog::BatchesReceived),
1988 access: vec![PUBLIC_SELECT],
1989 });
1990
1991pub static MZ_MESSAGE_BATCH_COUNTS_SENT_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
1992 name: "mz_message_batch_counts_sent_raw",
1993 schema: MZ_INTROSPECTION_SCHEMA,
1994 oid: oid::LOG_MZ_MESSAGE_BATCH_COUNTS_SENT_RAW_OID,
1995 variant: LogVariant::Timely(TimelyLog::BatchesSent),
1996 access: vec![PUBLIC_SELECT],
1997});
1998
1999pub static MZ_MESSAGE_COUNTS_RECEIVED_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
2000 name: "mz_message_counts_received_raw",
2001 schema: MZ_INTROSPECTION_SCHEMA,
2002 oid: oid::LOG_MZ_MESSAGE_COUNTS_RECEIVED_RAW_OID,
2003 variant: LogVariant::Timely(TimelyLog::MessagesReceived),
2004 access: vec![PUBLIC_SELECT],
2005});
2006
2007pub static MZ_MESSAGE_COUNTS_SENT_RAW: LazyLock<BuiltinLog> = LazyLock::new(|| BuiltinLog {
2008 name: "mz_message_counts_sent_raw",
2009 schema: MZ_INTROSPECTION_SCHEMA,
2010 oid: oid::LOG_MZ_MESSAGE_COUNTS_SENT_RAW_OID,
2011 variant: LogVariant::Timely(TimelyLog::MessagesSent),
2012 access: vec![PUBLIC_SELECT],
2013});
2014
2015pub static MZ_DATAFLOW_OPERATOR_REACHABILITY_RAW: LazyLock<BuiltinLog> =
2016 LazyLock::new(|| BuiltinLog {
2017 name: "mz_dataflow_operator_reachability_raw",
2018 schema: MZ_INTROSPECTION_SCHEMA,
2019 oid: oid::LOG_MZ_DATAFLOW_OPERATOR_REACHABILITY_RAW_OID,
2020 variant: LogVariant::Timely(TimelyLog::Reachability),
2021 access: vec![PUBLIC_SELECT],
2022 });
2023
2024pub static MZ_ICEBERG_SINKS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2025 name: "mz_iceberg_sinks",
2026 schema: MZ_CATALOG_SCHEMA,
2027 oid: oid::TABLE_MZ_ICEBERG_SINKS_OID,
2028 desc: RelationDesc::builder()
2029 .with_column("id", SqlScalarType::String.nullable(false))
2030 .with_column("namespace", SqlScalarType::String.nullable(false))
2031 .with_column("table", SqlScalarType::String.nullable(false))
2032 .finish(),
2033 column_comments: BTreeMap::from_iter([
2034 ("id", "The ID of the sink."),
2035 ("namespace", "The namespace of the sink."),
2036 ("table", "The table the sink is writing to."),
2037 ]),
2038 is_retained_metrics_object: false,
2039 access: vec![PUBLIC_SELECT],
2040});
2041
2042pub static MZ_KAFKA_SINKS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2043 name: "mz_kafka_sinks",
2044 schema: MZ_CATALOG_SCHEMA,
2045 oid: oid::TABLE_MZ_KAFKA_SINKS_OID,
2046 desc: RelationDesc::builder()
2047 .with_column("id", SqlScalarType::String.nullable(false))
2048 .with_column("topic", SqlScalarType::String.nullable(false))
2049 .with_key(vec![0])
2050 .finish(),
2051 column_comments: BTreeMap::from_iter([
2052 ("id", "The ID of the sink."),
2053 (
2054 "topic",
2055 "The name of the Kafka topic into which the sink is writing.",
2056 ),
2057 ]),
2058 is_retained_metrics_object: false,
2059 access: vec![PUBLIC_SELECT],
2060});
2061pub static MZ_KAFKA_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2062 name: "mz_kafka_connections",
2063 schema: MZ_CATALOG_SCHEMA,
2064 oid: oid::TABLE_MZ_KAFKA_CONNECTIONS_OID,
2065 desc: RelationDesc::builder()
2066 .with_column("id", SqlScalarType::String.nullable(false))
2067 .with_column(
2068 "brokers",
2069 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
2070 )
2071 .with_column("sink_progress_topic", SqlScalarType::String.nullable(false))
2072 .finish(),
2073 column_comments: BTreeMap::from_iter([
2074 ("id", "The ID of the connection."),
2075 (
2076 "brokers",
2077 "The addresses of the Kafka brokers to connect to.",
2078 ),
2079 (
2080 "sink_progress_topic",
2081 "The name of the Kafka topic where any sinks associated with this connection will track their progress information and other metadata. The contents of this topic are unspecified.",
2082 ),
2083 ]),
2084 is_retained_metrics_object: false,
2085 access: vec![PUBLIC_SELECT],
2086});
2087pub static MZ_KAFKA_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2088 name: "mz_kafka_sources",
2089 schema: MZ_CATALOG_SCHEMA,
2090 oid: oid::TABLE_MZ_KAFKA_SOURCES_OID,
2091 desc: RelationDesc::builder()
2092 .with_column("id", SqlScalarType::String.nullable(false))
2093 .with_column("group_id_prefix", SqlScalarType::String.nullable(false))
2094 .with_column("topic", SqlScalarType::String.nullable(false))
2095 .finish(),
2096 column_comments: BTreeMap::from_iter([
2097 (
2098 "id",
2099 "The ID of the Kafka source. Corresponds to `mz_catalog.mz_sources.id`.",
2100 ),
2101 (
2102 "group_id_prefix",
2103 "The value of the `GROUP ID PREFIX` connection option.",
2104 ),
2105 (
2106 "topic",
2107 "The name of the Kafka topic the source is reading from.",
2108 ),
2109 ]),
2110 is_retained_metrics_object: false,
2111 access: vec![PUBLIC_SELECT],
2112});
2113pub static MZ_POSTGRES_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2114 name: "mz_postgres_sources",
2115 schema: MZ_INTERNAL_SCHEMA,
2116 oid: oid::TABLE_MZ_POSTGRES_SOURCES_OID,
2117 desc: RelationDesc::builder()
2118 .with_column("id", SqlScalarType::String.nullable(false))
2119 .with_column("replication_slot", SqlScalarType::String.nullable(false))
2120 .with_column("timeline_id", SqlScalarType::UInt64.nullable(true))
2121 .finish(),
2122 column_comments: BTreeMap::from_iter([
2123 (
2124 "id",
2125 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
2126 ),
2127 (
2128 "replication_slot",
2129 "The name of the replication slot in the PostgreSQL database that Materialize will create and stream data from.",
2130 ),
2131 (
2132 "timeline_id",
2133 "The PostgreSQL timeline ID determined on source creation.",
2134 ),
2135 ]),
2136 is_retained_metrics_object: false,
2137 access: vec![PUBLIC_SELECT],
2138});
2139pub static MZ_POSTGRES_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2140 name: "mz_postgres_source_tables",
2141 schema: MZ_INTERNAL_SCHEMA,
2142 oid: oid::TABLE_MZ_POSTGRES_SOURCE_TABLES_OID,
2143 desc: RelationDesc::builder()
2144 .with_column("id", SqlScalarType::String.nullable(false))
2145 .with_column("schema_name", SqlScalarType::String.nullable(false))
2146 .with_column("table_name", SqlScalarType::String.nullable(false))
2147 .finish(),
2148 column_comments: BTreeMap::from_iter([
2149 (
2150 "id",
2151 "The ID of the subsource or table. Corresponds to `mz_catalog.mz_sources.id` or `mz_catalog.mz_tables.id`.",
2152 ),
2153 (
2154 "schema_name",
2155 "The schema of the upstream table being ingested.",
2156 ),
2157 (
2158 "table_name",
2159 "The name of the upstream table being ingested.",
2160 ),
2161 ]),
2162 is_retained_metrics_object: true,
2163 access: vec![PUBLIC_SELECT],
2164});
2165pub static MZ_MYSQL_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2166 name: "mz_mysql_source_tables",
2167 schema: MZ_INTERNAL_SCHEMA,
2168 oid: oid::TABLE_MZ_MYSQL_SOURCE_TABLES_OID,
2169 desc: RelationDesc::builder()
2170 .with_column("id", SqlScalarType::String.nullable(false))
2171 .with_column("schema_name", SqlScalarType::String.nullable(false))
2172 .with_column("table_name", SqlScalarType::String.nullable(false))
2173 .finish(),
2174 column_comments: BTreeMap::from_iter([
2175 (
2176 "id",
2177 "The ID of the subsource or table. Corresponds to `mz_catalog.mz_sources.id` or `mz_catalog.mz_tables.id`.",
2178 ),
2179 (
2180 "schema_name",
2181 "The schema (or, database) of the upstream table being ingested.",
2182 ),
2183 (
2184 "table_name",
2185 "The name of the upstream table being ingested.",
2186 ),
2187 ]),
2188 is_retained_metrics_object: true,
2189 access: vec![PUBLIC_SELECT],
2190});
2191pub static MZ_SQL_SERVER_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2192 name: "mz_sql_server_source_tables",
2193 schema: MZ_INTERNAL_SCHEMA,
2194 oid: oid::TABLE_MZ_SQL_SERVER_SOURCE_TABLES_OID,
2195 desc: RelationDesc::builder()
2196 .with_column("id", SqlScalarType::String.nullable(false))
2197 .with_column("schema_name", SqlScalarType::String.nullable(false))
2198 .with_column("table_name", SqlScalarType::String.nullable(false))
2199 .finish(),
2200 column_comments: BTreeMap::from_iter([
2201 (
2202 "id",
2203 "The ID of the subsource or table. Corresponds to `mz_catalog.mz_sources.id` or `mz_catalog.mz_tables.id`.",
2204 ),
2205 (
2206 "schema_name",
2207 "The schema (or, database) of the upstream table being ingested.",
2208 ),
2209 (
2210 "table_name",
2211 "The name of the upstream table being ingested.",
2212 ),
2213 ]),
2214 is_retained_metrics_object: true,
2215 access: vec![PUBLIC_SELECT],
2216});
2217pub static MZ_KAFKA_SOURCE_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2218 name: "mz_kafka_source_tables",
2219 schema: MZ_INTERNAL_SCHEMA,
2220 oid: oid::TABLE_MZ_KAFKA_SOURCE_TABLES_OID,
2221 desc: RelationDesc::builder()
2222 .with_column("id", SqlScalarType::String.nullable(false))
2223 .with_column("topic", SqlScalarType::String.nullable(false))
2224 .with_column("envelope_type", SqlScalarType::String.nullable(true))
2225 .with_column("key_format", SqlScalarType::String.nullable(true))
2226 .with_column("value_format", SqlScalarType::String.nullable(true))
2227 .finish(),
2228 column_comments: BTreeMap::from_iter([
2229 (
2230 "id",
2231 "The ID of the table. Corresponds to `mz_catalog.mz_tables.id`.",
2232 ),
2233 ("topic", "The topic being ingested."),
2234 (
2235 "envelope_type",
2236 "The envelope type: `none`, `upsert`, or `debezium`. `NULL` for other source types.",
2237 ),
2238 (
2239 "key_format",
2240 "The format of the Kafka message key: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`, or `NULL`.",
2241 ),
2242 (
2243 "value_format",
2244 "The format of the Kafka message value: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`. `NULL` for other source types.",
2245 ),
2246 ]),
2247 is_retained_metrics_object: true,
2248 access: vec![PUBLIC_SELECT],
2249});
2250pub static MZ_OBJECT_DEPENDENCIES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2251 name: "mz_object_dependencies",
2252 schema: MZ_INTERNAL_SCHEMA,
2253 oid: oid::TABLE_MZ_OBJECT_DEPENDENCIES_OID,
2254 desc: RelationDesc::builder()
2255 .with_column("object_id", SqlScalarType::String.nullable(false))
2256 .with_column(
2257 "referenced_object_id",
2258 SqlScalarType::String.nullable(false),
2259 )
2260 .finish(),
2261 column_comments: BTreeMap::from_iter([
2262 (
2263 "object_id",
2264 "The ID of the dependent object. Corresponds to `mz_objects.id`.",
2265 ),
2266 (
2267 "referenced_object_id",
2268 "The ID of the referenced object. Corresponds to `mz_objects.id`.",
2269 ),
2270 ]),
2271 is_retained_metrics_object: true,
2272 access: vec![PUBLIC_SELECT],
2273});
2274pub static MZ_COMPUTE_DEPENDENCIES: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
2275 name: "mz_compute_dependencies",
2276 schema: MZ_INTERNAL_SCHEMA,
2277 oid: oid::SOURCE_MZ_COMPUTE_DEPENDENCIES_OID,
2278 data_source: IntrospectionType::ComputeDependencies,
2279 desc: RelationDesc::builder()
2280 .with_column("object_id", SqlScalarType::String.nullable(false))
2281 .with_column("dependency_id", SqlScalarType::String.nullable(false))
2282 .finish(),
2283 column_comments: BTreeMap::from_iter([
2284 (
2285 "object_id",
2286 "The ID of a compute object. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, or `mz_internal.mz_subscriptions`.",
2287 ),
2288 (
2289 "dependency_id",
2290 "The ID of a compute dependency. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, `mz_catalog.mz_sources.id`, or `mz_catalog.mz_tables.id`.",
2291 ),
2292 ]),
2293 is_retained_metrics_object: false,
2294 access: vec![PUBLIC_SELECT],
2295});
2296
2297pub static MZ_DATABASES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2298 name: "mz_databases",
2299 schema: MZ_CATALOG_SCHEMA,
2300 oid: oid::TABLE_MZ_DATABASES_OID,
2301 desc: RelationDesc::builder()
2302 .with_column("id", SqlScalarType::String.nullable(false))
2303 .with_column("oid", SqlScalarType::Oid.nullable(false))
2304 .with_column("name", SqlScalarType::String.nullable(false))
2305 .with_column("owner_id", SqlScalarType::String.nullable(false))
2306 .with_column(
2307 "privileges",
2308 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2309 )
2310 .with_key(vec![0])
2311 .with_key(vec![1])
2312 .finish(),
2313 column_comments: BTreeMap::from_iter([
2314 ("id", "Materialize's unique ID for the database."),
2315 (
2316 "oid",
2317 "A [PostgreSQL-compatible OID][`oid`] for the database.",
2318 ),
2319 ("name", "The name of the database."),
2320 (
2321 "owner_id",
2322 "The role ID of the owner of the database. Corresponds to `mz_roles.id`.",
2323 ),
2324 ("privileges", "The privileges belonging to the database."),
2325 ]),
2326 is_retained_metrics_object: false,
2327 access: vec![PUBLIC_SELECT],
2328});
2329pub static MZ_SCHEMAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2330 name: "mz_schemas",
2331 schema: MZ_CATALOG_SCHEMA,
2332 oid: oid::TABLE_MZ_SCHEMAS_OID,
2333 desc: RelationDesc::builder()
2334 .with_column("id", SqlScalarType::String.nullable(false))
2335 .with_column("oid", SqlScalarType::Oid.nullable(false))
2336 .with_column("database_id", SqlScalarType::String.nullable(true))
2337 .with_column("name", SqlScalarType::String.nullable(false))
2338 .with_column("owner_id", SqlScalarType::String.nullable(false))
2339 .with_column(
2340 "privileges",
2341 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2342 )
2343 .with_key(vec![0])
2344 .with_key(vec![1])
2345 .finish(),
2346 column_comments: BTreeMap::from_iter([
2347 ("id", "Materialize's unique ID for the schema."),
2348 (
2349 "oid",
2350 "A [PostgreSQL-compatible oid][`oid`] for the schema.",
2351 ),
2352 (
2353 "database_id",
2354 "The ID of the database containing the schema. Corresponds to `mz_databases.id`.",
2355 ),
2356 ("name", "The name of the schema."),
2357 (
2358 "owner_id",
2359 "The role ID of the owner of the schema. Corresponds to `mz_roles.id`.",
2360 ),
2361 ("privileges", "The privileges belonging to the schema."),
2362 ]),
2363 is_retained_metrics_object: false,
2364 access: vec![PUBLIC_SELECT],
2365});
2366pub static MZ_COLUMNS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2367 name: "mz_columns",
2368 schema: MZ_CATALOG_SCHEMA,
2369 oid: oid::TABLE_MZ_COLUMNS_OID,
2370 desc: RelationDesc::builder()
2371 .with_column("id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false))
2373 .with_column("position", SqlScalarType::UInt64.nullable(false))
2374 .with_column("nullable", SqlScalarType::Bool.nullable(false))
2375 .with_column("type", SqlScalarType::String.nullable(false))
2376 .with_column("default", SqlScalarType::String.nullable(true))
2377 .with_column("type_oid", SqlScalarType::Oid.nullable(false))
2378 .with_column("type_mod", SqlScalarType::Int32.nullable(false))
2379 .finish(),
2380 column_comments: BTreeMap::from_iter([
2381 (
2382 "id",
2383 "The unique ID of the table, source, or view containing the column.",
2384 ),
2385 ("name", "The name of the column."),
2386 (
2387 "position",
2388 "The 1-indexed position of the column in its containing table, source, or view.",
2389 ),
2390 ("nullable", "Can the column contain a `NULL` value?"),
2391 ("type", "The data type of the column."),
2392 ("default", "The default expression of the column."),
2393 (
2394 "type_oid",
2395 "The OID of the type of the column (references `mz_types`).",
2396 ),
2397 ("type_mod", "The packed type identifier of the column."),
2398 ]),
2399 is_retained_metrics_object: false,
2400 access: vec![PUBLIC_SELECT],
2401});
2402pub static MZ_INDEXES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2403 name: "mz_indexes",
2404 schema: MZ_CATALOG_SCHEMA,
2405 oid: oid::TABLE_MZ_INDEXES_OID,
2406 desc: RelationDesc::builder()
2407 .with_column("id", SqlScalarType::String.nullable(false))
2408 .with_column("oid", SqlScalarType::Oid.nullable(false))
2409 .with_column("name", SqlScalarType::String.nullable(false))
2410 .with_column("on_id", SqlScalarType::String.nullable(false))
2411 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2412 .with_column("owner_id", SqlScalarType::String.nullable(false))
2413 .with_column("create_sql", SqlScalarType::String.nullable(false))
2414 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2415 .with_key(vec![0])
2416 .with_key(vec![1])
2417 .finish(),
2418 column_comments: BTreeMap::from_iter([
2419 ("id", "Materialize's unique ID for the index."),
2420 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the index."),
2421 ("name", "The name of the index."),
2422 (
2423 "on_id",
2424 "The ID of the relation on which the index is built.",
2425 ),
2426 (
2427 "cluster_id",
2428 "The ID of the cluster in which the index is built.",
2429 ),
2430 (
2431 "owner_id",
2432 "The role ID of the owner of the index. Corresponds to `mz_roles.id`.",
2433 ),
2434 ("create_sql", "The `CREATE` SQL statement for the index."),
2435 (
2436 "redacted_create_sql",
2437 "The redacted `CREATE` SQL statement for the index.",
2438 ),
2439 ]),
2440 is_retained_metrics_object: false,
2441 access: vec![PUBLIC_SELECT],
2442});
2443pub static MZ_INDEX_COLUMNS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2444 name: "mz_index_columns",
2445 schema: MZ_CATALOG_SCHEMA,
2446 oid: oid::TABLE_MZ_INDEX_COLUMNS_OID,
2447 desc: RelationDesc::builder()
2448 .with_column("index_id", SqlScalarType::String.nullable(false))
2449 .with_column("index_position", SqlScalarType::UInt64.nullable(false))
2450 .with_column("on_position", SqlScalarType::UInt64.nullable(true))
2451 .with_column("on_expression", SqlScalarType::String.nullable(true))
2452 .with_column("nullable", SqlScalarType::Bool.nullable(false))
2453 .finish(),
2454 column_comments: BTreeMap::from_iter([
2455 (
2456 "index_id",
2457 "The ID of the index which contains this column. Corresponds to `mz_indexes.id`.",
2458 ),
2459 (
2460 "index_position",
2461 "The 1-indexed position of this column within the index. (The order of columns in an index does not necessarily match the order of columns in the relation on which the index is built.)",
2462 ),
2463 (
2464 "on_position",
2465 "If not `NULL`, specifies the 1-indexed position of a column in the relation on which this index is built that determines the value of this index column.",
2466 ),
2467 (
2468 "on_expression",
2469 "If not `NULL`, specifies a SQL expression that is evaluated to compute the value of this index column. The expression may contain references to any of the columns of the relation.",
2470 ),
2471 (
2472 "nullable",
2473 "Can this column of the index evaluate to `NULL`?",
2474 ),
2475 ]),
2476 is_retained_metrics_object: false,
2477 access: vec![PUBLIC_SELECT],
2478});
2479pub static MZ_TABLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2480 name: "mz_tables",
2481 schema: MZ_CATALOG_SCHEMA,
2482 oid: oid::TABLE_MZ_TABLES_OID,
2483 desc: RelationDesc::builder()
2484 .with_column("id", SqlScalarType::String.nullable(false))
2485 .with_column("oid", SqlScalarType::Oid.nullable(false))
2486 .with_column("schema_id", SqlScalarType::String.nullable(false))
2487 .with_column("name", SqlScalarType::String.nullable(false))
2488 .with_column("owner_id", SqlScalarType::String.nullable(false))
2489 .with_column(
2490 "privileges",
2491 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2492 )
2493 .with_column("create_sql", SqlScalarType::String.nullable(true))
2494 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
2495 .with_column("source_id", SqlScalarType::String.nullable(true))
2496 .with_key(vec![0])
2497 .with_key(vec![1])
2498 .finish(),
2499 column_comments: BTreeMap::from_iter([
2500 ("id", "Materialize's unique ID for the table."),
2501 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the table."),
2502 (
2503 "schema_id",
2504 "The ID of the schema to which the table belongs. Corresponds to `mz_schemas.id`.",
2505 ),
2506 ("name", "The name of the table."),
2507 (
2508 "owner_id",
2509 "The role ID of the owner of the table. Corresponds to `mz_roles.id`.",
2510 ),
2511 ("privileges", "The privileges belonging to the table."),
2512 ("create_sql", "The `CREATE` SQL statement for the table."),
2513 (
2514 "redacted_create_sql",
2515 "The redacted `CREATE` SQL statement for the table.",
2516 ),
2517 (
2518 "source_id",
2519 "The ID of the source associated with the table, if any. Corresponds to `mz_sources.id`.",
2520 ),
2521 ]),
2522 is_retained_metrics_object: true,
2523 access: vec![PUBLIC_SELECT],
2524});
2525pub static MZ_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2526 name: "mz_connections",
2527 schema: MZ_CATALOG_SCHEMA,
2528 oid: oid::TABLE_MZ_CONNECTIONS_OID,
2529 desc: RelationDesc::builder()
2530 .with_column("id", SqlScalarType::String.nullable(false))
2531 .with_column("oid", SqlScalarType::Oid.nullable(false))
2532 .with_column("schema_id", SqlScalarType::String.nullable(false))
2533 .with_column("name", SqlScalarType::String.nullable(false))
2534 .with_column("type", SqlScalarType::String.nullable(false))
2535 .with_column("owner_id", SqlScalarType::String.nullable(false))
2536 .with_column(
2537 "privileges",
2538 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2539 )
2540 .with_column("create_sql", SqlScalarType::String.nullable(false))
2541 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2542 .with_key(vec![0])
2543 .with_key(vec![1])
2544 .finish(),
2545 column_comments: BTreeMap::from_iter([
2546 ("id", "The unique ID of the connection."),
2547 (
2548 "oid",
2549 "A [PostgreSQL-compatible OID][`oid`] for the connection.",
2550 ),
2551 (
2552 "schema_id",
2553 "The ID of the schema to which the connection belongs. Corresponds to `mz_schemas.id`.",
2554 ),
2555 ("name", "The name of the connection."),
2556 (
2557 "type",
2558 "The type of the connection: `confluent-schema-registry`, `kafka`, `postgres`, or `ssh-tunnel`.",
2559 ),
2560 (
2561 "owner_id",
2562 "The role ID of the owner of the connection. Corresponds to `mz_roles.id`.",
2563 ),
2564 ("privileges", "The privileges belonging to the connection."),
2565 (
2566 "create_sql",
2567 "The `CREATE` SQL statement for the connection.",
2568 ),
2569 (
2570 "redacted_create_sql",
2571 "The redacted `CREATE` SQL statement for the connection.",
2572 ),
2573 ]),
2574 is_retained_metrics_object: false,
2575 access: vec![PUBLIC_SELECT],
2576});
2577pub static MZ_SSH_TUNNEL_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2578 name: "mz_ssh_tunnel_connections",
2579 schema: MZ_CATALOG_SCHEMA,
2580 oid: oid::TABLE_MZ_SSH_TUNNEL_CONNECTIONS_OID,
2581 desc: RelationDesc::builder()
2582 .with_column("id", SqlScalarType::String.nullable(false))
2583 .with_column("public_key_1", SqlScalarType::String.nullable(false))
2584 .with_column("public_key_2", SqlScalarType::String.nullable(false))
2585 .finish(),
2586 column_comments: BTreeMap::from_iter([
2587 ("id", "The ID of the connection."),
2588 (
2589 "public_key_1",
2590 "The first public key associated with the SSH tunnel.",
2591 ),
2592 (
2593 "public_key_2",
2594 "The second public key associated with the SSH tunnel.",
2595 ),
2596 ]),
2597 is_retained_metrics_object: false,
2598 access: vec![PUBLIC_SELECT],
2599});
2600pub static MZ_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2601 name: "mz_sources",
2602 schema: MZ_CATALOG_SCHEMA,
2603 oid: oid::TABLE_MZ_SOURCES_OID,
2604 desc: RelationDesc::builder()
2605 .with_column("id", SqlScalarType::String.nullable(false))
2606 .with_column("oid", SqlScalarType::Oid.nullable(false))
2607 .with_column("schema_id", SqlScalarType::String.nullable(false))
2608 .with_column("name", SqlScalarType::String.nullable(false))
2609 .with_column("type", SqlScalarType::String.nullable(false))
2610 .with_column("connection_id", SqlScalarType::String.nullable(true))
2611 .with_column("size", SqlScalarType::String.nullable(true))
2612 .with_column("envelope_type", SqlScalarType::String.nullable(true))
2613 .with_column("key_format", SqlScalarType::String.nullable(true))
2614 .with_column("value_format", SqlScalarType::String.nullable(true))
2615 .with_column("cluster_id", SqlScalarType::String.nullable(true))
2616 .with_column("owner_id", SqlScalarType::String.nullable(false))
2617 .with_column(
2618 "privileges",
2619 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2620 )
2621 .with_column("create_sql", SqlScalarType::String.nullable(true))
2622 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
2623 .with_key(vec![0])
2624 .with_key(vec![1])
2625 .finish(),
2626 column_comments: BTreeMap::from_iter([
2627 ("id", "Materialize's unique ID for the source."),
2628 (
2629 "oid",
2630 "A [PostgreSQL-compatible OID][`oid`] for the source.",
2631 ),
2632 (
2633 "schema_id",
2634 "The ID of the schema to which the source belongs. Corresponds to `mz_schemas.id`.",
2635 ),
2636 ("name", "The name of the source."),
2637 (
2638 "type",
2639 "The type of the source: `kafka`, `mysql`, `postgres`, `load-generator`, `progress`, or `subsource`.",
2640 ),
2641 (
2642 "connection_id",
2643 "The ID of the connection associated with the source, if any. Corresponds to `mz_connections.id`.",
2644 ),
2645 ("size", "Deprecated The size of the source."),
2646 (
2647 "envelope_type",
2648 "For Kafka sources, the envelope type: `none`, `upsert`, or `debezium`. `NULL` for other source types.",
2649 ),
2650 (
2651 "key_format",
2652 "For Kafka sources, the format of the Kafka message key: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`, or `NULL`.",
2653 ),
2654 (
2655 "value_format",
2656 "For Kafka sources, the format of the Kafka message value: `avro`, `protobuf`, `csv`, `regex`, `bytes`, `json`, `text`. `NULL` for other source types.",
2657 ),
2658 (
2659 "cluster_id",
2660 "The ID of the cluster maintaining the source. Corresponds to `mz_clusters.id`.",
2661 ),
2662 (
2663 "owner_id",
2664 "The role ID of the owner of the source. Corresponds to `mz_roles.id`.",
2665 ),
2666 ("privileges", "The privileges granted on the source."),
2667 ("create_sql", "The `CREATE` SQL statement for the source."),
2668 (
2669 "redacted_create_sql",
2670 "The redacted `CREATE` SQL statement for the source.",
2671 ),
2672 ]),
2673 is_retained_metrics_object: true,
2674 access: vec![PUBLIC_SELECT],
2675});
2676pub static MZ_SINKS: LazyLock<BuiltinTable> = LazyLock::new(|| {
2677 BuiltinTable {
2678 name: "mz_sinks",
2679 schema: MZ_CATALOG_SCHEMA,
2680 oid: oid::TABLE_MZ_SINKS_OID,
2681 desc: RelationDesc::builder()
2682 .with_column("id", SqlScalarType::String.nullable(false))
2683 .with_column("oid", SqlScalarType::Oid.nullable(false))
2684 .with_column("schema_id", SqlScalarType::String.nullable(false))
2685 .with_column("name", SqlScalarType::String.nullable(false))
2686 .with_column("type", SqlScalarType::String.nullable(false))
2687 .with_column("connection_id", SqlScalarType::String.nullable(true))
2688 .with_column("size", SqlScalarType::String.nullable(true))
2689 .with_column("envelope_type", SqlScalarType::String.nullable(true))
2690 .with_column("format", SqlScalarType::String.nullable(true))
2693 .with_column("key_format", SqlScalarType::String.nullable(true))
2694 .with_column("value_format", SqlScalarType::String.nullable(true))
2695 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2696 .with_column("owner_id", SqlScalarType::String.nullable(false))
2697 .with_column("create_sql", SqlScalarType::String.nullable(false))
2698 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2699 .with_key(vec![0])
2700 .with_key(vec![1])
2701 .finish(),
2702 column_comments: BTreeMap::from_iter([
2703 ("id", "Materialize's unique ID for the sink."),
2704 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the sink."),
2705 (
2706 "schema_id",
2707 "The ID of the schema to which the sink belongs. Corresponds to `mz_schemas.id`.",
2708 ),
2709 ("name", "The name of the sink."),
2710 ("type", "The type of the sink: `kafka`."),
2711 (
2712 "connection_id",
2713 "The ID of the connection associated with the sink, if any. Corresponds to `mz_connections.id`.",
2714 ),
2715 ("size", "The size of the sink."),
2716 (
2717 "envelope_type",
2718 "The envelope of the sink: `upsert`, or `debezium`.",
2719 ),
2720 (
2721 "format",
2722 "Deprecated The format of the Kafka messages produced by the sink: `avro`, `json`, `text`, or `bytes`.",
2723 ),
2724 (
2725 "key_format",
2726 "The format of the Kafka message key for messages produced by the sink: `avro`, `json`, `bytes`, `text`, or `NULL`.",
2727 ),
2728 (
2729 "value_format",
2730 "The format of the Kafka message value for messages produced by the sink: `avro`, `json`, `text`, or `bytes`.",
2731 ),
2732 (
2733 "cluster_id",
2734 "The ID of the cluster maintaining the sink. Corresponds to `mz_clusters.id`.",
2735 ),
2736 (
2737 "owner_id",
2738 "The role ID of the owner of the sink. Corresponds to `mz_roles.id`.",
2739 ),
2740 ("create_sql", "The `CREATE` SQL statement for the sink."),
2741 (
2742 "redacted_create_sql",
2743 "The redacted `CREATE` SQL statement for the sink.",
2744 ),
2745 ]),
2746 is_retained_metrics_object: true,
2747 access: vec![PUBLIC_SELECT],
2748 }
2749});
2750pub static MZ_VIEWS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2751 name: "mz_views",
2752 schema: MZ_CATALOG_SCHEMA,
2753 oid: oid::TABLE_MZ_VIEWS_OID,
2754 desc: RelationDesc::builder()
2755 .with_column("id", SqlScalarType::String.nullable(false))
2756 .with_column("oid", SqlScalarType::Oid.nullable(false))
2757 .with_column("schema_id", SqlScalarType::String.nullable(false))
2758 .with_column("name", SqlScalarType::String.nullable(false))
2759 .with_column("definition", SqlScalarType::String.nullable(false))
2760 .with_column("owner_id", SqlScalarType::String.nullable(false))
2761 .with_column(
2762 "privileges",
2763 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2764 )
2765 .with_column("create_sql", SqlScalarType::String.nullable(false))
2766 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2767 .with_key(vec![0])
2768 .with_key(vec![1])
2769 .finish(),
2770 column_comments: BTreeMap::from_iter([
2771 ("id", "Materialize's unique ID for the view."),
2772 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the view."),
2773 (
2774 "schema_id",
2775 "The ID of the schema to which the view belongs. Corresponds to `mz_schemas.id`.",
2776 ),
2777 ("name", "The name of the view."),
2778 ("definition", "The view definition (a `SELECT` query)."),
2779 (
2780 "owner_id",
2781 "The role ID of the owner of the view. Corresponds to `mz_roles.id`.",
2782 ),
2783 ("privileges", "The privileges belonging to the view."),
2784 ("create_sql", "The `CREATE` SQL statement for the view."),
2785 (
2786 "redacted_create_sql",
2787 "The redacted `CREATE` SQL statement for the view.",
2788 ),
2789 ]),
2790 is_retained_metrics_object: false,
2791 access: vec![PUBLIC_SELECT],
2792});
2793pub static MZ_MATERIALIZED_VIEWS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2794 name: "mz_materialized_views",
2795 schema: MZ_CATALOG_SCHEMA,
2796 oid: oid::TABLE_MZ_MATERIALIZED_VIEWS_OID,
2797 desc: RelationDesc::builder()
2798 .with_column("id", SqlScalarType::String.nullable(false))
2799 .with_column("oid", SqlScalarType::Oid.nullable(false))
2800 .with_column("schema_id", SqlScalarType::String.nullable(false))
2801 .with_column("name", SqlScalarType::String.nullable(false))
2802 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2803 .with_column("definition", SqlScalarType::String.nullable(false))
2804 .with_column("owner_id", SqlScalarType::String.nullable(false))
2805 .with_column(
2806 "privileges",
2807 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2808 )
2809 .with_column("create_sql", SqlScalarType::String.nullable(false))
2810 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2811 .with_key(vec![0])
2812 .with_key(vec![1])
2813 .finish(),
2814 column_comments: BTreeMap::from_iter([
2815 ("id", "Materialize's unique ID for the materialized view."),
2816 (
2817 "oid",
2818 "A [PostgreSQL-compatible OID][`oid`] for the materialized view.",
2819 ),
2820 (
2821 "schema_id",
2822 "The ID of the schema to which the materialized view belongs. Corresponds to `mz_schemas.id`.",
2823 ),
2824 ("name", "The name of the materialized view."),
2825 (
2826 "cluster_id",
2827 "The ID of the cluster maintaining the materialized view. Corresponds to `mz_clusters.id`.",
2828 ),
2829 (
2830 "definition",
2831 "The materialized view definition (a `SELECT` query).",
2832 ),
2833 (
2834 "owner_id",
2835 "The role ID of the owner of the materialized view. Corresponds to `mz_roles.id`.",
2836 ),
2837 (
2838 "privileges",
2839 "The privileges belonging to the materialized view.",
2840 ),
2841 (
2842 "create_sql",
2843 "The `CREATE` SQL statement for the materialized view.",
2844 ),
2845 (
2846 "redacted_create_sql",
2847 "The redacted `CREATE` SQL statement for the materialized view.",
2848 ),
2849 ]),
2850 is_retained_metrics_object: false,
2851 access: vec![PUBLIC_SELECT],
2852});
2853pub static MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES: LazyLock<BuiltinTable> = LazyLock::new(|| {
2854 BuiltinTable {
2855 name: "mz_materialized_view_refresh_strategies",
2856 schema: MZ_INTERNAL_SCHEMA,
2857 oid: oid::TABLE_MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES_OID,
2858 desc: RelationDesc::builder()
2859 .with_column(
2860 "materialized_view_id",
2861 SqlScalarType::String.nullable(false),
2862 )
2863 .with_column("type", SqlScalarType::String.nullable(false))
2864 .with_column("interval", SqlScalarType::Interval.nullable(true))
2865 .with_column(
2866 "aligned_to",
2867 SqlScalarType::TimestampTz { precision: None }.nullable(true),
2868 )
2869 .with_column(
2870 "at",
2871 SqlScalarType::TimestampTz { precision: None }.nullable(true),
2872 )
2873 .finish(),
2874 column_comments: BTreeMap::from_iter([
2875 (
2876 "materialized_view_id",
2877 "The ID of the materialized view. Corresponds to `mz_catalog.mz_materialized_views.id`",
2878 ),
2879 (
2880 "type",
2881 "`at`, `every`, or `on-commit`. Default: `on-commit`",
2882 ),
2883 (
2884 "interval",
2885 "The refresh interval of a `REFRESH EVERY` option, or `NULL` if the `type` is not `every`.",
2886 ),
2887 (
2888 "aligned_to",
2889 "The `ALIGNED TO` option of a `REFRESH EVERY` option, or `NULL` if the `type` is not `every`.",
2890 ),
2891 (
2892 "at",
2893 "The time of a `REFRESH AT`, or `NULL` if the `type` is not `at`.",
2894 ),
2895 ]),
2896 is_retained_metrics_object: false,
2897 access: vec![PUBLIC_SELECT],
2898 }
2899});
2900pub static MZ_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2901 name: "mz_types",
2902 schema: MZ_CATALOG_SCHEMA,
2903 oid: oid::TABLE_MZ_TYPES_OID,
2904 desc: RelationDesc::builder()
2905 .with_column("id", SqlScalarType::String.nullable(false))
2906 .with_column("oid", SqlScalarType::Oid.nullable(false))
2907 .with_column("schema_id", SqlScalarType::String.nullable(false))
2908 .with_column("name", SqlScalarType::String.nullable(false))
2909 .with_column("category", SqlScalarType::String.nullable(false))
2910 .with_column("owner_id", SqlScalarType::String.nullable(false))
2911 .with_column(
2912 "privileges",
2913 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2914 )
2915 .with_column("create_sql", SqlScalarType::String.nullable(true))
2916 .with_column("redacted_create_sql", SqlScalarType::String.nullable(true))
2917 .with_key(vec![0])
2918 .with_key(vec![1])
2919 .finish(),
2920 column_comments: BTreeMap::from_iter([
2921 ("id", "Materialize's unique ID for the type."),
2922 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the type."),
2923 (
2924 "schema_id",
2925 "The ID of the schema to which the type belongs. Corresponds to `mz_schemas.id`.",
2926 ),
2927 ("name", "The name of the type."),
2928 ("category", "The category of the type."),
2929 (
2930 "owner_id",
2931 "The role ID of the owner of the type. Corresponds to `mz_roles.id`.",
2932 ),
2933 ("privileges", "The privileges belonging to the type."),
2934 ("create_sql", "The `CREATE` SQL statement for the type."),
2935 (
2936 "redacted_create_sql",
2937 "The redacted `CREATE` SQL statement for the type.",
2938 ),
2939 ]),
2940 is_retained_metrics_object: false,
2941 access: vec![PUBLIC_SELECT],
2942});
2943pub static MZ_CONTINUAL_TASKS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2944 name: "mz_continual_tasks",
2945 schema: MZ_INTERNAL_SCHEMA,
2946 oid: oid::TABLE_MZ_CONTINUAL_TASKS_OID,
2947 desc: RelationDesc::builder()
2948 .with_column("id", SqlScalarType::String.nullable(false))
2949 .with_column("oid", SqlScalarType::Oid.nullable(false))
2950 .with_column("schema_id", SqlScalarType::String.nullable(false))
2951 .with_column("name", SqlScalarType::String.nullable(false))
2952 .with_column("cluster_id", SqlScalarType::String.nullable(false))
2953 .with_column("definition", SqlScalarType::String.nullable(false))
2954 .with_column("owner_id", SqlScalarType::String.nullable(false))
2955 .with_column(
2956 "privileges",
2957 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2958 )
2959 .with_column("create_sql", SqlScalarType::String.nullable(false))
2960 .with_column("redacted_create_sql", SqlScalarType::String.nullable(false))
2961 .with_key(vec![0])
2962 .with_key(vec![1])
2963 .finish(),
2964 column_comments: BTreeMap::new(),
2965 is_retained_metrics_object: false,
2966 access: vec![PUBLIC_SELECT],
2967});
2968pub static MZ_NETWORK_POLICIES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
2969 name: "mz_network_policies",
2970 schema: MZ_INTERNAL_SCHEMA,
2971 oid: oid::TABLE_MZ_NETWORK_POLICIES_OID,
2972 desc: RelationDesc::builder()
2973 .with_column("id", SqlScalarType::String.nullable(false))
2974 .with_column("name", SqlScalarType::String.nullable(false))
2975 .with_column("owner_id", SqlScalarType::String.nullable(false))
2976 .with_column(
2977 "privileges",
2978 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
2979 )
2980 .with_column("oid", SqlScalarType::Oid.nullable(false))
2981 .finish(),
2982 column_comments: BTreeMap::from_iter([
2983 ("id", "The ID of the network policy."),
2984 ("name", "The name of the network policy."),
2985 (
2986 "owner_id",
2987 "The role ID of the owner of the network policy. Corresponds to `mz_catalog.mz_roles.id`.",
2988 ),
2989 (
2990 "privileges",
2991 "The privileges belonging to the network policy.",
2992 ),
2993 (
2994 "oid",
2995 "A [PostgreSQL-compatible OID][`oid`] for the network policy.",
2996 ),
2997 ]),
2998 is_retained_metrics_object: false,
2999 access: vec![PUBLIC_SELECT],
3000});
3001pub static MZ_NETWORK_POLICY_RULES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3002 name: "mz_network_policy_rules",
3003 schema: MZ_INTERNAL_SCHEMA,
3004 oid: oid::TABLE_MZ_NETWORK_POLICY_RULES_OID,
3005 desc: RelationDesc::builder()
3006 .with_column("name", SqlScalarType::String.nullable(false))
3007 .with_column("policy_id", SqlScalarType::String.nullable(false))
3008 .with_column("action", SqlScalarType::String.nullable(false))
3009 .with_column("address", SqlScalarType::String.nullable(false))
3010 .with_column("direction", SqlScalarType::String.nullable(false))
3011 .finish(),
3012 column_comments: BTreeMap::from_iter([
3013 (
3014 "name",
3015 "The name of the network policy rule. Can be combined with `policy_id` to form a unique identifier.",
3016 ),
3017 (
3018 "policy_id",
3019 "The ID the network policy the rule is part of. Corresponds to `mz_network_policy_rules.id`.",
3020 ),
3021 (
3022 "action",
3023 "The action of the rule. `allow` is the only supported action.",
3024 ),
3025 ("address", "The address the rule will take action on."),
3026 (
3027 "direction",
3028 "The direction of traffic the rule applies to. `ingress` is the only supported direction.",
3029 ),
3030 ]),
3031 is_retained_metrics_object: false,
3032 access: vec![PUBLIC_SELECT],
3033});
3034pub static MZ_TYPE_PG_METADATA: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3037 name: "mz_type_pg_metadata",
3038 schema: MZ_INTERNAL_SCHEMA,
3039 oid: oid::TABLE_MZ_TYPE_PG_METADATA_OID,
3040 desc: RelationDesc::builder()
3041 .with_column("id", SqlScalarType::String.nullable(false))
3042 .with_column("typinput", SqlScalarType::Oid.nullable(false))
3043 .with_column("typreceive", SqlScalarType::Oid.nullable(false))
3044 .finish(),
3045 column_comments: BTreeMap::new(),
3046 is_retained_metrics_object: false,
3047 access: vec![PUBLIC_SELECT],
3048});
3049pub static MZ_ARRAY_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3050 name: "mz_array_types",
3051 schema: MZ_CATALOG_SCHEMA,
3052 oid: oid::TABLE_MZ_ARRAY_TYPES_OID,
3053 desc: RelationDesc::builder()
3054 .with_column("id", SqlScalarType::String.nullable(false))
3055 .with_column("element_id", SqlScalarType::String.nullable(false))
3056 .finish(),
3057 column_comments: BTreeMap::from_iter([
3058 ("id", "The ID of the array type."),
3059 ("element_id", "The ID of the array's element type."),
3060 ]),
3061 is_retained_metrics_object: false,
3062 access: vec![PUBLIC_SELECT],
3063});
3064pub static MZ_BASE_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3065 name: "mz_base_types",
3066 schema: MZ_CATALOG_SCHEMA,
3067 oid: oid::TABLE_MZ_BASE_TYPES_OID,
3068 desc: RelationDesc::builder()
3069 .with_column("id", SqlScalarType::String.nullable(false))
3070 .finish(),
3071 column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]),
3072 is_retained_metrics_object: false,
3073 access: vec![PUBLIC_SELECT],
3074});
3075pub static MZ_LIST_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3076 name: "mz_list_types",
3077 schema: MZ_CATALOG_SCHEMA,
3078 oid: oid::TABLE_MZ_LIST_TYPES_OID,
3079 desc: RelationDesc::builder()
3080 .with_column("id", SqlScalarType::String.nullable(false))
3081 .with_column("element_id", SqlScalarType::String.nullable(false))
3082 .with_column(
3083 "element_modifiers",
3084 SqlScalarType::List {
3085 element_type: Box::new(SqlScalarType::Int64),
3086 custom_id: None,
3087 }
3088 .nullable(true),
3089 )
3090 .finish(),
3091 column_comments: BTreeMap::from_iter([
3092 ("id", "The ID of the list type."),
3093 ("element_id", "The IID of the list's element type."),
3094 (
3095 "element_modifiers",
3096 "The element type modifiers, or `NULL` if none.",
3097 ),
3098 ]),
3099 is_retained_metrics_object: false,
3100 access: vec![PUBLIC_SELECT],
3101});
3102pub static MZ_MAP_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3103 name: "mz_map_types",
3104 schema: MZ_CATALOG_SCHEMA,
3105 oid: oid::TABLE_MZ_MAP_TYPES_OID,
3106 desc: RelationDesc::builder()
3107 .with_column("id", SqlScalarType::String.nullable(false))
3108 .with_column("key_id", SqlScalarType::String.nullable(false))
3109 .with_column("value_id", SqlScalarType::String.nullable(false))
3110 .with_column(
3111 "key_modifiers",
3112 SqlScalarType::List {
3113 element_type: Box::new(SqlScalarType::Int64),
3114 custom_id: None,
3115 }
3116 .nullable(true),
3117 )
3118 .with_column(
3119 "value_modifiers",
3120 SqlScalarType::List {
3121 element_type: Box::new(SqlScalarType::Int64),
3122 custom_id: None,
3123 }
3124 .nullable(true),
3125 )
3126 .finish(),
3127 column_comments: BTreeMap::from_iter([
3128 ("id", "The ID of the map type."),
3129 ("key_id", "The ID of the map's key type."),
3130 ("value_id", "The ID of the map's value type."),
3131 (
3132 "key_modifiers",
3133 "The key type modifiers, or `NULL` if none.",
3134 ),
3135 (
3136 "value_modifiers",
3137 "The value type modifiers, or `NULL` if none.",
3138 ),
3139 ]),
3140 is_retained_metrics_object: false,
3141 access: vec![PUBLIC_SELECT],
3142});
3143pub static MZ_ROLES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3144 name: "mz_roles",
3145 schema: MZ_CATALOG_SCHEMA,
3146 oid: oid::TABLE_MZ_ROLES_OID,
3147 desc: RelationDesc::builder()
3148 .with_column("id", SqlScalarType::String.nullable(false))
3149 .with_column("oid", SqlScalarType::Oid.nullable(false))
3150 .with_column("name", SqlScalarType::String.nullable(false))
3151 .with_column("inherit", SqlScalarType::Bool.nullable(false))
3152 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(true))
3153 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
3154 .with_key(vec![0])
3155 .with_key(vec![1])
3156 .finish(),
3157 column_comments: BTreeMap::from_iter([
3158 ("id", "Materialize's unique ID for the role."),
3159 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the role."),
3160 ("name", "The name of the role."),
3161 (
3162 "inherit",
3163 "Indicates whether the role has inheritance of privileges.",
3164 ),
3165 (
3166 "rolcanlogin",
3167 "Indicates whether the role can log in (i.e., is a user).",
3168 ),
3169 ("rolsuper", "Indicates whether the role is a superuser."),
3170 ]),
3171 is_retained_metrics_object: false,
3172 access: vec![PUBLIC_SELECT],
3173});
3174pub static MZ_ROLE_MEMBERS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3175 name: "mz_role_members",
3176 schema: MZ_CATALOG_SCHEMA,
3177 oid: oid::TABLE_MZ_ROLE_MEMBERS_OID,
3178 desc: RelationDesc::builder()
3179 .with_column("role_id", SqlScalarType::String.nullable(false))
3180 .with_column("member", SqlScalarType::String.nullable(false))
3181 .with_column("grantor", SqlScalarType::String.nullable(false))
3182 .finish(),
3183 column_comments: BTreeMap::from_iter([
3184 (
3185 "role_id",
3186 "The ID of the role the `member` is a member of. Corresponds to `mz_roles.id`.",
3187 ),
3188 (
3189 "member",
3190 "The ID of the role that is a member of `role_id`. Corresponds to `mz_roles.id`.",
3191 ),
3192 (
3193 "grantor",
3194 "The ID of the role that granted membership of `member` to `role_id`. Corresponds to `mz_roles.id`.",
3195 ),
3196 ]),
3197 is_retained_metrics_object: false,
3198 access: vec![PUBLIC_SELECT],
3199});
3200pub static MZ_ROLE_PARAMETERS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3201 name: "mz_role_parameters",
3202 schema: MZ_CATALOG_SCHEMA,
3203 oid: oid::TABLE_MZ_ROLE_PARAMETERS_OID,
3204 desc: RelationDesc::builder()
3205 .with_column("role_id", SqlScalarType::String.nullable(false))
3206 .with_column("parameter_name", SqlScalarType::String.nullable(false))
3207 .with_column("parameter_value", SqlScalarType::String.nullable(false))
3208 .finish(),
3209 column_comments: BTreeMap::from_iter([
3210 (
3211 "role_id",
3212 "The ID of the role whose configuration parameter default is set. Corresponds to `mz_roles.id`.",
3213 ),
3214 (
3215 "parameter_name",
3216 "The configuration parameter name. One of the supported configuration parameters.",
3217 ),
3218 (
3219 "parameter_value",
3220 "The default value of the parameter for the given role. Can be either a single value, or a comma-separated list of values for configuration parameters that accept a list.",
3221 ),
3222 ]),
3223 is_retained_metrics_object: false,
3224 access: vec![PUBLIC_SELECT],
3225});
3226pub static MZ_ROLE_AUTH: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3227 name: "mz_role_auth",
3228 schema: MZ_CATALOG_SCHEMA,
3229 oid: oid::TABLE_MZ_ROLE_AUTH_OID,
3230 desc: RelationDesc::builder()
3231 .with_column("role_id", SqlScalarType::String.nullable(false))
3232 .with_column("role_oid", SqlScalarType::Oid.nullable(false))
3233 .with_column("password_hash", SqlScalarType::String.nullable(true))
3234 .with_column(
3235 "updated_at",
3236 SqlScalarType::TimestampTz { precision: None }.nullable(false),
3237 )
3238 .finish(),
3239 column_comments: BTreeMap::from_iter([
3240 (
3241 "role_id",
3242 "The ID of the role. Corresponds to `mz_roles.id`.",
3243 ),
3244 (
3245 "role_oid",
3246 "The OID of the role whose configuration parameter default is set. Corresponds to `mz_roles.oid`.",
3247 ),
3248 ("password_hash", "The hashed password for the role"),
3249 (
3250 "updated_at",
3251 "The timestamp when the password was last updated.",
3252 ),
3253 ]),
3254 is_retained_metrics_object: false,
3255 access: vec![rbac::owner_privilege(ObjectType::Table, MZ_SYSTEM_ROLE_ID)],
3256});
3257pub static MZ_PSEUDO_TYPES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3258 name: "mz_pseudo_types",
3259 schema: MZ_CATALOG_SCHEMA,
3260 oid: oid::TABLE_MZ_PSEUDO_TYPES_OID,
3261 desc: RelationDesc::builder()
3262 .with_column("id", SqlScalarType::String.nullable(false))
3263 .finish(),
3264 column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]),
3265 is_retained_metrics_object: false,
3266 access: vec![PUBLIC_SELECT],
3267});
3268pub static MZ_FUNCTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| {
3269 BuiltinTable {
3270 name: "mz_functions",
3271 schema: MZ_CATALOG_SCHEMA,
3272 oid: oid::TABLE_MZ_FUNCTIONS_OID,
3273 desc: RelationDesc::builder()
3274 .with_column("id", SqlScalarType::String.nullable(false)) .with_column("oid", SqlScalarType::Oid.nullable(false))
3276 .with_column("schema_id", SqlScalarType::String.nullable(false))
3277 .with_column("name", SqlScalarType::String.nullable(false))
3278 .with_column(
3279 "argument_type_ids",
3280 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
3281 )
3282 .with_column(
3283 "variadic_argument_type_id",
3284 SqlScalarType::String.nullable(true),
3285 )
3286 .with_column("return_type_id", SqlScalarType::String.nullable(true))
3287 .with_column("returns_set", SqlScalarType::Bool.nullable(false))
3288 .with_column("owner_id", SqlScalarType::String.nullable(false))
3289 .finish(),
3290 column_comments: BTreeMap::from_iter([
3291 ("id", "Materialize's unique ID for the function."),
3292 (
3293 "oid",
3294 "A [PostgreSQL-compatible OID][`oid`] for the function.",
3295 ),
3296 (
3297 "schema_id",
3298 "The ID of the schema to which the function belongs. Corresponds to `mz_schemas.id`.",
3299 ),
3300 ("name", "The name of the function."),
3301 (
3302 "argument_type_ids",
3303 "The ID of each argument's type. Each entry refers to `mz_types.id`.",
3304 ),
3305 (
3306 "variadic_argument_type_id",
3307 "The ID of the variadic argument's type, or `NULL` if the function does not have a variadic argument. Refers to `mz_types.id`.",
3308 ),
3309 (
3310 "return_type_id",
3311 "The returned value's type, or `NULL` if the function does not return a value. Refers to `mz_types.id`. Note that for table functions with > 1 column, this type corresponds to [`record`].",
3312 ),
3313 (
3314 "returns_set",
3315 "Whether the function returns a set, i.e. the function is a table function.",
3316 ),
3317 (
3318 "owner_id",
3319 "The role ID of the owner of the function. Corresponds to `mz_roles.id`.",
3320 ),
3321 ]),
3322 is_retained_metrics_object: false,
3323 access: vec![PUBLIC_SELECT],
3324 }
3325});
3326pub static MZ_OPERATORS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3327 name: "mz_operators",
3328 schema: MZ_CATALOG_SCHEMA,
3329 oid: oid::TABLE_MZ_OPERATORS_OID,
3330 desc: RelationDesc::builder()
3331 .with_column("oid", SqlScalarType::Oid.nullable(false))
3332 .with_column("name", SqlScalarType::String.nullable(false))
3333 .with_column(
3334 "argument_type_ids",
3335 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
3336 )
3337 .with_column("return_type_id", SqlScalarType::String.nullable(true))
3338 .finish(),
3339 column_comments: BTreeMap::new(),
3340 is_retained_metrics_object: false,
3341 access: vec![PUBLIC_SELECT],
3342});
3343pub static MZ_AGGREGATES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3344 name: "mz_aggregates",
3345 schema: MZ_INTERNAL_SCHEMA,
3346 oid: oid::TABLE_MZ_AGGREGATES_OID,
3347 desc: RelationDesc::builder()
3348 .with_column("oid", SqlScalarType::Oid.nullable(false))
3349 .with_column("agg_kind", SqlScalarType::String.nullable(false))
3350 .with_column("agg_num_direct_args", SqlScalarType::Int16.nullable(false))
3351 .finish(),
3352 column_comments: BTreeMap::new(),
3353 is_retained_metrics_object: false,
3354 access: vec![PUBLIC_SELECT],
3355});
3356
3357pub static MZ_CLUSTERS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3358 name: "mz_clusters",
3359 schema: MZ_CATALOG_SCHEMA,
3360 oid: oid::TABLE_MZ_CLUSTERS_OID,
3361 desc: RelationDesc::builder()
3362 .with_column("id", SqlScalarType::String.nullable(false))
3363 .with_column("name", SqlScalarType::String.nullable(false))
3364 .with_column("owner_id", SqlScalarType::String.nullable(false))
3365 .with_column(
3366 "privileges",
3367 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
3368 )
3369 .with_column("managed", SqlScalarType::Bool.nullable(false))
3370 .with_column("size", SqlScalarType::String.nullable(true))
3371 .with_column("replication_factor", SqlScalarType::UInt32.nullable(true))
3372 .with_column("disk", SqlScalarType::Bool.nullable(true))
3373 .with_column(
3374 "availability_zones",
3375 SqlScalarType::List {
3376 element_type: Box::new(SqlScalarType::String),
3377 custom_id: None,
3378 }
3379 .nullable(true),
3380 )
3381 .with_column(
3382 "introspection_debugging",
3383 SqlScalarType::Bool.nullable(true),
3384 )
3385 .with_column(
3386 "introspection_interval",
3387 SqlScalarType::Interval.nullable(true),
3388 )
3389 .with_key(vec![0])
3390 .finish(),
3391 column_comments: BTreeMap::from_iter([
3392 ("id", "Materialize's unique ID for the cluster."),
3393 ("name", "The name of the cluster."),
3394 (
3395 "owner_id",
3396 "The role ID of the owner of the cluster. Corresponds to `mz_roles.id`.",
3397 ),
3398 ("privileges", "The privileges belonging to the cluster."),
3399 (
3400 "managed",
3401 "Whether the cluster is a managed cluster with automatically managed replicas.",
3402 ),
3403 (
3404 "size",
3405 "If the cluster is managed, the desired size of the cluster's replicas. `NULL` for unmanaged clusters.",
3406 ),
3407 (
3408 "replication_factor",
3409 "If the cluster is managed, the desired number of replicas of the cluster. `NULL` for unmanaged clusters.",
3410 ),
3411 (
3412 "disk",
3413 "Unstable If the cluster is managed, `true` if the replicas have the `DISK` option . `NULL` for unmanaged clusters.",
3414 ),
3415 (
3416 "availability_zones",
3417 "Unstable If the cluster is managed, the list of availability zones specified in `AVAILABILITY ZONES`. `NULL` for unmanaged clusters.",
3418 ),
3419 (
3420 "introspection_debugging",
3421 "Whether introspection of the gathering of the introspection data is enabled.",
3422 ),
3423 (
3424 "introspection_interval",
3425 "The interval at which to collect introspection data.",
3426 ),
3427 ]),
3428 is_retained_metrics_object: false,
3429 access: vec![PUBLIC_SELECT],
3430});
3431
3432pub static MZ_CLUSTER_WORKLOAD_CLASSES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3433 name: "mz_cluster_workload_classes",
3434 schema: MZ_INTERNAL_SCHEMA,
3435 oid: oid::TABLE_MZ_CLUSTER_WORKLOAD_CLASSES_OID,
3436 desc: RelationDesc::builder()
3437 .with_column("id", SqlScalarType::String.nullable(false))
3438 .with_column("workload_class", SqlScalarType::String.nullable(true))
3439 .with_key(vec![0])
3440 .finish(),
3441 column_comments: BTreeMap::new(),
3442 is_retained_metrics_object: false,
3443 access: vec![PUBLIC_SELECT],
3444});
3445
3446pub const MZ_CLUSTER_WORKLOAD_CLASSES_IND: BuiltinIndex = BuiltinIndex {
3447 name: "mz_cluster_workload_classes_ind",
3448 schema: MZ_INTERNAL_SCHEMA,
3449 oid: oid::INDEX_MZ_CLUSTER_WORKLOAD_CLASSES_IND_OID,
3450 sql: "IN CLUSTER mz_catalog_server
3451ON mz_internal.mz_cluster_workload_classes (id)",
3452 is_retained_metrics_object: false,
3453};
3454
3455pub static MZ_CLUSTER_SCHEDULES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3456 name: "mz_cluster_schedules",
3457 schema: MZ_INTERNAL_SCHEMA,
3458 oid: oid::TABLE_MZ_CLUSTER_SCHEDULES_OID,
3459 desc: RelationDesc::builder()
3460 .with_column("cluster_id", SqlScalarType::String.nullable(false))
3461 .with_column("type", SqlScalarType::String.nullable(false))
3462 .with_column(
3463 "refresh_hydration_time_estimate",
3464 SqlScalarType::Interval.nullable(true),
3465 )
3466 .finish(),
3467 column_comments: BTreeMap::from_iter([
3468 (
3469 "cluster_id",
3470 "The ID of the cluster. Corresponds to `mz_clusters.id`.",
3471 ),
3472 ("type", "`on-refresh`, or `manual`. Default: `manual`"),
3473 (
3474 "refresh_hydration_time_estimate",
3475 "The interval given in the `HYDRATION TIME ESTIMATE` option.",
3476 ),
3477 ]),
3478 is_retained_metrics_object: false,
3479 access: vec![PUBLIC_SELECT],
3480});
3481
3482pub static MZ_SECRETS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3483 name: "mz_secrets",
3484 schema: MZ_CATALOG_SCHEMA,
3485 oid: oid::TABLE_MZ_SECRETS_OID,
3486 desc: RelationDesc::builder()
3487 .with_column("id", SqlScalarType::String.nullable(false))
3488 .with_column("oid", SqlScalarType::Oid.nullable(false))
3489 .with_column("schema_id", SqlScalarType::String.nullable(false))
3490 .with_column("name", SqlScalarType::String.nullable(false))
3491 .with_column("owner_id", SqlScalarType::String.nullable(false))
3492 .with_column(
3493 "privileges",
3494 SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false),
3495 )
3496 .finish(),
3497 column_comments: BTreeMap::from_iter([
3498 ("id", "The unique ID of the secret."),
3499 (
3500 "oid",
3501 "A [PostgreSQL-compatible oid][`oid`] for the secret.",
3502 ),
3503 (
3504 "schema_id",
3505 "The ID of the schema to which the secret belongs. Corresponds to `mz_schemas.id`.",
3506 ),
3507 ("name", "The name of the secret."),
3508 (
3509 "owner_id",
3510 "The role ID of the owner of the secret. Corresponds to `mz_roles.id`.",
3511 ),
3512 ("privileges", "The privileges belonging to the secret."),
3513 ]),
3514 is_retained_metrics_object: false,
3515 access: vec![PUBLIC_SELECT],
3516});
3517
3518pub static MZ_CLUSTER_REPLICAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3519 name: "mz_cluster_replicas",
3520 schema: MZ_CATALOG_SCHEMA,
3521 oid: oid::TABLE_MZ_CLUSTER_REPLICAS_OID,
3522 desc: RelationDesc::builder()
3523 .with_column("id", SqlScalarType::String.nullable(false))
3524 .with_column("name", SqlScalarType::String.nullable(false))
3525 .with_column("cluster_id", SqlScalarType::String.nullable(false))
3526 .with_column("size", SqlScalarType::String.nullable(true))
3527 .with_column("availability_zone", SqlScalarType::String.nullable(true))
3530 .with_column("owner_id", SqlScalarType::String.nullable(false))
3531 .with_column("disk", SqlScalarType::Bool.nullable(true))
3532 .finish(),
3533 column_comments: BTreeMap::from_iter([
3534 ("id", "Materialize's unique ID for the cluster replica."),
3535 ("name", "The name of the cluster replica."),
3536 (
3537 "cluster_id",
3538 "The ID of the cluster to which the replica belongs. Corresponds to `mz_clusters.id`.",
3539 ),
3540 (
3541 "size",
3542 "The cluster replica's size, selected during creation.",
3543 ),
3544 (
3545 "availability_zone",
3546 "The availability zone in which the cluster is running.",
3547 ),
3548 (
3549 "owner_id",
3550 "The role ID of the owner of the cluster replica. Corresponds to `mz_roles.id`.",
3551 ),
3552 ("disk", "If the replica has a local disk."),
3553 ]),
3554 is_retained_metrics_object: true,
3555 access: vec![PUBLIC_SELECT],
3556});
3557
3558pub static MZ_INTERNAL_CLUSTER_REPLICAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3559 name: "mz_internal_cluster_replicas",
3560 schema: MZ_INTERNAL_SCHEMA,
3561 oid: oid::TABLE_MZ_INTERNAL_CLUSTER_REPLICAS_OID,
3562 desc: RelationDesc::builder()
3563 .with_column("id", SqlScalarType::String.nullable(false))
3564 .finish(),
3565 column_comments: BTreeMap::from_iter([(
3566 "id",
3567 "The ID of a cluster replica. Corresponds to `mz_cluster_replicas.id`.",
3568 )]),
3569 is_retained_metrics_object: false,
3570 access: vec![PUBLIC_SELECT],
3571});
3572
3573pub static MZ_PENDING_CLUSTER_REPLICAS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3574 name: "mz_pending_cluster_replicas",
3575 schema: MZ_INTERNAL_SCHEMA,
3576 oid: oid::TABLE_MZ_PENDING_CLUSTER_REPLICAS_OID,
3577 desc: RelationDesc::builder()
3578 .with_column("id", SqlScalarType::String.nullable(false))
3579 .finish(),
3580 column_comments: BTreeMap::from_iter([(
3581 "id",
3582 "The ID of a cluster replica. Corresponds to `mz_cluster_replicas.id`.",
3583 )]),
3584 is_retained_metrics_object: false,
3585 access: vec![PUBLIC_SELECT],
3586});
3587
3588pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| {
3589 BuiltinSource {
3590 name: "mz_cluster_replica_status_history",
3591 schema: MZ_INTERNAL_SCHEMA,
3592 oid: oid::SOURCE_MZ_CLUSTER_REPLICA_STATUS_HISTORY_OID,
3593 data_source: IntrospectionType::ReplicaStatusHistory,
3594 desc: REPLICA_STATUS_HISTORY_DESC.clone(),
3595 column_comments: BTreeMap::from_iter([
3596 ("replica_id", "The ID of a cluster replica."),
3597 ("process_id", "The ID of a process within the replica."),
3598 (
3599 "status",
3600 "The status of the cluster replica: `online` or `offline`.",
3601 ),
3602 (
3603 "reason",
3604 "If the cluster replica is in an `offline` state, the reason (if available). For example, `oom-killed`.",
3605 ),
3606 (
3607 "occurred_at",
3608 "Wall-clock timestamp at which the event occurred.",
3609 ),
3610 ]),
3611 is_retained_metrics_object: false,
3612 access: vec![PUBLIC_SELECT],
3613 }
3614});
3615
3616pub static MZ_CLUSTER_REPLICA_STATUS_HISTORY_CT: LazyLock<BuiltinContinualTask> = LazyLock::new(
3617 || {
3618 BuiltinContinualTask {
3619 name: "mz_cluster_replica_status_history_ct",
3620 schema: MZ_INTERNAL_SCHEMA,
3621 oid: oid::CT_MZ_CLUSTER_REPLICA_STATUS_HISTORY_OID,
3622 desc: REPLICA_STATUS_HISTORY_DESC.clone(),
3623 sql: "
3624IN CLUSTER mz_catalog_server
3625ON INPUT mz_internal.mz_cluster_replica_status_history AS (
3626 DELETE FROM mz_internal.mz_cluster_replica_status_history_ct WHERE occurred_at + '30d' < mz_now();
3627 INSERT INTO mz_internal.mz_cluster_replica_status_history_ct SELECT * FROM mz_internal.mz_cluster_replica_status_history;
3628)",
3629 access: vec![PUBLIC_SELECT],
3630 }
3631 },
3632);
3633
3634pub static MZ_CLUSTER_REPLICA_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
3635 name: "mz_cluster_replica_statuses",
3636 schema: MZ_INTERNAL_SCHEMA,
3637 oid: oid::VIEW_MZ_CLUSTER_REPLICA_STATUSES_OID,
3638 desc: RelationDesc::builder()
3639 .with_column("replica_id", SqlScalarType::String.nullable(false))
3640 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
3641 .with_column("status", SqlScalarType::String.nullable(false))
3642 .with_column("reason", SqlScalarType::String.nullable(true))
3643 .with_column(
3644 "updated_at",
3645 SqlScalarType::TimestampTz { precision: None }.nullable(false),
3646 )
3647 .with_key(vec![0, 1])
3648 .finish(),
3649 column_comments: BTreeMap::from_iter([
3650 (
3651 "replica_id",
3652 "Materialize's unique ID for the cluster replica.",
3653 ),
3654 (
3655 "process_id",
3656 "The ID of the process within the cluster replica.",
3657 ),
3658 (
3659 "status",
3660 "The status of the cluster replica: `online` or `offline`.",
3661 ),
3662 (
3663 "reason",
3664 "If the cluster replica is in a `offline` state, the reason (if available). For example, `oom-killed`.",
3665 ),
3666 (
3667 "updated_at",
3668 "The time at which the status was last updated.",
3669 ),
3670 ]),
3671 sql: "
3672SELECT
3673 DISTINCT ON (replica_id, process_id)
3674 replica_id,
3675 process_id,
3676 status,
3677 reason,
3678 occurred_at as updated_at
3679FROM mz_internal.mz_cluster_replica_status_history
3680JOIN mz_cluster_replicas r ON r.id = replica_id
3681ORDER BY replica_id, process_id, occurred_at DESC",
3682 access: vec![PUBLIC_SELECT],
3683});
3684
3685pub static MZ_CLUSTER_REPLICA_SIZES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3686 name: "mz_cluster_replica_sizes",
3687 schema: MZ_CATALOG_SCHEMA,
3688 oid: oid::TABLE_MZ_CLUSTER_REPLICA_SIZES_OID,
3689 desc: RelationDesc::builder()
3690 .with_column("size", SqlScalarType::String.nullable(false))
3691 .with_column("processes", SqlScalarType::UInt64.nullable(false))
3692 .with_column("workers", SqlScalarType::UInt64.nullable(false))
3693 .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(false))
3694 .with_column("memory_bytes", SqlScalarType::UInt64.nullable(false))
3695 .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true))
3696 .with_column(
3697 "credits_per_hour",
3698 SqlScalarType::Numeric { max_scale: None }.nullable(false),
3699 )
3700 .finish(),
3701 column_comments: BTreeMap::from_iter([
3702 ("size", "The human-readable replica size."),
3703 ("processes", "The number of processes in the replica."),
3704 (
3705 "workers",
3706 "The number of Timely Dataflow workers per process.",
3707 ),
3708 (
3709 "cpu_nano_cores",
3710 "The CPU allocation per process, in billionths of a vCPU core.",
3711 ),
3712 (
3713 "memory_bytes",
3714 "The RAM allocation per process, in billionths of a vCPU core.",
3715 ),
3716 ("disk_bytes", "The disk allocation per process."),
3717 (
3718 "credits_per_hour",
3719 "The number of compute credits consumed per hour.",
3720 ),
3721 ]),
3722 is_retained_metrics_object: true,
3723 access: vec![PUBLIC_SELECT],
3724});
3725
3726pub static MZ_AUDIT_EVENTS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
3727 name: "mz_audit_events",
3728 schema: MZ_CATALOG_SCHEMA,
3729 oid: oid::TABLE_MZ_AUDIT_EVENTS_OID,
3730 desc: RelationDesc::builder()
3731 .with_column("id", SqlScalarType::UInt64.nullable(false))
3732 .with_column("event_type", SqlScalarType::String.nullable(false))
3733 .with_column("object_type", SqlScalarType::String.nullable(false))
3734 .with_column("details", SqlScalarType::Jsonb.nullable(false))
3735 .with_column("user", SqlScalarType::String.nullable(true))
3736 .with_column(
3737 "occurred_at",
3738 SqlScalarType::TimestampTz { precision: None }.nullable(false),
3739 )
3740 .with_key(vec![0])
3741 .finish(),
3742 column_comments: BTreeMap::from_iter([
3743 (
3744 "id",
3745 "Materialize's unique, monotonically increasing ID for the event.",
3746 ),
3747 (
3748 "event_type",
3749 "The type of the event: `create`, `drop`, or `alter`.",
3750 ),
3751 (
3752 "object_type",
3753 "The type of the affected object: `cluster`, `cluster-replica`, `connection`, `database`, `function`, `index`, `materialized-view`, `role`, `schema`, `secret`, `sink`, `source`, `table`, `type`, or `view`.",
3754 ),
3755 (
3756 "details",
3757 "Additional details about the event. The shape of the details varies based on `event_type` and `object_type`.",
3758 ),
3759 (
3760 "user",
3761 "The user who triggered the event, or `NULL` if triggered by the system.",
3762 ),
3763 (
3764 "occurred_at",
3765 "The time at which the event occurred. Guaranteed to be in order of event creation. Events created in the same transaction will have identical values.",
3766 ),
3767 ]),
3768 is_retained_metrics_object: false,
3769 access: vec![PUBLIC_SELECT],
3770});
3771
3772pub static MZ_SOURCE_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
3773 name: "mz_source_status_history",
3774 schema: MZ_INTERNAL_SCHEMA,
3775 oid: oid::SOURCE_MZ_SOURCE_STATUS_HISTORY_OID,
3776 data_source: IntrospectionType::SourceStatusHistory,
3777 desc: MZ_SOURCE_STATUS_HISTORY_DESC.clone(),
3778 column_comments: BTreeMap::from_iter([
3779 (
3780 "occurred_at",
3781 "Wall-clock timestamp of the source status change.",
3782 ),
3783 (
3784 "source_id",
3785 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
3786 ),
3787 (
3788 "status",
3789 "The status of the source: one of `created`, `starting`, `running`, `paused`, `stalled`, `failed`, or `dropped`.",
3790 ),
3791 (
3792 "error",
3793 "If the source is in an error state, the error message.",
3794 ),
3795 (
3796 "details",
3797 "Additional metadata provided by the source. In case of error, may contain a `hint` field with helpful suggestions.",
3798 ),
3799 (
3800 "replica_id",
3801 "The ID of the replica that an instance of a source is running on.",
3802 ),
3803 ]),
3804 is_retained_metrics_object: false,
3805 access: vec![PUBLIC_SELECT],
3806});
3807
3808pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(
3809 || BuiltinSource {
3810 name: "mz_aws_privatelink_connection_status_history",
3811 schema: MZ_INTERNAL_SCHEMA,
3812 oid: oid::SOURCE_MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_OID,
3813 data_source: IntrospectionType::PrivatelinkConnectionStatusHistory,
3814 desc: MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_DESC.clone(),
3815 column_comments: BTreeMap::from_iter([
3816 ("occurred_at", "Wall-clock timestamp of the status change."),
3817 (
3818 "connection_id",
3819 "The unique identifier of the AWS PrivateLink connection. Corresponds to `mz_catalog.mz_connections.id`.",
3820 ),
3821 (
3822 "status",
3823 "The status of the connection: one of `pending-service-discovery`, `creating-endpoint`, `recreating-endpoint`, `updating-endpoint`, `available`, `deleted`, `deleting`, `expired`, `failed`, `pending`, `pending-acceptance`, `rejected`, or `unknown`.",
3824 ),
3825 ]),
3826 is_retained_metrics_object: false,
3827 access: vec![PUBLIC_SELECT],
3828 },
3829);
3830
3831pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUSES: LazyLock<BuiltinView> =
3832 LazyLock::new(|| BuiltinView {
3833 name: "mz_aws_privatelink_connection_statuses",
3834 schema: MZ_INTERNAL_SCHEMA,
3835 oid: oid::VIEW_MZ_AWS_PRIVATELINK_CONNECTION_STATUSES_OID,
3836 desc: RelationDesc::builder()
3837 .with_column("id", SqlScalarType::String.nullable(false))
3838 .with_column("name", SqlScalarType::String.nullable(false))
3839 .with_column(
3840 "last_status_change_at",
3841 SqlScalarType::TimestampTz { precision: None }.nullable(true),
3842 )
3843 .with_column("status", SqlScalarType::String.nullable(true))
3844 .with_key(vec![0])
3845 .finish(),
3846 column_comments: BTreeMap::from_iter([
3847 (
3848 "id",
3849 "The ID of the connection. Corresponds to `mz_catalog.mz_connections.id`.",
3850 ),
3851 ("name", "The name of the connection."),
3852 (
3853 "last_status_change_at",
3854 "Wall-clock timestamp of the connection status change.",
3855 ),
3856 ("status", ""),
3857 ]),
3858 sql: "
3859 WITH statuses_w_last_status AS (
3860 SELECT
3861 connection_id,
3862 occurred_at,
3863 status,
3864 lag(status) OVER (PARTITION BY connection_id ORDER BY occurred_at) AS last_status
3865 FROM mz_internal.mz_aws_privatelink_connection_status_history
3866 ),
3867 latest_events AS (
3868 -- Only take the most recent transition for each ID
3869 SELECT DISTINCT ON(connection_id) connection_id, occurred_at, status
3870 FROM statuses_w_last_status
3871 -- Only keep first status transitions
3872 WHERE status <> last_status OR last_status IS NULL
3873 ORDER BY connection_id, occurred_at DESC
3874 )
3875 SELECT
3876 conns.id,
3877 name,
3878 occurred_at as last_status_change_at,
3879 status
3880 FROM latest_events
3881 JOIN mz_catalog.mz_connections AS conns
3882 ON conns.id = latest_events.connection_id",
3883 access: vec![PUBLIC_SELECT],
3884 });
3885
3886pub static MZ_STATEMENT_EXECUTION_HISTORY: LazyLock<BuiltinSource> =
3887 LazyLock::new(|| BuiltinSource {
3888 name: "mz_statement_execution_history",
3889 schema: MZ_INTERNAL_SCHEMA,
3890 oid: oid::SOURCE_MZ_STATEMENT_EXECUTION_HISTORY_OID,
3891 data_source: IntrospectionType::StatementExecutionHistory,
3892 desc: MZ_STATEMENT_EXECUTION_HISTORY_DESC.clone(),
3893 column_comments: BTreeMap::new(),
3894 is_retained_metrics_object: false,
3895 access: vec![MONITOR_SELECT],
3896 });
3897
3898pub static MZ_STATEMENT_EXECUTION_HISTORY_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| {
3899 BuiltinView {
3900 name: "mz_statement_execution_history_redacted",
3901 schema: MZ_INTERNAL_SCHEMA,
3902 oid: oid::VIEW_MZ_STATEMENT_EXECUTION_HISTORY_REDACTED_OID,
3903 desc: RelationDesc::builder()
3905 .with_column("id", SqlScalarType::Uuid.nullable(false))
3906 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
3907 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
3908 .with_column("cluster_id", SqlScalarType::String.nullable(true))
3909 .with_column("application_name", SqlScalarType::String.nullable(false))
3910 .with_column("cluster_name", SqlScalarType::String.nullable(true))
3911 .with_column("database_name", SqlScalarType::String.nullable(false))
3912 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
3913 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
3914 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
3915 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
3916 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
3917 .with_column("mz_version", SqlScalarType::String.nullable(false))
3918 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
3919 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
3920 .with_column("finished_status", SqlScalarType::String.nullable(true))
3921 .with_column("result_size", SqlScalarType::Int64.nullable(true))
3922 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
3923 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
3924 .finish(),
3925 column_comments: BTreeMap::new(),
3926 sql: "
3927SELECT id, prepared_statement_id, sample_rate, cluster_id, application_name,
3928cluster_name, database_name, search_path, transaction_isolation, execution_timestamp, transaction_id,
3929transient_index_id, mz_version, began_at, finished_at, finished_status,
3930result_size, rows_returned, execution_strategy
3931FROM mz_internal.mz_statement_execution_history",
3932 access: vec![SUPPORT_SELECT, ANALYTICS_SELECT, MONITOR_REDACTED_SELECT, MONITOR_SELECT],
3933}
3934});
3935
3936pub static MZ_PREPARED_STATEMENT_HISTORY: LazyLock<BuiltinSource> =
3937 LazyLock::new(|| BuiltinSource {
3938 name: "mz_prepared_statement_history",
3939 schema: MZ_INTERNAL_SCHEMA,
3940 oid: oid::SOURCE_MZ_PREPARED_STATEMENT_HISTORY_OID,
3941 data_source: IntrospectionType::PreparedStatementHistory,
3942 desc: MZ_PREPARED_STATEMENT_HISTORY_DESC.clone(),
3943 column_comments: BTreeMap::new(),
3944 is_retained_metrics_object: false,
3945 access: vec![
3946 SUPPORT_SELECT,
3947 ANALYTICS_SELECT,
3948 MONITOR_REDACTED_SELECT,
3949 MONITOR_SELECT,
3950 ],
3951 });
3952
3953pub static MZ_SQL_TEXT: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
3954 name: "mz_sql_text",
3955 schema: MZ_INTERNAL_SCHEMA,
3956 oid: oid::SOURCE_MZ_SQL_TEXT_OID,
3957 desc: MZ_SQL_TEXT_DESC.clone(),
3958 data_source: IntrospectionType::SqlText,
3959 column_comments: BTreeMap::new(),
3960 is_retained_metrics_object: false,
3961 access: vec![MONITOR_SELECT],
3962});
3963
3964pub static MZ_SQL_TEXT_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
3965 name: "mz_sql_text_redacted",
3966 schema: MZ_INTERNAL_SCHEMA,
3967 oid: oid::VIEW_MZ_SQL_TEXT_REDACTED_OID,
3968 desc: RelationDesc::builder()
3969 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
3970 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
3971 .finish(),
3972 column_comments: BTreeMap::new(),
3973 sql: "SELECT sql_hash, redacted_sql FROM mz_internal.mz_sql_text",
3974 access: vec![
3975 MONITOR_SELECT,
3976 MONITOR_REDACTED_SELECT,
3977 SUPPORT_SELECT,
3978 ANALYTICS_SELECT,
3979 ],
3980});
3981
3982pub static MZ_RECENT_SQL_TEXT: LazyLock<BuiltinView> = LazyLock::new(|| {
3983 BuiltinView {
3984 name: "mz_recent_sql_text",
3985 schema: MZ_INTERNAL_SCHEMA,
3986 oid: oid::VIEW_MZ_RECENT_SQL_TEXT_OID,
3987 desc: RelationDesc::builder()
3992 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
3993 .with_column("sql", SqlScalarType::String.nullable(false))
3994 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
3995 .with_key(vec![0, 1, 2])
3996 .finish(),
3997 column_comments: BTreeMap::new(),
3998 sql: "SELECT DISTINCT sql_hash, sql, redacted_sql FROM mz_internal.mz_sql_text WHERE prepared_day + INTERVAL '4 days' >= mz_now()",
3999 access: vec![MONITOR_SELECT],
4000 }
4001});
4002
4003pub static MZ_RECENT_SQL_TEXT_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4004 name: "mz_recent_sql_text_redacted",
4005 schema: MZ_INTERNAL_SCHEMA,
4006 oid: oid::VIEW_MZ_RECENT_SQL_TEXT_REDACTED_OID,
4007 desc: RelationDesc::builder()
4008 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4009 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
4010 .finish(),
4011 column_comments: BTreeMap::new(),
4012 sql: "SELECT sql_hash, redacted_sql FROM mz_internal.mz_recent_sql_text",
4013 access: vec![
4014 MONITOR_SELECT,
4015 MONITOR_REDACTED_SELECT,
4016 SUPPORT_SELECT,
4017 ANALYTICS_SELECT,
4018 ],
4019});
4020
4021pub static MZ_RECENT_SQL_TEXT_IND: LazyLock<BuiltinIndex> = LazyLock::new(|| BuiltinIndex {
4022 name: "mz_recent_sql_text_ind",
4023 schema: MZ_INTERNAL_SCHEMA,
4024 oid: oid::INDEX_MZ_RECENT_SQL_TEXT_IND_OID,
4025 sql: "IN CLUSTER mz_catalog_server ON mz_internal.mz_recent_sql_text (sql_hash)",
4026 is_retained_metrics_object: false,
4027});
4028
4029pub static MZ_SESSION_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
4030 name: "mz_session_history",
4031 schema: MZ_INTERNAL_SCHEMA,
4032 oid: oid::SOURCE_MZ_SESSION_HISTORY_OID,
4033 data_source: IntrospectionType::SessionHistory,
4034 desc: MZ_SESSION_HISTORY_DESC.clone(),
4035 column_comments: BTreeMap::new(),
4036 is_retained_metrics_object: false,
4037 access: vec![PUBLIC_SELECT],
4038});
4039
4040pub static MZ_ACTIVITY_LOG_THINNED: LazyLock<BuiltinView> = LazyLock::new(|| {
4041 BuiltinView {
4042 name: "mz_activity_log_thinned",
4043 schema: MZ_INTERNAL_SCHEMA,
4044 oid: oid::VIEW_MZ_ACTIVITY_LOG_THINNED_OID,
4045 desc: RelationDesc::builder()
4046 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4047 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4048 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4049 .with_column("application_name", SqlScalarType::String.nullable(false))
4050 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4051 .with_column("database_name", SqlScalarType::String.nullable(false))
4052 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
4053 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
4054 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4055 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4056 .with_column("params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false))
4057 .with_column("mz_version", SqlScalarType::String.nullable(false))
4058 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4059 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
4060 .with_column("finished_status", SqlScalarType::String.nullable(true))
4061 .with_column("error_message", SqlScalarType::String.nullable(true))
4062 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4063 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4064 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4065 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4066 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4067 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4068 .with_column("prepared_statement_name", SqlScalarType::String.nullable(false))
4069 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4070 .with_column("prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4071 .with_column("statement_type", SqlScalarType::String.nullable(true))
4072 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4073 .with_column("connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4074 .with_column("initial_application_name", SqlScalarType::String.nullable(false))
4075 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4076 .finish(),
4077 column_comments: BTreeMap::new(),
4078 sql: "
4079SELECT mseh.id AS execution_id, sample_rate, cluster_id, application_name, cluster_name, database_name, search_path,
4080transaction_isolation, execution_timestamp, transient_index_id, params, mz_version, began_at, finished_at, finished_status,
4081error_message, result_size, rows_returned, execution_strategy, transaction_id,
4082mpsh.id AS prepared_statement_id, sql_hash, mpsh.name AS prepared_statement_name,
4083mpsh.session_id, prepared_at, statement_type, throttled_count,
4084connected_at, initial_application_name, authenticated_user
4085FROM mz_internal.mz_statement_execution_history mseh,
4086 mz_internal.mz_prepared_statement_history mpsh,
4087 mz_internal.mz_session_history msh
4088WHERE mseh.prepared_statement_id = mpsh.id
4089AND mpsh.session_id = msh.session_id",
4090 access: vec![MONITOR_SELECT],
4091 }
4092});
4093
4094pub static MZ_RECENT_ACTIVITY_LOG_THINNED: LazyLock<BuiltinView> = LazyLock::new(|| {
4095 BuiltinView {
4096 name: "mz_recent_activity_log_thinned",
4097 schema: MZ_INTERNAL_SCHEMA,
4098 oid: oid::VIEW_MZ_RECENT_ACTIVITY_LOG_THINNED_OID,
4099 desc: RelationDesc::builder()
4100 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4101 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4102 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4103 .with_column("application_name", SqlScalarType::String.nullable(false))
4104 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4105 .with_column("database_name", SqlScalarType::String.nullable(false))
4106 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
4107 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
4108 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4109 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4110 .with_column("params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false))
4111 .with_column("mz_version", SqlScalarType::String.nullable(false))
4112 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4113 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
4114 .with_column("finished_status", SqlScalarType::String.nullable(true))
4115 .with_column("error_message", SqlScalarType::String.nullable(true))
4116 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4117 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4118 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4119 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4120 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4121 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4122 .with_column("prepared_statement_name", SqlScalarType::String.nullable(false))
4123 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4124 .with_column("prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4125 .with_column("statement_type", SqlScalarType::String.nullable(true))
4126 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4127 .with_column("connected_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4128 .with_column("initial_application_name", SqlScalarType::String.nullable(false))
4129 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4130 .finish(),
4131 column_comments: BTreeMap::new(),
4132 sql:
4135 "SELECT * FROM mz_internal.mz_activity_log_thinned WHERE prepared_at + INTERVAL '1 day' > mz_now()
4136AND began_at + INTERVAL '1 day' > mz_now() AND connected_at + INTERVAL '2 days' > mz_now()",
4137 access: vec![MONITOR_SELECT],
4138 }
4139});
4140
4141pub static MZ_RECENT_ACTIVITY_LOG: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4142 name: "mz_recent_activity_log",
4143 schema: MZ_INTERNAL_SCHEMA,
4144 oid: oid::VIEW_MZ_RECENT_ACTIVITY_LOG_OID,
4145 desc: RelationDesc::builder()
4146 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4147 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4148 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4149 .with_column("application_name", SqlScalarType::String.nullable(false))
4150 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4151 .with_column("database_name", SqlScalarType::String.nullable(false))
4152 .with_column(
4153 "search_path",
4154 SqlScalarType::List {
4155 element_type: Box::new(SqlScalarType::String),
4156 custom_id: None,
4157 }
4158 .nullable(false),
4159 )
4160 .with_column(
4161 "transaction_isolation",
4162 SqlScalarType::String.nullable(false),
4163 )
4164 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4165 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4166 .with_column(
4167 "params",
4168 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
4169 )
4170 .with_column("mz_version", SqlScalarType::String.nullable(false))
4171 .with_column(
4172 "began_at",
4173 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4174 )
4175 .with_column(
4176 "finished_at",
4177 SqlScalarType::TimestampTz { precision: None }.nullable(true),
4178 )
4179 .with_column("finished_status", SqlScalarType::String.nullable(true))
4180 .with_column("error_message", SqlScalarType::String.nullable(true))
4181 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4182 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4183 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4184 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4185 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4186 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4187 .with_column(
4188 "prepared_statement_name",
4189 SqlScalarType::String.nullable(false),
4190 )
4191 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4192 .with_column(
4193 "prepared_at",
4194 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4195 )
4196 .with_column("statement_type", SqlScalarType::String.nullable(true))
4197 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4198 .with_column(
4199 "connected_at",
4200 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4201 )
4202 .with_column(
4203 "initial_application_name",
4204 SqlScalarType::String.nullable(false),
4205 )
4206 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4207 .with_column("sql", SqlScalarType::String.nullable(false))
4208 .finish(),
4209 column_comments: BTreeMap::from_iter([
4210 (
4211 "execution_id",
4212 "An ID that is unique for each executed statement.",
4213 ),
4214 (
4215 "sample_rate",
4216 "The actual rate at which the statement was sampled.",
4217 ),
4218 (
4219 "cluster_id",
4220 "The ID of the cluster the statement execution was directed to. Corresponds to mz_clusters.id.",
4221 ),
4222 (
4223 "application_name",
4224 "The value of the `application_name` configuration parameter at execution time.",
4225 ),
4226 (
4227 "cluster_name",
4228 "The name of the cluster with ID `cluster_id` at execution time.",
4229 ),
4230 (
4231 "database_name",
4232 "The value of the `database` configuration parameter at execution time.",
4233 ),
4234 (
4235 "search_path",
4236 "The value of the `search_path` configuration parameter at execution time.",
4237 ),
4238 (
4239 "transaction_isolation",
4240 "The value of the `transaction_isolation` configuration parameter at execution time.",
4241 ),
4242 (
4243 "execution_timestamp",
4244 "The logical timestamp at which execution was scheduled.",
4245 ),
4246 (
4247 "transient_index_id",
4248 "The internal index of the compute dataflow created for the query, if any.",
4249 ),
4250 (
4251 "params",
4252 "The parameters with which the statement was executed.",
4253 ),
4254 (
4255 "mz_version",
4256 "The version of Materialize that was running when the statement was executed.",
4257 ),
4258 (
4259 "began_at",
4260 "The wall-clock time at which the statement began executing.",
4261 ),
4262 (
4263 "finished_at",
4264 "The wall-clock time at which the statement finished executing.",
4265 ),
4266 (
4267 "finished_status",
4268 "The final status of the statement (e.g., `success`, `canceled`, `error`, or `aborted`). `aborted` means that Materialize exited before the statement finished executing.",
4269 ),
4270 (
4271 "error_message",
4272 "The error message, if the statement failed.",
4273 ),
4274 (
4275 "result_size",
4276 "The size in bytes of the result, for statements that return rows.",
4277 ),
4278 (
4279 "rows_returned",
4280 "The number of rows returned, for statements that return rows.",
4281 ),
4282 (
4283 "execution_strategy",
4284 "For `SELECT` queries, the strategy for executing the query. `constant` means computed in the control plane without the involvement of a cluster, `fast-path` means read by a cluster directly from an in-memory index, and `standard` means computed by a temporary dataflow.",
4285 ),
4286 (
4287 "transaction_id",
4288 "The ID of the transaction that the statement was part of. Note that transaction IDs are only unique per session.",
4289 ),
4290 (
4291 "prepared_statement_id",
4292 "An ID that is unique for each prepared statement. For example, if a statement is prepared once and then executed multiple times, all executions will have the same value for this column (but different values for `execution_id`).",
4293 ),
4294 (
4295 "sql_hash",
4296 "An opaque value uniquely identifying the text of the query.",
4297 ),
4298 (
4299 "prepared_statement_name",
4300 "The name given by the client library to the prepared statement.",
4301 ),
4302 (
4303 "session_id",
4304 "An ID that is unique for each session. Corresponds to mz_sessions.id.",
4305 ),
4306 (
4307 "prepared_at",
4308 "The time at which the statement was prepared.",
4309 ),
4310 (
4311 "statement_type",
4312 "The type of the statement, e.g. `select` for a `SELECT` query, or `NULL` if the statement was empty.",
4313 ),
4314 (
4315 "throttled_count",
4316 "The number of statements that were dropped due to throttling before the current one was seen. If you have a very high volume of queries and need to log them without throttling, contact our team.",
4317 ),
4318 (
4319 "connected_at",
4320 "The time at which the session was established.",
4321 ),
4322 (
4323 "initial_application_name",
4324 "The initial value of `application_name` at the beginning of the session.",
4325 ),
4326 (
4327 "authenticated_user",
4328 "The name of the user for which the session was established.",
4329 ),
4330 ("sql", "The SQL text of the statement."),
4331 ]),
4332 sql: "SELECT mralt.*, mrst.sql
4333FROM mz_internal.mz_recent_activity_log_thinned mralt,
4334 mz_internal.mz_recent_sql_text mrst
4335WHERE mralt.sql_hash = mrst.sql_hash",
4336 access: vec![MONITOR_SELECT],
4337});
4338
4339pub static MZ_RECENT_ACTIVITY_LOG_REDACTED: LazyLock<BuiltinView> = LazyLock::new(|| {
4340 BuiltinView {
4341 name: "mz_recent_activity_log_redacted",
4342 schema: MZ_INTERNAL_SCHEMA,
4343 oid: oid::VIEW_MZ_RECENT_ACTIVITY_LOG_REDACTED_OID,
4344 desc: RelationDesc::builder()
4346 .with_column("execution_id", SqlScalarType::Uuid.nullable(false))
4347 .with_column("sample_rate", SqlScalarType::Float64.nullable(false))
4348 .with_column("cluster_id", SqlScalarType::String.nullable(true))
4349 .with_column("application_name", SqlScalarType::String.nullable(false))
4350 .with_column("cluster_name", SqlScalarType::String.nullable(true))
4351 .with_column("database_name", SqlScalarType::String.nullable(false))
4352 .with_column("search_path", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(false))
4353 .with_column("transaction_isolation", SqlScalarType::String.nullable(false))
4354 .with_column("execution_timestamp", SqlScalarType::UInt64.nullable(true))
4355 .with_column("transient_index_id", SqlScalarType::String.nullable(true))
4356 .with_column("params", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false))
4357 .with_column("mz_version", SqlScalarType::String.nullable(false))
4358 .with_column("began_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4359 .with_column("finished_at", SqlScalarType::TimestampTz { precision: None }.nullable(true))
4360 .with_column("finished_status", SqlScalarType::String.nullable(true))
4361 .with_column("result_size", SqlScalarType::Int64.nullable(true))
4362 .with_column("rows_returned", SqlScalarType::Int64.nullable(true))
4363 .with_column("execution_strategy", SqlScalarType::String.nullable(true))
4364 .with_column("transaction_id", SqlScalarType::UInt64.nullable(false))
4365 .with_column("prepared_statement_id", SqlScalarType::Uuid.nullable(false))
4366 .with_column("sql_hash", SqlScalarType::Bytes.nullable(false))
4367 .with_column("prepared_statement_name", SqlScalarType::String.nullable(false))
4368 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
4369 .with_column("prepared_at", SqlScalarType::TimestampTz { precision: None }.nullable(false))
4370 .with_column("statement_type", SqlScalarType::String.nullable(true))
4371 .with_column("throttled_count", SqlScalarType::UInt64.nullable(false))
4372 .with_column("initial_application_name", SqlScalarType::String.nullable(false))
4373 .with_column("authenticated_user", SqlScalarType::String.nullable(false))
4374 .with_column("redacted_sql", SqlScalarType::String.nullable(false))
4375 .finish(),
4376 column_comments: BTreeMap::new(),
4377 sql: "SELECT mralt.execution_id, mralt.sample_rate, mralt.cluster_id, mralt.application_name,
4378 mralt.cluster_name, mralt.database_name, mralt.search_path, mralt.transaction_isolation, mralt.execution_timestamp,
4379 mralt.transient_index_id, mralt.params, mralt.mz_version, mralt.began_at, mralt.finished_at,
4380 mralt.finished_status, mralt.result_size, mralt.rows_returned, mralt.execution_strategy, mralt.transaction_id,
4381 mralt.prepared_statement_id, mralt.sql_hash, mralt.prepared_statement_name, mralt.session_id,
4382 mralt.prepared_at, mralt.statement_type, mralt.throttled_count,
4383 mralt.initial_application_name, mralt.authenticated_user,
4384 mrst.redacted_sql
4385FROM mz_internal.mz_recent_activity_log_thinned mralt,
4386 mz_internal.mz_recent_sql_text mrst
4387WHERE mralt.sql_hash = mrst.sql_hash",
4388 access: vec![MONITOR_SELECT, MONITOR_REDACTED_SELECT, SUPPORT_SELECT, ANALYTICS_SELECT],
4389}
4390});
4391
4392pub static MZ_STATEMENT_LIFECYCLE_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| {
4393 BuiltinSource {
4394 name: "mz_statement_lifecycle_history",
4395 schema: MZ_INTERNAL_SCHEMA,
4396 oid: oid::SOURCE_MZ_STATEMENT_LIFECYCLE_HISTORY_OID,
4397 desc: RelationDesc::builder()
4398 .with_column("statement_id", SqlScalarType::Uuid.nullable(false))
4399 .with_column("event_type", SqlScalarType::String.nullable(false))
4400 .with_column(
4401 "occurred_at",
4402 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4403 )
4404 .finish(),
4405 data_source: IntrospectionType::StatementLifecycleHistory,
4406 column_comments: BTreeMap::from_iter([
4407 (
4408 "statement_id",
4409 "The ID of the execution event. Corresponds to `mz_recent_activity_log.execution_id`",
4410 ),
4411 (
4412 "event_type",
4413 "The type of lifecycle event, e.g. `'execution-began'`, `'storage-dependencies-finished'`, `'compute-dependencies-finished'`, or `'execution-finished'`",
4414 ),
4415 ("occurred_at", "The time at which the event took place."),
4416 ]),
4417 is_retained_metrics_object: false,
4418 access: vec![
4422 SUPPORT_SELECT,
4423 ANALYTICS_SELECT,
4424 MONITOR_REDACTED_SELECT,
4425 MONITOR_SELECT,
4426 ],
4427 }
4428});
4429
4430pub static MZ_SOURCE_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4431 name: "mz_source_statuses",
4432 schema: MZ_INTERNAL_SCHEMA,
4433 oid: oid::VIEW_MZ_SOURCE_STATUSES_OID,
4434 desc: RelationDesc::builder()
4435 .with_column("id", SqlScalarType::String.nullable(false))
4436 .with_column("name", SqlScalarType::String.nullable(false))
4437 .with_column("type", SqlScalarType::String.nullable(false))
4438 .with_column(
4439 "last_status_change_at",
4440 SqlScalarType::TimestampTz { precision: None }.nullable(true),
4441 )
4442 .with_column("status", SqlScalarType::String.nullable(false))
4443 .with_column("error", SqlScalarType::String.nullable(true))
4444 .with_column("details", SqlScalarType::Jsonb.nullable(true))
4445 .finish(),
4446 column_comments: BTreeMap::from_iter([
4447 (
4448 "id",
4449 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
4450 ),
4451 ("name", "The name of the source."),
4452 ("type", "The type of the source."),
4453 (
4454 "last_status_change_at",
4455 "Wall-clock timestamp of the source status change.",
4456 ),
4457 (
4458 "status",
4459 "The status of the source: one of `created`, `starting`, `running`, `paused`, `stalled`, `failed`, or `dropped`.",
4460 ),
4461 (
4462 "error",
4463 "If the source is in an error state, the error message.",
4464 ),
4465 (
4466 "details",
4467 "Additional metadata provided by the source. In case of error, may contain a `hint` field with helpful suggestions.",
4468 ),
4469 ]),
4470 sql: "
4471 WITH
4472 -- The status history contains per-replica events and source-global events.
4473 -- For the latter, replica_id is NULL. We turn these into '<source>', so that
4474 -- we can treat them uniformly below.
4475 uniform_status_history AS
4476 (
4477 SELECT
4478 s.source_id,
4479 COALESCE(s.replica_id, '<source>') as replica_id,
4480 s.occurred_at,
4481 s.status,
4482 s.error,
4483 s.details
4484 FROM mz_internal.mz_source_status_history s
4485 ),
4486 -- For getting the latest events, we first determine the latest per-replica
4487 -- events here and then apply precedence rules below.
4488 latest_per_replica_events AS
4489 (
4490 SELECT DISTINCT ON (source_id, replica_id)
4491 occurred_at, source_id, replica_id, status, error, details
4492 FROM uniform_status_history
4493 ORDER BY source_id, replica_id, occurred_at DESC
4494 ),
4495 -- We have a precedence list that determines the overall status in case
4496 -- there is differing per-replica (including source-global) statuses. If
4497 -- there is no 'dropped' status, and any replica reports 'running', the
4498 -- overall status is 'running' even if there might be some replica that has
4499 -- errors or is paused.
4500 latest_events AS
4501 (
4502 SELECT DISTINCT ON (source_id)
4503 source_id,
4504 occurred_at,
4505 status,
4506 error,
4507 details
4508 FROM latest_per_replica_events
4509 ORDER BY source_id, CASE status
4510 WHEN 'dropped' THEN 1
4511 WHEN 'running' THEN 2
4512 WHEN 'stalled' THEN 3
4513 WHEN 'starting' THEN 4
4514 WHEN 'paused' THEN 5
4515 WHEN 'ceased' THEN 6
4516 ELSE 7 -- For any other status values
4517 END
4518 ),
4519 -- Determine which sources are subsources and which are parent sources
4520 subsources AS
4521 (
4522 SELECT subsources.id AS self, sources.id AS parent
4523 FROM
4524 mz_catalog.mz_sources AS subsources
4525 JOIN
4526 mz_internal.mz_object_dependencies AS deps
4527 ON subsources.id = deps.object_id
4528 JOIN mz_catalog.mz_sources AS sources ON sources.id = deps.referenced_object_id
4529 ),
4530 -- Determine which sources are source tables
4531 tables AS
4532 (
4533 SELECT tables.id AS self, tables.source_id AS parent, tables.name
4534 FROM mz_catalog.mz_tables AS tables
4535 WHERE tables.source_id IS NOT NULL
4536 ),
4537 -- Determine which collection's ID to use for the status
4538 id_of_status_to_use AS
4539 (
4540 SELECT
4541 self_events.source_id,
4542 -- If self not errored, but parent is, use parent; else self
4543 CASE
4544 WHEN
4545 self_events.status <> 'ceased' AND
4546 parent_events.status = 'stalled'
4547 THEN parent_events.source_id
4548 ELSE self_events.source_id
4549 END AS id_to_use
4550 FROM
4551 latest_events AS self_events
4552 LEFT JOIN subsources ON self_events.source_id = subsources.self
4553 LEFT JOIN tables ON self_events.source_id = tables.self
4554 LEFT JOIN
4555 latest_events AS parent_events
4556 ON parent_events.source_id = COALESCE(subsources.parent, tables.parent)
4557 ),
4558 -- Swap out events for the ID of the event we plan to use instead
4559 latest_events_to_use AS
4560 (
4561 SELECT occurred_at, s.source_id, status, error, details
4562 FROM
4563 id_of_status_to_use AS s
4564 JOIN latest_events AS e ON e.source_id = s.id_to_use
4565 ),
4566 combined AS (
4567 SELECT
4568 mz_sources.id,
4569 mz_sources.name,
4570 mz_sources.type,
4571 occurred_at,
4572 status,
4573 error,
4574 details
4575 FROM
4576 mz_catalog.mz_sources
4577 LEFT JOIN latest_events_to_use AS e ON mz_sources.id = e.source_id
4578 UNION ALL
4579 SELECT
4580 tables.self AS id,
4581 tables.name,
4582 'table' AS type,
4583 occurred_at,
4584 status,
4585 error,
4586 details
4587 FROM
4588 tables
4589 LEFT JOIN latest_events_to_use AS e ON tables.self = e.source_id
4590 )
4591SELECT
4592 id,
4593 name,
4594 type,
4595 occurred_at AS last_status_change_at,
4596 -- TODO(parkmycar): Report status of webhook source once database-issues#5986 is closed.
4597 CASE
4598 WHEN
4599 type = 'webhook' OR
4600 type = 'progress'
4601 THEN 'running'
4602 ELSE COALESCE(status, 'created')
4603 END AS status,
4604 error,
4605 details
4606FROM combined
4607WHERE id NOT LIKE 's%';",
4608 access: vec![PUBLIC_SELECT],
4609});
4610
4611pub static MZ_SINK_STATUS_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
4612 name: "mz_sink_status_history",
4613 schema: MZ_INTERNAL_SCHEMA,
4614 oid: oid::SOURCE_MZ_SINK_STATUS_HISTORY_OID,
4615 data_source: IntrospectionType::SinkStatusHistory,
4616 desc: MZ_SINK_STATUS_HISTORY_DESC.clone(),
4617 column_comments: BTreeMap::from_iter([
4618 (
4619 "occurred_at",
4620 "Wall-clock timestamp of the sink status change.",
4621 ),
4622 (
4623 "sink_id",
4624 "The ID of the sink. Corresponds to `mz_catalog.mz_sinks.id`.",
4625 ),
4626 (
4627 "status",
4628 "The status of the sink: one of `created`, `starting`, `running`, `stalled`, `failed`, or `dropped`.",
4629 ),
4630 (
4631 "error",
4632 "If the sink is in an error state, the error message.",
4633 ),
4634 (
4635 "details",
4636 "Additional metadata provided by the sink. In case of error, may contain a `hint` field with helpful suggestions.",
4637 ),
4638 (
4639 "replica_id",
4640 "The ID of the replica that an instance of a sink is running on.",
4641 ),
4642 ]),
4643 is_retained_metrics_object: false,
4644 access: vec![PUBLIC_SELECT],
4645});
4646
4647pub static MZ_SINK_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4648 name: "mz_sink_statuses",
4649 schema: MZ_INTERNAL_SCHEMA,
4650 oid: oid::VIEW_MZ_SINK_STATUSES_OID,
4651 desc: RelationDesc::builder()
4652 .with_column("id", SqlScalarType::String.nullable(false))
4653 .with_column("name", SqlScalarType::String.nullable(false))
4654 .with_column("type", SqlScalarType::String.nullable(false))
4655 .with_column(
4656 "last_status_change_at",
4657 SqlScalarType::TimestampTz { precision: None }.nullable(true),
4658 )
4659 .with_column("status", SqlScalarType::String.nullable(false))
4660 .with_column("error", SqlScalarType::String.nullable(true))
4661 .with_column("details", SqlScalarType::Jsonb.nullable(true))
4662 .finish(),
4663 column_comments: BTreeMap::from_iter([
4664 (
4665 "id",
4666 "The ID of the sink. Corresponds to `mz_catalog.mz_sinks.id`.",
4667 ),
4668 ("name", "The name of the sink."),
4669 ("type", "The type of the sink."),
4670 (
4671 "last_status_change_at",
4672 "Wall-clock timestamp of the sink status change.",
4673 ),
4674 (
4675 "status",
4676 "The status of the sink: one of `created`, `starting`, `running`, `stalled`, `failed`, or `dropped`.",
4677 ),
4678 (
4679 "error",
4680 "If the sink is in an error state, the error message.",
4681 ),
4682 (
4683 "details",
4684 "Additional metadata provided by the sink. In case of error, may contain a `hint` field with helpful suggestions.",
4685 ),
4686 ]),
4687 sql: "
4688WITH
4689-- The status history contains per-replica events and sink-global events.
4690-- For the latter, replica_id is NULL. We turn these into '<sink>', so that
4691-- we can treat them uniformly below.
4692uniform_status_history AS
4693(
4694 SELECT
4695 s.sink_id,
4696 COALESCE(s.replica_id, '<sink>') as replica_id,
4697 s.occurred_at,
4698 s.status,
4699 s.error,
4700 s.details
4701 FROM mz_internal.mz_sink_status_history s
4702),
4703-- For getting the latest events, we first determine the latest per-replica
4704-- events here and then apply precedence rules below.
4705latest_per_replica_events AS
4706(
4707 SELECT DISTINCT ON (sink_id, replica_id)
4708 occurred_at, sink_id, replica_id, status, error, details
4709 FROM uniform_status_history
4710 ORDER BY sink_id, replica_id, occurred_at DESC
4711),
4712-- We have a precedence list that determines the overall status in case
4713-- there is differing per-replica (including sink-global) statuses. If
4714-- there is no 'dropped' status, and any replica reports 'running', the
4715-- overall status is 'running' even if there might be some replica that has
4716-- errors or is paused.
4717latest_events AS
4718(
4719 SELECT DISTINCT ON (sink_id)
4720 sink_id,
4721 occurred_at,
4722 status,
4723 error,
4724 details
4725 FROM latest_per_replica_events
4726 ORDER BY sink_id, CASE status
4727 WHEN 'dropped' THEN 1
4728 WHEN 'running' THEN 2
4729 WHEN 'stalled' THEN 3
4730 WHEN 'starting' THEN 4
4731 WHEN 'paused' THEN 5
4732 WHEN 'ceased' THEN 6
4733 ELSE 7 -- For any other status values
4734 END
4735)
4736SELECT
4737 mz_sinks.id,
4738 name,
4739 mz_sinks.type,
4740 occurred_at as last_status_change_at,
4741 coalesce(status, 'created') as status,
4742 error,
4743 details
4744FROM mz_catalog.mz_sinks
4745LEFT JOIN latest_events ON mz_sinks.id = latest_events.sink_id
4746WHERE
4747 -- This is a convenient way to filter out system sinks, like the status_history table itself.
4748 mz_sinks.id NOT LIKE 's%'",
4749 access: vec![PUBLIC_SELECT],
4750});
4751
4752pub static MZ_STORAGE_USAGE_BY_SHARD_DESCRIPTION: LazyLock<SystemObjectDescription> =
4753 LazyLock::new(|| SystemObjectDescription {
4754 schema_name: MZ_STORAGE_USAGE_BY_SHARD.schema.to_string(),
4755 object_type: CatalogItemType::Table,
4756 object_name: MZ_STORAGE_USAGE_BY_SHARD.name.to_string(),
4757 });
4758
4759pub static MZ_STORAGE_USAGE_BY_SHARD: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
4760 name: "mz_storage_usage_by_shard",
4761 schema: MZ_INTERNAL_SCHEMA,
4762 oid: oid::TABLE_MZ_STORAGE_USAGE_BY_SHARD_OID,
4763 desc: RelationDesc::builder()
4764 .with_column("id", SqlScalarType::UInt64.nullable(false))
4765 .with_column("shard_id", SqlScalarType::String.nullable(true))
4766 .with_column("size_bytes", SqlScalarType::UInt64.nullable(false))
4767 .with_column(
4768 "collection_timestamp",
4769 SqlScalarType::TimestampTz { precision: None }.nullable(false),
4770 )
4771 .finish(),
4772 column_comments: BTreeMap::new(),
4773 is_retained_metrics_object: false,
4774 access: vec![PUBLIC_SELECT],
4775});
4776
4777pub static MZ_EGRESS_IPS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
4778 name: "mz_egress_ips",
4779 schema: MZ_CATALOG_SCHEMA,
4780 oid: oid::TABLE_MZ_EGRESS_IPS_OID,
4781 desc: RelationDesc::builder()
4782 .with_column("egress_ip", SqlScalarType::String.nullable(false))
4783 .with_column("prefix_length", SqlScalarType::Int32.nullable(false))
4784 .with_column("cidr", SqlScalarType::String.nullable(false))
4785 .finish(),
4786 column_comments: BTreeMap::from_iter([
4787 ("egress_ip", "The start of the range of IP addresses."),
4788 (
4789 "prefix_length",
4790 "The number of leading bits in the CIDR netmask.",
4791 ),
4792 ("cidr", "The CIDR representation."),
4793 ]),
4794 is_retained_metrics_object: false,
4795 access: vec![PUBLIC_SELECT],
4796});
4797
4798pub static MZ_AWS_PRIVATELINK_CONNECTIONS: LazyLock<BuiltinTable> =
4799 LazyLock::new(|| BuiltinTable {
4800 name: "mz_aws_privatelink_connections",
4801 schema: MZ_CATALOG_SCHEMA,
4802 oid: oid::TABLE_MZ_AWS_PRIVATELINK_CONNECTIONS_OID,
4803 desc: RelationDesc::builder()
4804 .with_column("id", SqlScalarType::String.nullable(false))
4805 .with_column("principal", SqlScalarType::String.nullable(false))
4806 .finish(),
4807 column_comments: BTreeMap::from_iter([
4808 ("id", "The ID of the connection."),
4809 (
4810 "principal",
4811 "The AWS Principal that Materialize will use to connect to the VPC endpoint.",
4812 ),
4813 ]),
4814 is_retained_metrics_object: false,
4815 access: vec![PUBLIC_SELECT],
4816 });
4817
4818pub static MZ_AWS_CONNECTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
4819 name: "mz_aws_connections",
4820 schema: MZ_INTERNAL_SCHEMA,
4821 oid: oid::TABLE_MZ_AWS_CONNECTIONS_OID,
4822 desc: RelationDesc::builder()
4823 .with_column("id", SqlScalarType::String.nullable(false))
4824 .with_column("endpoint", SqlScalarType::String.nullable(true))
4825 .with_column("region", SqlScalarType::String.nullable(true))
4826 .with_column("access_key_id", SqlScalarType::String.nullable(true))
4827 .with_column(
4828 "access_key_id_secret_id",
4829 SqlScalarType::String.nullable(true),
4830 )
4831 .with_column(
4832 "secret_access_key_secret_id",
4833 SqlScalarType::String.nullable(true),
4834 )
4835 .with_column("session_token", SqlScalarType::String.nullable(true))
4836 .with_column(
4837 "session_token_secret_id",
4838 SqlScalarType::String.nullable(true),
4839 )
4840 .with_column("assume_role_arn", SqlScalarType::String.nullable(true))
4841 .with_column(
4842 "assume_role_session_name",
4843 SqlScalarType::String.nullable(true),
4844 )
4845 .with_column("principal", SqlScalarType::String.nullable(true))
4846 .with_column("external_id", SqlScalarType::String.nullable(true))
4847 .with_column("example_trust_policy", SqlScalarType::Jsonb.nullable(true))
4848 .finish(),
4849 column_comments: BTreeMap::from_iter([
4850 ("id", "The ID of the connection."),
4851 ("endpoint", "The value of the `ENDPOINT` option, if set."),
4852 ("region", "The value of the `REGION` option, if set."),
4853 (
4854 "access_key_id",
4855 "The value of the `ACCESS KEY ID` option, if provided in line.",
4856 ),
4857 (
4858 "access_key_id_secret_id",
4859 "The ID of the secret referenced by the `ACCESS KEY ID` option, if provided via a secret.",
4860 ),
4861 (
4862 "secret_access_key_secret_id",
4863 "The ID of the secret referenced by the `SECRET ACCESS KEY` option, if set.",
4864 ),
4865 (
4866 "session_token",
4867 "The value of the `SESSION TOKEN` option, if provided in line.",
4868 ),
4869 (
4870 "session_token_secret_id",
4871 "The ID of the secret referenced by the `SESSION TOKEN` option, if provided via a secret.",
4872 ),
4873 (
4874 "assume_role_arn",
4875 "The value of the `ASSUME ROLE ARN` option, if set.",
4876 ),
4877 (
4878 "assume_role_session_name",
4879 "The value of the `ASSUME ROLE SESSION NAME` option, if set.",
4880 ),
4881 (
4882 "principal",
4883 "The ARN of the AWS principal Materialize will use when assuming the provided role, if the connection is configured to use role assumption.",
4884 ),
4885 (
4886 "external_id",
4887 "The external ID Materialize will use when assuming the provided role, if the connection is configured to use role assumption.",
4888 ),
4889 (
4890 "example_trust_policy",
4891 "An example of an IAM role trust policy that allows this connection's principal and external ID to assume the role.",
4892 ),
4893 ]),
4894 is_retained_metrics_object: false,
4895 access: vec![PUBLIC_SELECT],
4896});
4897
4898pub static MZ_CLUSTER_REPLICA_METRICS_HISTORY: LazyLock<BuiltinSource> =
4899 LazyLock::new(|| BuiltinSource {
4900 name: "mz_cluster_replica_metrics_history",
4901 schema: MZ_INTERNAL_SCHEMA,
4902 oid: oid::SOURCE_MZ_CLUSTER_REPLICA_METRICS_HISTORY_OID,
4903 data_source: IntrospectionType::ReplicaMetricsHistory,
4904 desc: REPLICA_METRICS_HISTORY_DESC.clone(),
4905 column_comments: BTreeMap::from_iter([
4906 ("replica_id", "The ID of a cluster replica."),
4907 ("process_id", "The ID of a process within the replica."),
4908 (
4909 "cpu_nano_cores",
4910 "Approximate CPU usage, in billionths of a vCPU core.",
4911 ),
4912 ("memory_bytes", "Approximate memory usage, in bytes."),
4913 ("disk_bytes", "Approximate disk usage, in bytes."),
4914 (
4915 "occurred_at",
4916 "Wall-clock timestamp at which the event occurred.",
4917 ),
4918 (
4919 "heap_bytes",
4920 "Approximate heap (RAM + swap) usage, in bytes.",
4921 ),
4922 ("heap_limit", "Available heap (RAM + swap) space, in bytes."),
4923 ]),
4924 is_retained_metrics_object: false,
4925 access: vec![PUBLIC_SELECT],
4926 });
4927
4928pub static MZ_CLUSTER_REPLICA_METRICS_HISTORY_CT: LazyLock<BuiltinContinualTask> = LazyLock::new(
4929 || {
4930 BuiltinContinualTask {
4931 name: "mz_cluster_replica_metrics_history_ct",
4932 schema: MZ_INTERNAL_SCHEMA,
4933 oid: oid::CT_MZ_CLUSTER_REPLICA_METRICS_HISTORY_OID,
4934 desc: REPLICA_METRICS_HISTORY_DESC.clone(),
4935 sql: "
4936IN CLUSTER mz_catalog_server
4937ON INPUT mz_internal.mz_cluster_replica_metrics_history AS (
4938 DELETE FROM mz_internal.mz_cluster_replica_metrics_history_ct WHERE occurred_at + '30d' < mz_now();
4939 INSERT INTO mz_internal.mz_cluster_replica_metrics_history_ct SELECT * FROM mz_internal.mz_cluster_replica_metrics_history;
4940)",
4941 access: vec![PUBLIC_SELECT],
4942 }
4943 },
4944);
4945
4946pub static MZ_CLUSTER_REPLICA_METRICS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
4947 name: "mz_cluster_replica_metrics",
4948 schema: MZ_INTERNAL_SCHEMA,
4949 oid: oid::VIEW_MZ_CLUSTER_REPLICA_METRICS_OID,
4950 desc: RelationDesc::builder()
4951 .with_column("replica_id", SqlScalarType::String.nullable(false))
4952 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
4953 .with_column("cpu_nano_cores", SqlScalarType::UInt64.nullable(true))
4954 .with_column("memory_bytes", SqlScalarType::UInt64.nullable(true))
4955 .with_column("disk_bytes", SqlScalarType::UInt64.nullable(true))
4956 .with_column("heap_bytes", SqlScalarType::UInt64.nullable(true))
4957 .with_column("heap_limit", SqlScalarType::UInt64.nullable(true))
4958 .with_key(vec![0, 1])
4959 .finish(),
4960 column_comments: BTreeMap::from_iter([
4961 ("replica_id", "The ID of a cluster replica."),
4962 ("process_id", "The ID of a process within the replica."),
4963 (
4964 "cpu_nano_cores",
4965 "Approximate CPU usage, in billionths of a vCPU core.",
4966 ),
4967 ("memory_bytes", "Approximate RAM usage, in bytes."),
4968 ("disk_bytes", "Approximate disk usage, in bytes."),
4969 (
4970 "heap_bytes",
4971 "Approximate heap (RAM + swap) usage, in bytes.",
4972 ),
4973 ("heap_limit", "Available heap (RAM + swap) space, in bytes."),
4974 ]),
4975 sql: "
4976SELECT
4977 DISTINCT ON (replica_id, process_id)
4978 replica_id,
4979 process_id,
4980 cpu_nano_cores,
4981 memory_bytes,
4982 disk_bytes,
4983 heap_bytes,
4984 heap_limit
4985FROM mz_internal.mz_cluster_replica_metrics_history
4986JOIN mz_cluster_replicas r ON r.id = replica_id
4987ORDER BY replica_id, process_id, occurred_at DESC",
4988 access: vec![PUBLIC_SELECT],
4989});
4990
4991pub static MZ_CLUSTER_REPLICA_FRONTIERS: LazyLock<BuiltinSource> =
4992 LazyLock::new(|| BuiltinSource {
4993 name: "mz_cluster_replica_frontiers",
4994 schema: MZ_CATALOG_SCHEMA,
4995 oid: oid::SOURCE_MZ_CLUSTER_REPLICA_FRONTIERS_OID,
4996 data_source: IntrospectionType::ReplicaFrontiers,
4997 desc: RelationDesc::builder()
4998 .with_column("object_id", SqlScalarType::String.nullable(false))
4999 .with_column("replica_id", SqlScalarType::String.nullable(false))
5000 .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true))
5001 .finish(),
5002 column_comments: BTreeMap::from_iter([
5003 (
5004 "object_id",
5005 "The ID of the source, sink, index, materialized view, or subscription.",
5006 ),
5007 ("replica_id", "The ID of a cluster replica."),
5008 (
5009 "write_frontier",
5010 "The next timestamp at which the output may change.",
5011 ),
5012 ]),
5013 is_retained_metrics_object: false,
5014 access: vec![PUBLIC_SELECT],
5015 });
5016
5017pub static MZ_CLUSTER_REPLICA_FRONTIERS_IND: LazyLock<BuiltinIndex> =
5018 LazyLock::new(|| BuiltinIndex {
5019 name: "mz_cluster_replica_frontiers_ind",
5020 schema: MZ_CATALOG_SCHEMA,
5021 oid: oid::INDEX_MZ_CLUSTER_REPLICA_FRONTIERS_IND_OID,
5022 sql: "IN CLUSTER mz_catalog_server ON mz_catalog.mz_cluster_replica_frontiers (object_id)",
5023 is_retained_metrics_object: false,
5024 });
5025
5026pub static MZ_FRONTIERS: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5027 name: "mz_frontiers",
5028 schema: MZ_INTERNAL_SCHEMA,
5029 oid: oid::SOURCE_MZ_FRONTIERS_OID,
5030 data_source: IntrospectionType::Frontiers,
5031 desc: RelationDesc::builder()
5032 .with_column("object_id", SqlScalarType::String.nullable(false))
5033 .with_column("read_frontier", SqlScalarType::MzTimestamp.nullable(true))
5034 .with_column("write_frontier", SqlScalarType::MzTimestamp.nullable(true))
5035 .finish(),
5036 column_comments: BTreeMap::from_iter([
5037 (
5038 "object_id",
5039 "The ID of the source, sink, table, index, materialized view, or subscription.",
5040 ),
5041 (
5042 "read_frontier",
5043 "The earliest timestamp at which the output is still readable.",
5044 ),
5045 (
5046 "write_frontier",
5047 "The next timestamp at which the output may change.",
5048 ),
5049 ]),
5050 is_retained_metrics_object: false,
5051 access: vec![PUBLIC_SELECT],
5052});
5053
5054pub static MZ_GLOBAL_FRONTIERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5056 name: "mz_global_frontiers",
5057 schema: MZ_INTERNAL_SCHEMA,
5058 oid: oid::VIEW_MZ_GLOBAL_FRONTIERS_OID,
5059 desc: RelationDesc::builder()
5060 .with_column("object_id", SqlScalarType::String.nullable(false))
5061 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
5062 .finish(),
5063 column_comments: BTreeMap::new(),
5064 sql: "
5065SELECT object_id, write_frontier AS time
5066FROM mz_internal.mz_frontiers
5067WHERE write_frontier IS NOT NULL",
5068 access: vec![PUBLIC_SELECT],
5069});
5070
5071pub static MZ_WALLCLOCK_LAG_HISTORY: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5072 name: "mz_wallclock_lag_history",
5073 schema: MZ_INTERNAL_SCHEMA,
5074 oid: oid::SOURCE_MZ_WALLCLOCK_LAG_HISTORY_OID,
5075 desc: WALLCLOCK_LAG_HISTORY_DESC.clone(),
5076 data_source: IntrospectionType::WallclockLagHistory,
5077 column_comments: BTreeMap::from_iter([
5078 (
5079 "object_id",
5080 "The ID of the table, source, materialized view, index, or sink. Corresponds to `mz_objects.id`.",
5081 ),
5082 (
5083 "replica_id",
5084 "The ID of a replica computing the object, or `NULL` for persistent objects. Corresponds to `mz_cluster_replicas.id`.",
5085 ),
5086 (
5087 "lag",
5088 "The amount of time the object's write frontier lags behind wallclock time.",
5089 ),
5090 (
5091 "occurred_at",
5092 "Wall-clock timestamp at which the event occurred.",
5093 ),
5094 ]),
5095 is_retained_metrics_object: false,
5096 access: vec![PUBLIC_SELECT],
5097});
5098
5099pub static MZ_WALLCLOCK_LAG_HISTORY_CT: LazyLock<BuiltinContinualTask> = LazyLock::new(|| {
5100 BuiltinContinualTask {
5101 name: "mz_wallclock_lag_history_ct",
5102 schema: MZ_INTERNAL_SCHEMA,
5103 oid: oid::CT_MZ_WALLCLOCK_LAG_HISTORY_OID,
5104 desc: WALLCLOCK_LAG_HISTORY_DESC.clone(),
5105 sql: "
5106IN CLUSTER mz_catalog_server
5107ON INPUT mz_internal.mz_wallclock_lag_history AS (
5108 DELETE FROM mz_internal.mz_wallclock_lag_history_ct WHERE occurred_at + '30d' < mz_now();
5109 INSERT INTO mz_internal.mz_wallclock_lag_history_ct SELECT * FROM mz_internal.mz_wallclock_lag_history;
5110)",
5111 access: vec![PUBLIC_SELECT],
5112 }
5113});
5114
5115pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5116 name: "mz_wallclock_global_lag_history",
5117 schema: MZ_INTERNAL_SCHEMA,
5118 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_HISTORY_OID,
5119 desc: RelationDesc::builder()
5120 .with_column("object_id", SqlScalarType::String.nullable(false))
5121 .with_column("lag", SqlScalarType::Interval.nullable(true))
5122 .with_column(
5123 "occurred_at",
5124 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5125 )
5126 .with_key(vec![0, 2])
5127 .finish(),
5128 column_comments: BTreeMap::new(),
5129 sql: "
5130WITH times_binned AS (
5131 SELECT
5132 object_id,
5133 lag,
5134 date_trunc('minute', occurred_at) AS occurred_at
5135 FROM mz_internal.mz_wallclock_lag_history
5136)
5137SELECT
5138 object_id,
5139 min(lag) AS lag,
5140 occurred_at
5141FROM times_binned
5142GROUP BY object_id, occurred_at
5143OPTIONS (AGGREGATE INPUT GROUP SIZE = 1)",
5144 access: vec![PUBLIC_SELECT],
5145});
5146
5147pub static MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY: LazyLock<BuiltinView> =
5148 LazyLock::new(|| BuiltinView {
5149 name: "mz_wallclock_global_lag_recent_history",
5150 schema: MZ_INTERNAL_SCHEMA,
5151 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_OID,
5152 desc: RelationDesc::builder()
5153 .with_column("object_id", SqlScalarType::String.nullable(false))
5154 .with_column("lag", SqlScalarType::Interval.nullable(true))
5155 .with_column(
5156 "occurred_at",
5157 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5158 )
5159 .with_key(vec![0, 2])
5160 .finish(),
5161 column_comments: BTreeMap::new(),
5162 sql: "
5163SELECT object_id, lag, occurred_at
5164FROM mz_internal.mz_wallclock_global_lag_history
5165WHERE occurred_at + '1 day' > mz_now()",
5166 access: vec![PUBLIC_SELECT],
5167 });
5168
5169pub static MZ_WALLCLOCK_GLOBAL_LAG: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5170 name: "mz_wallclock_global_lag",
5171 schema: MZ_INTERNAL_SCHEMA,
5172 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_OID,
5173 desc: RelationDesc::builder()
5174 .with_column("object_id", SqlScalarType::String.nullable(false))
5175 .with_column("lag", SqlScalarType::Interval.nullable(true))
5176 .with_key(vec![0])
5177 .finish(),
5178 column_comments: BTreeMap::from_iter([
5179 (
5180 "object_id",
5181 "The ID of the table, source, materialized view, index, or sink. Corresponds to `mz_objects.id`.",
5182 ),
5183 (
5184 "lag",
5185 "The amount of time the object's write frontier lags behind wallclock time.",
5186 ),
5187 ]),
5188 sql: "
5189SELECT DISTINCT ON (object_id) object_id, lag
5190FROM mz_internal.mz_wallclock_global_lag_recent_history
5191WHERE occurred_at + '5 minutes' > mz_now()
5192ORDER BY object_id, occurred_at DESC",
5193 access: vec![PUBLIC_SELECT],
5194});
5195
5196pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW: LazyLock<BuiltinSource> =
5197 LazyLock::new(|| BuiltinSource {
5198 name: "mz_wallclock_global_lag_histogram_raw",
5199 schema: MZ_INTERNAL_SCHEMA,
5200 oid: oid::SOURCE_MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW_OID,
5201 desc: WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW_DESC.clone(),
5202 column_comments: BTreeMap::new(),
5203 data_source: IntrospectionType::WallclockLagHistogram,
5204 is_retained_metrics_object: false,
5205 access: vec![PUBLIC_SELECT],
5206 });
5207
5208pub static MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM: LazyLock<BuiltinView> =
5209 LazyLock::new(|| BuiltinView {
5210 name: "mz_wallclock_global_lag_histogram",
5211 schema: MZ_INTERNAL_SCHEMA,
5212 oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_OID,
5213 desc: RelationDesc::builder()
5214 .with_column(
5215 "period_start",
5216 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5217 )
5218 .with_column(
5219 "period_end",
5220 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5221 )
5222 .with_column("object_id", SqlScalarType::String.nullable(false))
5223 .with_column("lag_seconds", SqlScalarType::UInt64.nullable(true))
5224 .with_column("labels", SqlScalarType::Jsonb.nullable(false))
5225 .with_column("count", SqlScalarType::Int64.nullable(false))
5226 .with_key(vec![0, 1, 2, 3, 4])
5227 .finish(),
5228 column_comments: BTreeMap::new(),
5229 sql: "
5230SELECT *, count(*) AS count
5231FROM mz_internal.mz_wallclock_global_lag_histogram_raw
5232GROUP BY period_start, period_end, object_id, lag_seconds, labels",
5233 access: vec![PUBLIC_SELECT],
5234 });
5235
5236pub static MZ_MATERIALIZED_VIEW_REFRESHES: LazyLock<BuiltinSource> = LazyLock::new(|| {
5237 BuiltinSource {
5238 name: "mz_materialized_view_refreshes",
5239 schema: MZ_INTERNAL_SCHEMA,
5240 oid: oid::SOURCE_MZ_MATERIALIZED_VIEW_REFRESHES_OID,
5241 data_source: IntrospectionType::ComputeMaterializedViewRefreshes,
5242 desc: RelationDesc::builder()
5243 .with_column(
5244 "materialized_view_id",
5245 SqlScalarType::String.nullable(false),
5246 )
5247 .with_column(
5248 "last_completed_refresh",
5249 SqlScalarType::MzTimestamp.nullable(true),
5250 )
5251 .with_column("next_refresh", SqlScalarType::MzTimestamp.nullable(true))
5252 .finish(),
5253 column_comments: BTreeMap::from_iter([
5254 (
5255 "materialized_view_id",
5256 "The ID of the materialized view. Corresponds to `mz_catalog.mz_materialized_views.id`",
5257 ),
5258 (
5259 "last_completed_refresh",
5260 "The time of the last successfully completed refresh. `NULL` if the materialized view hasn't completed any refreshes yet.",
5261 ),
5262 (
5263 "next_refresh",
5264 "The time of the next scheduled refresh. `NULL` if the materialized view has no future scheduled refreshes.",
5265 ),
5266 ]),
5267 is_retained_metrics_object: false,
5268 access: vec![PUBLIC_SELECT],
5269 }
5270});
5271
5272pub static MZ_SUBSCRIPTIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5273 name: "mz_subscriptions",
5274 schema: MZ_INTERNAL_SCHEMA,
5275 oid: oid::TABLE_MZ_SUBSCRIPTIONS_OID,
5276 desc: RelationDesc::builder()
5277 .with_column("id", SqlScalarType::String.nullable(false))
5278 .with_column("session_id", SqlScalarType::Uuid.nullable(false))
5279 .with_column("cluster_id", SqlScalarType::String.nullable(false))
5280 .with_column(
5281 "created_at",
5282 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5283 )
5284 .with_column(
5285 "referenced_object_ids",
5286 SqlScalarType::List {
5287 element_type: Box::new(SqlScalarType::String),
5288 custom_id: None,
5289 }
5290 .nullable(false),
5291 )
5292 .finish(),
5293 column_comments: BTreeMap::from_iter([
5294 ("id", "The ID of the subscription."),
5295 (
5296 "session_id",
5297 "The ID of the session that runs the subscription. Corresponds to `mz_sessions.id`.",
5298 ),
5299 (
5300 "cluster_id",
5301 "The ID of the cluster on which the subscription is running. Corresponds to `mz_clusters.id`.",
5302 ),
5303 (
5304 "created_at",
5305 "The time at which the subscription was created.",
5306 ),
5307 (
5308 "referenced_object_ids",
5309 "The IDs of objects referenced by the subscription. Corresponds to `mz_objects.id`",
5310 ),
5311 ]),
5312 is_retained_metrics_object: false,
5313 access: vec![PUBLIC_SELECT],
5314});
5315
5316pub static MZ_SESSIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5317 name: "mz_sessions",
5318 schema: MZ_INTERNAL_SCHEMA,
5319 oid: oid::TABLE_MZ_SESSIONS_OID,
5320 desc: RelationDesc::builder()
5321 .with_column("id", SqlScalarType::Uuid.nullable(false))
5322 .with_column("connection_id", SqlScalarType::UInt32.nullable(false))
5323 .with_column("role_id", SqlScalarType::String.nullable(false))
5324 .with_column("client_ip", SqlScalarType::String.nullable(true))
5325 .with_column(
5326 "connected_at",
5327 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5328 )
5329 .finish(),
5330 column_comments: BTreeMap::from_iter([
5331 ("id", "The globally unique ID of the session."),
5332 (
5333 "connection_id",
5334 "The connection ID of the session. Unique only for active sessions and can be recycled. Corresponds to `pg_backend_pid()`.",
5335 ),
5336 (
5337 "role_id",
5338 "The role ID of the role that the session is logged in as. Corresponds to `mz_catalog.mz_roles`.",
5339 ),
5340 (
5341 "client_ip",
5342 "The IP address of the client that initiated the session.",
5343 ),
5344 (
5345 "connected_at",
5346 "The time at which the session connected to the system.",
5347 ),
5348 ]),
5349 is_retained_metrics_object: false,
5350 access: vec![PUBLIC_SELECT],
5351});
5352
5353pub static MZ_DEFAULT_PRIVILEGES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5354 name: "mz_default_privileges",
5355 schema: MZ_CATALOG_SCHEMA,
5356 oid: oid::TABLE_MZ_DEFAULT_PRIVILEGES_OID,
5357 desc: RelationDesc::builder()
5358 .with_column("role_id", SqlScalarType::String.nullable(false))
5359 .with_column("database_id", SqlScalarType::String.nullable(true))
5360 .with_column("schema_id", SqlScalarType::String.nullable(true))
5361 .with_column("object_type", SqlScalarType::String.nullable(false))
5362 .with_column("grantee", SqlScalarType::String.nullable(false))
5363 .with_column("privileges", SqlScalarType::String.nullable(false))
5364 .finish(),
5365 column_comments: BTreeMap::from_iter([
5366 (
5367 "role_id",
5368 "Privileges described in this row will be granted on objects created by `role_id`. The role ID `p` stands for the `PUBLIC` pseudo-role and applies to all roles.",
5369 ),
5370 (
5371 "database_id",
5372 "Privileges described in this row will be granted only on objects in the database identified by `database_id` if non-null.",
5373 ),
5374 (
5375 "schema_id",
5376 "Privileges described in this row will be granted only on objects in the schema identified by `schema_id` if non-null.",
5377 ),
5378 (
5379 "object_type",
5380 "Privileges described in this row will be granted only on objects of type `object_type`.",
5381 ),
5382 (
5383 "grantee",
5384 "Privileges described in this row will be granted to `grantee`. The role ID `p` stands for the `PUBLIC` pseudo-role and applies to all roles.",
5385 ),
5386 ("privileges", "The set of privileges that will be granted."),
5387 ]),
5388 is_retained_metrics_object: false,
5389 access: vec![PUBLIC_SELECT],
5390});
5391
5392pub static MZ_SYSTEM_PRIVILEGES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5393 name: "mz_system_privileges",
5394 schema: MZ_CATALOG_SCHEMA,
5395 oid: oid::TABLE_MZ_SYSTEM_PRIVILEGES_OID,
5396 desc: RelationDesc::builder()
5397 .with_column("privileges", SqlScalarType::MzAclItem.nullable(false))
5398 .finish(),
5399 column_comments: BTreeMap::from_iter([(
5400 "privileges",
5401 "The privileges belonging to the system.",
5402 )]),
5403 is_retained_metrics_object: false,
5404 access: vec![PUBLIC_SELECT],
5405});
5406
5407pub static MZ_COMMENTS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5408 name: "mz_comments",
5409 schema: MZ_INTERNAL_SCHEMA,
5410 oid: oid::TABLE_MZ_COMMENTS_OID,
5411 desc: RelationDesc::builder()
5412 .with_column("id", SqlScalarType::String.nullable(false))
5413 .with_column("object_type", SqlScalarType::String.nullable(false))
5414 .with_column("object_sub_id", SqlScalarType::Int32.nullable(true))
5415 .with_column("comment", SqlScalarType::String.nullable(false))
5416 .finish(),
5417 column_comments: BTreeMap::from_iter([
5418 (
5419 "id",
5420 "The ID of the object. Corresponds to `mz_objects.id`.",
5421 ),
5422 (
5423 "object_type",
5424 "The type of object the comment is associated with.",
5425 ),
5426 (
5427 "object_sub_id",
5428 "For a comment on a column of a relation, the column number. `NULL` for other object types.",
5429 ),
5430 ("comment", "The comment itself."),
5431 ]),
5432 is_retained_metrics_object: false,
5433 access: vec![PUBLIC_SELECT],
5434});
5435
5436pub static MZ_SOURCE_REFERENCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5437 name: "mz_source_references",
5438 schema: MZ_INTERNAL_SCHEMA,
5439 oid: oid::TABLE_MZ_SOURCE_REFERENCES_OID,
5440 desc: RelationDesc::builder()
5441 .with_column("source_id", SqlScalarType::String.nullable(false))
5442 .with_column("namespace", SqlScalarType::String.nullable(true))
5443 .with_column("name", SqlScalarType::String.nullable(false))
5444 .with_column(
5445 "updated_at",
5446 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5447 )
5448 .with_column(
5449 "columns",
5450 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
5451 )
5452 .finish(),
5453 column_comments: BTreeMap::new(),
5454 is_retained_metrics_object: false,
5455 access: vec![PUBLIC_SELECT],
5456});
5457
5458pub static MZ_WEBHOOKS_SOURCES: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5459 name: "mz_webhook_sources",
5460 schema: MZ_INTERNAL_SCHEMA,
5461 oid: oid::TABLE_MZ_WEBHOOK_SOURCES_OID,
5462 desc: RelationDesc::builder()
5463 .with_column("id", SqlScalarType::String.nullable(false))
5464 .with_column("name", SqlScalarType::String.nullable(false))
5465 .with_column("url", SqlScalarType::String.nullable(false))
5466 .finish(),
5467 column_comments: BTreeMap::from_iter([
5468 (
5469 "id",
5470 "The ID of the webhook source. Corresponds to `mz_sources.id`.",
5471 ),
5472 ("name", "The name of the webhook source."),
5473 (
5474 "url",
5475 "The URL which can be used to send events to the source.",
5476 ),
5477 ]),
5478 is_retained_metrics_object: false,
5479 access: vec![PUBLIC_SELECT],
5480});
5481
5482pub static MZ_HISTORY_RETENTION_STRATEGIES: LazyLock<BuiltinTable> = LazyLock::new(|| {
5483 BuiltinTable {
5484 name: "mz_history_retention_strategies",
5485 schema: MZ_INTERNAL_SCHEMA,
5486 oid: oid::TABLE_MZ_HISTORY_RETENTION_STRATEGIES_OID,
5487 desc: RelationDesc::builder()
5488 .with_column("id", SqlScalarType::String.nullable(false))
5489 .with_column("strategy", SqlScalarType::String.nullable(false))
5490 .with_column("value", SqlScalarType::Jsonb.nullable(false))
5491 .finish(),
5492 column_comments: BTreeMap::from_iter([
5493 ("id", "The ID of the object."),
5494 (
5495 "strategy",
5496 "The strategy. `FOR` is the only strategy, and means the object's compaction window is the duration of the `value` field.",
5497 ),
5498 (
5499 "value",
5500 "The value of the strategy. For `FOR`, is a number of milliseconds.",
5501 ),
5502 ]),
5503 is_retained_metrics_object: false,
5504 access: vec![PUBLIC_SELECT],
5505 }
5506});
5507
5508pub static MZ_LICENSE_KEYS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5509 name: "mz_license_keys",
5510 schema: MZ_INTERNAL_SCHEMA,
5511 oid: oid::TABLE_MZ_LICENSE_KEYS_OID,
5512 desc: RelationDesc::builder()
5513 .with_column("id", SqlScalarType::String.nullable(false))
5514 .with_column("organization", SqlScalarType::String.nullable(false))
5515 .with_column("environment_id", SqlScalarType::String.nullable(false))
5516 .with_column(
5517 "expiration",
5518 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5519 )
5520 .with_column(
5521 "not_before",
5522 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5523 )
5524 .finish(),
5525 column_comments: BTreeMap::from_iter([
5526 ("id", "The identifier of the license key."),
5527 (
5528 "organization",
5529 "The name of the organization that this license key was issued to.",
5530 ),
5531 (
5532 "environment_id",
5533 "The environment ID that this license key was issued for.",
5534 ),
5535 (
5536 "expiration",
5537 "The date and time when this license key expires.",
5538 ),
5539 (
5540 "not_before",
5541 "The start of the validity period for this license key.",
5542 ),
5543 ]),
5544 is_retained_metrics_object: false,
5545 access: vec![PUBLIC_SELECT],
5546});
5547
5548pub static MZ_REPLACEMENTS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5549 name: "mz_replacements",
5550 schema: MZ_INTERNAL_SCHEMA,
5551 oid: oid::TABLE_MZ_REPLACEMENTS_OID,
5552 desc: RelationDesc::builder()
5553 .with_column("id", SqlScalarType::String.nullable(false))
5554 .with_column("target_id", SqlScalarType::String.nullable(false))
5555 .finish(),
5556 column_comments: BTreeMap::from_iter([
5557 (
5558 "id",
5559 "The ID of the replacement object. Corresponds to `mz_objects.id`.",
5560 ),
5561 (
5562 "target_id",
5563 "The ID of the replacement target. Corresponds to `mz_objects.id`.",
5564 ),
5565 ]),
5566 is_retained_metrics_object: false,
5567 access: vec![PUBLIC_SELECT],
5568});
5569
5570pub static MZ_SOURCE_STATISTICS_RAW: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5573 name: "mz_source_statistics_raw",
5574 schema: MZ_INTERNAL_SCHEMA,
5575 oid: oid::SOURCE_MZ_SOURCE_STATISTICS_RAW_OID,
5576 data_source: IntrospectionType::StorageSourceStatistics,
5577 desc: MZ_SOURCE_STATISTICS_RAW_DESC.clone(),
5578 column_comments: BTreeMap::new(),
5579 is_retained_metrics_object: true,
5580 access: vec![PUBLIC_SELECT],
5581});
5582pub static MZ_SINK_STATISTICS_RAW: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5583 name: "mz_sink_statistics_raw",
5584 schema: MZ_INTERNAL_SCHEMA,
5585 oid: oid::SOURCE_MZ_SINK_STATISTICS_RAW_OID,
5586 data_source: IntrospectionType::StorageSinkStatistics,
5587 desc: MZ_SINK_STATISTICS_RAW_DESC.clone(),
5588 column_comments: BTreeMap::new(),
5589 is_retained_metrics_object: true,
5590 access: vec![PUBLIC_SELECT],
5591});
5592
5593pub static MZ_STORAGE_SHARDS: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
5594 name: "mz_storage_shards",
5595 schema: MZ_INTERNAL_SCHEMA,
5596 oid: oid::SOURCE_MZ_STORAGE_SHARDS_OID,
5597 data_source: IntrospectionType::ShardMapping,
5598 desc: RelationDesc::builder()
5599 .with_column("object_id", SqlScalarType::String.nullable(false))
5600 .with_column("shard_id", SqlScalarType::String.nullable(false))
5601 .finish(),
5602 column_comments: BTreeMap::new(),
5603 is_retained_metrics_object: false,
5604 access: vec![PUBLIC_SELECT],
5605});
5606
5607pub static MZ_STORAGE_USAGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5608 name: "mz_storage_usage",
5609 schema: MZ_CATALOG_SCHEMA,
5610 oid: oid::VIEW_MZ_STORAGE_USAGE_OID,
5611 desc: RelationDesc::builder()
5612 .with_column("object_id", SqlScalarType::String.nullable(false))
5613 .with_column("size_bytes", SqlScalarType::UInt64.nullable(false))
5614 .with_column(
5615 "collection_timestamp",
5616 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5617 )
5618 .with_key(vec![0, 2])
5619 .finish(),
5620 column_comments: BTreeMap::from_iter([
5621 (
5622 "object_id",
5623 "The ID of the table, source, or materialized view.",
5624 ),
5625 (
5626 "size_bytes",
5627 "The number of storage bytes used by the object.",
5628 ),
5629 (
5630 "collection_timestamp",
5631 "The time at which storage usage of the object was assessed.",
5632 ),
5633 ]),
5634 sql: "
5635SELECT
5636 object_id,
5637 sum(size_bytes)::uint8 AS size_bytes,
5638 collection_timestamp
5639FROM
5640 mz_internal.mz_storage_shards
5641 JOIN mz_internal.mz_storage_usage_by_shard USING (shard_id)
5642GROUP BY object_id, collection_timestamp",
5643 access: vec![PUBLIC_SELECT],
5644});
5645
5646pub static MZ_RECENT_STORAGE_USAGE: LazyLock<BuiltinView> = LazyLock::new(|| {
5647 BuiltinView {
5648 name: "mz_recent_storage_usage",
5649 schema: MZ_CATALOG_SCHEMA,
5650 oid: oid::VIEW_MZ_RECENT_STORAGE_USAGE_OID,
5651 desc: RelationDesc::builder()
5652 .with_column("object_id", SqlScalarType::String.nullable(false))
5653 .with_column("size_bytes", SqlScalarType::UInt64.nullable(true))
5654 .with_key(vec![0])
5655 .finish(),
5656 column_comments: BTreeMap::from_iter([
5657 ("object_id", "The ID of the table, source, or materialized view."),
5658 ("size_bytes", "The number of storage bytes used by the object in the most recent assessment."),
5659 ]),
5660 sql: "
5661WITH
5662
5663recent_storage_usage_by_shard AS (
5664 SELECT shard_id, size_bytes, collection_timestamp
5665 FROM mz_internal.mz_storage_usage_by_shard
5666 -- Restricting to the last 6 hours makes it feasible to index the view.
5667 WHERE collection_timestamp + '6 hours' >= mz_now()
5668),
5669
5670most_recent_collection_timestamp_by_shard AS (
5671 SELECT shard_id, max(collection_timestamp) AS collection_timestamp
5672 FROM recent_storage_usage_by_shard
5673 GROUP BY shard_id
5674)
5675
5676SELECT
5677 object_id,
5678 sum(size_bytes)::uint8 AS size_bytes
5679FROM
5680 mz_internal.mz_storage_shards
5681 LEFT JOIN most_recent_collection_timestamp_by_shard
5682 ON mz_storage_shards.shard_id = most_recent_collection_timestamp_by_shard.shard_id
5683 LEFT JOIN recent_storage_usage_by_shard
5684 ON mz_storage_shards.shard_id = recent_storage_usage_by_shard.shard_id
5685 AND most_recent_collection_timestamp_by_shard.collection_timestamp = recent_storage_usage_by_shard.collection_timestamp
5686GROUP BY object_id",
5687 access: vec![PUBLIC_SELECT],
5688}
5689});
5690
5691pub static MZ_RECENT_STORAGE_USAGE_IND: LazyLock<BuiltinIndex> = LazyLock::new(|| BuiltinIndex {
5692 name: "mz_recent_storage_usage_ind",
5693 schema: MZ_CATALOG_SCHEMA,
5694 oid: oid::INDEX_MZ_RECENT_STORAGE_USAGE_IND_OID,
5695 sql: "IN CLUSTER mz_catalog_server ON mz_catalog.mz_recent_storage_usage (object_id)",
5696 is_retained_metrics_object: false,
5697});
5698
5699pub static MZ_RELATIONS: LazyLock<BuiltinView> = LazyLock::new(|| {
5700 BuiltinView {
5701 name: "mz_relations",
5702 schema: MZ_CATALOG_SCHEMA,
5703 oid: oid::VIEW_MZ_RELATIONS_OID,
5704 desc: RelationDesc::builder()
5705 .with_column("id", SqlScalarType::String.nullable(false))
5706 .with_column("oid", SqlScalarType::Oid.nullable(false))
5707 .with_column("schema_id", SqlScalarType::String.nullable(false))
5708 .with_column("name", SqlScalarType::String.nullable(false))
5709 .with_column("type", SqlScalarType::String.nullable(false))
5710 .with_column("owner_id", SqlScalarType::String.nullable(false))
5711 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5712 .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false))
5713 .finish(),
5714 column_comments: BTreeMap::from_iter([
5715 ("id", "Materialize's unique ID for the relation."),
5716 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the relation."),
5717 ("schema_id", "The ID of the schema to which the relation belongs. Corresponds to `mz_schemas.id`."),
5718 ("name", "The name of the relation."),
5719 ("type", "The type of the relation: either `table`, `source`, `view`, or `materialized view`."),
5720 ("owner_id", "The role ID of the owner of the relation. Corresponds to `mz_roles.id`."),
5721 ("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."),
5722 ("privileges", "The privileges belonging to the relation."),
5723 ]),
5724 sql: "
5725 SELECT id, oid, schema_id, name, 'table' AS type, owner_id, NULL::text AS cluster_id, privileges FROM mz_catalog.mz_tables
5726UNION ALL SELECT id, oid, schema_id, name, 'source', owner_id, cluster_id, privileges FROM mz_catalog.mz_sources
5727UNION ALL SELECT id, oid, schema_id, name, 'view', owner_id, NULL::text, privileges FROM mz_catalog.mz_views
5728UNION ALL SELECT id, oid, schema_id, name, 'materialized-view', owner_id, cluster_id, privileges FROM mz_catalog.mz_materialized_views
5729UNION ALL SELECT id, oid, schema_id, name, 'continual-task', owner_id, cluster_id, privileges FROM mz_internal.mz_continual_tasks",
5730 access: vec![PUBLIC_SELECT],
5731 }
5732});
5733
5734pub static MZ_OBJECTS_ID_NAMESPACE_TYPES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5735 name: "mz_objects_id_namespace_types",
5736 schema: MZ_INTERNAL_SCHEMA,
5737 oid: oid::VIEW_MZ_OBJECTS_ID_NAMESPACE_TYPES_OID,
5738 desc: RelationDesc::builder()
5739 .with_column("object_type", SqlScalarType::String.nullable(false))
5740 .with_key(vec![0])
5741 .finish(),
5742 column_comments: BTreeMap::new(),
5743 sql: r#"SELECT *
5744 FROM (
5745 VALUES
5746 ('table'),
5747 ('view'),
5748 ('materialized-view'),
5749 ('source'),
5750 ('sink'),
5751 ('index'),
5752 ('connection'),
5753 ('type'),
5754 ('function'),
5755 ('secret')
5756 )
5757 AS _ (object_type)"#,
5758 access: vec![PUBLIC_SELECT],
5759});
5760
5761pub static MZ_OBJECT_OID_ALIAS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5762 name: "mz_object_oid_alias",
5763 schema: MZ_INTERNAL_SCHEMA,
5764 oid: oid::VIEW_MZ_OBJECT_OID_ALIAS_OID,
5765 desc: RelationDesc::builder()
5766 .with_column("object_type", SqlScalarType::String.nullable(false))
5767 .with_column("oid_alias", SqlScalarType::String.nullable(false))
5768 .with_key(vec![0])
5769 .finish(),
5770 column_comments: BTreeMap::new(),
5771 sql: "SELECT object_type, oid_alias
5772 FROM (
5773 VALUES
5774 (
5775 'table'::pg_catalog.text,
5776 'regclass'::pg_catalog.text
5777 ),
5778 ('source', 'regclass'),
5779 ('view', 'regclass'),
5780 ('materialized-view', 'regclass'),
5781 ('index', 'regclass'),
5782 ('type', 'regtype'),
5783 ('function', 'regproc')
5784 )
5785 AS _ (object_type, oid_alias);",
5786 access: vec![PUBLIC_SELECT],
5787});
5788
5789pub static MZ_OBJECTS: LazyLock<BuiltinView> = LazyLock::new(|| {
5790 BuiltinView {
5791 name: "mz_objects",
5792 schema: MZ_CATALOG_SCHEMA,
5793 oid: oid::VIEW_MZ_OBJECTS_OID,
5794 desc: RelationDesc::builder()
5795 .with_column("id", SqlScalarType::String.nullable(false))
5796 .with_column("oid", SqlScalarType::Oid.nullable(false))
5797 .with_column("schema_id", SqlScalarType::String.nullable(false))
5798 .with_column("name", SqlScalarType::String.nullable(false))
5799 .with_column("type", SqlScalarType::String.nullable(false))
5800 .with_column("owner_id", SqlScalarType::String.nullable(false))
5801 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5802 .with_column("privileges", SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(true))
5803 .finish(),
5804 column_comments: BTreeMap::from_iter([
5805 ("id", "Materialize's unique ID for the object."),
5806 ("oid", "A [PostgreSQL-compatible OID][`oid`] for the object."),
5807 ("schema_id", "The ID of the schema to which the object belongs. Corresponds to `mz_schemas.id`."),
5808 ("name", "The name of the object."),
5809 ("type", "The type of the object: one of `table`, `source`, `view`, `materialized-view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`."),
5810 ("owner_id", "The role ID of the owner of the object. Corresponds to `mz_roles.id`."),
5811 ("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."),
5812 ("privileges", "The privileges belonging to the object."),
5813 ]),
5814 sql:
5815 "SELECT id, oid, schema_id, name, type, owner_id, cluster_id, privileges FROM mz_catalog.mz_relations
5816UNION ALL
5817 SELECT id, oid, schema_id, name, 'sink', owner_id, cluster_id, NULL::mz_catalog.mz_aclitem[] FROM mz_catalog.mz_sinks
5818UNION ALL
5819 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[]
5820 FROM mz_catalog.mz_indexes
5821 JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
5822UNION ALL
5823 SELECT id, oid, schema_id, name, 'connection', owner_id, NULL::text, privileges FROM mz_catalog.mz_connections
5824UNION ALL
5825 SELECT id, oid, schema_id, name, 'type', owner_id, NULL::text, privileges FROM mz_catalog.mz_types
5826UNION ALL
5827 SELECT id, oid, schema_id, name, 'function', owner_id, NULL::text, NULL::mz_catalog.mz_aclitem[] FROM mz_catalog.mz_functions
5828UNION ALL
5829 SELECT id, oid, schema_id, name, 'secret', owner_id, NULL::text, privileges FROM mz_catalog.mz_secrets",
5830 access: vec![PUBLIC_SELECT],
5831 }
5832});
5833
5834pub static MZ_OBJECT_FULLY_QUALIFIED_NAMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5835 name: "mz_object_fully_qualified_names",
5836 schema: MZ_INTERNAL_SCHEMA,
5837 oid: oid::VIEW_MZ_OBJECT_FULLY_QUALIFIED_NAMES_OID,
5838 desc: RelationDesc::builder()
5839 .with_column("id", SqlScalarType::String.nullable(false))
5840 .with_column("name", SqlScalarType::String.nullable(false))
5841 .with_column("object_type", SqlScalarType::String.nullable(false))
5842 .with_column("schema_id", SqlScalarType::String.nullable(false))
5843 .with_column("schema_name", SqlScalarType::String.nullable(false))
5844 .with_column("database_id", SqlScalarType::String.nullable(true))
5845 .with_column("database_name", SqlScalarType::String.nullable(true))
5846 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5847 .finish(),
5848 column_comments: BTreeMap::from_iter([
5849 ("id", "Materialize's unique ID for the object."),
5850 ("name", "The name of the object."),
5851 (
5852 "object_type",
5853 "The type of the object: one of `table`, `source`, `view`, `materialized view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`.",
5854 ),
5855 (
5856 "schema_id",
5857 "The ID of the schema to which the object belongs. Corresponds to `mz_schemas.id`.",
5858 ),
5859 (
5860 "schema_name",
5861 "The name of the schema to which the object belongs. Corresponds to `mz_schemas.name`.",
5862 ),
5863 (
5864 "database_id",
5865 "The ID of the database to which the object belongs. Corresponds to `mz_databases.id`.",
5866 ),
5867 (
5868 "database_name",
5869 "The name of the database to which the object belongs. Corresponds to `mz_databases.name`.",
5870 ),
5871 (
5872 "cluster_id",
5873 "The ID of the cluster maintaining the source, materialized view, index, or sink. Corresponds to `mz_clusters.id`. `NULL` for other object types.",
5874 ),
5875 ]),
5876 sql: "
5877 SELECT o.id,
5878 o.name,
5879 o.type as object_type,
5880 sc.id as schema_id,
5881 sc.name as schema_name,
5882 db.id as database_id,
5883 db.name as database_name,
5884 o.cluster_id
5885 FROM mz_catalog.mz_objects o
5886 INNER JOIN mz_catalog.mz_schemas sc ON sc.id = o.schema_id
5887 -- LEFT JOIN accounts for objects in the ambient database.
5888 LEFT JOIN mz_catalog.mz_databases db ON db.id = sc.database_id",
5889 access: vec![PUBLIC_SELECT],
5890});
5891
5892pub static MZ_OBJECT_GLOBAL_IDS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
5893 name: "mz_object_global_ids",
5894 schema: MZ_INTERNAL_SCHEMA,
5895 oid: oid::VIEW_MZ_OBJECT_GLOBAL_IDS_OID,
5896 desc: RelationDesc::builder()
5897 .with_column("id", SqlScalarType::String.nullable(false))
5898 .with_column("global_id", SqlScalarType::String.nullable(false))
5899 .finish(),
5900 column_comments: BTreeMap::from_iter([
5901 ("id", "Materialize's unique catalog item ID for the object."),
5902 ("global_id", "A global ID for the object."),
5903 ]),
5904 is_retained_metrics_object: false,
5905 access: vec![PUBLIC_SELECT],
5906});
5907
5908pub static MZ_OBJECT_LIFETIMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5910 name: "mz_object_lifetimes",
5911 schema: MZ_INTERNAL_SCHEMA,
5912 oid: oid::VIEW_MZ_OBJECT_LIFETIMES_OID,
5913 desc: RelationDesc::builder()
5914 .with_column("id", SqlScalarType::String.nullable(true))
5915 .with_column("previous_id", SqlScalarType::String.nullable(true))
5916 .with_column("object_type", SqlScalarType::String.nullable(false))
5917 .with_column("event_type", SqlScalarType::String.nullable(false))
5918 .with_column(
5919 "occurred_at",
5920 SqlScalarType::TimestampTz { precision: None }.nullable(false),
5921 )
5922 .finish(),
5923 column_comments: BTreeMap::from_iter([
5924 ("id", "Materialize's unique ID for the object."),
5925 ("previous_id", "The object's previous ID, if one exists."),
5926 (
5927 "object_type",
5928 "The type of the object: one of `table`, `source`, `view`, `materialized view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`.",
5929 ),
5930 (
5931 "event_type",
5932 "The lifetime event, either `create` or `drop`.",
5933 ),
5934 (
5935 "occurred_at",
5936 "Wall-clock timestamp of when the event occurred.",
5937 ),
5938 ]),
5939 sql: "
5940 SELECT
5941 CASE
5942 WHEN a.object_type = 'cluster-replica' THEN a.details ->> 'replica_id'
5943 ELSE a.details ->> 'id'
5944 END id,
5945 a.details ->> 'previous_id' as previous_id,
5946 a.object_type,
5947 a.event_type,
5948 a.occurred_at
5949 FROM mz_catalog.mz_audit_events a
5950 WHERE a.event_type = 'create' OR a.event_type = 'drop'",
5951 access: vec![PUBLIC_SELECT],
5952});
5953
5954pub static MZ_OBJECT_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
5955 name: "mz_object_history",
5956 schema: MZ_INTERNAL_SCHEMA,
5957 oid: oid::VIEW_MZ_OBJECT_HISTORY_OID,
5958 desc: RelationDesc::builder()
5959 .with_column("id", SqlScalarType::String.nullable(true))
5960 .with_column("cluster_id", SqlScalarType::String.nullable(true))
5961 .with_column("object_type", SqlScalarType::String.nullable(false))
5962 .with_column(
5963 "created_at",
5964 SqlScalarType::TimestampTz { precision: None }.nullable(true),
5965 )
5966 .with_column(
5967 "dropped_at",
5968 SqlScalarType::TimestampTz { precision: None }.nullable(true),
5969 )
5970 .finish(),
5971 column_comments: BTreeMap::from_iter([
5972 ("id", "Materialize's unique ID for the object."),
5973 (
5974 "cluster_id",
5975 "The object's cluster ID. `NULL` if the object has no associated cluster.",
5976 ),
5977 (
5978 "object_type",
5979 "The type of the object: one of `table`, `source`, `view`, `materialized view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`.",
5980 ),
5981 (
5982 "created_at",
5983 "Wall-clock timestamp of when the object was created. `NULL` for built in system objects.",
5984 ),
5985 (
5986 "dropped_at",
5987 "Wall-clock timestamp of when the object was dropped. `NULL` for built in system objects or if the object hasn't been dropped.",
5988 ),
5989 ]),
5990 sql: r#"
5991 WITH
5992 creates AS
5993 (
5994 SELECT
5995 details ->> 'id' AS id,
5996 -- We need to backfill cluster_id since older object create events don't include the cluster ID in the audit log
5997 COALESCE(details ->> 'cluster_id', objects.cluster_id) AS cluster_id,
5998 object_type,
5999 occurred_at
6000 FROM
6001 mz_catalog.mz_audit_events AS events
6002 LEFT JOIN mz_catalog.mz_objects AS objects ON details ->> 'id' = objects.id
6003 WHERE event_type = 'create' AND object_type IN ( SELECT object_type FROM mz_internal.mz_objects_id_namespace_types )
6004 ),
6005 drops AS
6006 (
6007 SELECT details ->> 'id' AS id, occurred_at
6008 FROM mz_catalog.mz_audit_events
6009 WHERE event_type = 'drop' AND object_type IN ( SELECT object_type FROM mz_internal.mz_objects_id_namespace_types )
6010 ),
6011 user_object_history AS
6012 (
6013 SELECT
6014 creates.id,
6015 creates.cluster_id,
6016 creates.object_type,
6017 creates.occurred_at AS created_at,
6018 drops.occurred_at AS dropped_at
6019 FROM creates LEFT JOIN drops ON creates.id = drops.id
6020 WHERE creates.id LIKE 'u%'
6021 ),
6022 -- We need to union built in objects since they aren't in the audit log
6023 built_in_objects AS
6024 (
6025 -- Functions that accept different arguments have different oids but the same id. We deduplicate in this case.
6026 SELECT DISTINCT ON (objects.id)
6027 objects.id,
6028 objects.cluster_id,
6029 objects.type AS object_type,
6030 NULL::timestamptz AS created_at,
6031 NULL::timestamptz AS dropped_at
6032 FROM mz_catalog.mz_objects AS objects
6033 WHERE objects.id LIKE 's%'
6034 )
6035 SELECT * FROM user_object_history UNION ALL (SELECT * FROM built_in_objects)"#,
6036 access: vec![PUBLIC_SELECT],
6037});
6038
6039pub static MZ_DATAFLOWS_PER_WORKER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6040 name: "mz_dataflows_per_worker",
6041 schema: MZ_INTROSPECTION_SCHEMA,
6042 oid: oid::VIEW_MZ_DATAFLOWS_PER_WORKER_OID,
6043 desc: RelationDesc::builder()
6044 .with_column("id", SqlScalarType::UInt64.nullable(true))
6045 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6046 .with_column("name", SqlScalarType::String.nullable(false))
6047 .finish(),
6048 column_comments: BTreeMap::new(),
6049 sql: "SELECT
6050 addrs.address[1] AS id,
6051 ops.worker_id,
6052 ops.name
6053FROM
6054 mz_introspection.mz_dataflow_addresses_per_worker addrs,
6055 mz_introspection.mz_dataflow_operators_per_worker ops
6056WHERE
6057 addrs.id = ops.id AND
6058 addrs.worker_id = ops.worker_id AND
6059 mz_catalog.list_length(addrs.address) = 1",
6060 access: vec![PUBLIC_SELECT],
6061});
6062
6063pub static MZ_DATAFLOWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6064 name: "mz_dataflows",
6065 schema: MZ_INTROSPECTION_SCHEMA,
6066 oid: oid::VIEW_MZ_DATAFLOWS_OID,
6067 desc: RelationDesc::builder()
6068 .with_column("id", SqlScalarType::UInt64.nullable(true))
6069 .with_column("name", SqlScalarType::String.nullable(false))
6070 .finish(),
6071 column_comments: BTreeMap::from_iter([
6072 ("id", "The ID of the dataflow."),
6073 ("name", "The internal name of the dataflow."),
6074 ]),
6075 sql: "
6076SELECT id, name
6077FROM mz_introspection.mz_dataflows_per_worker
6078WHERE worker_id = 0",
6079 access: vec![PUBLIC_SELECT],
6080});
6081
6082pub static MZ_DATAFLOW_ADDRESSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6083 name: "mz_dataflow_addresses",
6084 schema: MZ_INTROSPECTION_SCHEMA,
6085 oid: oid::VIEW_MZ_DATAFLOW_ADDRESSES_OID,
6086 desc: RelationDesc::builder()
6087 .with_column("id", SqlScalarType::UInt64.nullable(false))
6088 .with_column(
6089 "address",
6090 SqlScalarType::List {
6091 element_type: Box::new(SqlScalarType::UInt64),
6092 custom_id: None,
6093 }
6094 .nullable(false),
6095 )
6096 .finish(),
6097 column_comments: BTreeMap::from_iter([
6098 (
6099 "id",
6100 "The ID of the channel or operator. Corresponds to `mz_dataflow_channels.id` or `mz_dataflow_operators.id`.",
6101 ),
6102 (
6103 "address",
6104 "A list of scope-local indexes indicating the path from the root to this channel or operator.",
6105 ),
6106 ]),
6107 sql: "
6108SELECT id, address
6109FROM mz_introspection.mz_dataflow_addresses_per_worker
6110WHERE worker_id = 0",
6111 access: vec![PUBLIC_SELECT],
6112});
6113
6114pub static MZ_DATAFLOW_CHANNELS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6115 name: "mz_dataflow_channels",
6116 schema: MZ_INTROSPECTION_SCHEMA,
6117 oid: oid::VIEW_MZ_DATAFLOW_CHANNELS_OID,
6118 desc: RelationDesc::builder()
6119 .with_column("id", SqlScalarType::UInt64.nullable(false))
6120 .with_column("from_index", SqlScalarType::UInt64.nullable(false))
6121 .with_column("from_port", SqlScalarType::UInt64.nullable(false))
6122 .with_column("to_index", SqlScalarType::UInt64.nullable(false))
6123 .with_column("to_port", SqlScalarType::UInt64.nullable(false))
6124 .with_column("type", SqlScalarType::String.nullable(false))
6125 .finish(),
6126 column_comments: BTreeMap::from_iter([
6127 ("id", "The ID of the channel."),
6128 (
6129 "from_index",
6130 "The scope-local index of the source operator. Corresponds to `mz_dataflow_addresses.address`.",
6131 ),
6132 ("from_port", "The source operator's output port."),
6133 (
6134 "to_index",
6135 "The scope-local index of the target operator. Corresponds to `mz_dataflow_addresses.address`.",
6136 ),
6137 ("to_port", "The target operator's input port."),
6138 ("type", "The container type of the channel."),
6139 ]),
6140 sql: "
6141SELECT id, from_index, from_port, to_index, to_port, type
6142FROM mz_introspection.mz_dataflow_channels_per_worker
6143WHERE worker_id = 0",
6144 access: vec![PUBLIC_SELECT],
6145});
6146
6147pub static MZ_DATAFLOW_OPERATORS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6148 name: "mz_dataflow_operators",
6149 schema: MZ_INTROSPECTION_SCHEMA,
6150 oid: oid::VIEW_MZ_DATAFLOW_OPERATORS_OID,
6151 desc: RelationDesc::builder()
6152 .with_column("id", SqlScalarType::UInt64.nullable(false))
6153 .with_column("name", SqlScalarType::String.nullable(false))
6154 .finish(),
6155 column_comments: BTreeMap::from_iter([
6156 ("id", "The ID of the operator."),
6157 ("name", "The internal name of the operator."),
6158 ]),
6159 sql: "
6160SELECT id, name
6161FROM mz_introspection.mz_dataflow_operators_per_worker
6162WHERE worker_id = 0",
6163 access: vec![PUBLIC_SELECT],
6164});
6165
6166pub static MZ_DATAFLOW_GLOBAL_IDS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6167 name: "mz_dataflow_global_ids",
6168 schema: MZ_INTROSPECTION_SCHEMA,
6169 oid: oid::VIEW_MZ_DATAFLOW_GLOBAL_IDS_OID,
6170 desc: RelationDesc::builder()
6171 .with_column("id", SqlScalarType::UInt64.nullable(false))
6172 .with_column("global_id", SqlScalarType::String.nullable(false))
6173 .finish(),
6174 column_comments: BTreeMap::from_iter([
6175 ("id", "The dataflow ID."),
6176 ("global_id", "A global ID associated with that dataflow."),
6177 ]),
6178 sql: "
6179SELECT id, global_id
6180FROM mz_introspection.mz_compute_dataflow_global_ids_per_worker
6181WHERE worker_id = 0",
6182 access: vec![PUBLIC_SELECT],
6183});
6184
6185pub static MZ_MAPPABLE_OBJECTS: LazyLock<BuiltinView> = LazyLock::new(|| {
6186 BuiltinView {
6187 name: "mz_mappable_objects",
6188 schema: MZ_INTROSPECTION_SCHEMA,
6189 oid: oid::VIEW_MZ_MAPPABLE_OBJECTS_OID,
6190 desc: RelationDesc::builder()
6191 .with_column("name", SqlScalarType::String.nullable(false))
6192 .with_column("global_id", SqlScalarType::String.nullable(false))
6193 .finish(),
6194 column_comments: BTreeMap::from_iter([
6195 ("name", "The name of the object."),
6196 ("global_id", "The global ID of the object."),
6197 ]),
6198 sql: "
6199SELECT COALESCE(quote_ident(md.name) || '.', '') || quote_ident(ms.name) || '.' || quote_ident(mo.name) AS name, mgi.global_id AS global_id
6200FROM mz_catalog.mz_objects mo
6201 JOIN mz_introspection.mz_compute_exports mce ON (mo.id = mce.export_id)
6202 JOIN mz_catalog.mz_schemas ms ON (mo.schema_id = ms.id)
6203 JOIN mz_introspection.mz_dataflow_global_ids mgi ON (mce.dataflow_id = mgi.id)
6204 LEFT JOIN mz_catalog.mz_databases md ON (ms.database_id = md.id);",
6205 access: vec![PUBLIC_SELECT],
6206}
6207});
6208
6209pub static MZ_LIR_MAPPING: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6210 name: "mz_lir_mapping",
6211 schema: MZ_INTROSPECTION_SCHEMA,
6212 oid: oid::VIEW_MZ_LIR_MAPPING_OID,
6213 desc: RelationDesc::builder()
6214 .with_column("global_id", SqlScalarType::String.nullable(false))
6215 .with_column("lir_id", SqlScalarType::UInt64.nullable(false))
6216 .with_column("operator", SqlScalarType::String.nullable(false))
6217 .with_column("parent_lir_id", SqlScalarType::UInt64.nullable(true))
6218 .with_column("nesting", SqlScalarType::UInt16.nullable(false))
6219 .with_column("operator_id_start", SqlScalarType::UInt64.nullable(false))
6220 .with_column("operator_id_end", SqlScalarType::UInt64.nullable(false))
6221 .finish(),
6222 column_comments: BTreeMap::from_iter([
6223 ("global_id", "The global ID."),
6224 ("lir_id", "The LIR node ID."),
6225 (
6226 "operator",
6227 "The LIR operator, in the format `OperatorName INPUTS [OPTIONS]`.",
6228 ),
6229 (
6230 "parent_lir_id",
6231 "The parent of this LIR node. May be `NULL`.",
6232 ),
6233 ("nesting", "The nesting level of this LIR node."),
6234 (
6235 "operator_id_start",
6236 "The first dataflow operator ID implementing this LIR operator (inclusive).",
6237 ),
6238 (
6239 "operator_id_end",
6240 "The first dataflow operator ID after this LIR operator (exclusive).",
6241 ),
6242 ]),
6243 sql: "
6244SELECT global_id, lir_id, operator, parent_lir_id, nesting, operator_id_start, operator_id_end
6245FROM mz_introspection.mz_compute_lir_mapping_per_worker
6246WHERE worker_id = 0",
6247 access: vec![PUBLIC_SELECT],
6248});
6249
6250pub static MZ_DATAFLOW_OPERATOR_DATAFLOWS_PER_WORKER: LazyLock<BuiltinView> =
6251 LazyLock::new(|| BuiltinView {
6252 name: "mz_dataflow_operator_dataflows_per_worker",
6253 schema: MZ_INTROSPECTION_SCHEMA,
6254 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_DATAFLOWS_PER_WORKER_OID,
6255 desc: RelationDesc::builder()
6256 .with_column("id", SqlScalarType::UInt64.nullable(false))
6257 .with_column("name", SqlScalarType::String.nullable(false))
6258 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6259 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6260 .with_column("dataflow_name", SqlScalarType::String.nullable(false))
6261 .finish(),
6262 column_comments: BTreeMap::new(),
6263 sql: "SELECT
6264 ops.id,
6265 ops.name,
6266 ops.worker_id,
6267 dfs.id as dataflow_id,
6268 dfs.name as dataflow_name
6269FROM
6270 mz_introspection.mz_dataflow_operators_per_worker ops,
6271 mz_introspection.mz_dataflow_addresses_per_worker addrs,
6272 mz_introspection.mz_dataflows_per_worker dfs
6273WHERE
6274 ops.id = addrs.id AND
6275 ops.worker_id = addrs.worker_id AND
6276 dfs.id = addrs.address[1] AND
6277 dfs.worker_id = addrs.worker_id",
6278 access: vec![PUBLIC_SELECT],
6279 });
6280
6281pub static MZ_DATAFLOW_OPERATOR_DATAFLOWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6282 name: "mz_dataflow_operator_dataflows",
6283 schema: MZ_INTROSPECTION_SCHEMA,
6284 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_DATAFLOWS_OID,
6285 desc: RelationDesc::builder()
6286 .with_column("id", SqlScalarType::UInt64.nullable(false))
6287 .with_column("name", SqlScalarType::String.nullable(false))
6288 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6289 .with_column("dataflow_name", SqlScalarType::String.nullable(false))
6290 .finish(),
6291 column_comments: BTreeMap::from_iter([
6292 (
6293 "id",
6294 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
6295 ),
6296 ("name", "The internal name of the operator."),
6297 (
6298 "dataflow_id",
6299 "The ID of the dataflow hosting the operator. Corresponds to `mz_dataflows.id`.",
6300 ),
6301 (
6302 "dataflow_name",
6303 "The internal name of the dataflow hosting the operator.",
6304 ),
6305 ]),
6306 sql: "
6307SELECT id, name, dataflow_id, dataflow_name
6308FROM mz_introspection.mz_dataflow_operator_dataflows_per_worker
6309WHERE worker_id = 0",
6310 access: vec![PUBLIC_SELECT],
6311});
6312
6313pub static MZ_OBJECT_TRANSITIVE_DEPENDENCIES: LazyLock<BuiltinView> = LazyLock::new(|| {
6314 BuiltinView {
6315 name: "mz_object_transitive_dependencies",
6316 schema: MZ_INTERNAL_SCHEMA,
6317 oid: oid::VIEW_MZ_OBJECT_TRANSITIVE_DEPENDENCIES_OID,
6318 desc: RelationDesc::builder()
6319 .with_column("object_id", SqlScalarType::String.nullable(false))
6320 .with_column(
6321 "referenced_object_id",
6322 SqlScalarType::String.nullable(false),
6323 )
6324 .with_key(vec![0, 1])
6325 .finish(),
6326 column_comments: BTreeMap::from_iter([
6327 (
6328 "object_id",
6329 "The ID of the dependent object. Corresponds to `mz_objects.id`.",
6330 ),
6331 (
6332 "referenced_object_id",
6333 "The ID of the (possibly transitively) referenced object. Corresponds to `mz_objects.id`.",
6334 ),
6335 ]),
6336 sql: "
6337WITH MUTUALLY RECURSIVE
6338 reach(object_id text, referenced_object_id text) AS (
6339 SELECT object_id, referenced_object_id FROM mz_internal.mz_object_dependencies
6340 UNION
6341 SELECT x, z FROM reach r1(x, y) JOIN reach r2(y, z) USING(y)
6342 )
6343SELECT object_id, referenced_object_id FROM reach;",
6344 access: vec![PUBLIC_SELECT],
6345 }
6346});
6347
6348pub static MZ_COMPUTE_EXPORTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6349 name: "mz_compute_exports",
6350 schema: MZ_INTROSPECTION_SCHEMA,
6351 oid: oid::VIEW_MZ_COMPUTE_EXPORTS_OID,
6352 desc: RelationDesc::builder()
6353 .with_column("export_id", SqlScalarType::String.nullable(false))
6354 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6355 .finish(),
6356 column_comments: BTreeMap::from_iter([
6357 (
6358 "export_id",
6359 "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`.",
6360 ),
6361 (
6362 "dataflow_id",
6363 "The ID of the dataflow. Corresponds to `mz_dataflows.id`.",
6364 ),
6365 ]),
6366 sql: "
6367SELECT export_id, dataflow_id
6368FROM mz_introspection.mz_compute_exports_per_worker
6369WHERE worker_id = 0",
6370 access: vec![PUBLIC_SELECT],
6371});
6372
6373pub static MZ_COMPUTE_FRONTIERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6374 name: "mz_compute_frontiers",
6375 schema: MZ_INTROSPECTION_SCHEMA,
6376 oid: oid::VIEW_MZ_COMPUTE_FRONTIERS_OID,
6377 desc: RelationDesc::builder()
6378 .with_column("export_id", SqlScalarType::String.nullable(false))
6379 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
6380 .with_key(vec![0])
6381 .finish(),
6382 column_comments: BTreeMap::from_iter([
6383 (
6384 "export_id",
6385 "The ID of the dataflow export. Corresponds to `mz_compute_exports.export_id`.",
6386 ),
6387 (
6388 "time",
6389 "The next timestamp at which the dataflow output may change.",
6390 ),
6391 ]),
6392 sql: "SELECT
6393 export_id, pg_catalog.min(time) AS time
6394FROM mz_introspection.mz_compute_frontiers_per_worker
6395GROUP BY export_id",
6396 access: vec![PUBLIC_SELECT],
6397});
6398
6399pub static MZ_DATAFLOW_CHANNEL_OPERATORS_PER_WORKER: LazyLock<BuiltinView> =
6400 LazyLock::new(|| BuiltinView {
6401 name: "mz_dataflow_channel_operators_per_worker",
6402 schema: MZ_INTROSPECTION_SCHEMA,
6403 oid: oid::VIEW_MZ_DATAFLOW_CHANNEL_OPERATORS_PER_WORKER_OID,
6404 desc: RelationDesc::builder()
6405 .with_column("id", SqlScalarType::UInt64.nullable(false))
6406 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6407 .with_column("from_operator_id", SqlScalarType::UInt64.nullable(true))
6408 .with_column(
6409 "from_operator_address",
6410 SqlScalarType::List {
6411 element_type: Box::new(SqlScalarType::UInt64),
6412 custom_id: None,
6413 }
6414 .nullable(true),
6415 )
6416 .with_column("to_operator_id", SqlScalarType::UInt64.nullable(true))
6417 .with_column(
6418 "to_operator_address",
6419 SqlScalarType::List {
6420 element_type: Box::new(SqlScalarType::UInt64),
6421 custom_id: None,
6422 }
6423 .nullable(true),
6424 )
6425 .with_column("type", SqlScalarType::String.nullable(false))
6426 .finish(),
6427 column_comments: BTreeMap::new(),
6428 sql: "
6429WITH
6430channel_addresses(id, worker_id, address, from_index, to_index, type) AS (
6431 SELECT id, worker_id, address, from_index, to_index, type
6432 FROM mz_introspection.mz_dataflow_channels_per_worker mdc
6433 INNER JOIN mz_introspection.mz_dataflow_addresses_per_worker mda
6434 USING (id, worker_id)
6435),
6436channel_operator_addresses(id, worker_id, from_address, to_address, type) AS (
6437 SELECT id, worker_id,
6438 address || from_index AS from_address,
6439 address || to_index AS to_address,
6440 type
6441 FROM channel_addresses
6442),
6443operator_addresses(id, worker_id, address) AS (
6444 SELECT id, worker_id, address
6445 FROM mz_introspection.mz_dataflow_addresses_per_worker mda
6446 INNER JOIN mz_introspection.mz_dataflow_operators_per_worker mdo
6447 USING (id, worker_id)
6448)
6449SELECT coa.id,
6450 coa.worker_id,
6451 from_ops.id AS from_operator_id,
6452 coa.from_address AS from_operator_address,
6453 to_ops.id AS to_operator_id,
6454 coa.to_address AS to_operator_address,
6455 coa.type
6456FROM channel_operator_addresses coa
6457 LEFT OUTER JOIN operator_addresses from_ops
6458 ON coa.from_address = from_ops.address AND
6459 coa.worker_id = from_ops.worker_id
6460 LEFT OUTER JOIN operator_addresses to_ops
6461 ON coa.to_address = to_ops.address AND
6462 coa.worker_id = to_ops.worker_id
6463",
6464 access: vec![PUBLIC_SELECT],
6465 });
6466
6467pub static MZ_DATAFLOW_CHANNEL_OPERATORS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6468 name: "mz_dataflow_channel_operators",
6469 schema: MZ_INTROSPECTION_SCHEMA,
6470 oid: oid::VIEW_MZ_DATAFLOW_CHANNEL_OPERATORS_OID,
6471 desc: RelationDesc::builder()
6472 .with_column("id", SqlScalarType::UInt64.nullable(false))
6473 .with_column("from_operator_id", SqlScalarType::UInt64.nullable(true))
6474 .with_column(
6475 "from_operator_address",
6476 SqlScalarType::List {
6477 element_type: Box::new(SqlScalarType::UInt64),
6478 custom_id: None,
6479 }
6480 .nullable(true),
6481 )
6482 .with_column("to_operator_id", SqlScalarType::UInt64.nullable(true))
6483 .with_column(
6484 "to_operator_address",
6485 SqlScalarType::List {
6486 element_type: Box::new(SqlScalarType::UInt64),
6487 custom_id: None,
6488 }
6489 .nullable(true),
6490 )
6491 .with_column("type", SqlScalarType::String.nullable(false))
6492 .finish(),
6493 column_comments: BTreeMap::from_iter([
6494 (
6495 "id",
6496 "The ID of the channel. Corresponds to `mz_dataflow_channels.id`.",
6497 ),
6498 (
6499 "from_operator_id",
6500 "The ID of the source of the channel. Corresponds to `mz_dataflow_operators.id`.",
6501 ),
6502 (
6503 "from_operator_address",
6504 "The address of the source of the channel. Corresponds to `mz_dataflow_addresses.address`.",
6505 ),
6506 (
6507 "to_operator_id",
6508 "The ID of the target of the channel. Corresponds to `mz_dataflow_operators.id`.",
6509 ),
6510 (
6511 "to_operator_address",
6512 "The address of the target of the channel. Corresponds to `mz_dataflow_addresses.address`.",
6513 ),
6514 ("type", "The container type of the channel."),
6515 ]),
6516 sql: "
6517SELECT id, from_operator_id, from_operator_address, to_operator_id, to_operator_address, type
6518FROM mz_introspection.mz_dataflow_channel_operators_per_worker
6519WHERE worker_id = 0",
6520 access: vec![PUBLIC_SELECT],
6521});
6522
6523pub static MZ_COMPUTE_IMPORT_FRONTIERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6524 name: "mz_compute_import_frontiers",
6525 schema: MZ_INTROSPECTION_SCHEMA,
6526 oid: oid::VIEW_MZ_COMPUTE_IMPORT_FRONTIERS_OID,
6527 desc: RelationDesc::builder()
6528 .with_column("export_id", SqlScalarType::String.nullable(false))
6529 .with_column("import_id", SqlScalarType::String.nullable(false))
6530 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
6531 .with_key(vec![0, 1])
6532 .finish(),
6533 column_comments: BTreeMap::from_iter([
6534 (
6535 "export_id",
6536 "The ID of the dataflow export. Corresponds to `mz_compute_exports.export_id`.",
6537 ),
6538 (
6539 "import_id",
6540 "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`.",
6541 ),
6542 (
6543 "time",
6544 "The next timestamp at which the dataflow input may change.",
6545 ),
6546 ]),
6547 sql: "SELECT
6548 export_id, import_id, pg_catalog.min(time) AS time
6549FROM mz_introspection.mz_compute_import_frontiers_per_worker
6550GROUP BY export_id, import_id",
6551 access: vec![PUBLIC_SELECT],
6552});
6553
6554pub static MZ_RECORDS_PER_DATAFLOW_OPERATOR_PER_WORKER: LazyLock<BuiltinView> =
6555 LazyLock::new(|| BuiltinView {
6556 name: "mz_records_per_dataflow_operator_per_worker",
6557 schema: MZ_INTROSPECTION_SCHEMA,
6558 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_OPERATOR_PER_WORKER_OID,
6559 desc: RelationDesc::builder()
6560 .with_column("id", SqlScalarType::UInt64.nullable(false))
6561 .with_column("name", SqlScalarType::String.nullable(false))
6562 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6563 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6564 .with_column("records", SqlScalarType::Int64.nullable(true))
6565 .with_column("batches", SqlScalarType::Int64.nullable(true))
6566 .with_column("size", SqlScalarType::Int64.nullable(true))
6567 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6568 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6569 .finish(),
6570 column_comments: BTreeMap::new(),
6571 sql: "
6572SELECT
6573 dod.id,
6574 dod.name,
6575 dod.worker_id,
6576 dod.dataflow_id,
6577 ar_size.records AS records,
6578 ar_size.batches AS batches,
6579 ar_size.size AS size,
6580 ar_size.capacity AS capacity,
6581 ar_size.allocations AS allocations
6582FROM
6583 mz_introspection.mz_dataflow_operator_dataflows_per_worker dod
6584 LEFT OUTER JOIN mz_introspection.mz_arrangement_sizes_per_worker ar_size ON
6585 dod.id = ar_size.operator_id AND
6586 dod.worker_id = ar_size.worker_id",
6587 access: vec![PUBLIC_SELECT],
6588 });
6589
6590pub static MZ_RECORDS_PER_DATAFLOW_OPERATOR: LazyLock<BuiltinView> =
6591 LazyLock::new(|| BuiltinView {
6592 name: "mz_records_per_dataflow_operator",
6593 schema: MZ_INTROSPECTION_SCHEMA,
6594 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_OPERATOR_OID,
6595 desc: RelationDesc::builder()
6596 .with_column("id", SqlScalarType::UInt64.nullable(false))
6597 .with_column("name", SqlScalarType::String.nullable(false))
6598 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
6599 .with_column("records", SqlScalarType::Int64.nullable(true))
6600 .with_column("batches", SqlScalarType::Int64.nullable(true))
6601 .with_column("size", SqlScalarType::Int64.nullable(true))
6602 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6603 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6604 .with_key(vec![0, 1, 2])
6605 .finish(),
6606 column_comments: BTreeMap::from_iter([
6607 (
6608 "id",
6609 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
6610 ),
6611 ("name", "The internal name of the operator."),
6612 (
6613 "dataflow_id",
6614 "The ID of the dataflow. Corresponds to `mz_dataflows.id`.",
6615 ),
6616 ("records", "The number of records in the operator."),
6617 ("batches", "The number of batches in the dataflow."),
6618 ("size", "The utilized size in bytes of the arrangement."),
6619 (
6620 "capacity",
6621 "The capacity in bytes of the arrangement. Can be larger than the size.",
6622 ),
6623 (
6624 "allocations",
6625 "The number of separate memory allocations backing the arrangement.",
6626 ),
6627 ]),
6628 sql: "
6629SELECT
6630 id,
6631 name,
6632 dataflow_id,
6633 SUM(records)::int8 AS records,
6634 SUM(batches)::int8 AS batches,
6635 SUM(size)::int8 AS size,
6636 SUM(capacity)::int8 AS capacity,
6637 SUM(allocations)::int8 AS allocations
6638FROM mz_introspection.mz_records_per_dataflow_operator_per_worker
6639GROUP BY id, name, dataflow_id",
6640 access: vec![PUBLIC_SELECT],
6641 });
6642
6643pub static MZ_RECORDS_PER_DATAFLOW_PER_WORKER: LazyLock<BuiltinView> =
6644 LazyLock::new(|| BuiltinView {
6645 name: "mz_records_per_dataflow_per_worker",
6646 schema: MZ_INTROSPECTION_SCHEMA,
6647 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_PER_WORKER_OID,
6648 desc: RelationDesc::builder()
6649 .with_column("id", SqlScalarType::UInt64.nullable(false))
6650 .with_column("name", SqlScalarType::String.nullable(false))
6651 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
6652 .with_column("records", SqlScalarType::Int64.nullable(true))
6653 .with_column("batches", SqlScalarType::Int64.nullable(true))
6654 .with_column("size", SqlScalarType::Int64.nullable(true))
6655 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6656 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6657 .with_key(vec![0, 1, 2])
6658 .finish(),
6659 column_comments: BTreeMap::new(),
6660 sql: "
6661SELECT
6662 rdo.dataflow_id as id,
6663 dfs.name,
6664 rdo.worker_id,
6665 SUM(rdo.records)::int8 as records,
6666 SUM(rdo.batches)::int8 as batches,
6667 SUM(rdo.size)::int8 as size,
6668 SUM(rdo.capacity)::int8 as capacity,
6669 SUM(rdo.allocations)::int8 as allocations
6670FROM
6671 mz_introspection.mz_records_per_dataflow_operator_per_worker rdo,
6672 mz_introspection.mz_dataflows_per_worker dfs
6673WHERE
6674 rdo.dataflow_id = dfs.id AND
6675 rdo.worker_id = dfs.worker_id
6676GROUP BY
6677 rdo.dataflow_id,
6678 dfs.name,
6679 rdo.worker_id",
6680 access: vec![PUBLIC_SELECT],
6681 });
6682
6683pub static MZ_RECORDS_PER_DATAFLOW: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6684 name: "mz_records_per_dataflow",
6685 schema: MZ_INTROSPECTION_SCHEMA,
6686 oid: oid::VIEW_MZ_RECORDS_PER_DATAFLOW_OID,
6687 desc: RelationDesc::builder()
6688 .with_column("id", SqlScalarType::UInt64.nullable(false))
6689 .with_column("name", SqlScalarType::String.nullable(false))
6690 .with_column("records", SqlScalarType::Int64.nullable(true))
6691 .with_column("batches", SqlScalarType::Int64.nullable(true))
6692 .with_column("size", SqlScalarType::Int64.nullable(true))
6693 .with_column("capacity", SqlScalarType::Int64.nullable(true))
6694 .with_column("allocations", SqlScalarType::Int64.nullable(true))
6695 .with_key(vec![0, 1])
6696 .finish(),
6697 column_comments: BTreeMap::from_iter([
6698 (
6699 "id",
6700 "The ID of the dataflow. Corresponds to `mz_dataflows.id`.",
6701 ),
6702 ("name", "The internal name of the dataflow."),
6703 ("records", "The number of records in the dataflow."),
6704 ("batches", "The number of batches in the dataflow."),
6705 ("size", "The utilized size in bytes of the arrangements."),
6706 (
6707 "capacity",
6708 "The capacity in bytes of the arrangements. Can be larger than the size.",
6709 ),
6710 (
6711 "allocations",
6712 "The number of separate memory allocations backing the arrangements.",
6713 ),
6714 ]),
6715 sql: "
6716SELECT
6717 id,
6718 name,
6719 SUM(records)::int8 as records,
6720 SUM(batches)::int8 as batches,
6721 SUM(size)::int8 as size,
6722 SUM(capacity)::int8 as capacity,
6723 SUM(allocations)::int8 as allocations
6724FROM
6725 mz_introspection.mz_records_per_dataflow_per_worker
6726GROUP BY
6727 id,
6728 name",
6729 access: vec![PUBLIC_SELECT],
6730});
6731
6732pub static PG_NAMESPACE_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6738 name: "pg_namespace_all_databases",
6739 schema: MZ_INTERNAL_SCHEMA,
6740 oid: oid::VIEW_PG_NAMESPACE_ALL_DATABASES_OID,
6741 desc: RelationDesc::builder()
6742 .with_column("oid", SqlScalarType::Oid.nullable(false))
6743 .with_column("nspname", SqlScalarType::String.nullable(false))
6744 .with_column("nspowner", SqlScalarType::Oid.nullable(false))
6745 .with_column(
6746 "nspacl",
6747 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
6748 )
6749 .with_column("database_name", SqlScalarType::String.nullable(true))
6750 .finish(),
6751 column_comments: BTreeMap::new(),
6752 sql: "
6753SELECT
6754 s.oid AS oid,
6755 s.name AS nspname,
6756 role_owner.oid AS nspowner,
6757 NULL::pg_catalog.text[] AS nspacl,
6758 d.name as database_name
6759FROM mz_catalog.mz_schemas s
6760LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
6761JOIN mz_catalog.mz_roles role_owner ON role_owner.id = s.owner_id",
6762 access: vec![PUBLIC_SELECT],
6763});
6764
6765pub const PG_NAMESPACE_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
6766 name: "pg_namespace_all_databases_ind",
6767 schema: MZ_INTERNAL_SCHEMA,
6768 oid: oid::INDEX_PG_NAMESPACE_ALL_DATABASES_IND_OID,
6769 sql: "IN CLUSTER mz_catalog_server
6770ON mz_internal.pg_namespace_all_databases (nspname)",
6771 is_retained_metrics_object: false,
6772};
6773
6774pub static PG_NAMESPACE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6775 name: "pg_namespace",
6776 schema: PG_CATALOG_SCHEMA,
6777 oid: oid::VIEW_PG_NAMESPACE_OID,
6778 desc: RelationDesc::builder()
6779 .with_column("oid", SqlScalarType::Oid.nullable(false))
6780 .with_column("nspname", SqlScalarType::String.nullable(false))
6781 .with_column("nspowner", SqlScalarType::Oid.nullable(false))
6782 .with_column(
6783 "nspacl",
6784 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
6785 )
6786 .finish(),
6787 column_comments: BTreeMap::new(),
6788 sql: "
6789SELECT
6790 oid, nspname, nspowner, nspacl
6791FROM mz_internal.pg_namespace_all_databases
6792WHERE database_name IS NULL OR database_name = pg_catalog.current_database();",
6793 access: vec![PUBLIC_SELECT],
6794});
6795
6796pub static PG_CLASS_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
6802 BuiltinView {
6803 name: "pg_class_all_databases",
6804 schema: MZ_INTERNAL_SCHEMA,
6805 oid: oid::VIEW_PG_CLASS_ALL_DATABASES_OID,
6806 desc: RelationDesc::builder()
6807 .with_column("oid", SqlScalarType::Oid.nullable(false))
6808 .with_column("relname", SqlScalarType::String.nullable(false))
6809 .with_column("relnamespace", SqlScalarType::Oid.nullable(false))
6810 .with_column("reloftype", SqlScalarType::Oid.nullable(false))
6811 .with_column("relowner", SqlScalarType::Oid.nullable(false))
6812 .with_column("relam", SqlScalarType::Oid.nullable(false))
6813 .with_column("reltablespace", SqlScalarType::Oid.nullable(false))
6814 .with_column("reltuples", SqlScalarType::Float32.nullable(false))
6815 .with_column("reltoastrelid", SqlScalarType::Oid.nullable(false))
6816 .with_column("relhasindex", SqlScalarType::Bool.nullable(false))
6817 .with_column("relpersistence", SqlScalarType::PgLegacyChar.nullable(false))
6818 .with_column("relkind", SqlScalarType::String.nullable(true))
6819 .with_column("relnatts", SqlScalarType::Int16.nullable(false))
6820 .with_column("relchecks", SqlScalarType::Int16.nullable(false))
6821 .with_column("relhasrules", SqlScalarType::Bool.nullable(false))
6822 .with_column("relhastriggers", SqlScalarType::Bool.nullable(false))
6823 .with_column("relhassubclass", SqlScalarType::Bool.nullable(false))
6824 .with_column("relrowsecurity", SqlScalarType::Bool.nullable(false))
6825 .with_column("relforcerowsecurity", SqlScalarType::Bool.nullable(false))
6826 .with_column("relreplident", SqlScalarType::PgLegacyChar.nullable(false))
6827 .with_column("relispartition", SqlScalarType::Bool.nullable(false))
6828 .with_column("relhasoids", SqlScalarType::Bool.nullable(false))
6829 .with_column("reloptions", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true))
6830 .with_column("database_name", SqlScalarType::String.nullable(true))
6831 .finish(),
6832 column_comments: BTreeMap::new(),
6833 sql: "
6834SELECT
6835 class_objects.oid,
6836 class_objects.name AS relname,
6837 mz_schemas.oid AS relnamespace,
6838 -- MZ doesn't support typed tables so reloftype is filled with 0
6839 0::pg_catalog.oid AS reloftype,
6840 role_owner.oid AS relowner,
6841 0::pg_catalog.oid AS relam,
6842 -- MZ doesn't have tablespaces so reltablespace is filled in with 0 implying the default tablespace
6843 0::pg_catalog.oid AS reltablespace,
6844 -- MZ doesn't support (estimated) row counts currently.
6845 -- Postgres defines a value of -1 as unknown.
6846 -1::float4 as reltuples,
6847 -- MZ doesn't use TOAST tables so reltoastrelid is filled with 0
6848 0::pg_catalog.oid AS reltoastrelid,
6849 EXISTS (SELECT id, oid, name, on_id, cluster_id FROM mz_catalog.mz_indexes where mz_indexes.on_id = class_objects.id) AS relhasindex,
6850 -- MZ doesn't have unlogged tables and because of (https://github.com/MaterializeInc/database-issues/issues/2689)
6851 -- temporary objects don't show up here, so relpersistence is filled with 'p' for permanent.
6852 -- TODO(jkosh44): update this column when issue is resolved.
6853 'p'::pg_catalog.\"char\" AS relpersistence,
6854 CASE
6855 WHEN class_objects.type = 'table' THEN 'r'
6856 WHEN class_objects.type = 'source' THEN 'r'
6857 WHEN class_objects.type = 'index' THEN 'i'
6858 WHEN class_objects.type = 'view' THEN 'v'
6859 WHEN class_objects.type = 'materialized-view' THEN 'm'
6860 END relkind,
6861 COALESCE(
6862 (
6863 SELECT count(*)::pg_catalog.int2
6864 FROM mz_catalog.mz_columns
6865 WHERE mz_columns.id = class_objects.id
6866 ),
6867 0::pg_catalog.int2
6868 ) AS relnatts,
6869 -- MZ doesn't support CHECK constraints so relchecks is filled with 0
6870 0::pg_catalog.int2 AS relchecks,
6871 -- MZ doesn't support creating rules so relhasrules is filled with false
6872 false AS relhasrules,
6873 -- MZ doesn't support creating triggers so relhastriggers is filled with false
6874 false AS relhastriggers,
6875 -- MZ doesn't support table inheritance or partitions so relhassubclass is filled with false
6876 false AS relhassubclass,
6877 -- MZ doesn't have row level security so relrowsecurity and relforcerowsecurity is filled with false
6878 false AS relrowsecurity,
6879 false AS relforcerowsecurity,
6880 -- MZ doesn't support replication so relreplident is filled with 'd' for default
6881 'd'::pg_catalog.\"char\" AS relreplident,
6882 -- MZ doesn't support table partitioning so relispartition is filled with false
6883 false AS relispartition,
6884 -- PG removed relhasoids in v12 so it's filled with false
6885 false AS relhasoids,
6886 -- MZ doesn't support options for relations
6887 NULL::pg_catalog.text[] as reloptions,
6888 d.name as database_name
6889FROM (
6890 -- pg_class catalogs relations and indexes
6891 SELECT id, oid, schema_id, name, type, owner_id FROM mz_catalog.mz_relations
6892 UNION ALL
6893 SELECT mz_indexes.id, mz_indexes.oid, mz_relations.schema_id, mz_indexes.name, 'index' AS type, mz_indexes.owner_id
6894 FROM mz_catalog.mz_indexes
6895 JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
6896) AS class_objects
6897JOIN mz_catalog.mz_schemas ON mz_schemas.id = class_objects.schema_id
6898LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
6899JOIN mz_catalog.mz_roles role_owner ON role_owner.id = class_objects.owner_id",
6900 access: vec![PUBLIC_SELECT],
6901 }
6902});
6903
6904pub const PG_CLASS_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
6905 name: "pg_class_all_databases_ind",
6906 schema: MZ_INTERNAL_SCHEMA,
6907 oid: oid::INDEX_PG_CLASS_ALL_DATABASES_IND_OID,
6908 sql: "IN CLUSTER mz_catalog_server
6909ON mz_internal.pg_class_all_databases (relname)",
6910 is_retained_metrics_object: false,
6911};
6912
6913pub static PG_CLASS: LazyLock<BuiltinView> = LazyLock::new(|| {
6914 BuiltinView {
6915 name: "pg_class",
6916 schema: PG_CATALOG_SCHEMA,
6917 oid: oid::VIEW_PG_CLASS_OID,
6918 desc: RelationDesc::builder()
6919 .with_column("oid", SqlScalarType::Oid.nullable(false))
6920 .with_column("relname", SqlScalarType::String.nullable(false))
6921 .with_column("relnamespace", SqlScalarType::Oid.nullable(false))
6922 .with_column("reloftype", SqlScalarType::Oid.nullable(false))
6923 .with_column("relowner", SqlScalarType::Oid.nullable(false))
6924 .with_column("relam", SqlScalarType::Oid.nullable(false))
6925 .with_column("reltablespace", SqlScalarType::Oid.nullable(false))
6926 .with_column("reltuples", SqlScalarType::Float32.nullable(false))
6927 .with_column("reltoastrelid", SqlScalarType::Oid.nullable(false))
6928 .with_column("relhasindex", SqlScalarType::Bool.nullable(false))
6929 .with_column("relpersistence", SqlScalarType::PgLegacyChar.nullable(false))
6930 .with_column("relkind", SqlScalarType::String.nullable(true))
6931 .with_column("relnatts", SqlScalarType::Int16.nullable(false))
6932 .with_column("relchecks", SqlScalarType::Int16.nullable(false))
6933 .with_column("relhasrules", SqlScalarType::Bool.nullable(false))
6934 .with_column("relhastriggers", SqlScalarType::Bool.nullable(false))
6935 .with_column("relhassubclass", SqlScalarType::Bool.nullable(false))
6936 .with_column("relrowsecurity", SqlScalarType::Bool.nullable(false))
6937 .with_column("relforcerowsecurity", SqlScalarType::Bool.nullable(false))
6938 .with_column("relreplident", SqlScalarType::PgLegacyChar.nullable(false))
6939 .with_column("relispartition", SqlScalarType::Bool.nullable(false))
6940 .with_column("relhasoids", SqlScalarType::Bool.nullable(false))
6941 .with_column(
6942 "reloptions",
6943 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
6944 )
6945 .finish(),
6946 column_comments: BTreeMap::new(),
6947 sql: "
6948SELECT
6949 oid, relname, relnamespace, reloftype, relowner, relam, reltablespace, reltuples, reltoastrelid,
6950 relhasindex, relpersistence, relkind, relnatts, relchecks, relhasrules, relhastriggers, relhassubclass,
6951 relrowsecurity, relforcerowsecurity, relreplident, relispartition, relhasoids, reloptions
6952FROM mz_internal.pg_class_all_databases
6953WHERE database_name IS NULL OR database_name = pg_catalog.current_database();
6954",
6955 access: vec![PUBLIC_SELECT],
6956}
6957});
6958
6959pub static PG_DEPEND: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
6960 name: "pg_depend",
6961 schema: PG_CATALOG_SCHEMA,
6962 oid: oid::VIEW_PG_DEPEND_OID,
6963 desc: RelationDesc::builder()
6964 .with_column("classid", SqlScalarType::Oid.nullable(true))
6965 .with_column("objid", SqlScalarType::Oid.nullable(false))
6966 .with_column("objsubid", SqlScalarType::Int32.nullable(false))
6967 .with_column("refclassid", SqlScalarType::Oid.nullable(true))
6968 .with_column("refobjid", SqlScalarType::Oid.nullable(false))
6969 .with_column("refobjsubid", SqlScalarType::Int32.nullable(false))
6970 .with_column("deptype", SqlScalarType::PgLegacyChar.nullable(false))
6971 .finish(),
6972 column_comments: BTreeMap::new(),
6973 sql: "
6974WITH class_objects AS (
6975 SELECT
6976 CASE
6977 WHEN type = 'table' THEN 'pg_tables'::pg_catalog.regclass::pg_catalog.oid
6978 WHEN type = 'source' THEN 'pg_tables'::pg_catalog.regclass::pg_catalog.oid
6979 WHEN type = 'view' THEN 'pg_views'::pg_catalog.regclass::pg_catalog.oid
6980 WHEN type = 'materialized-view' THEN 'pg_matviews'::pg_catalog.regclass::pg_catalog.oid
6981 END classid,
6982 id,
6983 oid,
6984 schema_id
6985 FROM mz_catalog.mz_relations
6986 UNION ALL
6987 SELECT
6988 'pg_index'::pg_catalog.regclass::pg_catalog.oid AS classid,
6989 i.id,
6990 i.oid,
6991 r.schema_id
6992 FROM mz_catalog.mz_indexes i
6993 JOIN mz_catalog.mz_relations r ON i.on_id = r.id
6994),
6995
6996current_objects AS (
6997 SELECT class_objects.*
6998 FROM class_objects
6999 JOIN mz_catalog.mz_schemas ON mz_schemas.id = class_objects.schema_id
7000 LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
7001 -- This filter is tricky, as it filters out not just objects outside the
7002 -- database, but *dependencies* on objects outside this database. It's not
7003 -- clear that this is the right choice, but because PostgreSQL doesn't
7004 -- support cross-database references, it's not clear that the other choice
7005 -- is better.
7006 WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()
7007)
7008
7009SELECT
7010 objects.classid::pg_catalog.oid,
7011 objects.oid::pg_catalog.oid AS objid,
7012 0::pg_catalog.int4 AS objsubid,
7013 dependents.classid::pg_catalog.oid AS refclassid,
7014 dependents.oid::pg_catalog.oid AS refobjid,
7015 0::pg_catalog.int4 AS refobjsubid,
7016 'n'::pg_catalog.char AS deptype
7017FROM mz_internal.mz_object_dependencies
7018JOIN current_objects objects ON object_id = objects.id
7019JOIN current_objects dependents ON referenced_object_id = dependents.id",
7020 access: vec![PUBLIC_SELECT],
7021});
7022
7023pub static PG_DATABASE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7024 name: "pg_database",
7025 schema: PG_CATALOG_SCHEMA,
7026 oid: oid::VIEW_PG_DATABASE_OID,
7027 desc: RelationDesc::builder()
7028 .with_column("oid", SqlScalarType::Oid.nullable(false))
7029 .with_column("datname", SqlScalarType::String.nullable(false))
7030 .with_column("datdba", SqlScalarType::Oid.nullable(false))
7031 .with_column("encoding", SqlScalarType::Int32.nullable(false))
7032 .with_column("datistemplate", SqlScalarType::Bool.nullable(false))
7033 .with_column("datallowconn", SqlScalarType::Bool.nullable(false))
7034 .with_column("datcollate", SqlScalarType::String.nullable(false))
7035 .with_column("datctype", SqlScalarType::String.nullable(false))
7036 .with_column(
7037 "datacl",
7038 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
7039 )
7040 .with_key(vec![0])
7041 .finish(),
7042 column_comments: BTreeMap::new(),
7043 sql: "SELECT
7044 d.oid as oid,
7045 d.name as datname,
7046 role_owner.oid as datdba,
7047 6 as encoding,
7048 -- Materialize doesn't support database cloning.
7049 FALSE AS datistemplate,
7050 TRUE AS datallowconn,
7051 'C' as datcollate,
7052 'C' as datctype,
7053 NULL::pg_catalog.text[] as datacl
7054FROM mz_catalog.mz_databases d
7055JOIN mz_catalog.mz_roles role_owner ON role_owner.id = d.owner_id",
7056 access: vec![PUBLIC_SELECT],
7057});
7058
7059pub static PG_INDEX: LazyLock<BuiltinView> = LazyLock::new(|| {
7060 BuiltinView {
7061 name: "pg_index",
7062 schema: PG_CATALOG_SCHEMA,
7063 oid: oid::VIEW_PG_INDEX_OID,
7064 desc: RelationDesc::builder()
7065 .with_column("indexrelid", SqlScalarType::Oid.nullable(false))
7066 .with_column("indrelid", SqlScalarType::Oid.nullable(false))
7067 .with_column("indnatts", SqlScalarType::Int16.nullable(false))
7068 .with_column("indisunique", SqlScalarType::Bool.nullable(false))
7069 .with_column("indisprimary", SqlScalarType::Bool.nullable(false))
7070 .with_column("indimmediate", SqlScalarType::Bool.nullable(false))
7071 .with_column("indisclustered", SqlScalarType::Bool.nullable(false))
7072 .with_column("indisvalid", SqlScalarType::Bool.nullable(false))
7073 .with_column("indisreplident", SqlScalarType::Bool.nullable(false))
7074 .with_column("indkey", SqlScalarType::Int2Vector.nullable(false))
7075 .with_column("indoption", SqlScalarType::Int2Vector.nullable(false))
7076 .with_column("indexprs", SqlScalarType::String.nullable(true))
7077 .with_column("indpred", SqlScalarType::String.nullable(true))
7078 .with_key(vec![0, 1])
7079 .finish(),
7080 column_comments: BTreeMap::new(),
7081 sql: "SELECT
7082 mz_indexes.oid AS indexrelid,
7083 mz_relations.oid AS indrelid,
7084 COALESCE(
7085 (
7086 SELECT count(*)::pg_catalog.int2
7087 FROM mz_catalog.mz_columns
7088 JOIN mz_catalog.mz_relations mri ON mz_columns.id = mri.id
7089 WHERE mri.oid = mz_catalog.mz_relations.oid
7090 ),
7091 0::pg_catalog.int2
7092 ) AS indnatts,
7093 -- MZ doesn't support creating unique indexes so indisunique is filled with false
7094 false::pg_catalog.bool AS indisunique,
7095 false::pg_catalog.bool AS indisprimary,
7096 -- MZ doesn't support unique indexes so indimmediate is filled with false
7097 false::pg_catalog.bool AS indimmediate,
7098 -- MZ doesn't support CLUSTER so indisclustered is filled with false
7099 false::pg_catalog.bool AS indisclustered,
7100 -- MZ never creates invalid indexes so indisvalid is filled with true
7101 true::pg_catalog.bool AS indisvalid,
7102 -- MZ doesn't support replication so indisreplident is filled with false
7103 false::pg_catalog.bool AS indisreplident,
7104 -- Return zero if the index attribute is not a simple column reference, column position otherwise
7105 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,
7106 -- MZ doesn't have per-column flags, so returning a 0 for each column in the index
7107 pg_catalog.string_agg('0', ' ')::pg_catalog.int2vector AS indoption,
7108 -- Index expressions are returned in MZ format
7109 CASE pg_catalog.string_agg(mz_index_columns.on_expression, ' ' ORDER BY mz_index_columns.index_position::int8)
7110 WHEN NULL THEN NULL
7111 ELSE '{' || pg_catalog.string_agg(mz_index_columns.on_expression, '}, {' ORDER BY mz_index_columns.index_position::int8) || '}'
7112 END AS indexprs,
7113 -- MZ doesn't support indexes with predicates
7114 NULL::pg_catalog.text AS indpred
7115FROM mz_catalog.mz_indexes
7116JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
7117JOIN mz_catalog.mz_index_columns ON mz_index_columns.index_id = mz_indexes.id
7118JOIN mz_catalog.mz_schemas ON mz_schemas.id = mz_relations.schema_id
7119LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
7120WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()
7121GROUP BY mz_indexes.oid, mz_relations.oid",
7122 access: vec![PUBLIC_SELECT],
7123 }
7124});
7125
7126pub static PG_INDEXES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7127 name: "pg_indexes",
7128 schema: PG_CATALOG_SCHEMA,
7129 oid: oid::VIEW_PG_INDEXES_OID,
7130 desc: RelationDesc::builder()
7131 .with_column("table_catalog", SqlScalarType::String.nullable(false))
7132 .with_column("schemaname", SqlScalarType::String.nullable(false))
7133 .with_column("tablename", SqlScalarType::String.nullable(false))
7134 .with_column("indexname", SqlScalarType::String.nullable(false))
7135 .with_column("tablespace", SqlScalarType::String.nullable(true))
7136 .with_column("indexdef", SqlScalarType::String.nullable(true))
7137 .finish(),
7138 column_comments: BTreeMap::new(),
7139 sql: "SELECT
7140 current_database() as table_catalog,
7141 s.name AS schemaname,
7142 r.name AS tablename,
7143 i.name AS indexname,
7144 NULL::text AS tablespace,
7145 -- TODO(jkosh44) Fill in with actual index definition.
7146 NULL::text AS indexdef
7147FROM mz_catalog.mz_indexes i
7148JOIN mz_catalog.mz_relations r ON i.on_id = r.id
7149JOIN mz_catalog.mz_schemas s ON s.id = r.schema_id
7150LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
7151WHERE s.database_id IS NULL OR d.name = current_database()",
7152 access: vec![PUBLIC_SELECT],
7153});
7154
7155pub static PG_DESCRIPTION_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
7161 BuiltinView {
7162 name: "pg_description_all_databases",
7163 schema: MZ_INTERNAL_SCHEMA,
7164 oid: oid::VIEW_PG_DESCRIPTION_ALL_DATABASES_OID,
7165 desc: RelationDesc::builder()
7166 .with_column("objoid", SqlScalarType::Oid.nullable(false))
7167 .with_column("classoid", SqlScalarType::Oid.nullable(true))
7168 .with_column("objsubid", SqlScalarType::Int32.nullable(false))
7169 .with_column("description", SqlScalarType::String.nullable(false))
7170 .with_column("oid_database_name", SqlScalarType::String.nullable(true))
7171 .with_column("class_database_name", SqlScalarType::String.nullable(true))
7172 .finish(),
7173 column_comments: BTreeMap::new(),
7174 sql: "
7175(
7176 -- Gather all of the class oid's for objects that can have comments.
7177 WITH pg_classoids AS (
7178 SELECT oid, database_name as oid_database_name,
7179 (SELECT oid FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_class') AS classoid,
7180 (SELECT database_name FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_class') AS class_database_name
7181 FROM mz_internal.pg_class_all_databases
7182 UNION ALL
7183 SELECT oid, database_name as oid_database_name,
7184 (SELECT oid FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_type') AS classoid,
7185 (SELECT database_name FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_type') AS class_database_name
7186 FROM mz_internal.pg_type_all_databases
7187 UNION ALL
7188 SELECT oid, database_name as oid_database_name,
7189 (SELECT oid FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_namespace') AS classoid,
7190 (SELECT database_name FROM mz_internal.pg_class_all_databases WHERE relname = 'pg_namespace') AS class_database_name
7191 FROM mz_internal.pg_namespace_all_databases
7192 ),
7193
7194 -- Gather all of the MZ ids for objects that can have comments.
7195 mz_objects AS (
7196 SELECT id, oid, type FROM mz_catalog.mz_objects
7197 UNION ALL
7198 SELECT id, oid, 'schema' AS type FROM mz_catalog.mz_schemas
7199 )
7200 SELECT
7201 pg_classoids.oid AS objoid,
7202 pg_classoids.classoid as classoid,
7203 COALESCE(cmt.object_sub_id, 0) AS objsubid,
7204 cmt.comment AS description,
7205 -- Columns added because of the peeling. (Note that there are 2 of these here.)
7206 oid_database_name,
7207 class_database_name
7208 FROM
7209 pg_classoids
7210 JOIN
7211 mz_objects ON pg_classoids.oid = mz_objects.oid
7212 JOIN
7213 mz_internal.mz_comments AS cmt ON mz_objects.id = cmt.id AND lower(mz_objects.type) = lower(cmt.object_type)
7214)",
7215 access: vec![PUBLIC_SELECT],
7216 }
7217});
7218
7219pub const PG_DESCRIPTION_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7220 name: "pg_description_all_databases_ind",
7221 schema: MZ_INTERNAL_SCHEMA,
7222 oid: oid::INDEX_PG_DESCRIPTION_ALL_DATABASES_IND_OID,
7223 sql: "IN CLUSTER mz_catalog_server
7224ON mz_internal.pg_description_all_databases (objoid, classoid, objsubid, description, oid_database_name, class_database_name)",
7225 is_retained_metrics_object: false,
7226};
7227
7228pub static PG_DESCRIPTION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7232 name: "pg_description",
7233 schema: PG_CATALOG_SCHEMA,
7234 oid: oid::VIEW_PG_DESCRIPTION_OID,
7235 desc: RelationDesc::builder()
7236 .with_column("objoid", SqlScalarType::Oid.nullable(false))
7237 .with_column("classoid", SqlScalarType::Oid.nullable(true))
7238 .with_column("objsubid", SqlScalarType::Int32.nullable(false))
7239 .with_column("description", SqlScalarType::String.nullable(false))
7240 .finish(),
7241 column_comments: BTreeMap::new(),
7242 sql: "
7243SELECT
7244 objoid,
7245 classoid,
7246 objsubid,
7247 description
7248FROM
7249 mz_internal.pg_description_all_databases
7250WHERE
7251 (oid_database_name IS NULL OR oid_database_name = pg_catalog.current_database()) AND
7252 (class_database_name IS NULL OR class_database_name = pg_catalog.current_database());",
7253 access: vec![PUBLIC_SELECT],
7254});
7255
7256pub static PG_TYPE_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
7262 BuiltinView {
7263 name: "pg_type_all_databases",
7264 schema: MZ_INTERNAL_SCHEMA,
7265 oid: oid::VIEW_PG_TYPE_ALL_DATABASES_OID,
7266 desc: RelationDesc::builder()
7267 .with_column("oid", SqlScalarType::Oid.nullable(false))
7268 .with_column("typname", SqlScalarType::String.nullable(false))
7269 .with_column("typnamespace", SqlScalarType::Oid.nullable(false))
7270 .with_column("typowner", SqlScalarType::Oid.nullable(false))
7271 .with_column("typlen", SqlScalarType::Int16.nullable(true))
7272 .with_column("typtype", SqlScalarType::PgLegacyChar.nullable(false))
7273 .with_column("typcategory", SqlScalarType::PgLegacyChar.nullable(true))
7274 .with_column("typdelim", SqlScalarType::PgLegacyChar.nullable(false))
7275 .with_column("typrelid", SqlScalarType::Oid.nullable(false))
7276 .with_column("typelem", SqlScalarType::Oid.nullable(false))
7277 .with_column("typarray", SqlScalarType::Oid.nullable(false))
7278 .with_column("typinput", SqlScalarType::RegProc.nullable(true))
7279 .with_column("typreceive", SqlScalarType::Oid.nullable(false))
7280 .with_column("typnotnull", SqlScalarType::Bool.nullable(false))
7281 .with_column("typbasetype", SqlScalarType::Oid.nullable(false))
7282 .with_column("typtypmod", SqlScalarType::Int32.nullable(false))
7283 .with_column("typcollation", SqlScalarType::Oid.nullable(false))
7284 .with_column("typdefault", SqlScalarType::String.nullable(true))
7285 .with_column("database_name", SqlScalarType::String.nullable(true))
7286 .finish(),
7287 column_comments: BTreeMap::new(),
7288 sql: "
7289SELECT
7290 mz_types.oid,
7291 mz_types.name AS typname,
7292 mz_schemas.oid AS typnamespace,
7293 role_owner.oid AS typowner,
7294 NULL::pg_catalog.int2 AS typlen,
7295 -- 'a' is used internally to denote an array type, but in postgres they show up
7296 -- as 'b'.
7297 (CASE mztype WHEN 'a' THEN 'b' ELSE mztype END)::pg_catalog.char AS typtype,
7298 (CASE category
7299 WHEN 'array' THEN 'A'
7300 WHEN 'bit-string' THEN 'V'
7301 WHEN 'boolean' THEN 'B'
7302 WHEN 'composite' THEN 'C'
7303 WHEN 'date-time' THEN 'D'
7304 WHEN 'enum' THEN 'E'
7305 WHEN 'geometric' THEN 'G'
7306 WHEN 'list' THEN 'U' -- List types are user-defined from PostgreSQL's perspective.
7307 WHEN 'network-address' THEN 'I'
7308 WHEN 'numeric' THEN 'N'
7309 WHEN 'pseudo' THEN 'P'
7310 WHEN 'string' THEN 'S'
7311 WHEN 'timespan' THEN 'T'
7312 WHEN 'user-defined' THEN 'U'
7313 WHEN 'unknown' THEN 'X'
7314 END)::pg_catalog.char AS typcategory,
7315 -- In pg only the 'box' type is not ','.
7316 ','::pg_catalog.char AS typdelim,
7317 0::pg_catalog.oid AS typrelid,
7318 coalesce(
7319 (
7320 SELECT t.oid
7321 FROM mz_catalog.mz_array_types a
7322 JOIN mz_catalog.mz_types t ON a.element_id = t.id
7323 WHERE a.id = mz_types.id
7324 ),
7325 0
7326 ) AS typelem,
7327 coalesce(
7328 (
7329 SELECT
7330 t.oid
7331 FROM
7332 mz_catalog.mz_array_types AS a
7333 JOIN mz_catalog.mz_types AS t ON a.id = t.id
7334 WHERE
7335 a.element_id = mz_types.id
7336 ),
7337 0
7338 )
7339 AS typarray,
7340 mz_internal.mz_type_pg_metadata.typinput::pg_catalog.regproc AS typinput,
7341 COALESCE(mz_internal.mz_type_pg_metadata.typreceive, 0) AS typreceive,
7342 false::pg_catalog.bool AS typnotnull,
7343 0::pg_catalog.oid AS typbasetype,
7344 -1::pg_catalog.int4 AS typtypmod,
7345 -- MZ doesn't support COLLATE so typcollation is filled with 0
7346 0::pg_catalog.oid AS typcollation,
7347 NULL::pg_catalog.text AS typdefault,
7348 d.name as database_name
7349FROM
7350 mz_catalog.mz_types
7351 LEFT JOIN mz_internal.mz_type_pg_metadata ON mz_catalog.mz_types.id = mz_internal.mz_type_pg_metadata.id
7352 JOIN mz_catalog.mz_schemas ON mz_schemas.id = mz_types.schema_id
7353 JOIN (
7354 -- 'a' is not a supported typtype, but we use it to denote an array. It is
7355 -- converted to the correct value above.
7356 SELECT id, 'a' AS mztype FROM mz_catalog.mz_array_types
7357 UNION ALL SELECT id, 'b' FROM mz_catalog.mz_base_types
7358 UNION ALL SELECT id, 'l' FROM mz_catalog.mz_list_types
7359 UNION ALL SELECT id, 'm' FROM mz_catalog.mz_map_types
7360 UNION ALL SELECT id, 'p' FROM mz_catalog.mz_pseudo_types
7361 )
7362 AS t ON mz_types.id = t.id
7363 LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
7364 JOIN mz_catalog.mz_roles role_owner ON role_owner.id = mz_types.owner_id",
7365 access: vec![PUBLIC_SELECT],
7366 }
7367});
7368
7369pub const PG_TYPE_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7370 name: "pg_type_all_databases_ind",
7371 schema: MZ_INTERNAL_SCHEMA,
7372 oid: oid::INDEX_PG_TYPE_ALL_DATABASES_IND_OID,
7373 sql: "IN CLUSTER mz_catalog_server
7374ON mz_internal.pg_type_all_databases (oid)",
7375 is_retained_metrics_object: false,
7376};
7377
7378pub static PG_TYPE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7379 name: "pg_type",
7380 schema: PG_CATALOG_SCHEMA,
7381 oid: oid::VIEW_PG_TYPE_OID,
7382 desc: RelationDesc::builder()
7383 .with_column("oid", SqlScalarType::Oid.nullable(false))
7384 .with_column("typname", SqlScalarType::String.nullable(false))
7385 .with_column("typnamespace", SqlScalarType::Oid.nullable(false))
7386 .with_column("typowner", SqlScalarType::Oid.nullable(false))
7387 .with_column("typlen", SqlScalarType::Int16.nullable(true))
7388 .with_column("typtype", SqlScalarType::PgLegacyChar.nullable(false))
7389 .with_column("typcategory", SqlScalarType::PgLegacyChar.nullable(true))
7390 .with_column("typdelim", SqlScalarType::PgLegacyChar.nullable(false))
7391 .with_column("typrelid", SqlScalarType::Oid.nullable(false))
7392 .with_column("typelem", SqlScalarType::Oid.nullable(false))
7393 .with_column("typarray", SqlScalarType::Oid.nullable(false))
7394 .with_column("typinput", SqlScalarType::RegProc.nullable(true))
7395 .with_column("typreceive", SqlScalarType::Oid.nullable(false))
7396 .with_column("typnotnull", SqlScalarType::Bool.nullable(false))
7397 .with_column("typbasetype", SqlScalarType::Oid.nullable(false))
7398 .with_column("typtypmod", SqlScalarType::Int32.nullable(false))
7399 .with_column("typcollation", SqlScalarType::Oid.nullable(false))
7400 .with_column("typdefault", SqlScalarType::String.nullable(true))
7401 .finish(),
7402 column_comments: BTreeMap::new(),
7403 sql: "SELECT
7404 oid, typname, typnamespace, typowner, typlen, typtype, typcategory, typdelim, typrelid, typelem,
7405 typarray, typinput, typreceive, typnotnull, typbasetype, typtypmod, typcollation, typdefault
7406FROM mz_internal.pg_type_all_databases
7407WHERE database_name IS NULL OR database_name = pg_catalog.current_database();",
7408 access: vec![PUBLIC_SELECT],
7409});
7410
7411pub static PG_ATTRIBUTE_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| {
7417 BuiltinView {
7418 name: "pg_attribute_all_databases",
7419 schema: MZ_INTERNAL_SCHEMA,
7420 oid: oid::VIEW_PG_ATTRIBUTE_ALL_DATABASES_OID,
7421 desc: RelationDesc::builder()
7422 .with_column("attrelid", SqlScalarType::Oid.nullable(false))
7423 .with_column("attname", SqlScalarType::String.nullable(false))
7424 .with_column("atttypid", SqlScalarType::Oid.nullable(false))
7425 .with_column("attlen", SqlScalarType::Int16.nullable(true))
7426 .with_column("attnum", SqlScalarType::Int16.nullable(false))
7427 .with_column("atttypmod", SqlScalarType::Int32.nullable(false))
7428 .with_column("attnotnull", SqlScalarType::Bool.nullable(false))
7429 .with_column("atthasdef", SqlScalarType::Bool.nullable(false))
7430 .with_column("attidentity", SqlScalarType::PgLegacyChar.nullable(false))
7431 .with_column("attgenerated", SqlScalarType::PgLegacyChar.nullable(false))
7432 .with_column("attisdropped", SqlScalarType::Bool.nullable(false))
7433 .with_column("attcollation", SqlScalarType::Oid.nullable(false))
7434 .with_column("database_name", SqlScalarType::String.nullable(true))
7435 .with_column("pg_type_database_name", SqlScalarType::String.nullable(true))
7436 .finish(),
7437 column_comments: BTreeMap::new(),
7438 sql: "
7439SELECT
7440 class_objects.oid as attrelid,
7441 mz_columns.name as attname,
7442 mz_columns.type_oid AS atttypid,
7443 pg_type_all_databases.typlen AS attlen,
7444 position::int8::int2 as attnum,
7445 mz_columns.type_mod as atttypmod,
7446 NOT nullable as attnotnull,
7447 mz_columns.default IS NOT NULL as atthasdef,
7448 ''::pg_catalog.\"char\" as attidentity,
7449 -- MZ doesn't support generated columns so attgenerated is filled with ''
7450 ''::pg_catalog.\"char\" as attgenerated,
7451 FALSE as attisdropped,
7452 -- MZ doesn't support COLLATE so attcollation is filled with 0
7453 0::pg_catalog.oid as attcollation,
7454 -- Columns added because of the peeling. (Note that there are 2 of these here.)
7455 d.name as database_name,
7456 pg_type_all_databases.database_name as pg_type_database_name
7457FROM (
7458 -- pg_attribute catalogs columns on relations and indexes
7459 SELECT id, oid, schema_id, name, type FROM mz_catalog.mz_relations
7460 UNION ALL
7461 SELECT mz_indexes.id, mz_indexes.oid, mz_relations.schema_id, mz_indexes.name, 'index' AS type
7462 FROM mz_catalog.mz_indexes
7463 JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
7464) AS class_objects
7465JOIN mz_catalog.mz_columns ON class_objects.id = mz_columns.id
7466JOIN mz_internal.pg_type_all_databases ON pg_type_all_databases.oid = mz_columns.type_oid
7467JOIN mz_catalog.mz_schemas ON mz_schemas.id = class_objects.schema_id
7468LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id",
7469 access: vec![PUBLIC_SELECT],
7472 }
7473});
7474
7475pub const PG_ATTRIBUTE_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7476 name: "pg_attribute_all_databases_ind",
7477 schema: MZ_INTERNAL_SCHEMA,
7478 oid: oid::INDEX_PG_ATTRIBUTE_ALL_DATABASES_IND_OID,
7479 sql: "IN CLUSTER mz_catalog_server
7480ON mz_internal.pg_attribute_all_databases (
7481 attrelid, attname, atttypid, attlen, attnum, atttypmod, attnotnull, atthasdef, attidentity,
7482 attgenerated, attisdropped, attcollation, database_name, pg_type_database_name
7483)",
7484 is_retained_metrics_object: false,
7485};
7486
7487pub static PG_ATTRIBUTE: LazyLock<BuiltinView> = LazyLock::new(|| {
7488 BuiltinView {
7489 name: "pg_attribute",
7490 schema: PG_CATALOG_SCHEMA,
7491 oid: oid::VIEW_PG_ATTRIBUTE_OID,
7492 desc: RelationDesc::builder()
7493 .with_column("attrelid", SqlScalarType::Oid.nullable(false))
7494 .with_column("attname", SqlScalarType::String.nullable(false))
7495 .with_column("atttypid", SqlScalarType::Oid.nullable(false))
7496 .with_column("attlen", SqlScalarType::Int16.nullable(true))
7497 .with_column("attnum", SqlScalarType::Int16.nullable(false))
7498 .with_column("atttypmod", SqlScalarType::Int32.nullable(false))
7499 .with_column("attnotnull", SqlScalarType::Bool.nullable(false))
7500 .with_column("atthasdef", SqlScalarType::Bool.nullable(false))
7501 .with_column("attidentity", SqlScalarType::PgLegacyChar.nullable(false))
7502 .with_column("attgenerated", SqlScalarType::PgLegacyChar.nullable(false))
7503 .with_column("attisdropped", SqlScalarType::Bool.nullable(false))
7504 .with_column("attcollation", SqlScalarType::Oid.nullable(false))
7505 .finish(),
7506 column_comments: BTreeMap::new(),
7507 sql: "
7508SELECT
7509 attrelid, attname, atttypid, attlen, attnum, atttypmod, attnotnull, atthasdef, attidentity,
7510 attgenerated, attisdropped, attcollation
7511FROM mz_internal.pg_attribute_all_databases
7512WHERE
7513 (database_name IS NULL OR database_name = pg_catalog.current_database()) AND
7514 (pg_type_database_name IS NULL OR pg_type_database_name = pg_catalog.current_database());",
7515 access: vec![PUBLIC_SELECT],
7518 }
7519});
7520
7521pub static PG_PROC: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7522 name: "pg_proc",
7523 schema: PG_CATALOG_SCHEMA,
7524 oid: oid::VIEW_PG_PROC_OID,
7525 desc: RelationDesc::builder()
7526 .with_column("oid", SqlScalarType::Oid.nullable(false))
7527 .with_column("proname", SqlScalarType::String.nullable(false))
7528 .with_column("pronamespace", SqlScalarType::Oid.nullable(false))
7529 .with_column("proowner", SqlScalarType::Oid.nullable(false))
7530 .with_column("proargdefaults", SqlScalarType::String.nullable(true))
7531 .with_column("prorettype", SqlScalarType::Oid.nullable(false))
7532 .finish(),
7533 column_comments: BTreeMap::new(),
7534 sql: "SELECT
7535 mz_functions.oid,
7536 mz_functions.name AS proname,
7537 mz_schemas.oid AS pronamespace,
7538 role_owner.oid AS proowner,
7539 NULL::pg_catalog.text AS proargdefaults,
7540 ret_type.oid AS prorettype
7541FROM mz_catalog.mz_functions
7542JOIN mz_catalog.mz_schemas ON mz_functions.schema_id = mz_schemas.id
7543LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
7544JOIN mz_catalog.mz_types AS ret_type ON mz_functions.return_type_id = ret_type.id
7545JOIN mz_catalog.mz_roles role_owner ON role_owner.id = mz_functions.owner_id
7546WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()",
7547 access: vec![PUBLIC_SELECT],
7548});
7549
7550pub static PG_OPERATOR: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7551 name: "pg_operator",
7552 schema: PG_CATALOG_SCHEMA,
7553 oid: oid::VIEW_PG_OPERATOR_OID,
7554 desc: RelationDesc::builder()
7555 .with_column("oid", SqlScalarType::Oid.nullable(false))
7556 .with_column("oprname", SqlScalarType::String.nullable(false))
7557 .with_column("oprresult", SqlScalarType::Oid.nullable(false))
7558 .with_column("oprleft", SqlScalarType::Oid.nullable(false))
7559 .with_column("oprright", SqlScalarType::Oid.nullable(false))
7560 .with_key(vec![0, 1, 2, 3, 4])
7561 .finish(),
7562 column_comments: BTreeMap::new(),
7563 sql: "SELECT
7564 mz_operators.oid,
7565 mz_operators.name AS oprname,
7566 ret_type.oid AS oprresult,
7567 left_type.oid as oprleft,
7568 right_type.oid as oprright
7569FROM mz_catalog.mz_operators
7570JOIN mz_catalog.mz_types AS ret_type ON mz_operators.return_type_id = ret_type.id
7571JOIN mz_catalog.mz_types AS left_type ON mz_operators.argument_type_ids[1] = left_type.id
7572JOIN mz_catalog.mz_types AS right_type ON mz_operators.argument_type_ids[2] = right_type.id
7573WHERE array_length(mz_operators.argument_type_ids, 1) = 2
7574UNION SELECT
7575 mz_operators.oid,
7576 mz_operators.name AS oprname,
7577 ret_type.oid AS oprresult,
7578 0 as oprleft,
7579 right_type.oid as oprright
7580FROM mz_catalog.mz_operators
7581JOIN mz_catalog.mz_types AS ret_type ON mz_operators.return_type_id = ret_type.id
7582JOIN mz_catalog.mz_types AS right_type ON mz_operators.argument_type_ids[1] = right_type.id
7583WHERE array_length(mz_operators.argument_type_ids, 1) = 1",
7584 access: vec![PUBLIC_SELECT],
7585});
7586
7587pub static PG_RANGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7588 name: "pg_range",
7589 schema: PG_CATALOG_SCHEMA,
7590 oid: oid::VIEW_PG_RANGE_OID,
7591 desc: RelationDesc::builder()
7592 .with_column("rngtypid", SqlScalarType::Oid.nullable(false))
7593 .with_column("rngsubtype", SqlScalarType::Oid.nullable(false))
7594 .with_key(vec![])
7595 .finish(),
7596 column_comments: BTreeMap::new(),
7597 sql: "SELECT
7598 NULL::pg_catalog.oid AS rngtypid,
7599 NULL::pg_catalog.oid AS rngsubtype
7600WHERE false",
7601 access: vec![PUBLIC_SELECT],
7602});
7603
7604pub static PG_ENUM: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7605 name: "pg_enum",
7606 schema: PG_CATALOG_SCHEMA,
7607 oid: oid::VIEW_PG_ENUM_OID,
7608 desc: RelationDesc::builder()
7609 .with_column("oid", SqlScalarType::Oid.nullable(false))
7610 .with_column("enumtypid", SqlScalarType::Oid.nullable(false))
7611 .with_column("enumsortorder", SqlScalarType::Float32.nullable(false))
7612 .with_column("enumlabel", SqlScalarType::String.nullable(false))
7613 .with_key(vec![])
7614 .finish(),
7615 column_comments: BTreeMap::new(),
7616 sql: "SELECT
7617 NULL::pg_catalog.oid AS oid,
7618 NULL::pg_catalog.oid AS enumtypid,
7619 NULL::pg_catalog.float4 AS enumsortorder,
7620 NULL::pg_catalog.text AS enumlabel
7621WHERE false",
7622 access: vec![PUBLIC_SELECT],
7623});
7624
7625pub static PG_ATTRDEF_ALL_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7629 name: "pg_attrdef_all_databases",
7630 schema: MZ_INTERNAL_SCHEMA,
7631 oid: oid::VIEW_PG_ATTRDEF_ALL_DATABASES_OID,
7632 desc: RelationDesc::builder()
7633 .with_column("oid", SqlScalarType::Oid.nullable(true))
7634 .with_column("adrelid", SqlScalarType::Oid.nullable(false))
7635 .with_column("adnum", SqlScalarType::Int64.nullable(false))
7636 .with_column("adbin", SqlScalarType::String.nullable(false))
7637 .with_column("adsrc", SqlScalarType::String.nullable(false))
7638 .finish(),
7639 column_comments: BTreeMap::new(),
7640 sql: "
7641SELECT
7642 NULL::pg_catalog.oid AS oid,
7643 mz_objects.oid AS adrelid,
7644 mz_columns.position::int8 AS adnum,
7645 mz_columns.default AS adbin,
7646 mz_columns.default AS adsrc
7647FROM mz_catalog.mz_columns
7648 JOIN mz_catalog.mz_objects ON mz_columns.id = mz_objects.id
7649WHERE default IS NOT NULL",
7650 access: vec![PUBLIC_SELECT],
7651});
7652
7653pub const PG_ATTRDEF_ALL_DATABASES_IND: BuiltinIndex = BuiltinIndex {
7654 name: "pg_attrdef_all_databases_ind",
7655 schema: MZ_INTERNAL_SCHEMA,
7656 oid: oid::INDEX_PG_ATTRDEF_ALL_DATABASES_IND_OID,
7657 sql: "IN CLUSTER mz_catalog_server
7658ON mz_internal.pg_attrdef_all_databases (oid, adrelid, adnum, adbin, adsrc)",
7659 is_retained_metrics_object: false,
7660};
7661
7662pub static PG_ATTRDEF: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7663 name: "pg_attrdef",
7664 schema: PG_CATALOG_SCHEMA,
7665 oid: oid::VIEW_PG_ATTRDEF_OID,
7666 desc: RelationDesc::builder()
7667 .with_column("oid", SqlScalarType::Oid.nullable(true))
7668 .with_column("adrelid", SqlScalarType::Oid.nullable(false))
7669 .with_column("adnum", SqlScalarType::Int64.nullable(false))
7670 .with_column("adbin", SqlScalarType::String.nullable(false))
7671 .with_column("adsrc", SqlScalarType::String.nullable(false))
7672 .finish(),
7673 column_comments: BTreeMap::new(),
7674 sql: "
7675SELECT
7676 pg_attrdef_all_databases.oid as oid,
7677 adrelid,
7678 adnum,
7679 adbin,
7680 adsrc
7681FROM mz_internal.pg_attrdef_all_databases
7682 JOIN mz_catalog.mz_databases d ON (d.id IS NULL OR d.name = pg_catalog.current_database());",
7683 access: vec![PUBLIC_SELECT],
7684});
7685
7686pub static PG_SETTINGS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7687 name: "pg_settings",
7688 schema: PG_CATALOG_SCHEMA,
7689 oid: oid::VIEW_PG_SETTINGS_OID,
7690 desc: RelationDesc::builder()
7691 .with_column("name", SqlScalarType::String.nullable(false))
7692 .with_column("setting", SqlScalarType::String.nullable(false))
7693 .with_key(vec![])
7694 .finish(),
7695 column_comments: BTreeMap::new(),
7696 sql: "SELECT
7697 name, setting
7698FROM (VALUES
7699 ('max_index_keys'::pg_catalog.text, '1000'::pg_catalog.text)
7700) AS _ (name, setting)",
7701 access: vec![PUBLIC_SELECT],
7702});
7703
7704pub static PG_AUTH_MEMBERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7705 name: "pg_auth_members",
7706 schema: PG_CATALOG_SCHEMA,
7707 oid: oid::VIEW_PG_AUTH_MEMBERS_OID,
7708 desc: RelationDesc::builder()
7709 .with_column("roleid", SqlScalarType::Oid.nullable(false))
7710 .with_column("member", SqlScalarType::Oid.nullable(false))
7711 .with_column("grantor", SqlScalarType::Oid.nullable(false))
7712 .with_column("admin_option", SqlScalarType::Bool.nullable(false))
7713 .finish(),
7714 column_comments: BTreeMap::new(),
7715 sql: "SELECT
7716 role.oid AS roleid,
7717 member.oid AS member,
7718 grantor.oid AS grantor,
7719 -- Materialize hasn't implemented admin_option.
7720 false as admin_option
7721FROM mz_catalog.mz_role_members membership
7722JOIN mz_catalog.mz_roles role ON membership.role_id = role.id
7723JOIN mz_catalog.mz_roles member ON membership.member = member.id
7724JOIN mz_catalog.mz_roles grantor ON membership.grantor = grantor.id",
7725 access: vec![PUBLIC_SELECT],
7726});
7727
7728pub static PG_EVENT_TRIGGER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7729 name: "pg_event_trigger",
7730 schema: PG_CATALOG_SCHEMA,
7731 oid: oid::VIEW_PG_EVENT_TRIGGER_OID,
7732 desc: RelationDesc::builder()
7733 .with_column("oid", SqlScalarType::Oid.nullable(false))
7734 .with_column("evtname", SqlScalarType::String.nullable(false))
7735 .with_column("evtevent", SqlScalarType::String.nullable(false))
7736 .with_column("evtowner", SqlScalarType::Oid.nullable(false))
7737 .with_column("evtfoid", SqlScalarType::Oid.nullable(false))
7738 .with_column("evtenabled", SqlScalarType::PgLegacyChar.nullable(false))
7739 .with_column(
7740 "evttags",
7741 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
7742 )
7743 .with_key(vec![])
7744 .finish(),
7745 column_comments: BTreeMap::new(),
7746 sql: "SELECT
7747 NULL::pg_catalog.oid AS oid,
7748 NULL::pg_catalog.text AS evtname,
7749 NULL::pg_catalog.text AS evtevent,
7750 NULL::pg_catalog.oid AS evtowner,
7751 NULL::pg_catalog.oid AS evtfoid,
7752 NULL::pg_catalog.char AS evtenabled,
7753 NULL::pg_catalog.text[] AS evttags
7754 WHERE false",
7755 access: vec![PUBLIC_SELECT],
7756});
7757
7758pub static PG_LANGUAGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7759 name: "pg_language",
7760 schema: PG_CATALOG_SCHEMA,
7761 oid: oid::VIEW_PG_LANGUAGE_OID,
7762 desc: RelationDesc::builder()
7763 .with_column("oid", SqlScalarType::Oid.nullable(false))
7764 .with_column("lanname", SqlScalarType::String.nullable(false))
7765 .with_column("lanowner", SqlScalarType::Oid.nullable(false))
7766 .with_column("lanispl", SqlScalarType::Bool.nullable(false))
7767 .with_column("lanpltrusted", SqlScalarType::Bool.nullable(false))
7768 .with_column("lanplcallfoid", SqlScalarType::Oid.nullable(false))
7769 .with_column("laninline", SqlScalarType::Oid.nullable(false))
7770 .with_column("lanvalidator", SqlScalarType::Oid.nullable(false))
7771 .with_column(
7772 "lanacl",
7773 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
7774 )
7775 .with_key(vec![])
7776 .finish(),
7777 column_comments: BTreeMap::new(),
7778 sql: "SELECT
7779 NULL::pg_catalog.oid AS oid,
7780 NULL::pg_catalog.text AS lanname,
7781 NULL::pg_catalog.oid AS lanowner,
7782 NULL::pg_catalog.bool AS lanispl,
7783 NULL::pg_catalog.bool AS lanpltrusted,
7784 NULL::pg_catalog.oid AS lanplcallfoid,
7785 NULL::pg_catalog.oid AS laninline,
7786 NULL::pg_catalog.oid AS lanvalidator,
7787 NULL::pg_catalog.text[] AS lanacl
7788 WHERE false",
7789 access: vec![PUBLIC_SELECT],
7790});
7791
7792pub static PG_SHDESCRIPTION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7793 name: "pg_shdescription",
7794 schema: PG_CATALOG_SCHEMA,
7795 oid: oid::VIEW_PG_SHDESCRIPTION_OID,
7796 desc: RelationDesc::builder()
7797 .with_column("objoid", SqlScalarType::Oid.nullable(false))
7798 .with_column("classoid", SqlScalarType::Oid.nullable(false))
7799 .with_column("description", SqlScalarType::String.nullable(false))
7800 .with_key(vec![])
7801 .finish(),
7802 column_comments: BTreeMap::new(),
7803 sql: "SELECT
7804 NULL::pg_catalog.oid AS objoid,
7805 NULL::pg_catalog.oid AS classoid,
7806 NULL::pg_catalog.text AS description
7807 WHERE false",
7808 access: vec![PUBLIC_SELECT],
7809});
7810
7811pub static PG_TIMEZONE_ABBREVS: LazyLock<BuiltinView> = LazyLock::new(|| {
7812 BuiltinView {
7813 name: "pg_timezone_abbrevs",
7814 schema: PG_CATALOG_SCHEMA,
7815 oid: oid::VIEW_PG_TIMEZONE_ABBREVS_OID,
7816 desc: RelationDesc::builder()
7817 .with_column("abbrev", SqlScalarType::String.nullable(false))
7818 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
7819 .with_column("is_dst", SqlScalarType::Bool.nullable(true))
7820 .with_key(vec![0])
7821 .finish(),
7822 column_comments: BTreeMap::new(),
7823 sql: "SELECT
7824 abbreviation AS abbrev,
7825 COALESCE(utc_offset, timezone_offset(timezone_name, now()).base_utc_offset + timezone_offset(timezone_name, now()).dst_offset)
7826 AS utc_offset,
7827 COALESCE(dst, timezone_offset(timezone_name, now()).dst_offset <> INTERVAL '0')
7828 AS is_dst
7829FROM mz_catalog.mz_timezone_abbreviations",
7830 access: vec![PUBLIC_SELECT],
7831 }
7832});
7833
7834pub static PG_TIMEZONE_NAMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7835 name: "pg_timezone_names",
7836 schema: PG_CATALOG_SCHEMA,
7837 oid: oid::VIEW_PG_TIMEZONE_NAMES_OID,
7838 desc: RelationDesc::builder()
7839 .with_column("name", SqlScalarType::String.nullable(false))
7840 .with_column("abbrev", SqlScalarType::String.nullable(true))
7841 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
7842 .with_column("is_dst", SqlScalarType::Bool.nullable(true))
7843 .with_key(vec![0])
7844 .finish(),
7845 column_comments: BTreeMap::new(),
7846 sql: "SELECT
7847 name,
7848 timezone_offset(name, now()).abbrev AS abbrev,
7849 timezone_offset(name, now()).base_utc_offset + timezone_offset(name, now()).dst_offset
7850 AS utc_offset,
7851 timezone_offset(name, now()).dst_offset <> INTERVAL '0'
7852 AS is_dst
7853FROM mz_catalog.mz_timezone_names",
7854 access: vec![PUBLIC_SELECT],
7855});
7856
7857pub static MZ_TIMEZONE_ABBREVIATIONS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7858 name: "mz_timezone_abbreviations",
7859 schema: MZ_CATALOG_SCHEMA,
7860 oid: oid::VIEW_MZ_TIMEZONE_ABBREVIATIONS_OID,
7861 desc: RelationDesc::builder()
7862 .with_column("abbreviation", SqlScalarType::String.nullable(false))
7863 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
7864 .with_column("dst", SqlScalarType::Bool.nullable(true))
7865 .with_column("timezone_name", SqlScalarType::String.nullable(true))
7866 .with_key(vec![0])
7867 .finish(),
7868 column_comments: BTreeMap::from_iter([
7869 ("abbreviation", "The timezone abbreviation."),
7870 (
7871 "utc_offset",
7872 "The UTC offset of the timezone or `NULL` if fixed.",
7873 ),
7874 (
7875 "dst",
7876 "Whether the timezone is in daylight savings or `NULL` if fixed.",
7877 ),
7878 (
7879 "timezone_name",
7880 "The full name of the non-fixed timezone or `NULL` if not fixed.",
7881 ),
7882 ]),
7883 sql: format!(
7884 "SELECT * FROM ({}) _ (abbreviation, utc_offset, dst, timezone_name)",
7885 mz_pgtz::abbrev::MZ_CATALOG_TIMEZONE_ABBREVIATIONS_SQL,
7886 )
7887 .leak(),
7888 access: vec![PUBLIC_SELECT],
7889});
7890
7891pub static MZ_TIMEZONE_NAMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7892 name: "mz_timezone_names",
7893 schema: MZ_CATALOG_SCHEMA,
7894 oid: oid::VIEW_MZ_TIMEZONE_NAMES_OID,
7895 desc: RelationDesc::builder()
7896 .with_column("name", SqlScalarType::String.nullable(false))
7897 .with_key(vec![0])
7898 .finish(),
7899 column_comments: BTreeMap::from_iter([("name", "The timezone name.")]),
7900 sql: format!(
7901 "SELECT * FROM ({}) _ (name)",
7902 mz_pgtz::timezone::MZ_CATALOG_TIMEZONE_NAMES_SQL,
7903 )
7904 .leak(),
7905 access: vec![PUBLIC_SELECT],
7906});
7907
7908pub static MZ_PEEK_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
7909 LazyLock::new(|| BuiltinView {
7910 name: "mz_peek_durations_histogram_per_worker",
7911 schema: MZ_INTROSPECTION_SCHEMA,
7912 oid: oid::VIEW_MZ_PEEK_DURATIONS_HISTOGRAM_PER_WORKER_OID,
7913 desc: RelationDesc::builder()
7914 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
7915 .with_column("type", SqlScalarType::String.nullable(false))
7916 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7917 .with_column("count", SqlScalarType::Int64.nullable(false))
7918 .with_key(vec![0, 1, 2])
7919 .finish(),
7920 column_comments: BTreeMap::new(),
7921 sql: "SELECT
7922 worker_id, type, duration_ns, pg_catalog.count(*) AS count
7923FROM
7924 mz_introspection.mz_peek_durations_histogram_raw
7925GROUP BY
7926 worker_id, type, duration_ns",
7927 access: vec![PUBLIC_SELECT],
7928 });
7929
7930pub static MZ_PEEK_DURATIONS_HISTOGRAM: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
7931 name: "mz_peek_durations_histogram",
7932 schema: MZ_INTROSPECTION_SCHEMA,
7933 oid: oid::VIEW_MZ_PEEK_DURATIONS_HISTOGRAM_OID,
7934 desc: RelationDesc::builder()
7935 .with_column("type", SqlScalarType::String.nullable(false))
7936 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7937 .with_column(
7938 "count",
7939 SqlScalarType::Numeric {
7940 max_scale: Some(NumericMaxScale::ZERO),
7941 }
7942 .nullable(false),
7943 )
7944 .with_key(vec![0, 1])
7945 .finish(),
7946 column_comments: BTreeMap::from_iter([
7947 ("type", "The peek variant: `index` or `persist`."),
7948 (
7949 "duration_ns",
7950 "The upper bound of the bucket in nanoseconds.",
7951 ),
7952 (
7953 "count",
7954 "The (noncumulative) count of peeks in this bucket.",
7955 ),
7956 ]),
7957 sql: "
7958SELECT
7959 type, duration_ns,
7960 pg_catalog.sum(count) AS count
7961FROM mz_introspection.mz_peek_durations_histogram_per_worker
7962GROUP BY type, duration_ns",
7963 access: vec![PUBLIC_SELECT],
7964});
7965
7966pub static MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
7967 LazyLock::new(|| BuiltinView {
7968 name: "mz_dataflow_shutdown_durations_histogram_per_worker",
7969 schema: MZ_INTROSPECTION_SCHEMA,
7970 oid: oid::VIEW_MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_PER_WORKER_OID,
7971 desc: RelationDesc::builder()
7972 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
7973 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7974 .with_column("count", SqlScalarType::Int64.nullable(false))
7975 .with_key(vec![0, 1])
7976 .finish(),
7977 column_comments: BTreeMap::new(),
7978 sql: "SELECT
7979 worker_id, duration_ns, pg_catalog.count(*) AS count
7980FROM
7981 mz_introspection.mz_dataflow_shutdown_durations_histogram_raw
7982GROUP BY
7983 worker_id, duration_ns",
7984 access: vec![PUBLIC_SELECT],
7985 });
7986
7987pub static MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM: LazyLock<BuiltinView> =
7988 LazyLock::new(|| BuiltinView {
7989 name: "mz_dataflow_shutdown_durations_histogram",
7990 schema: MZ_INTROSPECTION_SCHEMA,
7991 oid: oid::VIEW_MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_OID,
7992 desc: RelationDesc::builder()
7993 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
7994 .with_column(
7995 "count",
7996 SqlScalarType::Numeric {
7997 max_scale: Some(NumericMaxScale::ZERO),
7998 }
7999 .nullable(false),
8000 )
8001 .with_key(vec![0])
8002 .finish(),
8003 column_comments: BTreeMap::from_iter([
8004 (
8005 "duration_ns",
8006 "The upper bound of the bucket in nanoseconds.",
8007 ),
8008 (
8009 "count",
8010 "The (noncumulative) count of dataflows in this bucket.",
8011 ),
8012 ]),
8013 sql: "
8014SELECT
8015 duration_ns,
8016 pg_catalog.sum(count) AS count
8017FROM mz_introspection.mz_dataflow_shutdown_durations_histogram_per_worker
8018GROUP BY duration_ns",
8019 access: vec![PUBLIC_SELECT],
8020 });
8021
8022pub static MZ_SCHEDULING_ELAPSED_PER_WORKER: LazyLock<BuiltinView> =
8023 LazyLock::new(|| BuiltinView {
8024 name: "mz_scheduling_elapsed_per_worker",
8025 schema: MZ_INTROSPECTION_SCHEMA,
8026 oid: oid::VIEW_MZ_SCHEDULING_ELAPSED_PER_WORKER_OID,
8027 desc: RelationDesc::builder()
8028 .with_column("id", SqlScalarType::UInt64.nullable(false))
8029 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8030 .with_column("elapsed_ns", SqlScalarType::Int64.nullable(false))
8031 .with_key(vec![0, 1])
8032 .finish(),
8033 column_comments: BTreeMap::new(),
8034 sql: "SELECT
8035 id, worker_id, pg_catalog.count(*) AS elapsed_ns
8036FROM
8037 mz_introspection.mz_scheduling_elapsed_raw
8038GROUP BY
8039 id, worker_id",
8040 access: vec![PUBLIC_SELECT],
8041 });
8042
8043pub static MZ_SCHEDULING_ELAPSED: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8044 name: "mz_scheduling_elapsed",
8045 schema: MZ_INTROSPECTION_SCHEMA,
8046 oid: oid::VIEW_MZ_SCHEDULING_ELAPSED_OID,
8047 desc: RelationDesc::builder()
8048 .with_column("id", SqlScalarType::UInt64.nullable(false))
8049 .with_column(
8050 "elapsed_ns",
8051 SqlScalarType::Numeric {
8052 max_scale: Some(NumericMaxScale::ZERO),
8053 }
8054 .nullable(false),
8055 )
8056 .with_key(vec![0])
8057 .finish(),
8058 column_comments: BTreeMap::from_iter([
8059 (
8060 "id",
8061 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
8062 ),
8063 (
8064 "elapsed_ns",
8065 "The total elapsed time spent in the operator in nanoseconds.",
8066 ),
8067 ]),
8068 sql: "
8069SELECT
8070 id,
8071 pg_catalog.sum(elapsed_ns) AS elapsed_ns
8072FROM mz_introspection.mz_scheduling_elapsed_per_worker
8073GROUP BY id",
8074 access: vec![PUBLIC_SELECT],
8075});
8076
8077pub static MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
8078 LazyLock::new(|| BuiltinView {
8079 name: "mz_compute_operator_durations_histogram_per_worker",
8080 schema: MZ_INTROSPECTION_SCHEMA,
8081 oid: oid::VIEW_MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_PER_WORKER_OID,
8082 desc: RelationDesc::builder()
8083 .with_column("id", SqlScalarType::UInt64.nullable(false))
8084 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8085 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
8086 .with_column("count", SqlScalarType::Int64.nullable(false))
8087 .with_key(vec![0, 1, 2])
8088 .finish(),
8089 column_comments: BTreeMap::new(),
8090 sql: "SELECT
8091 id, worker_id, duration_ns, pg_catalog.count(*) AS count
8092FROM
8093 mz_introspection.mz_compute_operator_durations_histogram_raw
8094GROUP BY
8095 id, worker_id, duration_ns",
8096 access: vec![PUBLIC_SELECT],
8097 });
8098
8099pub static MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM: LazyLock<BuiltinView> =
8100 LazyLock::new(|| BuiltinView {
8101 name: "mz_compute_operator_durations_histogram",
8102 schema: MZ_INTROSPECTION_SCHEMA,
8103 oid: oid::VIEW_MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_OID,
8104 desc: RelationDesc::builder()
8105 .with_column("id", SqlScalarType::UInt64.nullable(false))
8106 .with_column("duration_ns", SqlScalarType::UInt64.nullable(false))
8107 .with_column(
8108 "count",
8109 SqlScalarType::Numeric {
8110 max_scale: Some(NumericMaxScale::ZERO),
8111 }
8112 .nullable(false),
8113 )
8114 .with_key(vec![0, 1])
8115 .finish(),
8116 column_comments: BTreeMap::from_iter([
8117 (
8118 "id",
8119 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
8120 ),
8121 (
8122 "duration_ns",
8123 "The upper bound of the duration bucket in nanoseconds.",
8124 ),
8125 (
8126 "count",
8127 "The (noncumulative) count of invocations in the bucket.",
8128 ),
8129 ]),
8130 sql: "
8131SELECT
8132 id,
8133 duration_ns,
8134 pg_catalog.sum(count) AS count
8135FROM mz_introspection.mz_compute_operator_durations_histogram_per_worker
8136GROUP BY id, duration_ns",
8137 access: vec![PUBLIC_SELECT],
8138 });
8139
8140pub static MZ_SCHEDULING_PARKS_HISTOGRAM_PER_WORKER: LazyLock<BuiltinView> =
8141 LazyLock::new(|| BuiltinView {
8142 name: "mz_scheduling_parks_histogram_per_worker",
8143 schema: MZ_INTROSPECTION_SCHEMA,
8144 oid: oid::VIEW_MZ_SCHEDULING_PARKS_HISTOGRAM_PER_WORKER_OID,
8145 desc: RelationDesc::builder()
8146 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8147 .with_column("slept_for_ns", SqlScalarType::UInt64.nullable(false))
8148 .with_column("requested_ns", SqlScalarType::UInt64.nullable(false))
8149 .with_column("count", SqlScalarType::Int64.nullable(false))
8150 .with_key(vec![0, 1, 2])
8151 .finish(),
8152 column_comments: BTreeMap::new(),
8153 sql: "SELECT
8154 worker_id, slept_for_ns, requested_ns, pg_catalog.count(*) AS count
8155FROM
8156 mz_introspection.mz_scheduling_parks_histogram_raw
8157GROUP BY
8158 worker_id, slept_for_ns, requested_ns",
8159 access: vec![PUBLIC_SELECT],
8160 });
8161
8162pub static MZ_SCHEDULING_PARKS_HISTOGRAM: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8163 name: "mz_scheduling_parks_histogram",
8164 schema: MZ_INTROSPECTION_SCHEMA,
8165 oid: oid::VIEW_MZ_SCHEDULING_PARKS_HISTOGRAM_OID,
8166 desc: RelationDesc::builder()
8167 .with_column("slept_for_ns", SqlScalarType::UInt64.nullable(false))
8168 .with_column("requested_ns", SqlScalarType::UInt64.nullable(false))
8169 .with_column(
8170 "count",
8171 SqlScalarType::Numeric {
8172 max_scale: Some(NumericMaxScale::ZERO),
8173 }
8174 .nullable(false),
8175 )
8176 .with_key(vec![0, 1])
8177 .finish(),
8178 column_comments: BTreeMap::from_iter([
8179 (
8180 "slept_for_ns",
8181 "The actual length of the park event in nanoseconds.",
8182 ),
8183 (
8184 "requested_ns",
8185 "The requested length of the park event in nanoseconds.",
8186 ),
8187 (
8188 "count",
8189 "The (noncumulative) count of park events in this bucket.",
8190 ),
8191 ]),
8192 sql: "
8193SELECT
8194 slept_for_ns,
8195 requested_ns,
8196 pg_catalog.sum(count) AS count
8197FROM mz_introspection.mz_scheduling_parks_histogram_per_worker
8198GROUP BY slept_for_ns, requested_ns",
8199 access: vec![PUBLIC_SELECT],
8200});
8201
8202pub static MZ_COMPUTE_ERROR_COUNTS_PER_WORKER: LazyLock<BuiltinView> =
8203 LazyLock::new(|| BuiltinView {
8204 name: "mz_compute_error_counts_per_worker",
8205 schema: MZ_INTROSPECTION_SCHEMA,
8206 oid: oid::VIEW_MZ_COMPUTE_ERROR_COUNTS_PER_WORKER_OID,
8207 desc: RelationDesc::builder()
8208 .with_column("export_id", SqlScalarType::String.nullable(false))
8209 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8210 .with_column("count", SqlScalarType::Int64.nullable(false))
8211 .with_key(vec![0, 1, 2])
8212 .finish(),
8213 column_comments: BTreeMap::new(),
8214 sql: "
8215WITH MUTUALLY RECURSIVE
8216 -- Indexes that reuse existing indexes rather than maintaining separate dataflows.
8217 -- For these we don't log error counts separately, so we need to forward the error counts from
8218 -- their dependencies instead.
8219 index_reuses(reuse_id text, index_id text) AS (
8220 SELECT d.object_id, d.dependency_id
8221 FROM mz_internal.mz_compute_dependencies d
8222 JOIN mz_introspection.mz_compute_exports e ON (e.export_id = d.object_id)
8223 WHERE NOT EXISTS (
8224 SELECT 1 FROM mz_introspection.mz_dataflows
8225 WHERE id = e.dataflow_id
8226 )
8227 ),
8228 -- Error counts that were directly logged on compute exports.
8229 direct_errors(export_id text, worker_id uint8, count int8) AS (
8230 SELECT export_id, worker_id, count
8231 FROM mz_introspection.mz_compute_error_counts_raw
8232 ),
8233 -- Error counts propagated to index reused.
8234 all_errors(export_id text, worker_id uint8, count int8) AS (
8235 SELECT * FROM direct_errors
8236 UNION
8237 SELECT r.reuse_id, e.worker_id, e.count
8238 FROM all_errors e
8239 JOIN index_reuses r ON (r.index_id = e.export_id)
8240 )
8241SELECT * FROM all_errors",
8242 access: vec![PUBLIC_SELECT],
8243 });
8244
8245pub static MZ_COMPUTE_ERROR_COUNTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8246 name: "mz_compute_error_counts",
8247 schema: MZ_INTROSPECTION_SCHEMA,
8248 oid: oid::VIEW_MZ_COMPUTE_ERROR_COUNTS_OID,
8249 desc: RelationDesc::builder()
8250 .with_column("export_id", SqlScalarType::String.nullable(false))
8251 .with_column(
8252 "count",
8253 SqlScalarType::Numeric {
8254 max_scale: Some(NumericMaxScale::ZERO),
8255 }
8256 .nullable(false),
8257 )
8258 .with_key(vec![0])
8259 .finish(),
8260 column_comments: BTreeMap::from_iter([
8261 (
8262 "export_id",
8263 "The ID of the dataflow export. Corresponds to `mz_compute_exports.export_id`.",
8264 ),
8265 (
8266 "count",
8267 "The count of errors present in this dataflow export.",
8268 ),
8269 ]),
8270 sql: "
8271SELECT
8272 export_id,
8273 pg_catalog.sum(count) AS count
8274FROM mz_introspection.mz_compute_error_counts_per_worker
8275GROUP BY export_id
8276HAVING pg_catalog.sum(count) != 0",
8277 access: vec![PUBLIC_SELECT],
8278});
8279
8280pub static MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED: LazyLock<BuiltinSource> =
8281 LazyLock::new(|| BuiltinSource {
8282 name: "mz_compute_error_counts_raw_unified",
8286 schema: MZ_INTERNAL_SCHEMA,
8287 oid: oid::SOURCE_MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED_OID,
8288 desc: RelationDesc::builder()
8289 .with_column("replica_id", SqlScalarType::String.nullable(false))
8290 .with_column("object_id", SqlScalarType::String.nullable(false))
8291 .with_column(
8292 "count",
8293 SqlScalarType::Numeric { max_scale: None }.nullable(false),
8294 )
8295 .finish(),
8296 data_source: IntrospectionType::ComputeErrorCounts,
8297 column_comments: BTreeMap::new(),
8298 is_retained_metrics_object: false,
8299 access: vec![PUBLIC_SELECT],
8300 });
8301
8302pub static MZ_COMPUTE_HYDRATION_TIMES: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
8303 name: "mz_compute_hydration_times",
8304 schema: MZ_INTERNAL_SCHEMA,
8305 oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_TIMES_OID,
8306 desc: RelationDesc::builder()
8307 .with_column("replica_id", SqlScalarType::String.nullable(false))
8308 .with_column("object_id", SqlScalarType::String.nullable(false))
8309 .with_column("time_ns", SqlScalarType::UInt64.nullable(true))
8310 .finish(),
8311 data_source: IntrospectionType::ComputeHydrationTimes,
8312 column_comments: BTreeMap::new(),
8313 is_retained_metrics_object: true,
8314 access: vec![PUBLIC_SELECT],
8315});
8316
8317pub static MZ_COMPUTE_HYDRATION_TIMES_IND: LazyLock<BuiltinIndex> =
8318 LazyLock::new(|| BuiltinIndex {
8319 name: "mz_compute_hydration_times_ind",
8320 schema: MZ_INTERNAL_SCHEMA,
8321 oid: oid::INDEX_MZ_COMPUTE_HYDRATION_TIMES_IND_OID,
8322 sql: "IN CLUSTER mz_catalog_server
8323 ON mz_internal.mz_compute_hydration_times (replica_id)",
8324 is_retained_metrics_object: true,
8325 });
8326
8327pub static MZ_COMPUTE_HYDRATION_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8328 name: "mz_compute_hydration_statuses",
8329 schema: MZ_INTERNAL_SCHEMA,
8330 oid: oid::SOURCE_MZ_COMPUTE_HYDRATION_STATUSES_OID,
8331 desc: RelationDesc::builder()
8332 .with_column("object_id", SqlScalarType::String.nullable(false))
8333 .with_column("replica_id", SqlScalarType::String.nullable(false))
8334 .with_column("hydrated", SqlScalarType::Bool.nullable(false))
8335 .with_column("hydration_time", SqlScalarType::Interval.nullable(true))
8336 .finish(),
8337 column_comments: BTreeMap::from_iter([
8338 (
8339 "object_id",
8340 "The ID of a compute object. Corresponds to `mz_catalog.mz_indexes.id` or `mz_catalog.mz_materialized_views.id`",
8341 ),
8342 ("replica_id", "The ID of a cluster replica."),
8343 (
8344 "hydrated",
8345 "Whether the compute object is hydrated on the replica.",
8346 ),
8347 (
8348 "hydration_time",
8349 "The amount of time it took for the replica to hydrate the compute object.",
8350 ),
8351 ]),
8352 sql: "
8353WITH
8354 dataflows AS (
8355 SELECT
8356 object_id,
8357 replica_id,
8358 time_ns IS NOT NULL AS hydrated,
8359 ((time_ns / 1000) || 'microseconds')::interval AS hydration_time
8360 FROM mz_internal.mz_compute_hydration_times
8361 ),
8362 -- MVs that have advanced to the empty frontier don't have a dataflow installed anymore and
8363 -- therefore don't show up in `mz_compute_hydration_times`. We still want to show them here to
8364 -- avoid surprises for people joining `mz_materialized_views` against this relation (like the
8365 -- blue-green readiness query does), so we include them as 'hydrated'.
8366 complete_mvs AS (
8367 SELECT
8368 mv.id,
8369 f.replica_id,
8370 true AS hydrated,
8371 NULL::interval AS hydration_time
8372 FROM mz_materialized_views mv
8373 JOIN mz_catalog.mz_cluster_replica_frontiers f ON f.object_id = mv.id
8374 WHERE f.write_frontier IS NULL
8375 ),
8376 -- Ditto CTs
8377 complete_cts AS (
8378 SELECT
8379 ct.id,
8380 f.replica_id,
8381 true AS hydrated,
8382 NULL::interval AS hydration_time
8383 FROM mz_internal.mz_continual_tasks ct
8384 JOIN mz_catalog.mz_cluster_replica_frontiers f ON f.object_id = ct.id
8385 WHERE f.write_frontier IS NULL
8386 )
8387SELECT * FROM dataflows
8388UNION ALL
8389SELECT * FROM complete_mvs
8390UNION ALL
8391SELECT * FROM complete_cts",
8392 access: vec![PUBLIC_SELECT],
8393});
8394
8395pub static MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES: LazyLock<BuiltinSource> = LazyLock::new(|| {
8396 BuiltinSource {
8397 name: "mz_compute_operator_hydration_statuses",
8398 schema: MZ_INTERNAL_SCHEMA,
8399 oid: oid::SOURCE_MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_OID,
8400 desc: RelationDesc::builder()
8401 .with_column("replica_id", SqlScalarType::String.nullable(false))
8402 .with_column("object_id", SqlScalarType::String.nullable(false))
8403 .with_column(
8404 "physical_plan_node_id",
8405 SqlScalarType::UInt64.nullable(false),
8406 )
8407 .with_column("hydrated", SqlScalarType::Bool.nullable(false))
8408 .with_key(vec![0, 1, 2])
8409 .finish(),
8410 data_source: IntrospectionType::ComputeOperatorHydrationStatus,
8411 column_comments: BTreeMap::from_iter([
8412 ("replica_id", "The ID of a cluster replica."),
8413 (
8414 "object_id",
8415 "The ID of a compute object. Corresponds to `mz_catalog.mz_indexes.id` or `mz_catalog.mz_materialized_views.id`.",
8416 ),
8417 (
8418 "physical_plan_node_id",
8419 "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)`.",
8420 ),
8421 ("hydrated", "Whether the node is hydrated on the replica."),
8422 ]),
8423 is_retained_metrics_object: false,
8424 access: vec![PUBLIC_SELECT],
8425 }
8426});
8427
8428pub static MZ_MESSAGE_COUNTS_PER_WORKER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8429 name: "mz_message_counts_per_worker",
8430 schema: MZ_INTROSPECTION_SCHEMA,
8431 oid: oid::VIEW_MZ_MESSAGE_COUNTS_PER_WORKER_OID,
8432 desc: RelationDesc::builder()
8433 .with_column("channel_id", SqlScalarType::UInt64.nullable(false))
8434 .with_column("from_worker_id", SqlScalarType::UInt64.nullable(false))
8435 .with_column("to_worker_id", SqlScalarType::UInt64.nullable(false))
8436 .with_column("sent", SqlScalarType::Int64.nullable(false))
8437 .with_column("received", SqlScalarType::Int64.nullable(false))
8438 .with_column("batch_sent", SqlScalarType::Int64.nullable(false))
8439 .with_column("batch_received", SqlScalarType::Int64.nullable(false))
8440 .with_key(vec![0, 1, 2])
8441 .finish(),
8442 column_comments: BTreeMap::new(),
8443 sql: "
8444WITH batch_sent_cte AS (
8445 SELECT
8446 channel_id,
8447 from_worker_id,
8448 to_worker_id,
8449 pg_catalog.count(*) AS sent
8450 FROM
8451 mz_introspection.mz_message_batch_counts_sent_raw
8452 GROUP BY
8453 channel_id, from_worker_id, to_worker_id
8454),
8455batch_received_cte AS (
8456 SELECT
8457 channel_id,
8458 from_worker_id,
8459 to_worker_id,
8460 pg_catalog.count(*) AS received
8461 FROM
8462 mz_introspection.mz_message_batch_counts_received_raw
8463 GROUP BY
8464 channel_id, from_worker_id, to_worker_id
8465),
8466sent_cte AS (
8467 SELECT
8468 channel_id,
8469 from_worker_id,
8470 to_worker_id,
8471 pg_catalog.count(*) AS sent
8472 FROM
8473 mz_introspection.mz_message_counts_sent_raw
8474 GROUP BY
8475 channel_id, from_worker_id, to_worker_id
8476),
8477received_cte AS (
8478 SELECT
8479 channel_id,
8480 from_worker_id,
8481 to_worker_id,
8482 pg_catalog.count(*) AS received
8483 FROM
8484 mz_introspection.mz_message_counts_received_raw
8485 GROUP BY
8486 channel_id, from_worker_id, to_worker_id
8487)
8488SELECT
8489 sent_cte.channel_id,
8490 sent_cte.from_worker_id,
8491 sent_cte.to_worker_id,
8492 sent_cte.sent,
8493 received_cte.received,
8494 batch_sent_cte.sent AS batch_sent,
8495 batch_received_cte.received AS batch_received
8496FROM sent_cte
8497JOIN received_cte USING (channel_id, from_worker_id, to_worker_id)
8498JOIN batch_sent_cte USING (channel_id, from_worker_id, to_worker_id)
8499JOIN batch_received_cte USING (channel_id, from_worker_id, to_worker_id)",
8500 access: vec![PUBLIC_SELECT],
8501});
8502
8503pub static MZ_MESSAGE_COUNTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8504 name: "mz_message_counts",
8505 schema: MZ_INTROSPECTION_SCHEMA,
8506 oid: oid::VIEW_MZ_MESSAGE_COUNTS_OID,
8507 desc: RelationDesc::builder()
8508 .with_column("channel_id", SqlScalarType::UInt64.nullable(false))
8509 .with_column(
8510 "sent",
8511 SqlScalarType::Numeric {
8512 max_scale: Some(NumericMaxScale::ZERO),
8513 }
8514 .nullable(false),
8515 )
8516 .with_column(
8517 "received",
8518 SqlScalarType::Numeric {
8519 max_scale: Some(NumericMaxScale::ZERO),
8520 }
8521 .nullable(false),
8522 )
8523 .with_column(
8524 "batch_sent",
8525 SqlScalarType::Numeric {
8526 max_scale: Some(NumericMaxScale::ZERO),
8527 }
8528 .nullable(false),
8529 )
8530 .with_column(
8531 "batch_received",
8532 SqlScalarType::Numeric {
8533 max_scale: Some(NumericMaxScale::ZERO),
8534 }
8535 .nullable(false),
8536 )
8537 .with_key(vec![0])
8538 .finish(),
8539 column_comments: BTreeMap::from_iter([
8540 (
8541 "channel_id",
8542 "The ID of the channel. Corresponds to `mz_dataflow_channels.id`.",
8543 ),
8544 ("sent", "The number of messages sent."),
8545 ("received", "The number of messages received."),
8546 ("batch_sent", "The number of batches sent."),
8547 ("batch_received", "The number of batches received."),
8548 ]),
8549 sql: "
8550SELECT
8551 channel_id,
8552 pg_catalog.sum(sent) AS sent,
8553 pg_catalog.sum(received) AS received,
8554 pg_catalog.sum(batch_sent) AS batch_sent,
8555 pg_catalog.sum(batch_received) AS batch_received
8556FROM mz_introspection.mz_message_counts_per_worker
8557GROUP BY channel_id",
8558 access: vec![PUBLIC_SELECT],
8559});
8560
8561pub static MZ_ACTIVE_PEEKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8562 name: "mz_active_peeks",
8563 schema: MZ_INTROSPECTION_SCHEMA,
8564 oid: oid::VIEW_MZ_ACTIVE_PEEKS_OID,
8565 desc: RelationDesc::builder()
8566 .with_column("id", SqlScalarType::Uuid.nullable(false))
8567 .with_column("object_id", SqlScalarType::String.nullable(false))
8568 .with_column("type", SqlScalarType::String.nullable(false))
8569 .with_column("time", SqlScalarType::MzTimestamp.nullable(false))
8570 .finish(),
8571 column_comments: BTreeMap::from_iter([
8572 ("id", "The ID of the peek request."),
8573 (
8574 "object_id",
8575 "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`.",
8576 ),
8577 (
8578 "type",
8579 "The type of the corresponding peek: `index` if targeting an index or temporary dataflow; `persist` for a source, materialized view, or table.",
8580 ),
8581 ("time", "The timestamp the peek has requested."),
8582 ]),
8583 sql: "
8584SELECT id, object_id, type, time
8585FROM mz_introspection.mz_active_peeks_per_worker
8586WHERE worker_id = 0",
8587 access: vec![PUBLIC_SELECT],
8588});
8589
8590pub static MZ_DATAFLOW_OPERATOR_REACHABILITY_PER_WORKER: LazyLock<BuiltinView> =
8591 LazyLock::new(|| BuiltinView {
8592 name: "mz_dataflow_operator_reachability_per_worker",
8593 schema: MZ_INTROSPECTION_SCHEMA,
8594 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_REACHABILITY_PER_WORKER_OID,
8595 desc: RelationDesc::builder()
8596 .with_column("id", SqlScalarType::UInt64.nullable(false))
8597 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8598 .with_column("port", SqlScalarType::UInt64.nullable(false))
8599 .with_column("update_type", SqlScalarType::String.nullable(false))
8600 .with_column("time", SqlScalarType::MzTimestamp.nullable(true))
8601 .with_column("count", SqlScalarType::Int64.nullable(false))
8602 .with_key(vec![0, 1, 2, 3, 4])
8603 .finish(),
8604 column_comments: BTreeMap::new(),
8605 sql: "SELECT
8606 addr2.id,
8607 reachability.worker_id,
8608 port,
8609 update_type,
8610 time,
8611 pg_catalog.count(*) as count
8612FROM
8613 mz_introspection.mz_dataflow_operator_reachability_raw reachability,
8614 mz_introspection.mz_dataflow_addresses_per_worker addr1,
8615 mz_introspection.mz_dataflow_addresses_per_worker addr2
8616WHERE
8617 addr2.address =
8618 CASE
8619 WHEN source = 0 THEN addr1.address
8620 ELSE addr1.address || reachability.source
8621 END
8622 AND addr1.id = reachability.id
8623 AND addr1.worker_id = reachability.worker_id
8624 AND addr2.worker_id = reachability.worker_id
8625GROUP BY addr2.id, reachability.worker_id, port, update_type, time",
8626 access: vec![PUBLIC_SELECT],
8627 });
8628
8629pub static MZ_DATAFLOW_OPERATOR_REACHABILITY: LazyLock<BuiltinView> =
8630 LazyLock::new(|| BuiltinView {
8631 name: "mz_dataflow_operator_reachability",
8632 schema: MZ_INTROSPECTION_SCHEMA,
8633 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_REACHABILITY_OID,
8634 desc: RelationDesc::builder()
8635 .with_column("id", SqlScalarType::UInt64.nullable(false))
8636 .with_column("port", SqlScalarType::UInt64.nullable(false))
8637 .with_column("update_type", SqlScalarType::String.nullable(false))
8638 .with_column("time", SqlScalarType::MzTimestamp.nullable(true))
8639 .with_column(
8640 "count",
8641 SqlScalarType::Numeric {
8642 max_scale: Some(NumericMaxScale::ZERO),
8643 }
8644 .nullable(false),
8645 )
8646 .with_key(vec![0, 1, 2, 3])
8647 .finish(),
8648 column_comments: BTreeMap::new(),
8649 sql: "
8650SELECT
8651 id,
8652 port,
8653 update_type,
8654 time,
8655 pg_catalog.sum(count) as count
8656FROM mz_introspection.mz_dataflow_operator_reachability_per_worker
8657GROUP BY id, port, update_type, time",
8658 access: vec![PUBLIC_SELECT],
8659 });
8660
8661pub static MZ_ARRANGEMENT_SIZES_PER_WORKER: LazyLock<BuiltinView> = LazyLock::new(|| {
8662 BuiltinView {
8663 name: "mz_arrangement_sizes_per_worker",
8664 schema: MZ_INTROSPECTION_SCHEMA,
8665 oid: oid::VIEW_MZ_ARRANGEMENT_SIZES_PER_WORKER_OID,
8666 desc: RelationDesc::builder()
8667 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8668 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8669 .with_column("records", SqlScalarType::Int64.nullable(true))
8670 .with_column("batches", SqlScalarType::Int64.nullable(true))
8671 .with_column("size", SqlScalarType::Int64.nullable(true))
8672 .with_column("capacity", SqlScalarType::Int64.nullable(true))
8673 .with_column("allocations", SqlScalarType::Int64.nullable(true))
8674 .finish(),
8675 column_comments: BTreeMap::new(),
8676 sql: "
8677WITH operators_per_worker_cte AS (
8678 SELECT
8679 id AS operator_id,
8680 worker_id
8681 FROM
8682 mz_introspection.mz_dataflow_operators_per_worker
8683),
8684batches_cte AS (
8685 SELECT
8686 operator_id,
8687 worker_id,
8688 COUNT(*) AS batches
8689 FROM
8690 mz_introspection.mz_arrangement_batches_raw
8691 GROUP BY
8692 operator_id, worker_id
8693),
8694records_cte AS (
8695 SELECT
8696 operator_id,
8697 worker_id,
8698 COUNT(*) AS records
8699 FROM
8700 mz_introspection.mz_arrangement_records_raw
8701 GROUP BY
8702 operator_id, worker_id
8703),
8704heap_size_cte AS (
8705 SELECT
8706 operator_id,
8707 worker_id,
8708 COUNT(*) AS size
8709 FROM
8710 mz_introspection.mz_arrangement_heap_size_raw
8711 GROUP BY
8712 operator_id, worker_id
8713),
8714heap_capacity_cte AS (
8715 SELECT
8716 operator_id,
8717 worker_id,
8718 COUNT(*) AS capacity
8719 FROM
8720 mz_introspection.mz_arrangement_heap_capacity_raw
8721 GROUP BY
8722 operator_id, worker_id
8723),
8724heap_allocations_cte AS (
8725 SELECT
8726 operator_id,
8727 worker_id,
8728 COUNT(*) AS allocations
8729 FROM
8730 mz_introspection.mz_arrangement_heap_allocations_raw
8731 GROUP BY
8732 operator_id, worker_id
8733),
8734batcher_records_cte AS (
8735 SELECT
8736 operator_id,
8737 worker_id,
8738 COUNT(*) AS records
8739 FROM
8740 mz_introspection.mz_arrangement_batcher_records_raw
8741 GROUP BY
8742 operator_id, worker_id
8743),
8744batcher_size_cte AS (
8745 SELECT
8746 operator_id,
8747 worker_id,
8748 COUNT(*) AS size
8749 FROM
8750 mz_introspection.mz_arrangement_batcher_size_raw
8751 GROUP BY
8752 operator_id, worker_id
8753),
8754batcher_capacity_cte AS (
8755 SELECT
8756 operator_id,
8757 worker_id,
8758 COUNT(*) AS capacity
8759 FROM
8760 mz_introspection.mz_arrangement_batcher_capacity_raw
8761 GROUP BY
8762 operator_id, worker_id
8763),
8764batcher_allocations_cte AS (
8765 SELECT
8766 operator_id,
8767 worker_id,
8768 COUNT(*) AS allocations
8769 FROM
8770 mz_introspection.mz_arrangement_batcher_allocations_raw
8771 GROUP BY
8772 operator_id, worker_id
8773),
8774combined AS (
8775 SELECT
8776 opw.operator_id,
8777 opw.worker_id,
8778 CASE
8779 WHEN records_cte.records IS NULL AND batcher_records_cte.records IS NULL THEN NULL
8780 ELSE COALESCE(records_cte.records, 0) + COALESCE(batcher_records_cte.records, 0)
8781 END AS records,
8782 batches_cte.batches AS batches,
8783 CASE
8784 WHEN heap_size_cte.size IS NULL AND batcher_size_cte.size IS NULL THEN NULL
8785 ELSE COALESCE(heap_size_cte.size, 0) + COALESCE(batcher_size_cte.size, 0)
8786 END AS size,
8787 CASE
8788 WHEN heap_capacity_cte.capacity IS NULL AND batcher_capacity_cte.capacity IS NULL THEN NULL
8789 ELSE COALESCE(heap_capacity_cte.capacity, 0) + COALESCE(batcher_capacity_cte.capacity, 0)
8790 END AS capacity,
8791 CASE
8792 WHEN heap_allocations_cte.allocations IS NULL AND batcher_allocations_cte.allocations IS NULL THEN NULL
8793 ELSE COALESCE(heap_allocations_cte.allocations, 0) + COALESCE(batcher_allocations_cte.allocations, 0)
8794 END AS allocations
8795 FROM
8796 operators_per_worker_cte opw
8797 LEFT OUTER JOIN batches_cte USING (operator_id, worker_id)
8798 LEFT OUTER JOIN records_cte USING (operator_id, worker_id)
8799 LEFT OUTER JOIN heap_size_cte USING (operator_id, worker_id)
8800 LEFT OUTER JOIN heap_capacity_cte USING (operator_id, worker_id)
8801 LEFT OUTER JOIN heap_allocations_cte USING (operator_id, worker_id)
8802 LEFT OUTER JOIN batcher_records_cte USING (operator_id, worker_id)
8803 LEFT OUTER JOIN batcher_size_cte USING (operator_id, worker_id)
8804 LEFT OUTER JOIN batcher_capacity_cte USING (operator_id, worker_id)
8805 LEFT OUTER JOIN batcher_allocations_cte USING (operator_id, worker_id)
8806)
8807SELECT
8808 operator_id, worker_id, records, batches, size, capacity, allocations
8809FROM combined
8810WHERE
8811 records IS NOT NULL
8812 OR batches IS NOT NULL
8813 OR size IS NOT NULL
8814 OR capacity IS NOT NULL
8815 OR allocations IS NOT NULL
8816",
8817 access: vec![PUBLIC_SELECT],
8818 }
8819});
8820
8821pub static MZ_ARRANGEMENT_SIZES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8822 name: "mz_arrangement_sizes",
8823 schema: MZ_INTROSPECTION_SCHEMA,
8824 oid: oid::VIEW_MZ_ARRANGEMENT_SIZES_OID,
8825 desc: RelationDesc::builder()
8826 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8827 .with_column("records", SqlScalarType::Int64.nullable(true))
8828 .with_column("batches", SqlScalarType::Int64.nullable(true))
8829 .with_column("size", SqlScalarType::Int64.nullable(true))
8830 .with_column("capacity", SqlScalarType::Int64.nullable(true))
8831 .with_column("allocations", SqlScalarType::Int64.nullable(true))
8832 .with_key(vec![0])
8833 .finish(),
8834 column_comments: BTreeMap::from_iter([
8835 (
8836 "operator_id",
8837 "The ID of the operator that created the arrangement. Corresponds to `mz_dataflow_operators.id`.",
8838 ),
8839 ("records", "The number of records in the arrangement."),
8840 ("batches", "The number of batches in the arrangement."),
8841 ("size", "The utilized size in bytes of the arrangement."),
8842 (
8843 "capacity",
8844 "The capacity in bytes of the arrangement. Can be larger than the size.",
8845 ),
8846 (
8847 "allocations",
8848 "The number of separate memory allocations backing the arrangement.",
8849 ),
8850 ]),
8851 sql: "
8852SELECT
8853 operator_id,
8854 SUM(records)::int8 AS records,
8855 SUM(batches)::int8 AS batches,
8856 SUM(size)::int8 AS size,
8857 SUM(capacity)::int8 AS capacity,
8858 SUM(allocations)::int8 AS allocations
8859FROM mz_introspection.mz_arrangement_sizes_per_worker
8860GROUP BY operator_id",
8861 access: vec![PUBLIC_SELECT],
8862});
8863
8864pub static MZ_ARRANGEMENT_SHARING_PER_WORKER: LazyLock<BuiltinView> =
8865 LazyLock::new(|| BuiltinView {
8866 name: "mz_arrangement_sharing_per_worker",
8867 schema: MZ_INTROSPECTION_SCHEMA,
8868 oid: oid::VIEW_MZ_ARRANGEMENT_SHARING_PER_WORKER_OID,
8869 desc: RelationDesc::builder()
8870 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8871 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
8872 .with_column("count", SqlScalarType::Int64.nullable(false))
8873 .with_key(vec![0, 1])
8874 .finish(),
8875 column_comments: BTreeMap::new(),
8876 sql: "
8877SELECT
8878 operator_id,
8879 worker_id,
8880 pg_catalog.count(*) AS count
8881FROM mz_introspection.mz_arrangement_sharing_raw
8882GROUP BY operator_id, worker_id",
8883 access: vec![PUBLIC_SELECT],
8884 });
8885
8886pub static MZ_ARRANGEMENT_SHARING: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8887 name: "mz_arrangement_sharing",
8888 schema: MZ_INTROSPECTION_SCHEMA,
8889 oid: oid::VIEW_MZ_ARRANGEMENT_SHARING_OID,
8890 desc: RelationDesc::builder()
8891 .with_column("operator_id", SqlScalarType::UInt64.nullable(false))
8892 .with_column("count", SqlScalarType::Int64.nullable(false))
8893 .finish(),
8894 column_comments: BTreeMap::from_iter([
8895 (
8896 "operator_id",
8897 "The ID of the operator that created the arrangement. Corresponds to `mz_dataflow_operators.id`.",
8898 ),
8899 (
8900 "count",
8901 "The number of operators that share the arrangement.",
8902 ),
8903 ]),
8904 sql: "
8905SELECT operator_id, count
8906FROM mz_introspection.mz_arrangement_sharing_per_worker
8907WHERE worker_id = 0",
8908 access: vec![PUBLIC_SELECT],
8909});
8910
8911pub static MZ_CLUSTER_REPLICA_UTILIZATION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
8912 name: "mz_cluster_replica_utilization",
8913 schema: MZ_INTERNAL_SCHEMA,
8914 oid: oid::VIEW_MZ_CLUSTER_REPLICA_UTILIZATION_OID,
8915 desc: RelationDesc::builder()
8916 .with_column("replica_id", SqlScalarType::String.nullable(false))
8917 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
8918 .with_column("cpu_percent", SqlScalarType::Float64.nullable(true))
8919 .with_column("memory_percent", SqlScalarType::Float64.nullable(true))
8920 .with_column("disk_percent", SqlScalarType::Float64.nullable(true))
8921 .with_column("heap_percent", SqlScalarType::Float64.nullable(true))
8922 .finish(),
8923 column_comments: BTreeMap::from_iter([
8924 ("replica_id", "The ID of a cluster replica."),
8925 ("process_id", "The ID of a process within the replica."),
8926 (
8927 "cpu_percent",
8928 "Approximate CPU usage, in percent of the total allocation.",
8929 ),
8930 (
8931 "memory_percent",
8932 "Approximate RAM usage, in percent of the total allocation.",
8933 ),
8934 (
8935 "disk_percent",
8936 "Approximate disk usage, in percent of the total allocation.",
8937 ),
8938 (
8939 "heap_percent",
8940 "Approximate heap (RAM + swap) usage, in percent of the total allocation.",
8941 ),
8942 ]),
8943 sql: "
8944SELECT
8945 r.id AS replica_id,
8946 m.process_id,
8947 m.cpu_nano_cores::float8 / NULLIF(s.cpu_nano_cores, 0) * 100 AS cpu_percent,
8948 m.memory_bytes::float8 / NULLIF(s.memory_bytes, 0) * 100 AS memory_percent,
8949 m.disk_bytes::float8 / NULLIF(s.disk_bytes, 0) * 100 AS disk_percent,
8950 m.heap_bytes::float8 / NULLIF(m.heap_limit, 0) * 100 AS heap_percent
8951FROM
8952 mz_catalog.mz_cluster_replicas AS r
8953 JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size
8954 JOIN mz_internal.mz_cluster_replica_metrics AS m ON m.replica_id = r.id",
8955 access: vec![PUBLIC_SELECT],
8956});
8957
8958pub static MZ_CLUSTER_REPLICA_UTILIZATION_HISTORY: LazyLock<BuiltinView> =
8959 LazyLock::new(|| BuiltinView {
8960 name: "mz_cluster_replica_utilization_history",
8961 schema: MZ_INTERNAL_SCHEMA,
8962 oid: oid::VIEW_MZ_CLUSTER_REPLICA_UTILIZATION_HISTORY_OID,
8963 desc: RelationDesc::builder()
8964 .with_column("replica_id", SqlScalarType::String.nullable(false))
8965 .with_column("process_id", SqlScalarType::UInt64.nullable(false))
8966 .with_column("cpu_percent", SqlScalarType::Float64.nullable(true))
8967 .with_column("memory_percent", SqlScalarType::Float64.nullable(true))
8968 .with_column("disk_percent", SqlScalarType::Float64.nullable(true))
8969 .with_column("heap_percent", SqlScalarType::Float64.nullable(true))
8970 .with_column(
8971 "occurred_at",
8972 SqlScalarType::TimestampTz { precision: None }.nullable(false),
8973 )
8974 .finish(),
8975 column_comments: BTreeMap::from_iter([
8976 ("replica_id", "The ID of a cluster replica."),
8977 ("process_id", "The ID of a process within the replica."),
8978 (
8979 "cpu_percent",
8980 "Approximate CPU usage, in percent of the total allocation.",
8981 ),
8982 (
8983 "memory_percent",
8984 "Approximate RAM usage, in percent of the total allocation.",
8985 ),
8986 (
8987 "disk_percent",
8988 "Approximate disk usage, in percent of the total allocation.",
8989 ),
8990 (
8991 "heap_percent",
8992 "Approximate heap (RAM + swap) usage, in percent of the total allocation.",
8993 ),
8994 (
8995 "occurred_at",
8996 "Wall-clock timestamp at which the event occurred.",
8997 ),
8998 ]),
8999 sql: "
9000SELECT
9001 r.id AS replica_id,
9002 m.process_id,
9003 m.cpu_nano_cores::float8 / NULLIF(s.cpu_nano_cores, 0) * 100 AS cpu_percent,
9004 m.memory_bytes::float8 / NULLIF(s.memory_bytes, 0) * 100 AS memory_percent,
9005 m.disk_bytes::float8 / NULLIF(s.disk_bytes, 0) * 100 AS disk_percent,
9006 m.heap_bytes::float8 / NULLIF(m.heap_limit, 0) * 100 AS heap_percent,
9007 m.occurred_at
9008FROM
9009 mz_catalog.mz_cluster_replicas AS r
9010 JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size
9011 JOIN mz_internal.mz_cluster_replica_metrics_history AS m ON m.replica_id = r.id",
9012 access: vec![PUBLIC_SELECT],
9013 });
9014
9015pub static MZ_DATAFLOW_OPERATOR_PARENTS_PER_WORKER: LazyLock<BuiltinView> =
9016 LazyLock::new(|| BuiltinView {
9017 name: "mz_dataflow_operator_parents_per_worker",
9018 schema: MZ_INTROSPECTION_SCHEMA,
9019 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_PARENTS_PER_WORKER_OID,
9020 desc: RelationDesc::builder()
9021 .with_column("id", SqlScalarType::UInt64.nullable(false))
9022 .with_column("parent_id", SqlScalarType::UInt64.nullable(false))
9023 .with_column("worker_id", SqlScalarType::UInt64.nullable(false))
9024 .finish(),
9025 column_comments: BTreeMap::new(),
9026 sql: "
9027WITH operator_addrs AS(
9028 SELECT
9029 id, address, worker_id
9030 FROM mz_introspection.mz_dataflow_addresses_per_worker
9031 INNER JOIN mz_introspection.mz_dataflow_operators_per_worker
9032 USING (id, worker_id)
9033),
9034parent_addrs AS (
9035 SELECT
9036 id,
9037 address[1:list_length(address) - 1] AS parent_address,
9038 worker_id
9039 FROM operator_addrs
9040)
9041SELECT pa.id, oa.id AS parent_id, pa.worker_id
9042FROM parent_addrs AS pa
9043 INNER JOIN operator_addrs AS oa
9044 ON pa.parent_address = oa.address
9045 AND pa.worker_id = oa.worker_id",
9046 access: vec![PUBLIC_SELECT],
9047 });
9048
9049pub static MZ_DATAFLOW_OPERATOR_PARENTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9050 name: "mz_dataflow_operator_parents",
9051 schema: MZ_INTROSPECTION_SCHEMA,
9052 oid: oid::VIEW_MZ_DATAFLOW_OPERATOR_PARENTS_OID,
9053 desc: RelationDesc::builder()
9054 .with_column("id", SqlScalarType::UInt64.nullable(false))
9055 .with_column("parent_id", SqlScalarType::UInt64.nullable(false))
9056 .finish(),
9057 column_comments: BTreeMap::from_iter([
9058 (
9059 "id",
9060 "The ID of the operator. Corresponds to `mz_dataflow_operators.id`.",
9061 ),
9062 (
9063 "parent_id",
9064 "The ID of the operator's parent operator. Corresponds to `mz_dataflow_operators.id`.",
9065 ),
9066 ]),
9067 sql: "
9068SELECT id, parent_id
9069FROM mz_introspection.mz_dataflow_operator_parents_per_worker
9070WHERE worker_id = 0",
9071 access: vec![PUBLIC_SELECT],
9072});
9073
9074pub static MZ_DATAFLOW_ARRANGEMENT_SIZES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9075 name: "mz_dataflow_arrangement_sizes",
9076 schema: MZ_INTROSPECTION_SCHEMA,
9077 oid: oid::VIEW_MZ_DATAFLOW_ARRANGEMENT_SIZES_OID,
9078 desc: RelationDesc::builder()
9079 .with_column("id", SqlScalarType::UInt64.nullable(false))
9080 .with_column("name", SqlScalarType::String.nullable(false))
9081 .with_column("records", SqlScalarType::Int64.nullable(true))
9082 .with_column("batches", SqlScalarType::Int64.nullable(true))
9083 .with_column("size", SqlScalarType::Int64.nullable(true))
9084 .with_column("capacity", SqlScalarType::Int64.nullable(true))
9085 .with_column("allocations", SqlScalarType::Int64.nullable(true))
9086 .with_key(vec![0, 1])
9087 .finish(),
9088 column_comments: BTreeMap::from_iter([
9089 (
9090 "id",
9091 "The ID of the [dataflow]. Corresponds to `mz_dataflows.id`.",
9092 ),
9093 ("name", "The name of the [dataflow]."),
9094 (
9095 "records",
9096 "The number of records in all arrangements in the dataflow.",
9097 ),
9098 (
9099 "batches",
9100 "The number of batches in all arrangements in the dataflow.",
9101 ),
9102 ("size", "The utilized size in bytes of the arrangements."),
9103 (
9104 "capacity",
9105 "The capacity in bytes of the arrangements. Can be larger than the size.",
9106 ),
9107 (
9108 "allocations",
9109 "The number of separate memory allocations backing the arrangements.",
9110 ),
9111 ]),
9112 sql: "
9113SELECT
9114 mdod.dataflow_id AS id,
9115 mdod.dataflow_name AS name,
9116 SUM(mas.records)::int8 AS records,
9117 SUM(mas.batches)::int8 AS batches,
9118 SUM(mas.size)::int8 AS size,
9119 SUM(mas.capacity)::int8 AS capacity,
9120 SUM(mas.allocations)::int8 AS allocations
9121FROM mz_introspection.mz_dataflow_operator_dataflows AS mdod
9122LEFT JOIN mz_introspection.mz_arrangement_sizes AS mas
9123 ON mdod.id = mas.operator_id
9124GROUP BY mdod.dataflow_id, mdod.dataflow_name",
9125 access: vec![PUBLIC_SELECT],
9126});
9127
9128pub static MZ_EXPECTED_GROUP_SIZE_ADVICE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9129 name: "mz_expected_group_size_advice",
9130 schema: MZ_INTROSPECTION_SCHEMA,
9131 oid: oid::VIEW_MZ_EXPECTED_GROUP_SIZE_ADVICE_OID,
9132 desc: RelationDesc::builder()
9133 .with_column("dataflow_id", SqlScalarType::UInt64.nullable(false))
9134 .with_column("dataflow_name", SqlScalarType::String.nullable(false))
9135 .with_column("region_id", SqlScalarType::UInt64.nullable(false))
9136 .with_column("region_name", SqlScalarType::String.nullable(false))
9137 .with_column("levels", SqlScalarType::Int64.nullable(false))
9138 .with_column("to_cut", SqlScalarType::Int64.nullable(false))
9139 .with_column(
9140 "savings",
9141 SqlScalarType::Numeric {
9142 max_scale: Some(NumericMaxScale::ZERO),
9143 }
9144 .nullable(true),
9145 )
9146 .with_column("hint", SqlScalarType::Float64.nullable(false))
9147 .finish(),
9148 column_comments: BTreeMap::from_iter([
9149 (
9150 "dataflow_id",
9151 "The ID of the [dataflow]. Corresponds to `mz_dataflows.id`.",
9152 ),
9153 (
9154 "dataflow_name",
9155 "The internal name of the dataflow hosting the min/max aggregation or Top K.",
9156 ),
9157 (
9158 "region_id",
9159 "The ID of the root operator scope. Corresponds to `mz_dataflow_operators.id`.",
9160 ),
9161 (
9162 "region_name",
9163 "The internal name of the root operator scope for the min/max aggregation or Top K.",
9164 ),
9165 (
9166 "levels",
9167 "The number of levels in the hierarchical scheme implemented by the region.",
9168 ),
9169 (
9170 "to_cut",
9171 "The number of levels that can be eliminated (cut) from the region's hierarchy.",
9172 ),
9173 (
9174 "savings",
9175 "A conservative estimate of the amount of memory in bytes to be saved by applying the hint.",
9176 ),
9177 (
9178 "hint",
9179 "The hint value that will eliminate `to_cut` levels from the region's hierarchy.",
9180 ),
9181 ]),
9182 sql: "
9183 -- The mz_expected_group_size_advice view provides tuning suggestions for the GROUP SIZE
9184 -- query hints. This tuning hint is effective for min/max/top-k patterns, where a stack
9185 -- of arrangements must be built. For each dataflow and region corresponding to one
9186 -- such pattern, we look for how many levels can be eliminated without hitting a level
9187 -- that actually substantially filters the input. The advice is constructed so that
9188 -- setting the hint for the affected region will eliminate these redundant levels of
9189 -- the hierarchical rendering.
9190 --
9191 -- A number of helper CTEs are used for the view definition. The first one, operators,
9192 -- looks for operator names that comprise arrangements of inputs to each level of a
9193 -- min/max/top-k hierarchy.
9194 WITH operators AS (
9195 SELECT
9196 dod.dataflow_id,
9197 dor.id AS region_id,
9198 dod.id,
9199 ars.records,
9200 ars.size
9201 FROM
9202 mz_introspection.mz_dataflow_operator_dataflows dod
9203 JOIN mz_introspection.mz_dataflow_addresses doa
9204 ON dod.id = doa.id
9205 JOIN mz_introspection.mz_dataflow_addresses dra
9206 ON dra.address = doa.address[:list_length(doa.address) - 1]
9207 JOIN mz_introspection.mz_dataflow_operators dor
9208 ON dor.id = dra.id
9209 JOIN mz_introspection.mz_arrangement_sizes ars
9210 ON ars.operator_id = dod.id
9211 WHERE
9212 dod.name = 'Arranged TopK input'
9213 OR dod.name = 'Arranged MinsMaxesHierarchical input'
9214 OR dod.name = 'Arrange ReduceMinsMaxes'
9215 ),
9216 -- The second CTE, levels, simply computes the heights of the min/max/top-k hierarchies
9217 -- identified in operators above.
9218 levels AS (
9219 SELECT o.dataflow_id, o.region_id, COUNT(*) AS levels
9220 FROM operators o
9221 GROUP BY o.dataflow_id, o.region_id
9222 ),
9223 -- The third CTE, pivot, determines for each min/max/top-k hierarchy, the first input
9224 -- operator. This operator is crucially important, as it records the number of records
9225 -- that was given as input to the gadget as a whole.
9226 pivot AS (
9227 SELECT
9228 o1.dataflow_id,
9229 o1.region_id,
9230 o1.id,
9231 o1.records
9232 FROM operators o1
9233 WHERE
9234 o1.id = (
9235 SELECT MIN(o2.id)
9236 FROM operators o2
9237 WHERE
9238 o2.dataflow_id = o1.dataflow_id
9239 AND o2.region_id = o1.region_id
9240 OPTIONS (AGGREGATE INPUT GROUP SIZE = 8)
9241 )
9242 ),
9243 -- The fourth CTE, candidates, will look for operators where the number of records
9244 -- maintained is not significantly different from the number at the pivot (excluding
9245 -- the pivot itself). These are the candidates for being cut from the dataflow region
9246 -- by adjusting the hint. The query includes a constant, heuristically tuned on TPC-H
9247 -- load generator data, to give some room for small deviations in number of records.
9248 -- The intuition for allowing for this deviation is that we are looking for a strongly
9249 -- reducing point in the hierarchy. To see why one such operator ought to exist in an
9250 -- untuned hierarchy, consider that at each level, we use hashing to distribute rows
9251 -- among groups where the min/max/top-k computation is (partially) applied. If the
9252 -- hierarchy has too many levels, the first-level (pivot) groups will be such that many
9253 -- groups might be empty or contain only one row. Each subsequent level will have a number
9254 -- of groups that is reduced exponentially. So at some point, we will find the level where
9255 -- we actually start having a few rows per group. That's where we will see the row counts
9256 -- significantly drop off.
9257 candidates AS (
9258 SELECT
9259 o.dataflow_id,
9260 o.region_id,
9261 o.id,
9262 o.records,
9263 o.size
9264 FROM
9265 operators o
9266 JOIN pivot p
9267 ON o.dataflow_id = p.dataflow_id
9268 AND o.region_id = p.region_id
9269 AND o.id <> p.id
9270 WHERE o.records >= p.records * (1 - 0.15)
9271 ),
9272 -- The fifth CTE, cuts, computes for each relevant dataflow region, the number of
9273 -- candidate levels that should be cut. We only return here dataflow regions where at
9274 -- least one level must be cut. Note that once we hit a point where the hierarchy starts
9275 -- to have a filtering effect, i.e., after the last candidate, it is dangerous to suggest
9276 -- cutting the height of the hierarchy further. This is because we will have way less
9277 -- groups in the next level, so there should be even further reduction happening or there
9278 -- is some substantial skew in the data. But if the latter is the case, then we should not
9279 -- tune the GROUP SIZE hints down anyway to avoid hurting latency upon updates directed
9280 -- at these unusually large groups. In addition to selecting the levels to cut, we also
9281 -- compute a conservative estimate of the memory savings in bytes that will result from
9282 -- cutting these levels from the hierarchy. The estimate is based on the sizes of the
9283 -- input arrangements for each level to be cut. These arrangements should dominate the
9284 -- size of each level that can be cut, since the reduction gadget internal to the level
9285 -- does not remove much data at these levels.
9286 cuts AS (
9287 SELECT c.dataflow_id, c.region_id, COUNT(*) AS to_cut, SUM(c.size) AS savings
9288 FROM candidates c
9289 GROUP BY c.dataflow_id, c.region_id
9290 HAVING COUNT(*) > 0
9291 )
9292 -- Finally, we compute the hint suggestion for each dataflow region based on the number of
9293 -- levels and the number of candidates to be cut. The hint is computed taking into account
9294 -- the fan-in used in rendering for the hash partitioning and reduction of the groups,
9295 -- currently equal to 16.
9296 SELECT
9297 dod.dataflow_id,
9298 dod.dataflow_name,
9299 dod.id AS region_id,
9300 dod.name AS region_name,
9301 l.levels,
9302 c.to_cut,
9303 c.savings,
9304 pow(16, l.levels - c.to_cut) - 1 AS hint
9305 FROM cuts c
9306 JOIN levels l
9307 ON c.dataflow_id = l.dataflow_id AND c.region_id = l.region_id
9308 JOIN mz_introspection.mz_dataflow_operator_dataflows dod
9309 ON dod.dataflow_id = c.dataflow_id AND dod.id = c.region_id",
9310 access: vec![PUBLIC_SELECT],
9311});
9312
9313pub static MZ_INDEX_ADVICE: LazyLock<BuiltinView> = LazyLock::new(|| {
9314 BuiltinView {
9315 name: "mz_index_advice",
9316 schema: MZ_INTERNAL_SCHEMA,
9317 oid: oid::VIEW_MZ_INDEX_ADVICE_OID,
9318 desc: RelationDesc::builder()
9319 .with_column("object_id", SqlScalarType::String.nullable(true))
9320 .with_column("hint", SqlScalarType::String.nullable(false))
9321 .with_column("details", SqlScalarType::String.nullable(false))
9322 .with_column("referenced_object_ids", SqlScalarType::List { element_type: Box::new(SqlScalarType::String), custom_id: None }.nullable(true))
9323 .finish(),
9324 column_comments: BTreeMap::from_iter([
9325 ("object_id", "The ID of the object. Corresponds to mz_objects.id."),
9326 ("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."),
9327 ("details", "Additional details on why the `hint` was proposed based on the dependencies of the object."),
9328 ("referenced_object_ids", "The IDs of objects referenced by `details`. Corresponds to mz_objects.id."),
9329 ]),
9330 sql: "
9331-- To avoid confusion with sources and sinks in the materialize sense,
9332-- the following uses the terms leafs (instead of sinks) and roots (instead of sources)
9333-- when referring to the object dependency graph.
9334--
9335-- The basic idea is to walk up the dependency graph to propagate the transitive dependencies
9336-- of maintained objected upwards. The leaves of the dependency graph are maintained objects
9337-- that are not depended on by other maintained objects and have a justification why they must
9338-- be maintained (e.g. a materialized view that is depended on by a sink).
9339-- Starting from these leaves, the dependencies are propagated upwards towards the roots according
9340-- to the object dependencies. Whenever there is a node that is being depended on by multiple
9341-- downstream objects, that node is marked to be converted into a maintained object and this
9342-- node is then propagated further up. Once completed, the list of objects that are marked as
9343-- maintained is checked against all objects to generate appropriate recommendations.
9344--
9345-- Note that the recommendations only incorporate dependencies between objects.
9346-- This can lead to bad recommendations, e.g. filters can no longer be pushed into (or close to)
9347-- a sink if an index is added in between the sink and the filter. For very selective filters,
9348-- this can lead to redundant work: the index is computing stuff only to discarded by the selective
9349-- filter later on. But these kind of aspects cannot be understood by merely looking at the
9350-- dependencies.
9351WITH MUTUALLY RECURSIVE
9352 -- for all objects, understand if they have an index on them and on which cluster they are running
9353 -- this avoids having different cases for views with an index and materialized views later on
9354 objects(id text, type text, cluster_id text, indexes text list) AS (
9355 -- views and materialized views without an index
9356 SELECT
9357 o.id,
9358 o.type,
9359 o.cluster_id,
9360 '{}'::text list AS indexes
9361 FROM mz_catalog.mz_objects o
9362 WHERE o.id LIKE 'u%' AND o.type IN ('materialized-view', 'view') AND NOT EXISTS (
9363 SELECT FROM mz_internal.mz_object_dependencies d
9364 JOIN mz_catalog.mz_objects AS i
9365 ON (i.id = d.object_id AND i.type = 'index')
9366 WHERE (o.id = d.referenced_object_id)
9367 )
9368
9369 UNION ALL
9370
9371 -- views and materialized views with an index
9372 SELECT
9373 o.id,
9374 o.type,
9375 -- o.cluster_id is always NULL for views, so use the cluster of the index instead
9376 COALESCE(o.cluster_id, i.cluster_id) AS cluster_id,
9377 list_agg(i.id) AS indexes
9378 FROM mz_catalog.mz_objects o
9379 JOIN mz_internal.mz_object_dependencies AS d
9380 ON (o.id = d.referenced_object_id)
9381 JOIN mz_catalog.mz_objects AS i
9382 ON (i.id = d.object_id AND i.type = 'index')
9383 WHERE o.id LIKE 'u%' AND o.type IN ('materialized-view', 'view', 'source')
9384 GROUP BY o.id, o.type, o.cluster_id, i.cluster_id
9385 ),
9386
9387 -- maintained objects that are at the leafs of the dependency graph with respect to a specific cluster
9388 maintained_leafs(id text, justification text) AS (
9389 -- materialized views that are connected to a sink
9390 SELECT
9391 m.id,
9392 s.id AS justification
9393 FROM objects AS m
9394 JOIN mz_internal.mz_object_dependencies AS d
9395 ON (m.id = d.referenced_object_id)
9396 JOIN mz_catalog.mz_objects AS s
9397 ON (s.id = d.object_id AND s.type = 'sink')
9398 WHERE m.type = 'materialized-view'
9399
9400 UNION ALL
9401
9402 -- (materialized) views with an index that are not transitively depend on by maintained objects on the same cluster
9403 SELECT
9404 v.id,
9405 unnest(v.indexes) AS justification
9406 FROM objects AS v
9407 WHERE v.type IN ('view', 'materialized-view', 'source') AND NOT EXISTS (
9408 SELECT FROM mz_internal.mz_object_transitive_dependencies AS d
9409 INNER JOIN mz_catalog.mz_objects AS child
9410 ON (d.object_id = child.id)
9411 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]
9412 )
9413 ),
9414
9415 -- this is just a helper cte to union multiple lists as part of an aggregation, which is not directly possible in SQL
9416 agg_maintained_children(id text, maintained_children text list) AS (
9417 SELECT
9418 parent_id AS id,
9419 list_agg(maintained_child) AS maintained_leafs
9420 FROM (
9421 SELECT DISTINCT
9422 d.referenced_object_id AS parent_id,
9423 -- it's not possible to union lists in an aggregation, so we have to unnest the list first
9424 unnest(child.maintained_children) AS maintained_child
9425 FROM propagate_dependencies AS child
9426 INNER JOIN mz_internal.mz_object_dependencies AS d
9427 ON (child.id = d.object_id)
9428 )
9429 GROUP BY parent_id
9430 ),
9431
9432 -- propagate dependencies of maintained objects from the leafs to the roots of the dependency graph and
9433 -- record a justification when an object should be maintained, e.g. when it is depended on by more than one maintained object
9434 -- 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
9435 propagate_dependencies(id text, maintained_children text list, justification text list) AS (
9436 -- base case: start with the leafs
9437 SELECT DISTINCT
9438 id,
9439 LIST[id] AS maintained_children,
9440 list_agg(justification) AS justification
9441 FROM maintained_leafs
9442 GROUP BY id
9443
9444 UNION
9445
9446 -- recursive case: if there is a child with the same dependencies as the parent,
9447 -- the parent is only reused by a single child
9448 SELECT
9449 parent.id,
9450 child.maintained_children,
9451 NULL::text list AS justification
9452 FROM agg_maintained_children AS parent
9453 INNER JOIN mz_internal.mz_object_dependencies AS d
9454 ON (parent.id = d.referenced_object_id)
9455 INNER JOIN propagate_dependencies AS child
9456 ON (d.object_id = child.id)
9457 WHERE parent.maintained_children = child.maintained_children
9458
9459 UNION
9460
9461 -- recursive case: if there is NO child with the same dependencies as the parent,
9462 -- different children are reusing the parent so maintaining the object is justified by itself
9463 SELECT DISTINCT
9464 parent.id,
9465 LIST[parent.id] AS maintained_children,
9466 parent.maintained_children AS justification
9467 FROM agg_maintained_children AS parent
9468 WHERE NOT EXISTS (
9469 SELECT FROM mz_internal.mz_object_dependencies AS d
9470 INNER JOIN propagate_dependencies AS child
9471 ON (d.object_id = child.id AND d.referenced_object_id = parent.id)
9472 WHERE parent.maintained_children = child.maintained_children
9473 )
9474 ),
9475
9476 objects_with_justification(id text, type text, cluster_id text, maintained_children text list, justification text list, indexes text list) AS (
9477 SELECT
9478 p.id,
9479 o.type,
9480 o.cluster_id,
9481 p.maintained_children,
9482 p.justification,
9483 o.indexes
9484 FROM propagate_dependencies p
9485 JOIN objects AS o
9486 ON (p.id = o.id)
9487 ),
9488
9489 hints(id text, hint text, details text, justification text list) AS (
9490 -- materialized views that are not required
9491 SELECT
9492 id,
9493 'convert to a view' AS hint,
9494 'no dependencies from sinks nor from objects on different clusters' AS details,
9495 justification
9496 FROM objects_with_justification
9497 WHERE type = 'materialized-view' AND justification IS NULL
9498
9499 UNION ALL
9500
9501 -- materialized views that are required because a sink or a maintained object from a different cluster depends on them
9502 SELECT
9503 id,
9504 'keep' AS hint,
9505 'dependencies from sinks or objects on different clusters: ' AS details,
9506 justification
9507 FROM objects_with_justification AS m
9508 WHERE type = 'materialized-view' AND justification IS NOT NULL AND EXISTS (
9509 SELECT FROM unnest(justification) AS dependency
9510 JOIN mz_catalog.mz_objects s ON (s.type = 'sink' AND s.id = dependency)
9511
9512 UNION ALL
9513
9514 SELECT FROM unnest(justification) AS dependency
9515 JOIN mz_catalog.mz_objects AS d ON (d.id = dependency)
9516 WHERE d.cluster_id != m.cluster_id
9517 )
9518
9519 UNION ALL
9520
9521 -- 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
9522 SELECT
9523 id,
9524 'convert to a view with an index' AS hint,
9525 'no dependencies from sinks nor from objects on different clusters, but maintained dependencies on the same cluster: ' AS details,
9526 justification
9527 FROM objects_with_justification AS m
9528 WHERE type = 'materialized-view' AND justification IS NOT NULL AND NOT EXISTS (
9529 SELECT FROM unnest(justification) AS dependency
9530 JOIN mz_catalog.mz_objects s ON (s.type = 'sink' AND s.id = dependency)
9531
9532 UNION ALL
9533
9534 SELECT FROM unnest(justification) AS dependency
9535 JOIN mz_catalog.mz_objects AS d ON (d.id = dependency)
9536 WHERE d.cluster_id != m.cluster_id
9537 )
9538
9539 UNION ALL
9540
9541 -- views that have indexes on different clusters should be a materialized view
9542 SELECT
9543 o.id,
9544 'convert to materialized view' AS hint,
9545 'dependencies on multiple clusters: ' AS details,
9546 o.justification
9547 FROM objects_with_justification o,
9548 LATERAL unnest(o.justification) j
9549 LEFT JOIN mz_catalog.mz_objects AS m
9550 ON (m.id = j AND m.type IN ('index', 'materialized-view'))
9551 WHERE o.type = 'view' AND o.justification IS NOT NULL
9552 GROUP BY o.id, o.justification
9553 HAVING count(DISTINCT m.cluster_id) >= 2
9554
9555 UNION ALL
9556
9557 -- views without an index that should be maintained
9558 SELECT
9559 id,
9560 'add index' AS hint,
9561 'multiple downstream dependencies: ' AS details,
9562 justification
9563 FROM objects_with_justification
9564 WHERE type = 'view' AND justification IS NOT NULL AND indexes = '{}'::text list
9565
9566 UNION ALL
9567
9568 -- index inside the dependency graph (not a leaf)
9569 SELECT
9570 unnest(indexes) AS id,
9571 'drop unless queried directly' AS hint,
9572 'fewer than two downstream dependencies: ' AS details,
9573 maintained_children AS justification
9574 FROM objects_with_justification
9575 WHERE type = 'view' AND NOT indexes = '{}'::text list AND justification IS NULL
9576
9577 UNION ALL
9578
9579 -- index on a leaf of the dependency graph
9580 SELECT
9581 unnest(indexes) AS id,
9582 'drop unless queried directly' AS hint,
9583 'associated object does not have any dependencies (maintained or not maintained)' AS details,
9584 NULL::text list AS justification
9585 FROM objects_with_justification
9586 -- indexes can only be part of justification for leaf nodes
9587 WHERE type IN ('view', 'materialized-view') AND NOT indexes = '{}'::text list AND justification @> indexes
9588
9589 UNION ALL
9590
9591 -- index on a source
9592 SELECT
9593 unnest(indexes) AS id,
9594 'drop unless queried directly' AS hint,
9595 'sources do not transform data and can expose data directly' AS details,
9596 NULL::text list AS justification
9597 FROM objects_with_justification
9598 -- indexes can only be part of justification for leaf nodes
9599 WHERE type = 'source' AND NOT indexes = '{}'::text list
9600
9601 UNION ALL
9602
9603 -- indexes on views inside the dependency graph
9604 SELECT
9605 unnest(indexes) AS id,
9606 'keep' AS hint,
9607 'multiple downstream dependencies: ' AS details,
9608 justification
9609 FROM objects_with_justification
9610 -- indexes can only be part of justification for leaf nodes
9611 WHERE type = 'view' AND justification IS NOT NULL AND NOT indexes = '{}'::text list AND NOT justification @> indexes
9612 ),
9613
9614 hints_resolved_ids(id text, hint text, details text, justification text list) AS (
9615 SELECT
9616 h.id,
9617 h.hint,
9618 h.details || list_agg(o.name)::text AS details,
9619 h.justification
9620 FROM hints AS h,
9621 LATERAL unnest(h.justification) j
9622 JOIN mz_catalog.mz_objects AS o
9623 ON (o.id = j)
9624 GROUP BY h.id, h.hint, h.details, h.justification
9625
9626 UNION ALL
9627
9628 SELECT
9629 id,
9630 hint,
9631 details,
9632 justification
9633 FROM hints
9634 WHERE justification IS NULL
9635 )
9636
9637SELECT
9638 h.id AS object_id,
9639 h.hint AS hint,
9640 h.details,
9641 h.justification AS referenced_object_ids
9642FROM hints_resolved_ids AS h",
9643 access: vec![PUBLIC_SELECT],
9644 }
9645});
9646
9647pub static PG_CONSTRAINT: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9650 name: "pg_constraint",
9651 schema: PG_CATALOG_SCHEMA,
9652 oid: oid::VIEW_PG_CONSTRAINT_OID,
9653 desc: RelationDesc::builder()
9654 .with_column("oid", SqlScalarType::Oid.nullable(false))
9655 .with_column("conname", SqlScalarType::String.nullable(false))
9656 .with_column("connamespace", SqlScalarType::Oid.nullable(false))
9657 .with_column("contype", SqlScalarType::PgLegacyChar.nullable(false))
9658 .with_column("condeferrable", SqlScalarType::Bool.nullable(false))
9659 .with_column("condeferred", SqlScalarType::Bool.nullable(false))
9660 .with_column("convalidated", SqlScalarType::Bool.nullable(false))
9661 .with_column("conrelid", SqlScalarType::Oid.nullable(false))
9662 .with_column("contypid", SqlScalarType::Oid.nullable(false))
9663 .with_column("conindid", SqlScalarType::Oid.nullable(false))
9664 .with_column("conparentid", SqlScalarType::Oid.nullable(false))
9665 .with_column("confrelid", SqlScalarType::Oid.nullable(false))
9666 .with_column("confupdtype", SqlScalarType::PgLegacyChar.nullable(false))
9667 .with_column("confdeltype", SqlScalarType::PgLegacyChar.nullable(false))
9668 .with_column("confmatchtype", SqlScalarType::PgLegacyChar.nullable(false))
9669 .with_column("conislocal", SqlScalarType::Bool.nullable(false))
9670 .with_column("coninhcount", SqlScalarType::Int32.nullable(false))
9671 .with_column("connoinherit", SqlScalarType::Bool.nullable(false))
9672 .with_column(
9673 "conkey",
9674 SqlScalarType::Array(Box::new(SqlScalarType::Int16)).nullable(false),
9675 )
9676 .with_column(
9677 "confkey",
9678 SqlScalarType::Array(Box::new(SqlScalarType::Int16)).nullable(false),
9679 )
9680 .with_column(
9681 "conpfeqop",
9682 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9683 )
9684 .with_column(
9685 "conppeqop",
9686 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9687 )
9688 .with_column(
9689 "conffeqop",
9690 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9691 )
9692 .with_column(
9693 "conexclop",
9694 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
9695 )
9696 .with_column("conbin", SqlScalarType::String.nullable(false))
9697 .with_key(vec![])
9698 .finish(),
9699 column_comments: BTreeMap::new(),
9700 sql: "SELECT
9701 NULL::pg_catalog.oid as oid,
9702 NULL::pg_catalog.text as conname,
9703 NULL::pg_catalog.oid as connamespace,
9704 NULL::pg_catalog.\"char\" as contype,
9705 NULL::pg_catalog.bool as condeferrable,
9706 NULL::pg_catalog.bool as condeferred,
9707 NULL::pg_catalog.bool as convalidated,
9708 NULL::pg_catalog.oid as conrelid,
9709 NULL::pg_catalog.oid as contypid,
9710 NULL::pg_catalog.oid as conindid,
9711 NULL::pg_catalog.oid as conparentid,
9712 NULL::pg_catalog.oid as confrelid,
9713 NULL::pg_catalog.\"char\" as confupdtype,
9714 NULL::pg_catalog.\"char\" as confdeltype,
9715 NULL::pg_catalog.\"char\" as confmatchtype,
9716 NULL::pg_catalog.bool as conislocal,
9717 NULL::pg_catalog.int4 as coninhcount,
9718 NULL::pg_catalog.bool as connoinherit,
9719 NULL::pg_catalog.int2[] as conkey,
9720 NULL::pg_catalog.int2[] as confkey,
9721 NULL::pg_catalog.oid[] as conpfeqop,
9722 NULL::pg_catalog.oid[] as conppeqop,
9723 NULL::pg_catalog.oid[] as conffeqop,
9724 NULL::pg_catalog.oid[] as conexclop,
9725 NULL::pg_catalog.text as conbin
9726WHERE false",
9727 access: vec![PUBLIC_SELECT],
9728});
9729
9730pub static PG_TABLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9731 name: "pg_tables",
9732 schema: PG_CATALOG_SCHEMA,
9733 oid: oid::VIEW_PG_TABLES_OID,
9734 desc: RelationDesc::builder()
9735 .with_column("schemaname", SqlScalarType::String.nullable(true))
9736 .with_column("tablename", SqlScalarType::String.nullable(false))
9737 .with_column("tableowner", SqlScalarType::String.nullable(false))
9738 .finish(),
9739 column_comments: BTreeMap::new(),
9740 sql: "
9741SELECT n.nspname AS schemaname,
9742 c.relname AS tablename,
9743 pg_catalog.pg_get_userbyid(c.relowner) AS tableowner
9744FROM pg_catalog.pg_class c
9745LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
9746WHERE c.relkind IN ('r', 'p')",
9747 access: vec![PUBLIC_SELECT],
9748});
9749
9750pub static PG_TABLESPACE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9751 name: "pg_tablespace",
9752 schema: PG_CATALOG_SCHEMA,
9753 oid: oid::VIEW_PG_TABLESPACE_OID,
9754 desc: RelationDesc::builder()
9755 .with_column("oid", SqlScalarType::Oid.nullable(false))
9756 .with_column("spcname", SqlScalarType::String.nullable(false))
9757 .with_column("spcowner", SqlScalarType::Oid.nullable(true))
9758 .with_column(
9759 "spcacl",
9760 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9761 )
9762 .with_column(
9763 "spcoptions",
9764 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9765 )
9766 .with_key(vec![])
9767 .finish(),
9768 column_comments: BTreeMap::new(),
9769 sql: "
9770 SELECT oid, spcname, spcowner, spcacl, spcoptions
9771 FROM (
9772 VALUES (
9773 --These are the same defaults CockroachDB uses.
9774 0::pg_catalog.oid,
9775 'pg_default'::pg_catalog.text,
9776 NULL::pg_catalog.oid,
9777 NULL::pg_catalog.text[],
9778 NULL::pg_catalog.text[]
9779 )
9780 ) AS _ (oid, spcname, spcowner, spcacl, spcoptions)
9781",
9782 access: vec![PUBLIC_SELECT],
9783});
9784
9785pub static PG_ACCESS_METHODS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9786 name: "pg_am",
9787 schema: PG_CATALOG_SCHEMA,
9788 oid: oid::VIEW_PG_AM_OID,
9789 desc: RelationDesc::builder()
9790 .with_column("oid", SqlScalarType::Oid.nullable(false))
9791 .with_column("amname", SqlScalarType::String.nullable(false))
9792 .with_column("amhandler", SqlScalarType::RegProc.nullable(false))
9793 .with_column("amtype", SqlScalarType::PgLegacyChar.nullable(false))
9794 .with_key(vec![])
9795 .finish(),
9796 column_comments: BTreeMap::new(),
9797 sql: "
9798SELECT NULL::pg_catalog.oid AS oid,
9799 NULL::pg_catalog.text AS amname,
9800 NULL::pg_catalog.regproc AS amhandler,
9801 NULL::pg_catalog.\"char\" AS amtype
9802WHERE false",
9803 access: vec![PUBLIC_SELECT],
9804});
9805
9806pub static PG_ROLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9807 name: "pg_roles",
9808 schema: PG_CATALOG_SCHEMA,
9809 oid: oid::VIEW_PG_ROLES_OID,
9810 desc: RelationDesc::builder()
9811 .with_column("rolname", SqlScalarType::String.nullable(false))
9812 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
9813 .with_column("rolinherit", SqlScalarType::Bool.nullable(false))
9814 .with_column("rolcreaterole", SqlScalarType::Bool.nullable(true))
9815 .with_column("rolcreatedb", SqlScalarType::Bool.nullable(true))
9816 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(false))
9817 .with_column("rolreplication", SqlScalarType::Bool.nullable(false))
9818 .with_column("rolconnlimit", SqlScalarType::Int32.nullable(false))
9819 .with_column("rolpassword", SqlScalarType::String.nullable(false))
9820 .with_column(
9821 "rolvaliduntil",
9822 SqlScalarType::TimestampTz { precision: None }.nullable(true),
9823 )
9824 .with_column("rolbypassrls", SqlScalarType::Bool.nullable(false))
9825 .with_column(
9826 "rolconfig",
9827 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9828 )
9829 .with_column("oid", SqlScalarType::Oid.nullable(false))
9830 .finish(),
9831 column_comments: BTreeMap::new(),
9832 sql: "SELECT
9833 rolname,
9834 rolsuper,
9835 rolinherit,
9836 rolcreaterole,
9837 rolcreatedb,
9838 COALESCE(rolcanlogin, false) AS rolcanlogin,
9839 rolreplication,
9840 rolconnlimit,
9841 '********' as rolpassword,
9842 rolvaliduntil,
9843 rolbypassrls,
9844 (
9845 SELECT array_agg(parameter_name || '=' || parameter_value)
9846 FROM mz_catalog.mz_role_parameters rp
9847 JOIN mz_catalog.mz_roles r ON r.id = rp.role_id
9848 WHERE ai.oid = r.oid
9849 ) AS rolconfig,
9850 oid
9851FROM pg_catalog.pg_authid ai",
9852 access: vec![PUBLIC_SELECT],
9853});
9854
9855pub static PG_USER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9856 name: "pg_user",
9857 schema: PG_CATALOG_SCHEMA,
9858 oid: oid::VIEW_PG_USER_OID,
9859 desc: RelationDesc::builder()
9860 .with_column("usename", SqlScalarType::String.nullable(false))
9861 .with_column("usesysid", SqlScalarType::Oid.nullable(false))
9862 .with_column("usecreatedb", SqlScalarType::Bool.nullable(true))
9863 .with_column("usesuper", SqlScalarType::Bool.nullable(true))
9864 .with_column("userepl", SqlScalarType::Bool.nullable(false))
9865 .with_column("usebypassrls", SqlScalarType::Bool.nullable(false))
9866 .with_column("passwd", SqlScalarType::String.nullable(true))
9867 .with_column(
9868 "valuntil",
9869 SqlScalarType::TimestampTz { precision: None }.nullable(true),
9870 )
9871 .with_column(
9872 "useconfig",
9873 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
9874 )
9875 .finish(),
9876 column_comments: BTreeMap::new(),
9877 sql: "
9878SELECT
9879 rolname as usename,
9880 ai.oid as usesysid,
9881 rolcreatedb AS usecreatedb,
9882 rolsuper AS usesuper,
9883 rolreplication AS userepl,
9884 rolbypassrls AS usebypassrls,
9885 rolpassword as passwd,
9886 rolvaliduntil as valuntil,
9887 (
9888 SELECT array_agg(parameter_name || '=' || parameter_value)
9889 FROM mz_catalog.mz_role_parameters rp
9890 JOIN mz_catalog.mz_roles r ON r.id = rp.role_id
9891 WHERE ai.oid = r.oid
9892 ) AS useconfig
9893FROM pg_catalog.pg_authid ai
9894WHERE rolcanlogin",
9895 access: vec![PUBLIC_SELECT],
9896});
9897
9898pub static PG_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9899 name: "pg_views",
9900 schema: PG_CATALOG_SCHEMA,
9901 oid: oid::VIEW_PG_VIEWS_OID,
9902 desc: RelationDesc::builder()
9903 .with_column("schemaname", SqlScalarType::String.nullable(true))
9904 .with_column("viewname", SqlScalarType::String.nullable(false))
9905 .with_column("viewowner", SqlScalarType::Oid.nullable(false))
9906 .with_column("definition", SqlScalarType::String.nullable(false))
9907 .finish(),
9908 column_comments: BTreeMap::new(),
9909 sql: "SELECT
9910 s.name AS schemaname,
9911 v.name AS viewname,
9912 role_owner.oid AS viewowner,
9913 v.definition AS definition
9914FROM mz_catalog.mz_views v
9915LEFT JOIN mz_catalog.mz_schemas s ON s.id = v.schema_id
9916LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
9917JOIN mz_catalog.mz_roles role_owner ON role_owner.id = v.owner_id
9918WHERE s.database_id IS NULL OR d.name = current_database()",
9919 access: vec![PUBLIC_SELECT],
9920});
9921
9922pub static PG_MATVIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9923 name: "pg_matviews",
9924 schema: PG_CATALOG_SCHEMA,
9925 oid: oid::VIEW_PG_MATVIEWS_OID,
9926 desc: RelationDesc::builder()
9927 .with_column("schemaname", SqlScalarType::String.nullable(true))
9928 .with_column("matviewname", SqlScalarType::String.nullable(false))
9929 .with_column("matviewowner", SqlScalarType::Oid.nullable(false))
9930 .with_column("definition", SqlScalarType::String.nullable(false))
9931 .finish(),
9932 column_comments: BTreeMap::new(),
9933 sql: "SELECT
9934 s.name AS schemaname,
9935 m.name AS matviewname,
9936 role_owner.oid AS matviewowner,
9937 m.definition AS definition
9938FROM mz_catalog.mz_materialized_views m
9939LEFT JOIN mz_catalog.mz_schemas s ON s.id = m.schema_id
9940LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
9941JOIN mz_catalog.mz_roles role_owner ON role_owner.id = m.owner_id
9942WHERE s.database_id IS NULL OR d.name = current_database()",
9943 access: vec![PUBLIC_SELECT],
9944});
9945
9946pub static INFORMATION_SCHEMA_APPLICABLE_ROLES: LazyLock<BuiltinView> =
9947 LazyLock::new(|| BuiltinView {
9948 name: "applicable_roles",
9949 schema: INFORMATION_SCHEMA,
9950 oid: oid::VIEW_APPLICABLE_ROLES_OID,
9951 desc: RelationDesc::builder()
9952 .with_column("grantee", SqlScalarType::String.nullable(false))
9953 .with_column("role_name", SqlScalarType::String.nullable(false))
9954 .with_column("is_grantable", SqlScalarType::String.nullable(false))
9955 .finish(),
9956 column_comments: BTreeMap::new(),
9957 sql: "
9958SELECT
9959 member.name AS grantee,
9960 role.name AS role_name,
9961 -- ADMIN OPTION isn't implemented.
9962 'NO' AS is_grantable
9963FROM mz_catalog.mz_role_members membership
9964JOIN mz_catalog.mz_roles role ON membership.role_id = role.id
9965JOIN mz_catalog.mz_roles member ON membership.member = member.id
9966WHERE mz_catalog.mz_is_superuser() OR pg_has_role(current_role, member.oid, 'USAGE')",
9967 access: vec![PUBLIC_SELECT],
9968 });
9969
9970pub static INFORMATION_SCHEMA_COLUMNS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
9971 name: "columns",
9972 schema: INFORMATION_SCHEMA,
9973 oid: oid::VIEW_COLUMNS_OID,
9974 desc: RelationDesc::builder()
9975 .with_column("table_catalog", SqlScalarType::String.nullable(false))
9976 .with_column("table_schema", SqlScalarType::String.nullable(false))
9977 .with_column("table_name", SqlScalarType::String.nullable(false))
9978 .with_column("column_name", SqlScalarType::String.nullable(false))
9979 .with_column("ordinal_position", SqlScalarType::Int64.nullable(false))
9980 .with_column("column_default", SqlScalarType::String.nullable(true))
9981 .with_column("is_nullable", SqlScalarType::String.nullable(false))
9982 .with_column("data_type", SqlScalarType::String.nullable(false))
9983 .with_column(
9984 "character_maximum_length",
9985 SqlScalarType::Int32.nullable(true),
9986 )
9987 .with_column("numeric_precision", SqlScalarType::Int32.nullable(true))
9988 .with_column("numeric_scale", SqlScalarType::Int32.nullable(true))
9989 .finish(),
9990 column_comments: BTreeMap::new(),
9991 sql: "
9992SELECT
9993 current_database() as table_catalog,
9994 s.name AS table_schema,
9995 o.name AS table_name,
9996 c.name AS column_name,
9997 c.position::int8 AS ordinal_position,
9998 c.default AS column_default,
9999 CASE WHEN c.nullable THEN 'YES' ELSE 'NO' END AS is_nullable,
10000 c.type AS data_type,
10001 NULL::pg_catalog.int4 AS character_maximum_length,
10002 NULL::pg_catalog.int4 AS numeric_precision,
10003 NULL::pg_catalog.int4 AS numeric_scale
10004FROM mz_catalog.mz_columns c
10005JOIN mz_catalog.mz_objects o ON o.id = c.id
10006JOIN mz_catalog.mz_schemas s ON s.id = o.schema_id
10007LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10008WHERE s.database_id IS NULL OR d.name = current_database()",
10009 access: vec![PUBLIC_SELECT],
10010});
10011
10012pub static INFORMATION_SCHEMA_ENABLED_ROLES: LazyLock<BuiltinView> =
10013 LazyLock::new(|| BuiltinView {
10014 name: "enabled_roles",
10015 schema: INFORMATION_SCHEMA,
10016 oid: oid::VIEW_ENABLED_ROLES_OID,
10017 desc: RelationDesc::builder()
10018 .with_column("role_name", SqlScalarType::String.nullable(false))
10019 .finish(),
10020 column_comments: BTreeMap::new(),
10021 sql: "
10022SELECT name AS role_name
10023FROM mz_catalog.mz_roles
10024WHERE mz_catalog.mz_is_superuser() OR pg_has_role(current_role, oid, 'USAGE')",
10025 access: vec![PUBLIC_SELECT],
10026 });
10027
10028pub static INFORMATION_SCHEMA_ROLE_TABLE_GRANTS: LazyLock<BuiltinView> = LazyLock::new(|| {
10029 BuiltinView {
10030 name: "role_table_grants",
10031 schema: INFORMATION_SCHEMA,
10032 oid: oid::VIEW_ROLE_TABLE_GRANTS_OID,
10033 desc: RelationDesc::builder()
10034 .with_column("grantor", SqlScalarType::String.nullable(false))
10035 .with_column("grantee", SqlScalarType::String.nullable(true))
10036 .with_column("table_catalog", SqlScalarType::String.nullable(true))
10037 .with_column("table_schema", SqlScalarType::String.nullable(false))
10038 .with_column("table_name", SqlScalarType::String.nullable(false))
10039 .with_column("privilege_type", SqlScalarType::String.nullable(true))
10040 .with_column("is_grantable", SqlScalarType::String.nullable(false))
10041 .with_column("with_hierarchy", SqlScalarType::String.nullable(false))
10042 .finish(),
10043 column_comments: BTreeMap::new(),
10044 sql: "
10045SELECT grantor, grantee, table_catalog, table_schema, table_name, privilege_type, is_grantable, with_hierarchy
10046FROM information_schema.table_privileges
10047WHERE
10048 grantor IN (SELECT role_name FROM information_schema.enabled_roles)
10049 OR grantee IN (SELECT role_name FROM information_schema.enabled_roles)",
10050 access: vec![PUBLIC_SELECT],
10051 }
10052});
10053
10054pub static INFORMATION_SCHEMA_KEY_COLUMN_USAGE: LazyLock<BuiltinView> =
10055 LazyLock::new(|| BuiltinView {
10056 name: "key_column_usage",
10057 schema: INFORMATION_SCHEMA,
10058 oid: oid::VIEW_KEY_COLUMN_USAGE_OID,
10059 desc: RelationDesc::builder()
10060 .with_column("constraint_catalog", SqlScalarType::String.nullable(false))
10061 .with_column("constraint_schema", SqlScalarType::String.nullable(false))
10062 .with_column("constraint_name", SqlScalarType::String.nullable(false))
10063 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10064 .with_column("table_schema", SqlScalarType::String.nullable(false))
10065 .with_column("table_name", SqlScalarType::String.nullable(false))
10066 .with_column("column_name", SqlScalarType::String.nullable(false))
10067 .with_column("ordinal_position", SqlScalarType::Int32.nullable(false))
10068 .with_column(
10069 "position_in_unique_constraint",
10070 SqlScalarType::Int32.nullable(false),
10071 )
10072 .with_key(vec![])
10073 .finish(),
10074 column_comments: BTreeMap::new(),
10075 sql: "SELECT
10076 NULL::text AS constraint_catalog,
10077 NULL::text AS constraint_schema,
10078 NULL::text AS constraint_name,
10079 NULL::text AS table_catalog,
10080 NULL::text AS table_schema,
10081 NULL::text AS table_name,
10082 NULL::text AS column_name,
10083 NULL::integer AS ordinal_position,
10084 NULL::integer AS position_in_unique_constraint
10085WHERE false",
10086 access: vec![PUBLIC_SELECT],
10087 });
10088
10089pub static INFORMATION_SCHEMA_REFERENTIAL_CONSTRAINTS: LazyLock<BuiltinView> =
10090 LazyLock::new(|| BuiltinView {
10091 name: "referential_constraints",
10092 schema: INFORMATION_SCHEMA,
10093 oid: oid::VIEW_REFERENTIAL_CONSTRAINTS_OID,
10094 desc: RelationDesc::builder()
10095 .with_column("constraint_catalog", SqlScalarType::String.nullable(false))
10096 .with_column("constraint_schema", SqlScalarType::String.nullable(false))
10097 .with_column("constraint_name", SqlScalarType::String.nullable(false))
10098 .with_column(
10099 "unique_constraint_catalog",
10100 SqlScalarType::String.nullable(false),
10101 )
10102 .with_column(
10103 "unique_constraint_schema",
10104 SqlScalarType::String.nullable(false),
10105 )
10106 .with_column(
10107 "unique_constraint_name",
10108 SqlScalarType::String.nullable(false),
10109 )
10110 .with_column("match_option", SqlScalarType::String.nullable(false))
10111 .with_column("update_rule", SqlScalarType::String.nullable(false))
10112 .with_column("delete_rule", SqlScalarType::String.nullable(false))
10113 .with_key(vec![])
10114 .finish(),
10115 column_comments: BTreeMap::new(),
10116 sql: "SELECT
10117 NULL::text AS constraint_catalog,
10118 NULL::text AS constraint_schema,
10119 NULL::text AS constraint_name,
10120 NULL::text AS unique_constraint_catalog,
10121 NULL::text AS unique_constraint_schema,
10122 NULL::text AS unique_constraint_name,
10123 NULL::text AS match_option,
10124 NULL::text AS update_rule,
10125 NULL::text AS delete_rule
10126WHERE false",
10127 access: vec![PUBLIC_SELECT],
10128 });
10129
10130pub static INFORMATION_SCHEMA_ROUTINES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10131 name: "routines",
10132 schema: INFORMATION_SCHEMA,
10133 oid: oid::VIEW_ROUTINES_OID,
10134 desc: RelationDesc::builder()
10135 .with_column("routine_catalog", SqlScalarType::String.nullable(false))
10136 .with_column("routine_schema", SqlScalarType::String.nullable(false))
10137 .with_column("routine_name", SqlScalarType::String.nullable(false))
10138 .with_column("routine_type", SqlScalarType::String.nullable(false))
10139 .with_column("routine_definition", SqlScalarType::String.nullable(true))
10140 .finish(),
10141 column_comments: BTreeMap::new(),
10142 sql: "SELECT
10143 current_database() as routine_catalog,
10144 s.name AS routine_schema,
10145 f.name AS routine_name,
10146 'FUNCTION' AS routine_type,
10147 NULL::text AS routine_definition
10148FROM mz_catalog.mz_functions f
10149JOIN mz_catalog.mz_schemas s ON s.id = f.schema_id
10150LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10151WHERE s.database_id IS NULL OR d.name = current_database()",
10152 access: vec![PUBLIC_SELECT],
10153});
10154
10155pub static INFORMATION_SCHEMA_SCHEMATA: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10156 name: "schemata",
10157 schema: INFORMATION_SCHEMA,
10158 oid: oid::VIEW_SCHEMATA_OID,
10159 desc: RelationDesc::builder()
10160 .with_column("catalog_name", SqlScalarType::String.nullable(false))
10161 .with_column("schema_name", SqlScalarType::String.nullable(false))
10162 .finish(),
10163 column_comments: BTreeMap::new(),
10164 sql: "
10165SELECT
10166 current_database() as catalog_name,
10167 s.name AS schema_name
10168FROM mz_catalog.mz_schemas s
10169LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10170WHERE s.database_id IS NULL OR d.name = current_database()",
10171 access: vec![PUBLIC_SELECT],
10172});
10173
10174pub static INFORMATION_SCHEMA_TABLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10175 name: "tables",
10176 schema: INFORMATION_SCHEMA,
10177 oid: oid::VIEW_TABLES_OID,
10178 desc: RelationDesc::builder()
10179 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10180 .with_column("table_schema", SqlScalarType::String.nullable(false))
10181 .with_column("table_name", SqlScalarType::String.nullable(false))
10182 .with_column("table_type", SqlScalarType::String.nullable(false))
10183 .finish(),
10184 column_comments: BTreeMap::new(),
10185 sql: "SELECT
10186 current_database() as table_catalog,
10187 s.name AS table_schema,
10188 r.name AS table_name,
10189 CASE r.type
10190 WHEN 'materialized-view' THEN 'MATERIALIZED VIEW'
10191 WHEN 'table' THEN 'BASE TABLE'
10192 ELSE pg_catalog.upper(r.type)
10193 END AS table_type
10194FROM mz_catalog.mz_relations r
10195JOIN mz_catalog.mz_schemas s ON s.id = r.schema_id
10196LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10197WHERE s.database_id IS NULL OR d.name = current_database()",
10198 access: vec![PUBLIC_SELECT],
10199});
10200
10201pub static INFORMATION_SCHEMA_TABLE_CONSTRAINTS: LazyLock<BuiltinView> =
10202 LazyLock::new(|| BuiltinView {
10203 name: "table_constraints",
10204 schema: INFORMATION_SCHEMA,
10205 oid: oid::VIEW_TABLE_CONSTRAINTS_OID,
10206 desc: RelationDesc::builder()
10207 .with_column("constraint_catalog", SqlScalarType::String.nullable(false))
10208 .with_column("constraint_schema", SqlScalarType::String.nullable(false))
10209 .with_column("constraint_name", SqlScalarType::String.nullable(false))
10210 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10211 .with_column("table_schema", SqlScalarType::String.nullable(false))
10212 .with_column("table_name", SqlScalarType::String.nullable(false))
10213 .with_column("constraint_type", SqlScalarType::String.nullable(false))
10214 .with_column("is_deferrable", SqlScalarType::String.nullable(false))
10215 .with_column("initially_deferred", SqlScalarType::String.nullable(false))
10216 .with_column("enforced", SqlScalarType::String.nullable(false))
10217 .with_column("nulls_distinct", SqlScalarType::String.nullable(false))
10218 .with_key(vec![])
10219 .finish(),
10220 column_comments: BTreeMap::new(),
10221 sql: "SELECT
10222 NULL::text AS constraint_catalog,
10223 NULL::text AS constraint_schema,
10224 NULL::text AS constraint_name,
10225 NULL::text AS table_catalog,
10226 NULL::text AS table_schema,
10227 NULL::text AS table_name,
10228 NULL::text AS constraint_type,
10229 NULL::text AS is_deferrable,
10230 NULL::text AS initially_deferred,
10231 NULL::text AS enforced,
10232 NULL::text AS nulls_distinct
10233WHERE false",
10234 access: vec![PUBLIC_SELECT],
10235 });
10236
10237pub static INFORMATION_SCHEMA_TABLE_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| {
10238 BuiltinView {
10239 name: "table_privileges",
10240 schema: INFORMATION_SCHEMA,
10241 oid: oid::VIEW_TABLE_PRIVILEGES_OID,
10242 desc: RelationDesc::builder()
10243 .with_column("grantor", SqlScalarType::String.nullable(false))
10244 .with_column("grantee", SqlScalarType::String.nullable(true))
10245 .with_column("table_catalog", SqlScalarType::String.nullable(true))
10246 .with_column("table_schema", SqlScalarType::String.nullable(false))
10247 .with_column("table_name", SqlScalarType::String.nullable(false))
10248 .with_column("privilege_type", SqlScalarType::String.nullable(true))
10249 .with_column("is_grantable", SqlScalarType::String.nullable(false))
10250 .with_column("with_hierarchy", SqlScalarType::String.nullable(false))
10251 .finish(),
10252 column_comments: BTreeMap::new(),
10253 sql: "
10254SELECT
10255 grantor,
10256 grantee,
10257 table_catalog,
10258 table_schema,
10259 table_name,
10260 privilege_type,
10261 is_grantable,
10262 CASE privilege_type
10263 WHEN 'SELECT' THEN 'YES'
10264 ELSE 'NO'
10265 END AS with_hierarchy
10266FROM
10267 (SELECT
10268 grantor.name AS grantor,
10269 CASE mz_internal.mz_aclitem_grantee(privileges)
10270 WHEN 'p' THEN 'PUBLIC'
10271 ELSE grantee.name
10272 END AS grantee,
10273 table_catalog,
10274 table_schema,
10275 table_name,
10276 unnest(mz_internal.mz_format_privileges(mz_internal.mz_aclitem_privileges(privileges))) AS privilege_type,
10277 -- ADMIN OPTION isn't implemented.
10278 'NO' AS is_grantable
10279 FROM
10280 (SELECT
10281 unnest(relations.privileges) AS privileges,
10282 CASE
10283 WHEN schemas.database_id IS NULL THEN current_database()
10284 ELSE databases.name
10285 END AS table_catalog,
10286 schemas.name AS table_schema,
10287 relations.name AS table_name
10288 FROM mz_catalog.mz_relations AS relations
10289 JOIN mz_catalog.mz_schemas AS schemas ON relations.schema_id = schemas.id
10290 LEFT JOIN mz_catalog.mz_databases AS databases ON schemas.database_id = databases.id
10291 WHERE schemas.database_id IS NULL OR databases.name = current_database())
10292 JOIN mz_catalog.mz_roles AS grantor ON mz_internal.mz_aclitem_grantor(privileges) = grantor.id
10293 LEFT JOIN mz_catalog.mz_roles AS grantee ON mz_internal.mz_aclitem_grantee(privileges) = grantee.id)
10294WHERE
10295 -- WHERE clause is not guaranteed to short-circuit and 'PUBLIC' will cause an error when passed
10296 -- to pg_has_role. Therefore we need to use a CASE statement.
10297 CASE
10298 WHEN grantee = 'PUBLIC' THEN true
10299 ELSE mz_catalog.mz_is_superuser()
10300 OR pg_has_role(current_role, grantee, 'USAGE')
10301 OR pg_has_role(current_role, grantor, 'USAGE')
10302 END",
10303 access: vec![PUBLIC_SELECT],
10304 }
10305});
10306
10307pub static INFORMATION_SCHEMA_TRIGGERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10308 name: "triggers",
10309 schema: INFORMATION_SCHEMA,
10310 oid: oid::VIEW_TRIGGERS_OID,
10311 desc: RelationDesc::builder()
10312 .with_column("trigger_catalog", SqlScalarType::String.nullable(false))
10313 .with_column("trigger_schema", SqlScalarType::String.nullable(false))
10314 .with_column("trigger_name", SqlScalarType::String.nullable(false))
10315 .with_column("event_manipulation", SqlScalarType::String.nullable(false))
10316 .with_column(
10317 "event_object_catalog",
10318 SqlScalarType::String.nullable(false),
10319 )
10320 .with_column("event_object_schema", SqlScalarType::String.nullable(false))
10321 .with_column("event_object_table", SqlScalarType::String.nullable(false))
10322 .with_column("action_order", SqlScalarType::Int32.nullable(false))
10323 .with_column("action_condition", SqlScalarType::String.nullable(false))
10324 .with_column("action_statement", SqlScalarType::String.nullable(false))
10325 .with_column("action_orientation", SqlScalarType::String.nullable(false))
10326 .with_column("action_timing", SqlScalarType::String.nullable(false))
10327 .with_column(
10328 "action_reference_old_table",
10329 SqlScalarType::String.nullable(false),
10330 )
10331 .with_column(
10332 "action_reference_new_table",
10333 SqlScalarType::String.nullable(false),
10334 )
10335 .with_key(vec![])
10336 .finish(),
10337 column_comments: BTreeMap::new(),
10338 sql: "SELECT
10339 NULL::text as trigger_catalog,
10340 NULL::text AS trigger_schema,
10341 NULL::text AS trigger_name,
10342 NULL::text AS event_manipulation,
10343 NULL::text AS event_object_catalog,
10344 NULL::text AS event_object_schema,
10345 NULL::text AS event_object_table,
10346 NULL::integer AS action_order,
10347 NULL::text AS action_condition,
10348 NULL::text AS action_statement,
10349 NULL::text AS action_orientation,
10350 NULL::text AS action_timing,
10351 NULL::text AS action_reference_old_table,
10352 NULL::text AS action_reference_new_table
10353WHERE FALSE",
10354 access: vec![PUBLIC_SELECT],
10355});
10356
10357pub static INFORMATION_SCHEMA_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10358 name: "views",
10359 schema: INFORMATION_SCHEMA,
10360 oid: oid::VIEW_VIEWS_OID,
10361 desc: RelationDesc::builder()
10362 .with_column("table_catalog", SqlScalarType::String.nullable(false))
10363 .with_column("table_schema", SqlScalarType::String.nullable(false))
10364 .with_column("table_name", SqlScalarType::String.nullable(false))
10365 .with_column("view_definition", SqlScalarType::String.nullable(false))
10366 .finish(),
10367 column_comments: BTreeMap::new(),
10368 sql: "SELECT
10369 current_database() as table_catalog,
10370 s.name AS table_schema,
10371 v.name AS table_name,
10372 v.definition AS view_definition
10373FROM mz_catalog.mz_views v
10374JOIN mz_catalog.mz_schemas s ON s.id = v.schema_id
10375LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
10376WHERE s.database_id IS NULL OR d.name = current_database()",
10377 access: vec![PUBLIC_SELECT],
10378});
10379
10380pub static INFORMATION_SCHEMA_CHARACTER_SETS: LazyLock<BuiltinView> =
10381 LazyLock::new(|| BuiltinView {
10382 name: "character_sets",
10383 schema: INFORMATION_SCHEMA,
10384 oid: oid::VIEW_CHARACTER_SETS_OID,
10385 desc: RelationDesc::builder()
10386 .with_column(
10387 "character_set_catalog",
10388 SqlScalarType::String.nullable(true),
10389 )
10390 .with_column("character_set_schema", SqlScalarType::String.nullable(true))
10391 .with_column("character_set_name", SqlScalarType::String.nullable(false))
10392 .with_column(
10393 "character_repertoire",
10394 SqlScalarType::String.nullable(false),
10395 )
10396 .with_column("form_of_use", SqlScalarType::String.nullable(false))
10397 .with_column(
10398 "default_collate_catalog",
10399 SqlScalarType::String.nullable(false),
10400 )
10401 .with_column(
10402 "default_collate_schema",
10403 SqlScalarType::String.nullable(false),
10404 )
10405 .with_column(
10406 "default_collate_name",
10407 SqlScalarType::String.nullable(false),
10408 )
10409 .with_key(vec![])
10410 .finish(),
10411 column_comments: BTreeMap::new(),
10412 sql: "SELECT
10413 NULL as character_set_catalog,
10414 NULL as character_set_schema,
10415 'UTF8' as character_set_name,
10416 'UCS' as character_repertoire,
10417 'UTF8' as form_of_use,
10418 current_database() as default_collate_catalog,
10419 'pg_catalog' as default_collate_schema,
10420 'en_US.utf8' as default_collate_name",
10421 access: vec![PUBLIC_SELECT],
10422 });
10423
10424pub static PG_COLLATION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10427 name: "pg_collation",
10428 schema: PG_CATALOG_SCHEMA,
10429 oid: oid::VIEW_PG_COLLATION_OID,
10430 desc: RelationDesc::builder()
10431 .with_column("oid", SqlScalarType::Oid.nullable(false))
10432 .with_column("collname", SqlScalarType::String.nullable(false))
10433 .with_column("collnamespace", SqlScalarType::Oid.nullable(false))
10434 .with_column("collowner", SqlScalarType::Oid.nullable(false))
10435 .with_column("collprovider", SqlScalarType::PgLegacyChar.nullable(false))
10436 .with_column("collisdeterministic", SqlScalarType::Bool.nullable(false))
10437 .with_column("collencoding", SqlScalarType::Int32.nullable(false))
10438 .with_column("collcollate", SqlScalarType::String.nullable(false))
10439 .with_column("collctype", SqlScalarType::String.nullable(false))
10440 .with_column("collversion", SqlScalarType::String.nullable(false))
10441 .with_key(vec![])
10442 .finish(),
10443 column_comments: BTreeMap::new(),
10444 sql: "
10445SELECT
10446 NULL::pg_catalog.oid AS oid,
10447 NULL::pg_catalog.text AS collname,
10448 NULL::pg_catalog.oid AS collnamespace,
10449 NULL::pg_catalog.oid AS collowner,
10450 NULL::pg_catalog.\"char\" AS collprovider,
10451 NULL::pg_catalog.bool AS collisdeterministic,
10452 NULL::pg_catalog.int4 AS collencoding,
10453 NULL::pg_catalog.text AS collcollate,
10454 NULL::pg_catalog.text AS collctype,
10455 NULL::pg_catalog.text AS collversion
10456WHERE false",
10457 access: vec![PUBLIC_SELECT],
10458});
10459
10460pub static PG_POLICY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10462 name: "pg_policy",
10463 schema: PG_CATALOG_SCHEMA,
10464 oid: oid::VIEW_PG_POLICY_OID,
10465 desc: RelationDesc::builder()
10466 .with_column("oid", SqlScalarType::Oid.nullable(false))
10467 .with_column("polname", SqlScalarType::String.nullable(false))
10468 .with_column("polrelid", SqlScalarType::Oid.nullable(false))
10469 .with_column("polcmd", SqlScalarType::PgLegacyChar.nullable(false))
10470 .with_column("polpermissive", SqlScalarType::Bool.nullable(false))
10471 .with_column(
10472 "polroles",
10473 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
10474 )
10475 .with_column("polqual", SqlScalarType::String.nullable(false))
10476 .with_column("polwithcheck", SqlScalarType::String.nullable(false))
10477 .with_key(vec![])
10478 .finish(),
10479 column_comments: BTreeMap::new(),
10480 sql: "
10481SELECT
10482 NULL::pg_catalog.oid AS oid,
10483 NULL::pg_catalog.text AS polname,
10484 NULL::pg_catalog.oid AS polrelid,
10485 NULL::pg_catalog.\"char\" AS polcmd,
10486 NULL::pg_catalog.bool AS polpermissive,
10487 NULL::pg_catalog.oid[] AS polroles,
10488 NULL::pg_catalog.text AS polqual,
10489 NULL::pg_catalog.text AS polwithcheck
10490WHERE false",
10491 access: vec![PUBLIC_SELECT],
10492});
10493
10494pub static PG_INHERITS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10496 name: "pg_inherits",
10497 schema: PG_CATALOG_SCHEMA,
10498 oid: oid::VIEW_PG_INHERITS_OID,
10499 desc: RelationDesc::builder()
10500 .with_column("inhrelid", SqlScalarType::Oid.nullable(false))
10501 .with_column("inhparent", SqlScalarType::Oid.nullable(false))
10502 .with_column("inhseqno", SqlScalarType::Int32.nullable(false))
10503 .with_column("inhdetachpending", SqlScalarType::Bool.nullable(false))
10504 .with_key(vec![])
10505 .finish(),
10506 column_comments: BTreeMap::new(),
10507 sql: "
10508SELECT
10509 NULL::pg_catalog.oid AS inhrelid,
10510 NULL::pg_catalog.oid AS inhparent,
10511 NULL::pg_catalog.int4 AS inhseqno,
10512 NULL::pg_catalog.bool AS inhdetachpending
10513WHERE false",
10514 access: vec![PUBLIC_SELECT],
10515});
10516
10517pub static PG_LOCKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10518 name: "pg_locks",
10519 schema: PG_CATALOG_SCHEMA,
10520 oid: oid::VIEW_PG_LOCKS_OID,
10521 desc: RelationDesc::builder()
10522 .with_column("locktype", SqlScalarType::String.nullable(false))
10523 .with_column("database", SqlScalarType::Oid.nullable(false))
10524 .with_column("relation", SqlScalarType::Oid.nullable(false))
10525 .with_column("page", SqlScalarType::Int32.nullable(false))
10526 .with_column("tuple", SqlScalarType::Int16.nullable(false))
10527 .with_column("virtualxid", SqlScalarType::String.nullable(false))
10528 .with_column("transactionid", SqlScalarType::String.nullable(false))
10529 .with_column("classid", SqlScalarType::Oid.nullable(false))
10530 .with_column("objid", SqlScalarType::Oid.nullable(false))
10531 .with_column("objsubid", SqlScalarType::Int16.nullable(false))
10532 .with_column("virtualtransaction", SqlScalarType::String.nullable(false))
10533 .with_column("pid", SqlScalarType::Int32.nullable(false))
10534 .with_column("mode", SqlScalarType::String.nullable(false))
10535 .with_column("granted", SqlScalarType::Bool.nullable(false))
10536 .with_column("fastpath", SqlScalarType::Bool.nullable(false))
10537 .with_column(
10538 "waitstart",
10539 SqlScalarType::TimestampTz { precision: None }.nullable(false),
10540 )
10541 .with_key(vec![])
10542 .finish(),
10543 column_comments: BTreeMap::new(),
10544 sql: "
10545SELECT
10546-- While there exist locks in Materialize, we don't expose them, so all of these fields are NULL.
10547 NULL::pg_catalog.text AS locktype,
10548 NULL::pg_catalog.oid AS database,
10549 NULL::pg_catalog.oid AS relation,
10550 NULL::pg_catalog.int4 AS page,
10551 NULL::pg_catalog.int2 AS tuple,
10552 NULL::pg_catalog.text AS virtualxid,
10553 NULL::pg_catalog.text AS transactionid,
10554 NULL::pg_catalog.oid AS classid,
10555 NULL::pg_catalog.oid AS objid,
10556 NULL::pg_catalog.int2 AS objsubid,
10557 NULL::pg_catalog.text AS virtualtransaction,
10558 NULL::pg_catalog.int4 AS pid,
10559 NULL::pg_catalog.text AS mode,
10560 NULL::pg_catalog.bool AS granted,
10561 NULL::pg_catalog.bool AS fastpath,
10562 NULL::pg_catalog.timestamptz AS waitstart
10563WHERE false",
10564 access: vec![PUBLIC_SELECT],
10565});
10566
10567pub static PG_AUTHID_CORE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10570 name: "pg_authid_core",
10571 schema: MZ_INTERNAL_SCHEMA,
10572 oid: oid::VIEW_PG_AUTHID_CORE_OID,
10573 desc: RelationDesc::builder()
10574 .with_column("oid", SqlScalarType::Oid.nullable(false))
10575 .with_column("rolname", SqlScalarType::String.nullable(false))
10576 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
10577 .with_column("rolinherit", SqlScalarType::Bool.nullable(false))
10578 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(false))
10579 .with_column("rolreplication", SqlScalarType::Bool.nullable(false))
10580 .with_column("rolbypassrls", SqlScalarType::Bool.nullable(false))
10581 .with_column("rolconnlimit", SqlScalarType::Int32.nullable(false))
10582 .with_column("rolpassword", SqlScalarType::String.nullable(true))
10583 .with_column(
10584 "rolvaliduntil",
10585 SqlScalarType::TimestampTz { precision: None }.nullable(true),
10586 )
10587 .finish(),
10588 column_comments: BTreeMap::new(),
10589 sql: r#"
10590SELECT
10591 r.oid AS oid,
10592 r.name AS rolname,
10593 rolsuper,
10594 inherit AS rolinherit,
10595 COALESCE(r.rolcanlogin, false) AS rolcanlogin,
10596 -- MZ doesn't support replication in the same way Postgres does
10597 false AS rolreplication,
10598 -- MZ doesn't how row level security
10599 false AS rolbypassrls,
10600 -- MZ doesn't have a connection limit
10601 -1 AS rolconnlimit,
10602 a.password_hash AS rolpassword,
10603 NULL::pg_catalog.timestamptz AS rolvaliduntil
10604FROM mz_catalog.mz_roles r
10605LEFT JOIN mz_catalog.mz_role_auth a ON r.oid = a.role_oid"#,
10606 access: vec![rbac::owner_privilege(ObjectType::Table, MZ_SYSTEM_ROLE_ID)],
10607});
10608
10609pub const PG_AUTHID_CORE_IND: BuiltinIndex = BuiltinIndex {
10610 name: "pg_authid_core_ind",
10611 schema: MZ_INTERNAL_SCHEMA,
10612 oid: oid::INDEX_PG_AUTHID_CORE_IND_OID,
10613 sql: "IN CLUSTER mz_catalog_server
10614ON mz_internal.pg_authid_core (rolname)",
10615 is_retained_metrics_object: false,
10616};
10617
10618pub static PG_AUTHID: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10619 name: "pg_authid",
10620 schema: PG_CATALOG_SCHEMA,
10621 oid: oid::VIEW_PG_AUTHID_OID,
10622 desc: RelationDesc::builder()
10623 .with_column("oid", SqlScalarType::Oid.nullable(false))
10624 .with_column("rolname", SqlScalarType::String.nullable(false))
10625 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
10626 .with_column("rolinherit", SqlScalarType::Bool.nullable(false))
10627 .with_column("rolcreaterole", SqlScalarType::Bool.nullable(true))
10628 .with_column("rolcreatedb", SqlScalarType::Bool.nullable(true))
10629 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(false))
10630 .with_column("rolreplication", SqlScalarType::Bool.nullable(false))
10631 .with_column("rolbypassrls", SqlScalarType::Bool.nullable(false))
10632 .with_column("rolconnlimit", SqlScalarType::Int32.nullable(false))
10633 .with_column("rolpassword", SqlScalarType::String.nullable(true))
10634 .with_column(
10635 "rolvaliduntil",
10636 SqlScalarType::TimestampTz { precision: None }.nullable(true),
10637 )
10638 .finish(),
10639 column_comments: BTreeMap::new(),
10640 sql: r#"
10656WITH extra AS (
10657 SELECT
10658 DISTINCT ON (oid)
10659 oid,
10660 mz_catalog.has_system_privilege(oid, 'CREATEROLE') AS rolcreaterole,
10661 mz_catalog.has_system_privilege(oid, 'CREATEDB') AS rolcreatedb
10662 FROM mz_internal.pg_authid_core
10663)
10664SELECT
10665 oid,
10666 rolname,
10667 rolsuper,
10668 rolinherit,
10669 extra.rolcreaterole,
10670 extra.rolcreatedb,
10671 rolcanlogin,
10672 rolreplication,
10673 rolbypassrls,
10674 rolconnlimit,
10675 rolpassword,
10676 rolvaliduntil
10677FROM mz_internal.pg_authid_core
10678LEFT JOIN extra USING (oid)"#,
10679 access: vec![rbac::owner_privilege(ObjectType::Table, MZ_SYSTEM_ROLE_ID)],
10680});
10681
10682pub static PG_AGGREGATE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10683 name: "pg_aggregate",
10684 schema: PG_CATALOG_SCHEMA,
10685 oid: oid::VIEW_PG_AGGREGATE_OID,
10686 desc: RelationDesc::builder()
10687 .with_column("aggfnoid", SqlScalarType::Oid.nullable(false))
10688 .with_column("aggkind", SqlScalarType::String.nullable(false))
10689 .with_column("aggnumdirectargs", SqlScalarType::Int16.nullable(false))
10690 .with_column("aggtransfn", SqlScalarType::RegProc.nullable(true))
10691 .with_column("aggfinalfn", SqlScalarType::RegProc.nullable(false))
10692 .with_column("aggcombinefn", SqlScalarType::RegProc.nullable(false))
10693 .with_column("aggserialfn", SqlScalarType::RegProc.nullable(false))
10694 .with_column("aggdeserialfn", SqlScalarType::RegProc.nullable(false))
10695 .with_column("aggmtransfn", SqlScalarType::RegProc.nullable(false))
10696 .with_column("aggminvtransfn", SqlScalarType::RegProc.nullable(false))
10697 .with_column("aggmfinalfn", SqlScalarType::RegProc.nullable(false))
10698 .with_column("aggfinalextra", SqlScalarType::Bool.nullable(false))
10699 .with_column("aggmfinalextra", SqlScalarType::Bool.nullable(false))
10700 .with_column("aggfinalmodify", SqlScalarType::PgLegacyChar.nullable(true))
10701 .with_column(
10702 "aggmfinalmodify",
10703 SqlScalarType::PgLegacyChar.nullable(true),
10704 )
10705 .with_column("aggsortop", SqlScalarType::Oid.nullable(false))
10706 .with_column("aggtranstype", SqlScalarType::Oid.nullable(true))
10707 .with_column("aggtransspace", SqlScalarType::Int32.nullable(true))
10708 .with_column("aggmtranstype", SqlScalarType::Oid.nullable(false))
10709 .with_column("aggmtransspace", SqlScalarType::Int32.nullable(true))
10710 .with_column("agginitval", SqlScalarType::String.nullable(true))
10711 .with_column("aggminitval", SqlScalarType::String.nullable(true))
10712 .finish(),
10713 column_comments: BTreeMap::new(),
10714 sql: "SELECT
10715 a.oid as aggfnoid,
10716 -- Currently Materialize only support 'normal' aggregate functions.
10717 a.agg_kind as aggkind,
10718 a.agg_num_direct_args as aggnumdirectargs,
10719 -- Materialize doesn't support these fields.
10720 NULL::pg_catalog.regproc as aggtransfn,
10721 '0'::pg_catalog.regproc as aggfinalfn,
10722 '0'::pg_catalog.regproc as aggcombinefn,
10723 '0'::pg_catalog.regproc as aggserialfn,
10724 '0'::pg_catalog.regproc as aggdeserialfn,
10725 '0'::pg_catalog.regproc as aggmtransfn,
10726 '0'::pg_catalog.regproc as aggminvtransfn,
10727 '0'::pg_catalog.regproc as aggmfinalfn,
10728 false as aggfinalextra,
10729 false as aggmfinalextra,
10730 NULL::pg_catalog.\"char\" AS aggfinalmodify,
10731 NULL::pg_catalog.\"char\" AS aggmfinalmodify,
10732 '0'::pg_catalog.oid as aggsortop,
10733 NULL::pg_catalog.oid as aggtranstype,
10734 NULL::pg_catalog.int4 as aggtransspace,
10735 '0'::pg_catalog.oid as aggmtranstype,
10736 NULL::pg_catalog.int4 as aggmtransspace,
10737 NULL::pg_catalog.text as agginitval,
10738 NULL::pg_catalog.text as aggminitval
10739FROM mz_internal.mz_aggregates a",
10740 access: vec![PUBLIC_SELECT],
10741});
10742
10743pub static PG_TRIGGER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10744 name: "pg_trigger",
10745 schema: PG_CATALOG_SCHEMA,
10746 oid: oid::VIEW_PG_TRIGGER_OID,
10747 desc: RelationDesc::builder()
10748 .with_column("oid", SqlScalarType::Oid.nullable(false))
10749 .with_column("tgrelid", SqlScalarType::Oid.nullable(false))
10750 .with_column("tgparentid", SqlScalarType::Oid.nullable(false))
10751 .with_column("tgname", SqlScalarType::String.nullable(false))
10752 .with_column("tgfoid", SqlScalarType::Oid.nullable(false))
10753 .with_column("tgtype", SqlScalarType::Int16.nullable(false))
10754 .with_column("tgenabled", SqlScalarType::PgLegacyChar.nullable(false))
10755 .with_column("tgisinternal", SqlScalarType::Bool.nullable(false))
10756 .with_column("tgconstrrelid", SqlScalarType::Oid.nullable(false))
10757 .with_column("tgconstrindid", SqlScalarType::Oid.nullable(false))
10758 .with_column("tgconstraint", SqlScalarType::Oid.nullable(false))
10759 .with_column("tgdeferrable", SqlScalarType::Bool.nullable(false))
10760 .with_column("tginitdeferred", SqlScalarType::Bool.nullable(false))
10761 .with_column("tgnargs", SqlScalarType::Int16.nullable(false))
10762 .with_column("tgattr", SqlScalarType::Int2Vector.nullable(false))
10763 .with_column("tgargs", SqlScalarType::Bytes.nullable(false))
10764 .with_column("tgqual", SqlScalarType::String.nullable(false))
10765 .with_column("tgoldtable", SqlScalarType::String.nullable(false))
10766 .with_column("tgnewtable", SqlScalarType::String.nullable(false))
10767 .with_key(vec![])
10768 .finish(),
10769 column_comments: BTreeMap::new(),
10770 sql: "SELECT
10771 -- MZ doesn't support triggers so all of these fields are NULL.
10772 NULL::pg_catalog.oid AS oid,
10773 NULL::pg_catalog.oid AS tgrelid,
10774 NULL::pg_catalog.oid AS tgparentid,
10775 NULL::pg_catalog.text AS tgname,
10776 NULL::pg_catalog.oid AS tgfoid,
10777 NULL::pg_catalog.int2 AS tgtype,
10778 NULL::pg_catalog.\"char\" AS tgenabled,
10779 NULL::pg_catalog.bool AS tgisinternal,
10780 NULL::pg_catalog.oid AS tgconstrrelid,
10781 NULL::pg_catalog.oid AS tgconstrindid,
10782 NULL::pg_catalog.oid AS tgconstraint,
10783 NULL::pg_catalog.bool AS tgdeferrable,
10784 NULL::pg_catalog.bool AS tginitdeferred,
10785 NULL::pg_catalog.int2 AS tgnargs,
10786 NULL::pg_catalog.int2vector AS tgattr,
10787 NULL::pg_catalog.bytea AS tgargs,
10788 -- NOTE: The tgqual column is actually type `pg_node_tree` which we don't support. CockroachDB
10789 -- uses text as a placeholder, so we'll follow their lead here.
10790 NULL::pg_catalog.text AS tgqual,
10791 NULL::pg_catalog.text AS tgoldtable,
10792 NULL::pg_catalog.text AS tgnewtable
10793WHERE false
10794 ",
10795 access: vec![PUBLIC_SELECT],
10796});
10797
10798pub static PG_REWRITE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10799 name: "pg_rewrite",
10800 schema: PG_CATALOG_SCHEMA,
10801 oid: oid::VIEW_PG_REWRITE_OID,
10802 desc: RelationDesc::builder()
10803 .with_column("oid", SqlScalarType::Oid.nullable(false))
10804 .with_column("rulename", SqlScalarType::String.nullable(false))
10805 .with_column("ev_class", SqlScalarType::Oid.nullable(false))
10806 .with_column("ev_type", SqlScalarType::PgLegacyChar.nullable(false))
10807 .with_column("ev_enabled", SqlScalarType::PgLegacyChar.nullable(false))
10808 .with_column("is_instead", SqlScalarType::Bool.nullable(false))
10809 .with_column("ev_qual", SqlScalarType::String.nullable(false))
10810 .with_column("ev_action", SqlScalarType::String.nullable(false))
10811 .with_key(vec![])
10812 .finish(),
10813 column_comments: BTreeMap::new(),
10814 sql: "SELECT
10815 -- MZ doesn't support rewrite rules so all of these fields are NULL.
10816 NULL::pg_catalog.oid AS oid,
10817 NULL::pg_catalog.text AS rulename,
10818 NULL::pg_catalog.oid AS ev_class,
10819 NULL::pg_catalog.\"char\" AS ev_type,
10820 NULL::pg_catalog.\"char\" AS ev_enabled,
10821 NULL::pg_catalog.bool AS is_instead,
10822 -- NOTE: The ev_qual and ev_action columns are actually type `pg_node_tree` which we don't
10823 -- support. CockroachDB uses text as a placeholder, so we'll follow their lead here.
10824 NULL::pg_catalog.text AS ev_qual,
10825 NULL::pg_catalog.text AS ev_action
10826WHERE false
10827 ",
10828 access: vec![PUBLIC_SELECT],
10829});
10830
10831pub static PG_EXTENSION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10832 name: "pg_extension",
10833 schema: PG_CATALOG_SCHEMA,
10834 oid: oid::VIEW_PG_EXTENSION_OID,
10835 desc: RelationDesc::builder()
10836 .with_column("oid", SqlScalarType::Oid.nullable(false))
10837 .with_column("extname", SqlScalarType::String.nullable(false))
10838 .with_column("extowner", SqlScalarType::Oid.nullable(false))
10839 .with_column("extnamespace", SqlScalarType::Oid.nullable(false))
10840 .with_column("extrelocatable", SqlScalarType::Bool.nullable(false))
10841 .with_column("extversion", SqlScalarType::String.nullable(false))
10842 .with_column(
10843 "extconfig",
10844 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
10845 )
10846 .with_column(
10847 "extcondition",
10848 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
10849 )
10850 .with_key(vec![])
10851 .finish(),
10852 column_comments: BTreeMap::new(),
10853 sql: "SELECT
10854 -- MZ doesn't support extensions so all of these fields are NULL.
10855 NULL::pg_catalog.oid AS oid,
10856 NULL::pg_catalog.text AS extname,
10857 NULL::pg_catalog.oid AS extowner,
10858 NULL::pg_catalog.oid AS extnamespace,
10859 NULL::pg_catalog.bool AS extrelocatable,
10860 NULL::pg_catalog.text AS extversion,
10861 NULL::pg_catalog.oid[] AS extconfig,
10862 NULL::pg_catalog.text[] AS extcondition
10863WHERE false
10864 ",
10865 access: vec![PUBLIC_SELECT],
10866});
10867
10868pub static MZ_SHOW_ALL_OBJECTS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10869 name: "mz_show_all_objects",
10870 schema: MZ_INTERNAL_SCHEMA,
10871 oid: oid::VIEW_MZ_SHOW_ALL_OBJECTS_OID,
10872 desc: RelationDesc::builder()
10873 .with_column("schema_id", SqlScalarType::String.nullable(false))
10874 .with_column("name", SqlScalarType::String.nullable(false))
10875 .with_column("type", SqlScalarType::String.nullable(false))
10876 .with_column("comment", SqlScalarType::String.nullable(false))
10877 .finish(),
10878 column_comments: BTreeMap::new(),
10879 sql: "WITH comments AS (
10880 SELECT id, object_type, comment
10881 FROM mz_internal.mz_comments
10882 WHERE object_sub_id IS NULL
10883 )
10884 SELECT schema_id, name, type, COALESCE(comment, '') AS comment
10885 FROM mz_catalog.mz_objects AS objs
10886 LEFT JOIN comments ON objs.id = comments.id
10887 WHERE (comments.object_type = objs.type OR comments.object_type IS NULL)",
10888 access: vec![PUBLIC_SELECT],
10889});
10890
10891pub static MZ_SHOW_CLUSTERS: LazyLock<BuiltinView> = LazyLock::new(|| {
10892 BuiltinView {
10893 name: "mz_show_clusters",
10894 schema: MZ_INTERNAL_SCHEMA,
10895 oid: oid::VIEW_MZ_SHOW_CLUSTERS_OID,
10896 desc: RelationDesc::builder()
10897 .with_column("name", SqlScalarType::String.nullable(false))
10898 .with_column("replicas", SqlScalarType::String.nullable(true))
10899 .with_column("comment", SqlScalarType::String.nullable(false))
10900 .finish(),
10901 column_comments: BTreeMap::new(),
10902 sql: "
10903 WITH clusters AS (
10904 SELECT
10905 mc.id,
10906 mc.name,
10907 pg_catalog.string_agg(mcr.name || ' (' || mcr.size || ')', ', ' ORDER BY mcr.name) AS replicas
10908 FROM mz_catalog.mz_clusters mc
10909 LEFT JOIN mz_catalog.mz_cluster_replicas mcr
10910 ON mc.id = mcr.cluster_id
10911 GROUP BY mc.id, mc.name
10912 ),
10913 comments AS (
10914 SELECT id, comment
10915 FROM mz_internal.mz_comments
10916 WHERE object_type = 'cluster' AND object_sub_id IS NULL
10917 )
10918 SELECT name, replicas, COALESCE(comment, '') as comment
10919 FROM clusters
10920 LEFT JOIN comments ON clusters.id = comments.id",
10921 access: vec![PUBLIC_SELECT],
10922}
10923});
10924
10925pub static MZ_SHOW_SECRETS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10926 name: "mz_show_secrets",
10927 schema: MZ_INTERNAL_SCHEMA,
10928 oid: oid::VIEW_MZ_SHOW_SECRETS_OID,
10929 desc: RelationDesc::builder()
10930 .with_column("schema_id", SqlScalarType::String.nullable(false))
10931 .with_column("name", SqlScalarType::String.nullable(false))
10932 .with_column("comment", SqlScalarType::String.nullable(false))
10933 .finish(),
10934 column_comments: BTreeMap::new(),
10935 sql: "WITH comments AS (
10936 SELECT id, comment
10937 FROM mz_internal.mz_comments
10938 WHERE object_type = 'secret' AND object_sub_id IS NULL
10939 )
10940 SELECT schema_id, name, COALESCE(comment, '') as comment
10941 FROM mz_catalog.mz_secrets secrets
10942 LEFT JOIN comments ON secrets.id = comments.id",
10943 access: vec![PUBLIC_SELECT],
10944});
10945
10946pub static MZ_SHOW_COLUMNS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10947 name: "mz_show_columns",
10948 schema: MZ_INTERNAL_SCHEMA,
10949 oid: oid::VIEW_MZ_SHOW_COLUMNS_OID,
10950 desc: RelationDesc::builder()
10951 .with_column("id", SqlScalarType::String.nullable(false))
10952 .with_column("name", SqlScalarType::String.nullable(false))
10953 .with_column("nullable", SqlScalarType::Bool.nullable(false))
10954 .with_column("type", SqlScalarType::String.nullable(false))
10955 .with_column("position", SqlScalarType::UInt64.nullable(false))
10956 .with_column("comment", SqlScalarType::String.nullable(false))
10957 .finish(),
10958 column_comments: BTreeMap::new(),
10959 sql: "
10960 SELECT columns.id, name, nullable, type, position, COALESCE(comment, '') as comment
10961 FROM mz_catalog.mz_columns columns
10962 LEFT JOIN mz_internal.mz_comments comments
10963 ON columns.id = comments.id AND columns.position = comments.object_sub_id",
10964 access: vec![PUBLIC_SELECT],
10965});
10966
10967pub static MZ_SHOW_DATABASES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10968 name: "mz_show_databases",
10969 schema: MZ_INTERNAL_SCHEMA,
10970 oid: oid::VIEW_MZ_SHOW_DATABASES_OID,
10971 desc: RelationDesc::builder()
10972 .with_column("name", SqlScalarType::String.nullable(false))
10973 .with_column("comment", SqlScalarType::String.nullable(false))
10974 .finish(),
10975 column_comments: BTreeMap::new(),
10976 sql: "WITH comments AS (
10977 SELECT id, comment
10978 FROM mz_internal.mz_comments
10979 WHERE object_type = 'database' AND object_sub_id IS NULL
10980 )
10981 SELECT name, COALESCE(comment, '') as comment
10982 FROM mz_catalog.mz_databases databases
10983 LEFT JOIN comments ON databases.id = comments.id",
10984 access: vec![PUBLIC_SELECT],
10985});
10986
10987pub static MZ_SHOW_SCHEMAS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
10988 name: "mz_show_schemas",
10989 schema: MZ_INTERNAL_SCHEMA,
10990 oid: oid::VIEW_MZ_SHOW_SCHEMAS_OID,
10991 desc: RelationDesc::builder()
10992 .with_column("database_id", SqlScalarType::String.nullable(true))
10993 .with_column("name", SqlScalarType::String.nullable(false))
10994 .with_column("comment", SqlScalarType::String.nullable(false))
10995 .finish(),
10996 column_comments: BTreeMap::new(),
10997 sql: "WITH comments AS (
10998 SELECT id, comment
10999 FROM mz_internal.mz_comments
11000 WHERE object_type = 'schema' AND object_sub_id IS NULL
11001 )
11002 SELECT database_id, name, COALESCE(comment, '') as comment
11003 FROM mz_catalog.mz_schemas schemas
11004 LEFT JOIN comments ON schemas.id = comments.id",
11005 access: vec![PUBLIC_SELECT],
11006});
11007
11008pub static MZ_SHOW_ROLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11009 name: "mz_show_roles",
11010 schema: MZ_INTERNAL_SCHEMA,
11011 oid: oid::VIEW_MZ_SHOW_ROLES_OID,
11012 desc: RelationDesc::builder()
11013 .with_column("name", SqlScalarType::String.nullable(false))
11014 .with_column("comment", SqlScalarType::String.nullable(false))
11015 .finish(),
11016 column_comments: BTreeMap::new(),
11017 sql: "WITH comments AS (
11018 SELECT id, comment
11019 FROM mz_internal.mz_comments
11020 WHERE object_type = 'role' AND object_sub_id IS NULL
11021 )
11022 SELECT name, COALESCE(comment, '') as comment
11023 FROM mz_catalog.mz_roles roles
11024 LEFT JOIN comments ON roles.id = comments.id
11025 WHERE roles.id NOT LIKE 's%'
11026 AND roles.id NOT LIKE 'g%'",
11027 access: vec![PUBLIC_SELECT],
11028});
11029
11030pub static MZ_SHOW_TABLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11031 name: "mz_show_tables",
11032 schema: MZ_INTERNAL_SCHEMA,
11033 oid: oid::VIEW_MZ_SHOW_TABLES_OID,
11034 desc: RelationDesc::builder()
11035 .with_column("schema_id", SqlScalarType::String.nullable(false))
11036 .with_column("name", SqlScalarType::String.nullable(false))
11037 .with_column("comment", SqlScalarType::String.nullable(false))
11038 .with_column("source_id", SqlScalarType::String.nullable(true))
11039 .finish(),
11040 column_comments: BTreeMap::new(),
11041 sql: "WITH comments AS (
11042 SELECT id, comment
11043 FROM mz_internal.mz_comments
11044 WHERE object_type = 'table' AND object_sub_id IS NULL
11045 )
11046 SELECT schema_id, name, COALESCE(comment, '') as comment, source_id
11047 FROM mz_catalog.mz_tables tables
11048 LEFT JOIN comments ON tables.id = comments.id",
11049 access: vec![PUBLIC_SELECT],
11050});
11051
11052pub static MZ_SHOW_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11053 name: "mz_show_views",
11054 schema: MZ_INTERNAL_SCHEMA,
11055 oid: oid::VIEW_MZ_SHOW_VIEWS_OID,
11056 desc: RelationDesc::builder()
11057 .with_column("schema_id", SqlScalarType::String.nullable(false))
11058 .with_column("name", SqlScalarType::String.nullable(false))
11059 .with_column("comment", SqlScalarType::String.nullable(false))
11060 .finish(),
11061 column_comments: BTreeMap::new(),
11062 sql: "WITH comments AS (
11063 SELECT id, comment
11064 FROM mz_internal.mz_comments
11065 WHERE object_type = 'view' AND object_sub_id IS NULL
11066 )
11067 SELECT schema_id, name, COALESCE(comment, '') as comment
11068 FROM mz_catalog.mz_views views
11069 LEFT JOIN comments ON views.id = comments.id",
11070 access: vec![PUBLIC_SELECT],
11071});
11072
11073pub static MZ_SHOW_TYPES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11074 name: "mz_show_types",
11075 schema: MZ_INTERNAL_SCHEMA,
11076 oid: oid::VIEW_MZ_SHOW_TYPES_OID,
11077 desc: RelationDesc::builder()
11078 .with_column("schema_id", SqlScalarType::String.nullable(false))
11079 .with_column("name", SqlScalarType::String.nullable(false))
11080 .with_column("comment", SqlScalarType::String.nullable(false))
11081 .finish(),
11082 column_comments: BTreeMap::new(),
11083 sql: "WITH comments AS (
11084 SELECT id, comment
11085 FROM mz_internal.mz_comments
11086 WHERE object_type = 'type' AND object_sub_id IS NULL
11087 )
11088 SELECT schema_id, name, COALESCE(comment, '') as comment
11089 FROM mz_catalog.mz_types types
11090 LEFT JOIN comments ON types.id = comments.id",
11091 access: vec![PUBLIC_SELECT],
11092});
11093
11094pub static MZ_SHOW_CONNECTIONS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11095 name: "mz_show_connections",
11096 schema: MZ_INTERNAL_SCHEMA,
11097 oid: oid::VIEW_MZ_SHOW_CONNECTIONS_OID,
11098 desc: RelationDesc::builder()
11099 .with_column("schema_id", SqlScalarType::String.nullable(false))
11100 .with_column("name", SqlScalarType::String.nullable(false))
11101 .with_column("type", SqlScalarType::String.nullable(false))
11102 .with_column("comment", SqlScalarType::String.nullable(false))
11103 .finish(),
11104 column_comments: BTreeMap::new(),
11105 sql: "WITH comments AS (
11106 SELECT id, comment
11107 FROM mz_internal.mz_comments
11108 WHERE object_type = 'connection' AND object_sub_id IS NULL
11109 )
11110 SELECT schema_id, name, type, COALESCE(comment, '') as comment
11111 FROM mz_catalog.mz_connections connections
11112 LEFT JOIN comments ON connections.id = comments.id",
11113 access: vec![PUBLIC_SELECT],
11114});
11115
11116pub static MZ_SHOW_SOURCES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11117 name: "mz_show_sources",
11118 schema: MZ_INTERNAL_SCHEMA,
11119 oid: oid::VIEW_MZ_SHOW_SOURCES_OID,
11120 desc: RelationDesc::builder()
11121 .with_column("id", SqlScalarType::String.nullable(false))
11122 .with_column("name", SqlScalarType::String.nullable(false))
11123 .with_column("type", SqlScalarType::String.nullable(false))
11124 .with_column("cluster", SqlScalarType::String.nullable(true))
11125 .with_column("schema_id", SqlScalarType::String.nullable(false))
11126 .with_column("cluster_id", SqlScalarType::String.nullable(true))
11127 .with_column("comment", SqlScalarType::String.nullable(false))
11128 .finish(),
11129 column_comments: BTreeMap::new(),
11130 sql: "
11131WITH comments AS (
11132 SELECT id, comment
11133 FROM mz_internal.mz_comments
11134 WHERE object_type = 'source' AND object_sub_id IS NULL
11135)
11136SELECT
11137 sources.id,
11138 sources.name,
11139 sources.type,
11140 clusters.name AS cluster,
11141 schema_id,
11142 cluster_id,
11143 COALESCE(comments.comment, '') as comment
11144FROM
11145 mz_catalog.mz_sources AS sources
11146 LEFT JOIN
11147 mz_catalog.mz_clusters AS clusters
11148 ON clusters.id = sources.cluster_id
11149 LEFT JOIN comments ON sources.id = comments.id",
11150 access: vec![PUBLIC_SELECT],
11151});
11152
11153pub static MZ_SHOW_SINKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11154 name: "mz_show_sinks",
11155 schema: MZ_INTERNAL_SCHEMA,
11156 oid: oid::VIEW_MZ_SHOW_SINKS_OID,
11157 desc: RelationDesc::builder()
11158 .with_column("id", SqlScalarType::String.nullable(false))
11159 .with_column("name", SqlScalarType::String.nullable(false))
11160 .with_column("type", SqlScalarType::String.nullable(false))
11161 .with_column("cluster", SqlScalarType::String.nullable(false))
11162 .with_column("schema_id", SqlScalarType::String.nullable(false))
11163 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11164 .with_column("comment", SqlScalarType::String.nullable(false))
11165 .finish(),
11166 column_comments: BTreeMap::new(),
11167 sql: "
11168WITH comments AS (
11169 SELECT id, comment
11170 FROM mz_internal.mz_comments
11171 WHERE object_type = 'sink' AND object_sub_id IS NULL
11172)
11173SELECT
11174 sinks.id,
11175 sinks.name,
11176 sinks.type,
11177 clusters.name AS cluster,
11178 schema_id,
11179 cluster_id,
11180 COALESCE(comments.comment, '') as comment
11181FROM
11182 mz_catalog.mz_sinks AS sinks
11183 JOIN
11184 mz_catalog.mz_clusters AS clusters
11185 ON clusters.id = sinks.cluster_id
11186 LEFT JOIN comments ON sinks.id = comments.id",
11187 access: vec![PUBLIC_SELECT],
11188});
11189
11190pub static MZ_SHOW_MATERIALIZED_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11191 name: "mz_show_materialized_views",
11192 schema: MZ_INTERNAL_SCHEMA,
11193 oid: oid::VIEW_MZ_SHOW_MATERIALIZED_VIEWS_OID,
11194 desc: RelationDesc::builder()
11195 .with_column("id", SqlScalarType::String.nullable(false))
11196 .with_column("name", SqlScalarType::String.nullable(false))
11197 .with_column("cluster", SqlScalarType::String.nullable(false))
11198 .with_column("schema_id", SqlScalarType::String.nullable(false))
11199 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11200 .with_column("comment", SqlScalarType::String.nullable(false))
11201 .finish(),
11202 column_comments: BTreeMap::new(),
11203 sql: "
11204WITH
11205 comments AS (
11206 SELECT id, comment
11207 FROM mz_internal.mz_comments
11208 WHERE object_type = 'materialized-view' AND object_sub_id IS NULL
11209 )
11210SELECT
11211 mviews.id as id,
11212 mviews.name,
11213 clusters.name AS cluster,
11214 schema_id,
11215 cluster_id,
11216 COALESCE(comments.comment, '') as comment
11217FROM
11218 mz_catalog.mz_materialized_views AS mviews
11219 JOIN mz_catalog.mz_clusters AS clusters ON clusters.id = mviews.cluster_id
11220 LEFT JOIN comments ON mviews.id = comments.id",
11221 access: vec![PUBLIC_SELECT],
11222});
11223
11224pub static MZ_SHOW_INDEXES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11225 name: "mz_show_indexes",
11226 schema: MZ_INTERNAL_SCHEMA,
11227 oid: oid::VIEW_MZ_SHOW_INDEXES_OID,
11228 desc: RelationDesc::builder()
11229 .with_column("id", SqlScalarType::String.nullable(false))
11230 .with_column("name", SqlScalarType::String.nullable(false))
11231 .with_column("on", SqlScalarType::String.nullable(false))
11232 .with_column("cluster", SqlScalarType::String.nullable(false))
11233 .with_column(
11234 "key",
11235 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
11236 )
11237 .with_column("on_id", SqlScalarType::String.nullable(false))
11238 .with_column("schema_id", SqlScalarType::String.nullable(false))
11239 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11240 .with_column("comment", SqlScalarType::String.nullable(false))
11241 .finish(),
11242 column_comments: BTreeMap::new(),
11243 sql: "
11244WITH comments AS (
11245 SELECT id, comment
11246 FROM mz_internal.mz_comments
11247 WHERE object_type = 'index' AND object_sub_id IS NULL
11248)
11249SELECT
11250 idxs.id AS id,
11251 idxs.name AS name,
11252 objs.name AS on,
11253 clusters.name AS cluster,
11254 COALESCE(keys.key, '{}'::_text) AS key,
11255 idxs.on_id AS on_id,
11256 objs.schema_id AS schema_id,
11257 clusters.id AS cluster_id,
11258 COALESCE(comments.comment, '') as comment
11259FROM
11260 mz_catalog.mz_indexes AS idxs
11261 JOIN mz_catalog.mz_objects AS objs ON idxs.on_id = objs.id
11262 JOIN mz_catalog.mz_clusters AS clusters ON clusters.id = idxs.cluster_id
11263 LEFT JOIN
11264 (SELECT
11265 idxs.id,
11266 ARRAY_AGG(
11267 CASE
11268 WHEN idx_cols.on_expression IS NULL THEN obj_cols.name
11269 ELSE idx_cols.on_expression
11270 END
11271 ORDER BY idx_cols.index_position ASC
11272 ) AS key
11273 FROM
11274 mz_catalog.mz_indexes AS idxs
11275 JOIN mz_catalog.mz_index_columns idx_cols ON idxs.id = idx_cols.index_id
11276 LEFT JOIN mz_catalog.mz_columns obj_cols ON
11277 idxs.on_id = obj_cols.id AND idx_cols.on_position = obj_cols.position
11278 GROUP BY idxs.id) AS keys
11279 ON idxs.id = keys.id
11280 LEFT JOIN comments ON idxs.id = comments.id",
11281 access: vec![PUBLIC_SELECT],
11282});
11283
11284pub static MZ_SHOW_CLUSTER_REPLICAS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11285 name: "mz_show_cluster_replicas",
11286 schema: MZ_INTERNAL_SCHEMA,
11287 oid: oid::VIEW_MZ_SHOW_CLUSTER_REPLICAS_OID,
11288 desc: RelationDesc::builder()
11289 .with_column("cluster", SqlScalarType::String.nullable(false))
11290 .with_column("replica", SqlScalarType::String.nullable(false))
11291 .with_column("replica_id", SqlScalarType::String.nullable(false))
11292 .with_column("size", SqlScalarType::String.nullable(true))
11293 .with_column("ready", SqlScalarType::Bool.nullable(false))
11294 .with_column("comment", SqlScalarType::String.nullable(false))
11295 .finish(),
11296 column_comments: BTreeMap::new(),
11297 sql: r#"SELECT
11298 mz_catalog.mz_clusters.name AS cluster,
11299 mz_catalog.mz_cluster_replicas.name AS replica,
11300 mz_catalog.mz_cluster_replicas.id as replica_id,
11301 mz_catalog.mz_cluster_replicas.size AS size,
11302 coalesce(statuses.ready, FALSE) AS ready,
11303 coalesce(comments.comment, '') as comment
11304FROM
11305 mz_catalog.mz_cluster_replicas
11306 JOIN mz_catalog.mz_clusters
11307 ON mz_catalog.mz_cluster_replicas.cluster_id = mz_catalog.mz_clusters.id
11308 LEFT JOIN
11309 (
11310 SELECT
11311 replica_id,
11312 bool_and(hydrated) AS ready
11313 FROM mz_internal.mz_hydration_statuses
11314 WHERE replica_id is not null
11315 GROUP BY replica_id
11316 ) AS statuses
11317 ON mz_catalog.mz_cluster_replicas.id = statuses.replica_id
11318 LEFT JOIN mz_internal.mz_comments comments
11319 ON mz_catalog.mz_cluster_replicas.id = comments.id
11320WHERE (comments.object_type = 'cluster-replica' OR comments.object_type IS NULL)
11321ORDER BY 1, 2"#,
11322 access: vec![PUBLIC_SELECT],
11323});
11324
11325pub static MZ_SHOW_CONTINUAL_TASKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11326 name: "mz_show_continual_tasks",
11327 schema: MZ_INTERNAL_SCHEMA,
11328 oid: oid::VIEW_MZ_SHOW_CONTINUAL_TASKS_OID,
11329 desc: RelationDesc::builder()
11330 .with_column("id", SqlScalarType::String.nullable(false))
11331 .with_column("name", SqlScalarType::String.nullable(false))
11332 .with_column("cluster", SqlScalarType::String.nullable(false))
11333 .with_column("schema_id", SqlScalarType::String.nullable(false))
11334 .with_column("cluster_id", SqlScalarType::String.nullable(false))
11335 .with_column("comment", SqlScalarType::String.nullable(false))
11336 .finish(),
11337 column_comments: BTreeMap::new(),
11338 sql: "
11339WITH comments AS (
11340 SELECT id, comment
11341 FROM mz_internal.mz_comments
11342 WHERE object_type = 'continual-task' AND object_sub_id IS NULL
11343)
11344SELECT
11345 cts.id as id,
11346 cts.name,
11347 clusters.name AS cluster,
11348 schema_id,
11349 cluster_id,
11350 COALESCE(comments.comment, '') as comment
11351FROM
11352 mz_internal.mz_continual_tasks AS cts
11353 JOIN mz_catalog.mz_clusters AS clusters ON clusters.id = cts.cluster_id
11354 LEFT JOIN comments ON cts.id = comments.id",
11355 access: vec![PUBLIC_SELECT],
11356});
11357
11358pub static MZ_SHOW_ROLE_MEMBERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11359 name: "mz_show_role_members",
11360 schema: MZ_INTERNAL_SCHEMA,
11361 oid: oid::VIEW_MZ_SHOW_ROLE_MEMBERS_OID,
11362 desc: RelationDesc::builder()
11363 .with_column("role", SqlScalarType::String.nullable(false))
11364 .with_column("member", SqlScalarType::String.nullable(false))
11365 .with_column("grantor", SqlScalarType::String.nullable(false))
11366 .finish(),
11367 column_comments: BTreeMap::from_iter([
11368 ("role", "The role that `member` is a member of."),
11369 ("member", "The role that is a member of `role`."),
11370 (
11371 "grantor",
11372 "The role that granted membership of `member` to `role`.",
11373 ),
11374 ]),
11375 sql: r#"SELECT
11376 r1.name AS role,
11377 r2.name AS member,
11378 r3.name AS grantor
11379FROM mz_catalog.mz_role_members rm
11380JOIN mz_catalog.mz_roles r1 ON r1.id = rm.role_id
11381JOIN mz_catalog.mz_roles r2 ON r2.id = rm.member
11382JOIN mz_catalog.mz_roles r3 ON r3.id = rm.grantor
11383ORDER BY role"#,
11384 access: vec![PUBLIC_SELECT],
11385});
11386
11387pub static MZ_SHOW_MY_ROLE_MEMBERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11388 name: "mz_show_my_role_members",
11389 schema: MZ_INTERNAL_SCHEMA,
11390 oid: oid::VIEW_MZ_SHOW_MY_ROLE_MEMBERS_OID,
11391 desc: RelationDesc::builder()
11392 .with_column("role", SqlScalarType::String.nullable(false))
11393 .with_column("member", SqlScalarType::String.nullable(false))
11394 .with_column("grantor", SqlScalarType::String.nullable(false))
11395 .finish(),
11396 column_comments: BTreeMap::from_iter([
11397 ("role", "The role that `member` is a member of."),
11398 ("member", "The role that is a member of `role`."),
11399 (
11400 "grantor",
11401 "The role that granted membership of `member` to `role`.",
11402 ),
11403 ]),
11404 sql: r#"SELECT role, member, grantor
11405FROM mz_internal.mz_show_role_members
11406WHERE pg_has_role(member, 'USAGE')"#,
11407 access: vec![PUBLIC_SELECT],
11408});
11409
11410pub static MZ_SHOW_SYSTEM_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11411 name: "mz_show_system_privileges",
11412 schema: MZ_INTERNAL_SCHEMA,
11413 oid: oid::VIEW_MZ_SHOW_SYSTEM_PRIVILEGES_OID,
11414 desc: RelationDesc::builder()
11415 .with_column("grantor", SqlScalarType::String.nullable(true))
11416 .with_column("grantee", SqlScalarType::String.nullable(true))
11417 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11418 .finish(),
11419 column_comments: BTreeMap::from_iter([
11420 ("grantor", "The role that granted the privilege."),
11421 ("grantee", "The role that the privilege was granted to."),
11422 ("privilege_type", "They type of privilege granted."),
11423 ]),
11424 sql: r#"SELECT
11425 grantor.name AS grantor,
11426 CASE privileges.grantee
11427 WHEN 'p' THEN 'PUBLIC'
11428 ELSE grantee.name
11429 END AS grantee,
11430 privileges.privilege_type AS privilege_type
11431FROM
11432 (SELECT mz_internal.mz_aclexplode(ARRAY[privileges]).*
11433 FROM mz_catalog.mz_system_privileges) AS privileges
11434LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11435LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11436WHERE privileges.grantee NOT LIKE 's%'"#,
11437 access: vec![PUBLIC_SELECT],
11438});
11439
11440pub static MZ_SHOW_MY_SYSTEM_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11441 name: "mz_show_my_system_privileges",
11442 schema: MZ_INTERNAL_SCHEMA,
11443 oid: oid::VIEW_MZ_SHOW_MY_SYSTEM_PRIVILEGES_OID,
11444 desc: RelationDesc::builder()
11445 .with_column("grantor", SqlScalarType::String.nullable(true))
11446 .with_column("grantee", SqlScalarType::String.nullable(true))
11447 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11448 .finish(),
11449 column_comments: BTreeMap::from_iter([
11450 ("grantor", "The role that granted the privilege."),
11451 ("grantee", "The role that the privilege was granted to."),
11452 ("privilege_type", "They type of privilege granted."),
11453 ]),
11454 sql: r#"SELECT grantor, grantee, privilege_type
11455FROM mz_internal.mz_show_system_privileges
11456WHERE
11457 CASE
11458 WHEN grantee = 'PUBLIC' THEN true
11459 ELSE pg_has_role(grantee, 'USAGE')
11460 END"#,
11461 access: vec![PUBLIC_SELECT],
11462});
11463
11464pub static MZ_SHOW_CLUSTER_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11465 name: "mz_show_cluster_privileges",
11466 schema: MZ_INTERNAL_SCHEMA,
11467 oid: oid::VIEW_MZ_SHOW_CLUSTER_PRIVILEGES_OID,
11468 desc: RelationDesc::builder()
11469 .with_column("grantor", SqlScalarType::String.nullable(true))
11470 .with_column("grantee", SqlScalarType::String.nullable(true))
11471 .with_column("name", SqlScalarType::String.nullable(false))
11472 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11473 .finish(),
11474 column_comments: BTreeMap::from_iter([
11475 ("grantor", "The role that granted the privilege."),
11476 ("grantee", "The role that the privilege was granted to."),
11477 ("name", "The name of the cluster."),
11478 ("privilege_type", "They type of privilege granted."),
11479 ]),
11480 sql: r#"SELECT
11481 grantor.name AS grantor,
11482 CASE privileges.grantee
11483 WHEN 'p' THEN 'PUBLIC'
11484 ELSE grantee.name
11485 END AS grantee,
11486 privileges.name AS name,
11487 privileges.privilege_type AS privilege_type
11488FROM
11489 (SELECT mz_internal.mz_aclexplode(privileges).*, name
11490 FROM mz_catalog.mz_clusters
11491 WHERE id NOT LIKE 's%') AS privileges
11492LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11493LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11494WHERE privileges.grantee NOT LIKE 's%'"#,
11495 access: vec![PUBLIC_SELECT],
11496});
11497
11498pub static MZ_SHOW_MY_CLUSTER_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11499 name: "mz_show_my_cluster_privileges",
11500 schema: MZ_INTERNAL_SCHEMA,
11501 oid: oid::VIEW_MZ_SHOW_MY_CLUSTER_PRIVILEGES_OID,
11502 desc: RelationDesc::builder()
11503 .with_column("grantor", SqlScalarType::String.nullable(true))
11504 .with_column("grantee", SqlScalarType::String.nullable(true))
11505 .with_column("name", SqlScalarType::String.nullable(false))
11506 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11507 .finish(),
11508 column_comments: BTreeMap::from_iter([
11509 ("grantor", "The role that granted the privilege."),
11510 ("grantee", "The role that the privilege was granted to."),
11511 ("name", "The name of the cluster."),
11512 ("privilege_type", "They type of privilege granted."),
11513 ]),
11514 sql: r#"SELECT grantor, grantee, name, privilege_type
11515FROM mz_internal.mz_show_cluster_privileges
11516WHERE
11517 CASE
11518 WHEN grantee = 'PUBLIC' THEN true
11519 ELSE pg_has_role(grantee, 'USAGE')
11520 END"#,
11521 access: vec![PUBLIC_SELECT],
11522});
11523
11524pub static MZ_SHOW_DATABASE_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11525 name: "mz_show_database_privileges",
11526 schema: MZ_INTERNAL_SCHEMA,
11527 oid: oid::VIEW_MZ_SHOW_DATABASE_PRIVILEGES_OID,
11528 desc: RelationDesc::builder()
11529 .with_column("grantor", SqlScalarType::String.nullable(true))
11530 .with_column("grantee", SqlScalarType::String.nullable(true))
11531 .with_column("name", SqlScalarType::String.nullable(false))
11532 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11533 .finish(),
11534 column_comments: BTreeMap::from_iter([
11535 ("grantor", "The role that granted the privilege."),
11536 ("grantee", "The role that the privilege was granted to."),
11537 ("name", "The name of the database."),
11538 ("privilege_type", "They type of privilege granted."),
11539 ]),
11540 sql: r#"SELECT
11541 grantor.name AS grantor,
11542 CASE privileges.grantee
11543 WHEN 'p' THEN 'PUBLIC'
11544 ELSE grantee.name
11545 END AS grantee,
11546 privileges.name AS name,
11547 privileges.privilege_type AS privilege_type
11548FROM
11549 (SELECT mz_internal.mz_aclexplode(privileges).*, name
11550 FROM mz_catalog.mz_databases
11551 WHERE id NOT LIKE 's%') AS privileges
11552LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11553LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11554WHERE privileges.grantee NOT LIKE 's%'"#,
11555 access: vec![PUBLIC_SELECT],
11556});
11557
11558pub static MZ_SHOW_MY_DATABASE_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11559 name: "mz_show_my_database_privileges",
11560 schema: MZ_INTERNAL_SCHEMA,
11561 oid: oid::VIEW_MZ_SHOW_MY_DATABASE_PRIVILEGES_OID,
11562 desc: RelationDesc::builder()
11563 .with_column("grantor", SqlScalarType::String.nullable(true))
11564 .with_column("grantee", 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 ("name", "The name of the cluster."),
11572 ("privilege_type", "They type of privilege granted."),
11573 ]),
11574 sql: r#"SELECT grantor, grantee, name, privilege_type
11575FROM mz_internal.mz_show_database_privileges
11576WHERE
11577 CASE
11578 WHEN grantee = 'PUBLIC' THEN true
11579 ELSE pg_has_role(grantee, 'USAGE')
11580 END"#,
11581 access: vec![PUBLIC_SELECT],
11582});
11583
11584pub static MZ_SHOW_SCHEMA_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11585 name: "mz_show_schema_privileges",
11586 schema: MZ_INTERNAL_SCHEMA,
11587 oid: oid::VIEW_MZ_SHOW_SCHEMA_PRIVILEGES_OID,
11588 desc: RelationDesc::builder()
11589 .with_column("grantor", SqlScalarType::String.nullable(true))
11590 .with_column("grantee", SqlScalarType::String.nullable(true))
11591 .with_column("database", SqlScalarType::String.nullable(true))
11592 .with_column("name", SqlScalarType::String.nullable(false))
11593 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11594 .finish(),
11595 column_comments: BTreeMap::from_iter([
11596 ("grantor", "The role that granted the privilege."),
11597 ("grantee", "The role that the privilege was granted to."),
11598 (
11599 "database",
11600 "The name of the database containing the schema.",
11601 ),
11602 ("name", "The name of the schema."),
11603 ("privilege_type", "They type of privilege granted."),
11604 ]),
11605 sql: r#"SELECT
11606 grantor.name AS grantor,
11607 CASE privileges.grantee
11608 WHEN 'p' THEN 'PUBLIC'
11609 ELSE grantee.name
11610 END AS grantee,
11611 databases.name AS database,
11612 privileges.name AS name,
11613 privileges.privilege_type AS privilege_type
11614FROM
11615 (SELECT mz_internal.mz_aclexplode(privileges).*, database_id, name
11616 FROM mz_catalog.mz_schemas
11617 WHERE id NOT LIKE 's%') AS privileges
11618LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11619LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11620LEFT JOIN mz_catalog.mz_databases databases ON privileges.database_id = databases.id
11621WHERE privileges.grantee NOT LIKE 's%'"#,
11622 access: vec![PUBLIC_SELECT],
11623});
11624
11625pub static MZ_SHOW_MY_SCHEMA_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11626 name: "mz_show_my_schema_privileges",
11627 schema: MZ_INTERNAL_SCHEMA,
11628 oid: oid::VIEW_MZ_SHOW_MY_SCHEMA_PRIVILEGES_OID,
11629 desc: RelationDesc::builder()
11630 .with_column("grantor", SqlScalarType::String.nullable(true))
11631 .with_column("grantee", SqlScalarType::String.nullable(true))
11632 .with_column("database", SqlScalarType::String.nullable(true))
11633 .with_column("name", SqlScalarType::String.nullable(false))
11634 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11635 .finish(),
11636 column_comments: BTreeMap::from_iter([
11637 ("grantor", "The role that granted the privilege."),
11638 ("grantee", "The role that the privilege was granted to."),
11639 (
11640 "database",
11641 "The name of the database containing the schema.",
11642 ),
11643 ("name", "The name of the schema."),
11644 ("privilege_type", "They type of privilege granted."),
11645 ]),
11646 sql: r#"SELECT grantor, grantee, database, name, privilege_type
11647FROM mz_internal.mz_show_schema_privileges
11648WHERE
11649 CASE
11650 WHEN grantee = 'PUBLIC' THEN true
11651 ELSE pg_has_role(grantee, 'USAGE')
11652 END"#,
11653 access: vec![PUBLIC_SELECT],
11654});
11655
11656pub static MZ_SHOW_OBJECT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11657 name: "mz_show_object_privileges",
11658 schema: MZ_INTERNAL_SCHEMA,
11659 oid: oid::VIEW_MZ_SHOW_OBJECT_PRIVILEGES_OID,
11660 desc: RelationDesc::builder()
11661 .with_column("grantor", SqlScalarType::String.nullable(true))
11662 .with_column("grantee", SqlScalarType::String.nullable(true))
11663 .with_column("database", SqlScalarType::String.nullable(true))
11664 .with_column("schema", SqlScalarType::String.nullable(true))
11665 .with_column("name", SqlScalarType::String.nullable(false))
11666 .with_column("object_type", SqlScalarType::String.nullable(false))
11667 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11668 .finish(),
11669 column_comments: BTreeMap::from_iter([
11670 ("grantor", "The role that granted the privilege."),
11671 ("grantee", "The role that the privilege was granted to."),
11672 (
11673 "database",
11674 "The name of the database containing the object.",
11675 ),
11676 ("schema", "The name of the schema containing the object."),
11677 ("name", "The name of the object."),
11678 (
11679 "object_type",
11680 "The type of object the privilege is granted on.",
11681 ),
11682 ("privilege_type", "They type of privilege granted."),
11683 ]),
11684 sql: r#"SELECT
11685 grantor.name AS grantor,
11686 CASE privileges.grantee
11687 WHEN 'p' THEN 'PUBLIC'
11688 ELSE grantee.name
11689 END AS grantee,
11690 databases.name AS database,
11691 schemas.name AS schema,
11692 privileges.name AS name,
11693 privileges.type AS object_type,
11694 privileges.privilege_type AS privilege_type
11695FROM
11696 (SELECT mz_internal.mz_aclexplode(privileges).*, schema_id, name, type
11697 FROM mz_catalog.mz_objects
11698 WHERE id NOT LIKE 's%') AS privileges
11699LEFT JOIN mz_catalog.mz_roles grantor ON privileges.grantor = grantor.id
11700LEFT JOIN mz_catalog.mz_roles grantee ON privileges.grantee = grantee.id
11701LEFT JOIN mz_catalog.mz_schemas schemas ON privileges.schema_id = schemas.id
11702LEFT JOIN mz_catalog.mz_databases databases ON schemas.database_id = databases.id
11703WHERE privileges.grantee NOT LIKE 's%'"#,
11704 access: vec![PUBLIC_SELECT],
11705});
11706
11707pub static MZ_SHOW_MY_OBJECT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11708 name: "mz_show_my_object_privileges",
11709 schema: MZ_INTERNAL_SCHEMA,
11710 oid: oid::VIEW_MZ_SHOW_MY_OBJECT_PRIVILEGES_OID,
11711 desc: RelationDesc::builder()
11712 .with_column("grantor", SqlScalarType::String.nullable(true))
11713 .with_column("grantee", SqlScalarType::String.nullable(true))
11714 .with_column("database", SqlScalarType::String.nullable(true))
11715 .with_column("schema", SqlScalarType::String.nullable(true))
11716 .with_column("name", SqlScalarType::String.nullable(false))
11717 .with_column("object_type", SqlScalarType::String.nullable(false))
11718 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11719 .finish(),
11720 column_comments: BTreeMap::from_iter([
11721 ("grantor", "The role that granted the privilege."),
11722 ("grantee", "The role that the privilege was granted to."),
11723 (
11724 "database",
11725 "The name of the database containing the object.",
11726 ),
11727 ("schema", "The name of the schema containing the object."),
11728 ("name", "The name of the object."),
11729 (
11730 "object_type",
11731 "The type of object the privilege is granted on.",
11732 ),
11733 ("privilege_type", "They type of privilege granted."),
11734 ]),
11735 sql: r#"SELECT grantor, grantee, database, schema, name, object_type, privilege_type
11736FROM mz_internal.mz_show_object_privileges
11737WHERE
11738 CASE
11739 WHEN grantee = 'PUBLIC' THEN true
11740 ELSE pg_has_role(grantee, 'USAGE')
11741 END"#,
11742 access: vec![PUBLIC_SELECT],
11743});
11744
11745pub static MZ_SHOW_ALL_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11746 name: "mz_show_all_privileges",
11747 schema: MZ_INTERNAL_SCHEMA,
11748 oid: oid::VIEW_MZ_SHOW_ALL_PRIVILEGES_OID,
11749 desc: RelationDesc::builder()
11750 .with_column("grantor", SqlScalarType::String.nullable(true))
11751 .with_column("grantee", SqlScalarType::String.nullable(true))
11752 .with_column("database", SqlScalarType::String.nullable(true))
11753 .with_column("schema", SqlScalarType::String.nullable(true))
11754 .with_column("name", SqlScalarType::String.nullable(true))
11755 .with_column("object_type", SqlScalarType::String.nullable(false))
11756 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11757 .finish(),
11758 column_comments: BTreeMap::from_iter([
11759 ("grantor", "The role that granted the privilege."),
11760 ("grantee", "The role that the privilege was granted to."),
11761 (
11762 "database",
11763 "The name of the database containing the object.",
11764 ),
11765 ("schema", "The name of the schema containing the object."),
11766 ("name", "The name of the privilege target."),
11767 (
11768 "object_type",
11769 "The type of object the privilege is granted on.",
11770 ),
11771 ("privilege_type", "They type of privilege granted."),
11772 ]),
11773 sql: r#"SELECT grantor, grantee, NULL AS database, NULL AS schema, NULL AS name, 'system' AS object_type, privilege_type
11774FROM mz_internal.mz_show_system_privileges
11775UNION ALL
11776SELECT grantor, grantee, NULL AS database, NULL AS schema, name, 'cluster' AS object_type, privilege_type
11777FROM mz_internal.mz_show_cluster_privileges
11778UNION ALL
11779SELECT grantor, grantee, NULL AS database, NULL AS schema, name, 'database' AS object_type, privilege_type
11780FROM mz_internal.mz_show_database_privileges
11781UNION ALL
11782SELECT grantor, grantee, database, NULL AS schema, name, 'schema' AS object_type, privilege_type
11783FROM mz_internal.mz_show_schema_privileges
11784UNION ALL
11785SELECT grantor, grantee, database, schema, name, object_type, privilege_type
11786FROM mz_internal.mz_show_object_privileges"#,
11787 access: vec![PUBLIC_SELECT],
11788});
11789
11790pub static MZ_SHOW_ALL_MY_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11791 name: "mz_show_all_my_privileges",
11792 schema: MZ_INTERNAL_SCHEMA,
11793 oid: oid::VIEW_MZ_SHOW_ALL_MY_PRIVILEGES_OID,
11794 desc: RelationDesc::builder()
11795 .with_column("grantor", SqlScalarType::String.nullable(true))
11796 .with_column("grantee", SqlScalarType::String.nullable(true))
11797 .with_column("database", SqlScalarType::String.nullable(true))
11798 .with_column("schema", SqlScalarType::String.nullable(true))
11799 .with_column("name", SqlScalarType::String.nullable(true))
11800 .with_column("object_type", SqlScalarType::String.nullable(false))
11801 .with_column("privilege_type", SqlScalarType::String.nullable(false))
11802 .finish(),
11803 column_comments: BTreeMap::from_iter([
11804 ("grantor", "The role that granted the privilege."),
11805 ("grantee", "The role that the privilege was granted to."),
11806 (
11807 "database",
11808 "The name of the database containing the object.",
11809 ),
11810 ("schema", "The name of the schema containing the object."),
11811 ("name", "The name of the privilege target."),
11812 (
11813 "object_type",
11814 "The type of object the privilege is granted on.",
11815 ),
11816 ("privilege_type", "They type of privilege granted."),
11817 ]),
11818 sql: r#"SELECT grantor, grantee, database, schema, name, object_type, privilege_type
11819FROM mz_internal.mz_show_all_privileges
11820WHERE
11821 CASE
11822 WHEN grantee = 'PUBLIC' THEN true
11823 ELSE pg_has_role(grantee, 'USAGE')
11824 END"#,
11825 access: vec![PUBLIC_SELECT],
11826});
11827
11828pub static MZ_SHOW_DEFAULT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11829 name: "mz_show_default_privileges",
11830 schema: MZ_INTERNAL_SCHEMA,
11831 oid: oid::VIEW_MZ_SHOW_DEFAULT_PRIVILEGES_OID,
11832 desc: RelationDesc::builder()
11833 .with_column("object_owner", SqlScalarType::String.nullable(true))
11834 .with_column("database", SqlScalarType::String.nullable(true))
11835 .with_column("schema", SqlScalarType::String.nullable(true))
11836 .with_column("object_type", SqlScalarType::String.nullable(false))
11837 .with_column("grantee", SqlScalarType::String.nullable(true))
11838 .with_column("privilege_type", SqlScalarType::String.nullable(true))
11839 .finish(),
11840 column_comments: BTreeMap::from_iter([
11841 (
11842 "object_owner",
11843 "Privileges described in this row will be granted on objects created by `object_owner`.",
11844 ),
11845 (
11846 "database",
11847 "Privileges described in this row will be granted only on objects created in `database` if non-null.",
11848 ),
11849 (
11850 "schema",
11851 "Privileges described in this row will be granted only on objects created in `schema` if non-null.",
11852 ),
11853 (
11854 "object_type",
11855 "Privileges described in this row will be granted only on objects of type `object_type`.",
11856 ),
11857 (
11858 "grantee",
11859 "Privileges described in this row will be granted to `grantee`.",
11860 ),
11861 ("privilege_type", "They type of privilege to be granted."),
11862 ]),
11863 sql: r#"SELECT
11864 CASE defaults.role_id
11865 WHEN 'p' THEN 'PUBLIC'
11866 ELSE object_owner.name
11867 END AS object_owner,
11868 databases.name AS database,
11869 schemas.name AS schema,
11870 object_type,
11871 CASE defaults.grantee
11872 WHEN 'p' THEN 'PUBLIC'
11873 ELSE grantee.name
11874 END AS grantee,
11875 unnest(mz_internal.mz_format_privileges(defaults.privileges)) AS privilege_type
11876FROM mz_catalog.mz_default_privileges defaults
11877LEFT JOIN mz_catalog.mz_roles AS object_owner ON defaults.role_id = object_owner.id
11878LEFT JOIN mz_catalog.mz_roles AS grantee ON defaults.grantee = grantee.id
11879LEFT JOIN mz_catalog.mz_databases AS databases ON defaults.database_id = databases.id
11880LEFT JOIN mz_catalog.mz_schemas AS schemas ON defaults.schema_id = schemas.id
11881WHERE defaults.grantee NOT LIKE 's%'
11882 AND defaults.database_id IS NULL OR defaults.database_id NOT LIKE 's%'
11883 AND defaults.schema_id IS NULL OR defaults.schema_id NOT LIKE 's%'"#,
11884 access: vec![PUBLIC_SELECT],
11885});
11886
11887pub static MZ_SHOW_MY_DEFAULT_PRIVILEGES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11888 name: "mz_show_my_default_privileges",
11889 schema: MZ_INTERNAL_SCHEMA,
11890 oid: oid::VIEW_MZ_SHOW_MY_DEFAULT_PRIVILEGES_OID,
11891 desc: RelationDesc::builder()
11892 .with_column("object_owner", SqlScalarType::String.nullable(true))
11893 .with_column("database", SqlScalarType::String.nullable(true))
11894 .with_column("schema", SqlScalarType::String.nullable(true))
11895 .with_column("object_type", SqlScalarType::String.nullable(false))
11896 .with_column("grantee", SqlScalarType::String.nullable(true))
11897 .with_column("privilege_type", SqlScalarType::String.nullable(true))
11898 .finish(),
11899 column_comments: BTreeMap::from_iter([
11900 (
11901 "object_owner",
11902 "Privileges described in this row will be granted on objects created by `object_owner`.",
11903 ),
11904 (
11905 "database",
11906 "Privileges described in this row will be granted only on objects created in `database` if non-null.",
11907 ),
11908 (
11909 "schema",
11910 "Privileges described in this row will be granted only on objects created in `schema` if non-null.",
11911 ),
11912 (
11913 "object_type",
11914 "Privileges described in this row will be granted only on objects of type `object_type`.",
11915 ),
11916 (
11917 "grantee",
11918 "Privileges described in this row will be granted to `grantee`.",
11919 ),
11920 ("privilege_type", "They type of privilege to be granted."),
11921 ]),
11922 sql: r#"SELECT object_owner, database, schema, object_type, grantee, privilege_type
11923FROM mz_internal.mz_show_default_privileges
11924WHERE
11925 CASE
11926 WHEN grantee = 'PUBLIC' THEN true
11927 ELSE pg_has_role(grantee, 'USAGE')
11928 END"#,
11929 access: vec![PUBLIC_SELECT],
11930});
11931
11932pub static MZ_SHOW_NETWORK_POLICIES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11933 name: "mz_show_network_policies",
11934 schema: MZ_INTERNAL_SCHEMA,
11935 oid: oid::VIEW_MZ_SHOW_NETWORK_POLICIES_OID,
11936 desc: RelationDesc::builder()
11937 .with_column("name", SqlScalarType::String.nullable(false))
11938 .with_column("rules", SqlScalarType::String.nullable(true))
11939 .with_column("comment", SqlScalarType::String.nullable(false))
11940 .finish(),
11941 column_comments: BTreeMap::new(),
11942 sql: "
11943WITH comments AS (
11944 SELECT id, comment
11945 FROM mz_internal.mz_comments
11946 WHERE object_type = 'network-policy' AND object_sub_id IS NULL
11947)
11948SELECT
11949 policy.name,
11950 pg_catalog.string_agg(rule.name,',' ORDER BY rule.name) as rules,
11951 COALESCE(comment, '') as comment
11952FROM
11953 mz_internal.mz_network_policies as policy
11954LEFT JOIN
11955 mz_internal.mz_network_policy_rules as rule ON policy.id = rule.policy_id
11956LEFT JOIN
11957 comments ON policy.id = comments.id
11958WHERE
11959 policy.id NOT LIKE 's%'
11960AND
11961 policy.id NOT LIKE 'g%'
11962GROUP BY policy.name, comments.comment;",
11963 access: vec![PUBLIC_SELECT],
11964});
11965
11966pub static MZ_CLUSTER_REPLICA_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
11967 name: "mz_cluster_replica_history",
11968 schema: MZ_INTERNAL_SCHEMA,
11969 oid: oid::VIEW_MZ_CLUSTER_REPLICA_HISTORY_OID,
11970 desc: RelationDesc::builder()
11971 .with_column("replica_id", SqlScalarType::String.nullable(true))
11972 .with_column("size", SqlScalarType::String.nullable(true))
11973 .with_column("cluster_id", SqlScalarType::String.nullable(true))
11974 .with_column("cluster_name", SqlScalarType::String.nullable(true))
11975 .with_column("replica_name", SqlScalarType::String.nullable(true))
11976 .with_column(
11977 "created_at",
11978 SqlScalarType::TimestampTz { precision: None }.nullable(false),
11979 )
11980 .with_column(
11981 "dropped_at",
11982 SqlScalarType::TimestampTz { precision: None }.nullable(true),
11983 )
11984 .with_column(
11985 "credits_per_hour",
11986 SqlScalarType::Numeric { max_scale: None }.nullable(true),
11987 )
11988 .finish(),
11989 column_comments: BTreeMap::from_iter([
11990 ("replica_id", "The ID of a cluster replica."),
11991 (
11992 "size",
11993 "The size of the cluster replica. Corresponds to `mz_cluster_replica_sizes.size`.",
11994 ),
11995 (
11996 "cluster_id",
11997 "The ID of the cluster associated with the replica.",
11998 ),
11999 (
12000 "cluster_name",
12001 "The name of the cluster associated with the replica.",
12002 ),
12003 ("replica_name", "The name of the replica."),
12004 ("created_at", "The time at which the replica was created."),
12005 (
12006 "dropped_at",
12007 "The time at which the replica was dropped, or `NULL` if it still exists.",
12008 ),
12009 (
12010 "credits_per_hour",
12011 "The number of compute credits consumed per hour. Corresponds to `mz_cluster_replica_sizes.credits_per_hour`.",
12012 ),
12013 ]),
12014 sql: r#"
12015 WITH
12016 creates AS
12017 (
12018 SELECT
12019 details ->> 'logical_size' AS size,
12020 details ->> 'replica_id' AS replica_id,
12021 details ->> 'replica_name' AS replica_name,
12022 details ->> 'cluster_name' AS cluster_name,
12023 details ->> 'cluster_id' AS cluster_id,
12024 occurred_at
12025 FROM mz_catalog.mz_audit_events
12026 WHERE
12027 object_type = 'cluster-replica' AND event_type = 'create'
12028 AND
12029 details ->> 'replica_id' IS NOT NULL
12030 AND
12031 details ->> 'cluster_id' !~~ 's%'
12032 ),
12033 drops AS
12034 (
12035 SELECT details ->> 'replica_id' AS replica_id, occurred_at
12036 FROM mz_catalog.mz_audit_events
12037 WHERE object_type = 'cluster-replica' AND event_type = 'drop'
12038 )
12039 SELECT
12040 creates.replica_id,
12041 creates.size,
12042 creates.cluster_id,
12043 creates.cluster_name,
12044 creates.replica_name,
12045 creates.occurred_at AS created_at,
12046 drops.occurred_at AS dropped_at,
12047 mz_cluster_replica_sizes.credits_per_hour as credits_per_hour
12048 FROM
12049 creates
12050 LEFT JOIN drops ON creates.replica_id = drops.replica_id
12051 LEFT JOIN
12052 mz_catalog.mz_cluster_replica_sizes
12053 ON mz_cluster_replica_sizes.size = creates.size"#,
12054 access: vec![PUBLIC_SELECT],
12055});
12056
12057pub static MZ_CLUSTER_REPLICA_NAME_HISTORY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12058 name: "mz_cluster_replica_name_history",
12059 schema: MZ_INTERNAL_SCHEMA,
12060 oid: oid::VIEW_MZ_CLUSTER_REPLICA_NAME_HISTORY_OID,
12061 desc: RelationDesc::builder()
12062 .with_column(
12063 "occurred_at",
12064 SqlScalarType::TimestampTz { precision: None }.nullable(true),
12065 )
12066 .with_column("id", SqlScalarType::String.nullable(true))
12067 .with_column("previous_name", SqlScalarType::String.nullable(true))
12068 .with_column("new_name", SqlScalarType::String.nullable(true))
12069 .finish(),
12070 column_comments: BTreeMap::from_iter([
12071 (
12072 "occurred_at",
12073 "The time at which the cluster replica was created or renamed. `NULL` if it's a built in system cluster replica.",
12074 ),
12075 ("id", "The ID of the cluster replica."),
12076 (
12077 "previous_name",
12078 "The previous name of the cluster replica. `NULL` if there was no previous name.",
12079 ),
12080 ("new_name", "The new name of the cluster replica."),
12081 ]),
12082 sql: r#"WITH user_replica_alter_history AS (
12083 SELECT occurred_at,
12084 audit_events.details->>'replica_id' AS id,
12085 audit_events.details->>'old_name' AS previous_name,
12086 audit_events.details->>'new_name' AS new_name
12087 FROM mz_catalog.mz_audit_events AS audit_events
12088 WHERE object_type = 'cluster-replica'
12089 AND audit_events.event_type = 'alter'
12090 AND audit_events.details->>'replica_id' like 'u%'
12091),
12092user_replica_create_history AS (
12093 SELECT occurred_at,
12094 audit_events.details->>'replica_id' AS id,
12095 NULL AS previous_name,
12096 audit_events.details->>'replica_name' AS new_name
12097 FROM mz_catalog.mz_audit_events AS audit_events
12098 WHERE object_type = 'cluster-replica'
12099 AND audit_events.event_type = 'create'
12100 AND audit_events.details->>'replica_id' like 'u%'
12101),
12102-- Because built in system cluster replicas don't have audit events, we need to manually add them
12103system_replicas AS (
12104 -- We assume that the system cluster replicas were created at the beginning of time
12105 SELECT NULL::timestamptz AS occurred_at,
12106 id,
12107 NULL AS previous_name,
12108 name AS new_name
12109 FROM mz_catalog.mz_cluster_replicas
12110 WHERE id LIKE 's%'
12111)
12112SELECT *
12113FROM user_replica_alter_history
12114UNION ALL
12115SELECT *
12116FROM user_replica_create_history
12117UNION ALL
12118SELECT *
12119FROM system_replicas"#,
12120 access: vec![PUBLIC_SELECT],
12121});
12122
12123pub static MZ_HYDRATION_STATUSES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12124 name: "mz_hydration_statuses",
12125 schema: MZ_INTERNAL_SCHEMA,
12126 oid: oid::VIEW_MZ_HYDRATION_STATUSES_OID,
12127 desc: RelationDesc::builder()
12128 .with_column("object_id", SqlScalarType::String.nullable(false))
12129 .with_column("replica_id", SqlScalarType::String.nullable(true))
12130 .with_column("hydrated", SqlScalarType::Bool.nullable(true))
12131 .finish(),
12132 column_comments: BTreeMap::from_iter([
12133 (
12134 "object_id",
12135 "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`.",
12136 ),
12137 ("replica_id", "The ID of a cluster replica."),
12138 ("hydrated", "Whether the object is hydrated on the replica."),
12139 ]),
12140 sql: r#"WITH
12141-- Joining against the linearizable catalog tables ensures that this view
12142-- always contains the set of installed objects, even when it depends
12143-- on introspection relations that may received delayed updates.
12144--
12145-- Note that this view only includes objects that are maintained by dataflows.
12146-- In particular, some source types (webhook, introspection, ...) are not and
12147-- are therefore omitted.
12148indexes AS (
12149 SELECT
12150 i.id AS object_id,
12151 h.replica_id,
12152 COALESCE(h.hydrated, false) AS hydrated
12153 FROM mz_catalog.mz_indexes i
12154 LEFT JOIN mz_internal.mz_compute_hydration_statuses h
12155 ON (h.object_id = i.id)
12156),
12157materialized_views AS (
12158 SELECT
12159 i.id AS object_id,
12160 h.replica_id,
12161 COALESCE(h.hydrated, false) AS hydrated
12162 FROM mz_catalog.mz_materialized_views i
12163 LEFT JOIN mz_internal.mz_compute_hydration_statuses h
12164 ON (h.object_id = i.id)
12165),
12166continual_tasks AS (
12167 SELECT
12168 i.id AS object_id,
12169 h.replica_id,
12170 COALESCE(h.hydrated, false) AS hydrated
12171 FROM mz_internal.mz_continual_tasks i
12172 LEFT JOIN mz_internal.mz_compute_hydration_statuses h
12173 ON (h.object_id = i.id)
12174),
12175-- Hydration is a dataflow concept and not all sources are maintained by
12176-- dataflows, so we need to find the ones that are. Generally, sources that
12177-- have a cluster ID are maintained by a dataflow running on that cluster.
12178-- Webhook sources are an exception to this rule.
12179sources_with_clusters AS (
12180 SELECT id, cluster_id
12181 FROM mz_catalog.mz_sources
12182 WHERE cluster_id IS NOT NULL AND type != 'webhook'
12183),
12184sources AS (
12185 SELECT
12186 s.id AS object_id,
12187 ss.replica_id AS replica_id,
12188 ss.rehydration_latency IS NOT NULL AS hydrated
12189 FROM sources_with_clusters s
12190 LEFT JOIN mz_internal.mz_source_statistics ss USING (id)
12191),
12192-- We don't yet report sink hydration status (database-issues#8331), so we do a best effort attempt here and
12193-- define a sink as hydrated when it's both "running" and has a frontier greater than the minimum.
12194-- There is likely still a possibility of FPs.
12195sinks AS (
12196 SELECT
12197 s.id AS object_id,
12198 r.id AS replica_id,
12199 ss.status = 'running' AND COALESCE(f.write_frontier, 0) > 0 AS hydrated
12200 FROM mz_catalog.mz_sinks s
12201 LEFT JOIN mz_internal.mz_sink_statuses ss USING (id)
12202 JOIN mz_catalog.mz_cluster_replicas r
12203 ON (r.cluster_id = s.cluster_id)
12204 LEFT JOIN mz_catalog.mz_cluster_replica_frontiers f
12205 ON (f.object_id = s.id AND f.replica_id = r.id)
12206)
12207SELECT * FROM indexes
12208UNION ALL
12209SELECT * FROM materialized_views
12210UNION ALL
12211SELECT * FROM continual_tasks
12212UNION ALL
12213SELECT * FROM sources
12214UNION ALL
12215SELECT * FROM sinks"#,
12216 access: vec![PUBLIC_SELECT],
12217});
12218
12219pub static MZ_MATERIALIZATION_DEPENDENCIES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12220 name: "mz_materialization_dependencies",
12221 schema: MZ_INTERNAL_SCHEMA,
12222 oid: oid::VIEW_MZ_MATERIALIZATION_DEPENDENCIES_OID,
12223 desc: RelationDesc::builder()
12224 .with_column("object_id", SqlScalarType::String.nullable(false))
12225 .with_column("dependency_id", SqlScalarType::String.nullable(false))
12226 .finish(),
12227 column_comments: BTreeMap::from_iter([
12228 (
12229 "object_id",
12230 "The ID of a materialization. Corresponds to `mz_catalog.mz_indexes.id`, `mz_catalog.mz_materialized_views.id`, or `mz_catalog.mz_sinks.id`.",
12231 ),
12232 (
12233 "dependency_id",
12234 "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`.",
12235 ),
12236 ]),
12237 sql: "
12238SELECT object_id, dependency_id
12239FROM mz_internal.mz_compute_dependencies
12240UNION ALL
12241SELECT s.id, d.referenced_object_id AS dependency_id
12242FROM mz_internal.mz_object_dependencies d
12243JOIN mz_catalog.mz_sinks s ON (s.id = d.object_id)
12244JOIN mz_catalog.mz_relations r ON (r.id = d.referenced_object_id)",
12245 access: vec![PUBLIC_SELECT],
12246});
12247
12248pub static MZ_MATERIALIZATION_LAG: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12249 name: "mz_materialization_lag",
12250 schema: MZ_INTERNAL_SCHEMA,
12251 oid: oid::VIEW_MZ_MATERIALIZATION_LAG_OID,
12252 desc: RelationDesc::builder()
12253 .with_column("object_id", SqlScalarType::String.nullable(false))
12254 .with_column("local_lag", SqlScalarType::Interval.nullable(true))
12255 .with_column("global_lag", SqlScalarType::Interval.nullable(true))
12256 .with_column(
12257 "slowest_local_input_id",
12258 SqlScalarType::String.nullable(false),
12259 )
12260 .with_column(
12261 "slowest_global_input_id",
12262 SqlScalarType::String.nullable(false),
12263 )
12264 .finish(),
12265 column_comments: BTreeMap::from_iter([
12266 (
12267 "object_id",
12268 "The ID of the materialized view, index, or sink.",
12269 ),
12270 (
12271 "local_lag",
12272 "The amount of time the materialization lags behind its direct inputs.",
12273 ),
12274 (
12275 "global_lag",
12276 "The amount of time the materialization lags behind its root inputs (sources and tables).",
12277 ),
12278 (
12279 "slowest_local_input_id",
12280 "The ID of the slowest direct input.",
12281 ),
12282 (
12283 "slowest_global_input_id",
12284 "The ID of the slowest root input.",
12285 ),
12286 ]),
12287 sql: "
12288WITH MUTUALLY RECURSIVE
12289 -- IDs of objects for which we want to know the lag.
12290 materializations (id text) AS (
12291 SELECT id FROM mz_catalog.mz_indexes
12292 UNION ALL
12293 SELECT id FROM mz_catalog.mz_materialized_views
12294 UNION ALL
12295 SELECT id FROM mz_internal.mz_continual_tasks
12296 UNION ALL
12297 SELECT id FROM mz_catalog.mz_sinks
12298 ),
12299 -- Direct dependencies of materializations.
12300 direct_dependencies (id text, dep_id text) AS (
12301 SELECT m.id, d.dependency_id
12302 FROM materializations m
12303 JOIN mz_internal.mz_materialization_dependencies d ON (m.id = d.object_id)
12304 ),
12305 -- All transitive dependencies of materializations.
12306 transitive_dependencies (id text, dep_id text) AS (
12307 SELECT id, dep_id FROM direct_dependencies
12308 UNION
12309 SELECT td.id, dd.dep_id
12310 FROM transitive_dependencies td
12311 JOIN direct_dependencies dd ON (dd.id = td.dep_id)
12312 ),
12313 -- Root dependencies of materializations (sources and tables).
12314 root_dependencies (id text, dep_id text) AS (
12315 SELECT *
12316 FROM transitive_dependencies td
12317 WHERE NOT EXISTS (
12318 SELECT 1
12319 FROM direct_dependencies dd
12320 WHERE dd.id = td.dep_id
12321 )
12322 ),
12323 -- Write progress times of materializations.
12324 materialization_times (id text, time timestamptz) AS (
12325 SELECT m.id, to_timestamp(f.write_frontier::text::double / 1000)
12326 FROM materializations m
12327 JOIN mz_internal.mz_frontiers f ON (m.id = f.object_id)
12328 ),
12329 -- Write progress times of direct dependencies of materializations.
12330 input_times (id text, slowest_dep text, time timestamptz) AS (
12331 SELECT DISTINCT ON (d.id)
12332 d.id,
12333 d.dep_id,
12334 to_timestamp(f.write_frontier::text::double / 1000)
12335 FROM direct_dependencies d
12336 JOIN mz_internal.mz_frontiers f ON (d.dep_id = f.object_id)
12337 ORDER BY d.id, f.write_frontier ASC
12338 ),
12339 -- Write progress times of root dependencies of materializations.
12340 root_times (id text, slowest_dep text, time timestamptz) AS (
12341 SELECT DISTINCT ON (d.id)
12342 d.id,
12343 d.dep_id,
12344 to_timestamp(f.write_frontier::text::double / 1000)
12345 FROM root_dependencies d
12346 JOIN mz_internal.mz_frontiers f ON (d.dep_id = f.object_id)
12347 ORDER BY d.id, f.write_frontier ASC
12348 )
12349SELECT
12350 id AS object_id,
12351 -- Ensure that lag values are always NULL for materializations that have reached the empty
12352 -- frontier, as those have processed all their input data.
12353 -- Also make sure that lag values are never negative, even when input frontiers are before
12354 -- output frontiers (as can happen during hydration).
12355 CASE
12356 WHEN m.time IS NULL THEN INTERVAL '0'
12357 WHEN i.time IS NULL THEN NULL
12358 ELSE greatest(i.time - m.time, INTERVAL '0')
12359 END AS local_lag,
12360 CASE
12361 WHEN m.time IS NULL THEN INTERVAL '0'
12362 WHEN r.time IS NULL THEN NULL
12363 ELSE greatest(r.time - m.time, INTERVAL '0')
12364 END AS global_lag,
12365 i.slowest_dep AS slowest_local_input_id,
12366 r.slowest_dep AS slowest_global_input_id
12367FROM materialization_times m
12368JOIN input_times i USING (id)
12369JOIN root_times r USING (id)",
12370 access: vec![PUBLIC_SELECT],
12371});
12372
12373pub static MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW: LazyLock<BuiltinView> = LazyLock::new(|| {
12379 BuiltinView {
12380 name: "mz_console_cluster_utilization_overview",
12381 schema: MZ_INTERNAL_SCHEMA,
12382 oid: oid::VIEW_MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_OID,
12383 desc: RelationDesc::builder()
12384 .with_column(
12385 "bucket_start",
12386 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12387 )
12388 .with_column("replica_id", SqlScalarType::String.nullable(false))
12389 .with_column("memory_percent", SqlScalarType::Float64.nullable(true))
12390 .with_column(
12391 "max_memory_at",
12392 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12393 )
12394 .with_column("disk_percent", SqlScalarType::Float64.nullable(true))
12395 .with_column(
12396 "max_disk_at",
12397 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12398 )
12399 .with_column(
12400 "memory_and_disk_percent",
12401 SqlScalarType::Float64.nullable(true),
12402 )
12403 .with_column(
12404 "max_memory_and_disk_memory_percent",
12405 SqlScalarType::Float64.nullable(true),
12406 )
12407 .with_column(
12408 "max_memory_and_disk_disk_percent",
12409 SqlScalarType::Float64.nullable(true),
12410 )
12411 .with_column(
12412 "max_memory_and_disk_at",
12413 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12414 )
12415 .with_column("heap_percent", SqlScalarType::Float64.nullable(true))
12416 .with_column(
12417 "max_heap_at",
12418 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12419 )
12420 .with_column("max_cpu_percent", SqlScalarType::Float64.nullable(true))
12421 .with_column(
12422 "max_cpu_at",
12423 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12424 )
12425 .with_column("offline_events", SqlScalarType::Jsonb.nullable(true))
12426 .with_column(
12427 "bucket_end",
12428 SqlScalarType::TimestampTz { precision: None }.nullable(false),
12429 )
12430 .with_column("name", SqlScalarType::String.nullable(true))
12431 .with_column("cluster_id", SqlScalarType::String.nullable(true))
12432 .with_column("size", SqlScalarType::String.nullable(true))
12433 .finish(),
12434 column_comments: BTreeMap::new(),
12435 sql: r#"WITH replica_history AS (
12436 SELECT replica_id,
12437 size,
12438 cluster_id
12439 FROM mz_internal.mz_cluster_replica_history
12440 UNION
12441 -- We need to union the current set of cluster replicas since mz_cluster_replica_history doesn't include system clusters
12442 SELECT id AS replica_id,
12443 size,
12444 cluster_id
12445 FROM mz_catalog.mz_cluster_replicas
12446),
12447replica_metrics_history AS (
12448 SELECT
12449 m.occurred_at,
12450 m.replica_id,
12451 r.size,
12452 (SUM(m.cpu_nano_cores::float8) / NULLIF(s.cpu_nano_cores, 0)) / NULLIF(s.processes, 0) AS cpu_percent,
12453 (SUM(m.memory_bytes::float8) / NULLIF(s.memory_bytes, 0)) / NULLIF(s.processes, 0) AS memory_percent,
12454 (SUM(m.disk_bytes::float8) / NULLIF(s.disk_bytes, 0)) / NULLIF(s.processes, 0) AS disk_percent,
12455 (SUM(m.heap_bytes::float8) / NULLIF(m.heap_limit, 0)) / NULLIF(s.processes, 0) AS heap_percent,
12456 SUM(m.disk_bytes::float8) AS disk_bytes,
12457 SUM(m.memory_bytes::float8) AS memory_bytes,
12458 s.disk_bytes::numeric * s.processes AS total_disk_bytes,
12459 s.memory_bytes::numeric * s.processes AS total_memory_bytes
12460 FROM
12461 replica_history AS r
12462 INNER JOIN mz_catalog.mz_cluster_replica_sizes AS s ON r.size = s.size
12463 INNER JOIN mz_internal.mz_cluster_replica_metrics_history AS m ON m.replica_id = r.replica_id
12464 GROUP BY
12465 m.occurred_at,
12466 m.replica_id,
12467 r.size,
12468 s.cpu_nano_cores,
12469 s.memory_bytes,
12470 s.disk_bytes,
12471 m.heap_limit,
12472 s.processes
12473),
12474replica_utilization_history_binned AS (
12475 SELECT m.occurred_at,
12476 m.replica_id,
12477 m.cpu_percent,
12478 m.memory_percent,
12479 m.memory_bytes,
12480 m.disk_percent,
12481 m.disk_bytes,
12482 m.heap_percent,
12483 m.total_disk_bytes,
12484 m.total_memory_bytes,
12485 m.size,
12486 date_bin(
12487 '8 HOURS',
12488 occurred_at,
12489 '1970-01-01'::timestamp
12490 ) AS bucket_start
12491 FROM replica_history AS r
12492 JOIN replica_metrics_history AS m ON m.replica_id = r.replica_id
12493 WHERE mz_now() <= date_bin(
12494 '8 HOURS',
12495 occurred_at,
12496 '1970-01-01'::timestamp
12497 ) + INTERVAL '14 DAYS'
12498),
12499-- For each (replica, bucket), take the (replica, bucket) with the highest memory
12500max_memory AS (
12501 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12502 replica_id,
12503 memory_percent,
12504 occurred_at
12505 FROM replica_utilization_history_binned
12506 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12507 ORDER BY bucket_start,
12508 replica_id,
12509 COALESCE(memory_bytes, 0) DESC
12510),
12511max_disk AS (
12512 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12513 replica_id,
12514 disk_percent,
12515 occurred_at
12516 FROM replica_utilization_history_binned
12517 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12518 ORDER BY bucket_start,
12519 replica_id,
12520 COALESCE(disk_bytes, 0) DESC
12521),
12522max_cpu AS (
12523 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12524 replica_id,
12525 cpu_percent,
12526 occurred_at
12527 FROM replica_utilization_history_binned
12528 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12529 ORDER BY bucket_start,
12530 replica_id,
12531 COALESCE(cpu_percent, 0) DESC
12532),
12533/*
12534 This is different
12535 from adding max_memory
12536 and max_disk per bucket because both
12537 values may not occur at the same time if the bucket interval is large.
12538 */
12539max_memory_and_disk AS (
12540 SELECT DISTINCT ON (bucket_start, replica_id) bucket_start,
12541 replica_id,
12542 memory_percent,
12543 disk_percent,
12544 memory_and_disk_percent,
12545 occurred_at
12546 FROM (
12547 SELECT *,
12548 CASE
12549 WHEN disk_bytes IS NULL
12550 AND memory_bytes IS NULL THEN NULL
12551 ELSE (COALESCE(disk_bytes, 0) + COALESCE(memory_bytes, 0))
12552 / (total_disk_bytes::numeric + total_memory_bytes::numeric)
12553 END AS memory_and_disk_percent
12554 FROM replica_utilization_history_binned
12555 ) AS max_memory_and_disk_inner
12556 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12557 ORDER BY bucket_start,
12558 replica_id,
12559 COALESCE(memory_and_disk_percent, 0) DESC
12560),
12561max_heap AS (
12562 SELECT DISTINCT ON (bucket_start, replica_id)
12563 bucket_start,
12564 replica_id,
12565 heap_percent,
12566 occurred_at
12567 FROM replica_utilization_history_binned
12568 OPTIONS (DISTINCT ON INPUT GROUP SIZE = 480)
12569 ORDER BY bucket_start, replica_id, COALESCE(heap_percent, 0) DESC
12570),
12571-- For each (replica, bucket), get its offline events at that time
12572replica_offline_event_history AS (
12573 SELECT date_bin(
12574 '8 HOURS',
12575 occurred_at,
12576 '1970-01-01'::timestamp
12577 ) AS bucket_start,
12578 replica_id,
12579 jsonb_agg(
12580 jsonb_build_object(
12581 'replicaId',
12582 rsh.replica_id,
12583 'occurredAt',
12584 rsh.occurred_at,
12585 'status',
12586 rsh.status,
12587 'reason',
12588 rsh.reason
12589 )
12590 ) AS offline_events
12591 FROM mz_internal.mz_cluster_replica_status_history AS rsh -- We assume the statuses for process 0 are the same as all processes
12592 WHERE process_id = '0'
12593 AND status = 'offline'
12594 AND mz_now() <= date_bin(
12595 '8 HOURS',
12596 occurred_at,
12597 '1970-01-01'::timestamp
12598 ) + INTERVAL '14 DAYS'
12599 GROUP BY bucket_start,
12600 replica_id
12601)
12602SELECT
12603 bucket_start,
12604 replica_id,
12605 max_memory.memory_percent,
12606 max_memory.occurred_at as max_memory_at,
12607 max_disk.disk_percent,
12608 max_disk.occurred_at as max_disk_at,
12609 max_memory_and_disk.memory_and_disk_percent as memory_and_disk_percent,
12610 max_memory_and_disk.memory_percent as max_memory_and_disk_memory_percent,
12611 max_memory_and_disk.disk_percent as max_memory_and_disk_disk_percent,
12612 max_memory_and_disk.occurred_at as max_memory_and_disk_at,
12613 max_heap.heap_percent,
12614 max_heap.occurred_at as max_heap_at,
12615 max_cpu.cpu_percent as max_cpu_percent,
12616 max_cpu.occurred_at as max_cpu_at,
12617 replica_offline_event_history.offline_events,
12618 bucket_start + INTERVAL '8 HOURS' as bucket_end,
12619 replica_name_history.new_name AS name,
12620 replica_history.cluster_id,
12621 replica_history.size
12622FROM max_memory
12623JOIN max_disk USING (bucket_start, replica_id)
12624JOIN max_cpu USING (bucket_start, replica_id)
12625JOIN max_memory_and_disk USING (bucket_start, replica_id)
12626JOIN max_heap USING (bucket_start, replica_id)
12627JOIN replica_history USING (replica_id)
12628CROSS JOIN LATERAL (
12629 SELECT new_name
12630 FROM mz_internal.mz_cluster_replica_name_history as replica_name_history
12631 WHERE replica_id = replica_name_history.id -- We treat NULLs as the beginning of time
12632 AND bucket_start + INTERVAL '8 HOURS' >= COALESCE(
12633 replica_name_history.occurred_at,
12634 '1970-01-01'::timestamp
12635 )
12636 ORDER BY replica_name_history.occurred_at DESC
12637 LIMIT '1'
12638) AS replica_name_history
12639LEFT JOIN replica_offline_event_history USING (bucket_start, replica_id)"#,
12640 access: vec![PUBLIC_SELECT],
12641 }
12642});
12643
12644pub static MZ_CLUSTER_DEPLOYMENT_LINEAGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
12667 name: "mz_cluster_deployment_lineage",
12668 schema: MZ_INTERNAL_SCHEMA,
12669 oid: oid::VIEW_MZ_CLUSTER_DEPLOYMENT_LINEAGE_OID,
12670 desc: RelationDesc::builder()
12671 .with_column("cluster_id", SqlScalarType::String.nullable(true))
12672 .with_column(
12673 "current_deployment_cluster_id",
12674 SqlScalarType::String.nullable(false),
12675 )
12676 .with_column("cluster_name", SqlScalarType::String.nullable(false))
12677 .with_key(vec![0, 1, 2])
12678 .finish(),
12679 column_comments: BTreeMap::from_iter([
12680 (
12681 "cluster_id",
12682 "The ID of the cluster. Corresponds to `mz_clusters.id` (though the cluster may no longer exist).",
12683 ),
12684 (
12685 "current_deployment_cluster_id",
12686 "The cluster ID of the last cluster in `cluster_id`'s blue/green lineage (the cluster is guaranteed to exist).",
12687 ),
12688 ("cluster_name", "The name of the cluster"),
12689 ]),
12690 sql: r#"WITH MUTUALLY RECURSIVE cluster_events (
12691 cluster_id text,
12692 cluster_name text,
12693 event_type text,
12694 occurred_at timestamptz
12695) AS (
12696 SELECT coalesce(details->>'id', details->>'cluster_id') AS cluster_id,
12697 coalesce(details->>'name', details->>'new_name') AS cluster_name,
12698 event_type,
12699 occurred_at
12700 FROM mz_audit_events
12701 WHERE (
12702 event_type IN ('create', 'drop')
12703 OR (
12704 event_type = 'alter'
12705 AND details ? 'new_name'
12706 )
12707 )
12708 AND object_type = 'cluster'
12709 AND mz_now() < occurred_at + INTERVAL '30 days'
12710),
12711mz_cluster_deployment_lineage (
12712 cluster_id text,
12713 current_deployment_cluster_id text,
12714 cluster_name text
12715) AS (
12716 SELECT c.id,
12717 c.id,
12718 c.name
12719 FROM mz_clusters c
12720 WHERE c.id LIKE 'u%'
12721 UNION
12722 SELECT *
12723 FROM dropped_clusters
12724),
12725-- Closest create or rename event based on the current clusters in the result set
12726most_recent_create_or_rename (
12727 cluster_id text,
12728 current_deployment_cluster_id text,
12729 cluster_name text,
12730 occurred_at timestamptz
12731) AS (
12732 SELECT DISTINCT ON (e.cluster_id) e.cluster_id,
12733 c.current_deployment_cluster_id,
12734 e.cluster_name,
12735 e.occurred_at
12736 FROM mz_cluster_deployment_lineage c
12737 JOIN cluster_events e ON c.cluster_id = e.cluster_id
12738 AND c.cluster_name = e.cluster_name
12739 WHERE e.event_type <> 'drop'
12740 ORDER BY e.cluster_id,
12741 e.occurred_at DESC
12742),
12743-- Clusters that were dropped most recently within 1 minute of most_recent_create_or_rename
12744dropped_clusters (
12745 cluster_id text,
12746 current_deployment_cluster_id text,
12747 cluster_name text
12748) AS (
12749 SELECT DISTINCT ON (cr.cluster_id) e.cluster_id,
12750 cr.current_deployment_cluster_id,
12751 cr.cluster_name
12752 FROM most_recent_create_or_rename cr
12753 JOIN cluster_events e ON e.occurred_at BETWEEN cr.occurred_at - interval '1 minute'
12754 AND cr.occurred_at + interval '1 minute'
12755 AND (
12756 e.cluster_name = cr.cluster_name
12757 OR e.cluster_name = cr.cluster_name || '_dbt_deploy'
12758 )
12759 WHERE e.event_type = 'drop'
12760 ORDER BY cr.cluster_id,
12761 abs(
12762 extract(
12763 epoch
12764 FROM cr.occurred_at - e.occurred_at
12765 )
12766 )
12767)
12768SELECT *
12769FROM mz_cluster_deployment_lineage"#,
12770 access: vec![PUBLIC_SELECT],
12771});
12772
12773pub const MZ_SHOW_DATABASES_IND: BuiltinIndex = BuiltinIndex {
12774 name: "mz_show_databases_ind",
12775 schema: MZ_INTERNAL_SCHEMA,
12776 oid: oid::INDEX_MZ_SHOW_DATABASES_IND_OID,
12777 sql: "IN CLUSTER mz_catalog_server
12778ON mz_internal.mz_show_databases (name)",
12779 is_retained_metrics_object: false,
12780};
12781
12782pub const MZ_SHOW_SCHEMAS_IND: BuiltinIndex = BuiltinIndex {
12783 name: "mz_show_schemas_ind",
12784 schema: MZ_INTERNAL_SCHEMA,
12785 oid: oid::INDEX_MZ_SHOW_SCHEMAS_IND_OID,
12786 sql: "IN CLUSTER mz_catalog_server
12787ON mz_internal.mz_show_schemas (database_id)",
12788 is_retained_metrics_object: false,
12789};
12790
12791pub const MZ_SHOW_CONNECTIONS_IND: BuiltinIndex = BuiltinIndex {
12792 name: "mz_show_connections_ind",
12793 schema: MZ_INTERNAL_SCHEMA,
12794 oid: oid::INDEX_MZ_SHOW_CONNECTIONS_IND_OID,
12795 sql: "IN CLUSTER mz_catalog_server
12796ON mz_internal.mz_show_connections (schema_id)",
12797 is_retained_metrics_object: false,
12798};
12799
12800pub const MZ_SHOW_TABLES_IND: BuiltinIndex = BuiltinIndex {
12801 name: "mz_show_tables_ind",
12802 schema: MZ_INTERNAL_SCHEMA,
12803 oid: oid::INDEX_MZ_SHOW_TABLES_IND_OID,
12804 sql: "IN CLUSTER mz_catalog_server
12805ON mz_internal.mz_show_tables (schema_id)",
12806 is_retained_metrics_object: false,
12807};
12808
12809pub const MZ_SHOW_SOURCES_IND: BuiltinIndex = BuiltinIndex {
12810 name: "mz_show_sources_ind",
12811 schema: MZ_INTERNAL_SCHEMA,
12812 oid: oid::INDEX_MZ_SHOW_SOURCES_IND_OID,
12813 sql: "IN CLUSTER mz_catalog_server
12814ON mz_internal.mz_show_sources (schema_id)",
12815 is_retained_metrics_object: false,
12816};
12817
12818pub const MZ_SHOW_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12819 name: "mz_show_views_ind",
12820 schema: MZ_INTERNAL_SCHEMA,
12821 oid: oid::INDEX_MZ_SHOW_VIEWS_IND_OID,
12822 sql: "IN CLUSTER mz_catalog_server
12823ON mz_internal.mz_show_views (schema_id)",
12824 is_retained_metrics_object: false,
12825};
12826
12827pub const MZ_SHOW_MATERIALIZED_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12828 name: "mz_show_materialized_views_ind",
12829 schema: MZ_INTERNAL_SCHEMA,
12830 oid: oid::INDEX_MZ_SHOW_MATERIALIZED_VIEWS_IND_OID,
12831 sql: "IN CLUSTER mz_catalog_server
12832ON mz_internal.mz_show_materialized_views (schema_id)",
12833 is_retained_metrics_object: false,
12834};
12835
12836pub const MZ_SHOW_SINKS_IND: BuiltinIndex = BuiltinIndex {
12837 name: "mz_show_sinks_ind",
12838 schema: MZ_INTERNAL_SCHEMA,
12839 oid: oid::INDEX_MZ_SHOW_SINKS_IND_OID,
12840 sql: "IN CLUSTER mz_catalog_server
12841ON mz_internal.mz_show_sinks (schema_id)",
12842 is_retained_metrics_object: false,
12843};
12844
12845pub const MZ_SHOW_TYPES_IND: BuiltinIndex = BuiltinIndex {
12846 name: "mz_show_types_ind",
12847 schema: MZ_INTERNAL_SCHEMA,
12848 oid: oid::INDEX_MZ_SHOW_TYPES_IND_OID,
12849 sql: "IN CLUSTER mz_catalog_server
12850ON mz_internal.mz_show_types (schema_id)",
12851 is_retained_metrics_object: false,
12852};
12853
12854pub const MZ_SHOW_ROLES_IND: BuiltinIndex = BuiltinIndex {
12855 name: "mz_show_roles_ind",
12856 schema: MZ_INTERNAL_SCHEMA,
12857 oid: oid::INDEX_MZ_SHOW_ROLES_IND_OID,
12858 sql: "IN CLUSTER mz_catalog_server
12859ON mz_internal.mz_show_roles (name)",
12860 is_retained_metrics_object: false,
12861};
12862
12863pub const MZ_SHOW_ALL_OBJECTS_IND: BuiltinIndex = BuiltinIndex {
12864 name: "mz_show_all_objects_ind",
12865 schema: MZ_INTERNAL_SCHEMA,
12866 oid: oid::INDEX_MZ_SHOW_ALL_OBJECTS_IND_OID,
12867 sql: "IN CLUSTER mz_catalog_server
12868ON mz_internal.mz_show_all_objects (schema_id)",
12869 is_retained_metrics_object: false,
12870};
12871
12872pub const MZ_SHOW_INDEXES_IND: BuiltinIndex = BuiltinIndex {
12873 name: "mz_show_indexes_ind",
12874 schema: MZ_INTERNAL_SCHEMA,
12875 oid: oid::INDEX_MZ_SHOW_INDEXES_IND_OID,
12876 sql: "IN CLUSTER mz_catalog_server
12877ON mz_internal.mz_show_indexes (schema_id)",
12878 is_retained_metrics_object: false,
12879};
12880
12881pub const MZ_SHOW_COLUMNS_IND: BuiltinIndex = BuiltinIndex {
12882 name: "mz_show_columns_ind",
12883 schema: MZ_INTERNAL_SCHEMA,
12884 oid: oid::INDEX_MZ_SHOW_COLUMNS_IND_OID,
12885 sql: "IN CLUSTER mz_catalog_server
12886ON mz_internal.mz_show_columns (id)",
12887 is_retained_metrics_object: false,
12888};
12889
12890pub const MZ_SHOW_CLUSTERS_IND: BuiltinIndex = BuiltinIndex {
12891 name: "mz_show_clusters_ind",
12892 schema: MZ_INTERNAL_SCHEMA,
12893 oid: oid::INDEX_MZ_SHOW_CLUSTERS_IND_OID,
12894 sql: "IN CLUSTER mz_catalog_server
12895ON mz_internal.mz_show_clusters (name)",
12896 is_retained_metrics_object: false,
12897};
12898
12899pub const MZ_SHOW_CLUSTER_REPLICAS_IND: BuiltinIndex = BuiltinIndex {
12900 name: "mz_show_cluster_replicas_ind",
12901 schema: MZ_INTERNAL_SCHEMA,
12902 oid: oid::INDEX_MZ_SHOW_CLUSTER_REPLICAS_IND_OID,
12903 sql: "IN CLUSTER mz_catalog_server
12904ON mz_internal.mz_show_cluster_replicas (cluster)",
12905 is_retained_metrics_object: false,
12906};
12907
12908pub const MZ_SHOW_SECRETS_IND: BuiltinIndex = BuiltinIndex {
12909 name: "mz_show_secrets_ind",
12910 schema: MZ_INTERNAL_SCHEMA,
12911 oid: oid::INDEX_MZ_SHOW_SECRETS_IND_OID,
12912 sql: "IN CLUSTER mz_catalog_server
12913ON mz_internal.mz_show_secrets (schema_id)",
12914 is_retained_metrics_object: false,
12915};
12916
12917pub const MZ_DATABASES_IND: BuiltinIndex = BuiltinIndex {
12918 name: "mz_databases_ind",
12919 schema: MZ_CATALOG_SCHEMA,
12920 oid: oid::INDEX_MZ_DATABASES_IND_OID,
12921 sql: "IN CLUSTER mz_catalog_server
12922ON mz_catalog.mz_databases (name)",
12923 is_retained_metrics_object: false,
12924};
12925
12926pub const MZ_SCHEMAS_IND: BuiltinIndex = BuiltinIndex {
12927 name: "mz_schemas_ind",
12928 schema: MZ_CATALOG_SCHEMA,
12929 oid: oid::INDEX_MZ_SCHEMAS_IND_OID,
12930 sql: "IN CLUSTER mz_catalog_server
12931ON mz_catalog.mz_schemas (database_id)",
12932 is_retained_metrics_object: false,
12933};
12934
12935pub const MZ_CONNECTIONS_IND: BuiltinIndex = BuiltinIndex {
12936 name: "mz_connections_ind",
12937 schema: MZ_CATALOG_SCHEMA,
12938 oid: oid::INDEX_MZ_CONNECTIONS_IND_OID,
12939 sql: "IN CLUSTER mz_catalog_server
12940ON mz_catalog.mz_connections (schema_id)",
12941 is_retained_metrics_object: false,
12942};
12943
12944pub const MZ_TABLES_IND: BuiltinIndex = BuiltinIndex {
12945 name: "mz_tables_ind",
12946 schema: MZ_CATALOG_SCHEMA,
12947 oid: oid::INDEX_MZ_TABLES_IND_OID,
12948 sql: "IN CLUSTER mz_catalog_server
12949ON mz_catalog.mz_tables (schema_id)",
12950 is_retained_metrics_object: false,
12951};
12952
12953pub const MZ_TYPES_IND: BuiltinIndex = BuiltinIndex {
12954 name: "mz_types_ind",
12955 schema: MZ_CATALOG_SCHEMA,
12956 oid: oid::INDEX_MZ_TYPES_IND_OID,
12957 sql: "IN CLUSTER mz_catalog_server
12958ON mz_catalog.mz_types (schema_id)",
12959 is_retained_metrics_object: false,
12960};
12961
12962pub const MZ_OBJECTS_IND: BuiltinIndex = BuiltinIndex {
12963 name: "mz_objects_ind",
12964 schema: MZ_CATALOG_SCHEMA,
12965 oid: oid::INDEX_MZ_OBJECTS_IND_OID,
12966 sql: "IN CLUSTER mz_catalog_server
12967ON mz_catalog.mz_objects (schema_id)",
12968 is_retained_metrics_object: false,
12969};
12970
12971pub const MZ_COLUMNS_IND: BuiltinIndex = BuiltinIndex {
12972 name: "mz_columns_ind",
12973 schema: MZ_CATALOG_SCHEMA,
12974 oid: oid::INDEX_MZ_COLUMNS_IND_OID,
12975 sql: "IN CLUSTER mz_catalog_server
12976ON mz_catalog.mz_columns (name)",
12977 is_retained_metrics_object: false,
12978};
12979
12980pub const MZ_SECRETS_IND: BuiltinIndex = BuiltinIndex {
12981 name: "mz_secrets_ind",
12982 schema: MZ_CATALOG_SCHEMA,
12983 oid: oid::INDEX_MZ_SECRETS_IND_OID,
12984 sql: "IN CLUSTER mz_catalog_server
12985ON mz_catalog.mz_secrets (name)",
12986 is_retained_metrics_object: false,
12987};
12988
12989pub const MZ_VIEWS_IND: BuiltinIndex = BuiltinIndex {
12990 name: "mz_views_ind",
12991 schema: MZ_CATALOG_SCHEMA,
12992 oid: oid::INDEX_MZ_VIEWS_IND_OID,
12993 sql: "IN CLUSTER mz_catalog_server
12994ON mz_catalog.mz_views (schema_id)",
12995 is_retained_metrics_object: false,
12996};
12997
12998pub const MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_IND: BuiltinIndex = BuiltinIndex {
12999 name: "mz_console_cluster_utilization_overview_ind",
13000 schema: MZ_INTERNAL_SCHEMA,
13001 oid: oid::INDEX_MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_IND_OID,
13002 sql: "IN CLUSTER mz_catalog_server
13003ON mz_internal.mz_console_cluster_utilization_overview (cluster_id)",
13004 is_retained_metrics_object: false,
13005};
13006
13007pub const MZ_CLUSTER_DEPLOYMENT_LINEAGE_IND: BuiltinIndex = BuiltinIndex {
13008 name: "mz_cluster_deployment_lineage_ind",
13009 schema: MZ_INTERNAL_SCHEMA,
13010 oid: oid::INDEX_MZ_CLUSTER_DEPLOYMENT_LINEAGE_IND_OID,
13011 sql: "IN CLUSTER mz_catalog_server
13012ON mz_internal.mz_cluster_deployment_lineage (cluster_id)",
13013 is_retained_metrics_object: false,
13014};
13015
13016pub const MZ_CLUSTERS_IND: BuiltinIndex = BuiltinIndex {
13017 name: "mz_clusters_ind",
13018 schema: MZ_CATALOG_SCHEMA,
13019 oid: oid::INDEX_MZ_CLUSTERS_IND_OID,
13020 sql: "IN CLUSTER mz_catalog_server
13021ON mz_catalog.mz_clusters (id)",
13022 is_retained_metrics_object: false,
13023};
13024
13025pub const MZ_INDEXES_IND: BuiltinIndex = BuiltinIndex {
13026 name: "mz_indexes_ind",
13027 schema: MZ_CATALOG_SCHEMA,
13028 oid: oid::INDEX_MZ_INDEXES_IND_OID,
13029 sql: "IN CLUSTER mz_catalog_server
13030ON mz_catalog.mz_indexes (id)",
13031 is_retained_metrics_object: false,
13032};
13033
13034pub const MZ_ROLES_IND: BuiltinIndex = BuiltinIndex {
13035 name: "mz_roles_ind",
13036 schema: MZ_CATALOG_SCHEMA,
13037 oid: oid::INDEX_MZ_ROLES_IND_OID,
13038 sql: "IN CLUSTER mz_catalog_server
13039ON mz_catalog.mz_roles (id)",
13040 is_retained_metrics_object: false,
13041};
13042
13043pub const MZ_SOURCES_IND: BuiltinIndex = BuiltinIndex {
13044 name: "mz_sources_ind",
13045 schema: MZ_CATALOG_SCHEMA,
13046 oid: oid::INDEX_MZ_SOURCES_IND_OID,
13047 sql: "IN CLUSTER mz_catalog_server
13048ON mz_catalog.mz_sources (id)",
13049 is_retained_metrics_object: true,
13050};
13051
13052pub const MZ_SINKS_IND: BuiltinIndex = BuiltinIndex {
13053 name: "mz_sinks_ind",
13054 schema: MZ_CATALOG_SCHEMA,
13055 oid: oid::INDEX_MZ_SINKS_IND_OID,
13056 sql: "IN CLUSTER mz_catalog_server
13057ON mz_catalog.mz_sinks (id)",
13058 is_retained_metrics_object: true,
13059};
13060
13061pub const MZ_MATERIALIZED_VIEWS_IND: BuiltinIndex = BuiltinIndex {
13062 name: "mz_materialized_views_ind",
13063 schema: MZ_CATALOG_SCHEMA,
13064 oid: oid::INDEX_MZ_MATERIALIZED_VIEWS_IND_OID,
13065 sql: "IN CLUSTER mz_catalog_server
13066ON mz_catalog.mz_materialized_views (id)",
13067 is_retained_metrics_object: false,
13068};
13069
13070pub const MZ_CONTINUAL_TASKS_IND: BuiltinIndex = BuiltinIndex {
13071 name: "mz_continual_tasks_ind",
13072 schema: MZ_INTERNAL_SCHEMA,
13073 oid: oid::INDEX_MZ_CONTINUAL_TASKS_IND_OID,
13074 sql: "IN CLUSTER mz_catalog_server
13075ON mz_internal.mz_continual_tasks (id)",
13076 is_retained_metrics_object: false,
13077};
13078
13079pub const MZ_SOURCE_STATUSES_IND: BuiltinIndex = BuiltinIndex {
13080 name: "mz_source_statuses_ind",
13081 schema: MZ_INTERNAL_SCHEMA,
13082 oid: oid::INDEX_MZ_SOURCE_STATUSES_IND_OID,
13083 sql: "IN CLUSTER mz_catalog_server
13084ON mz_internal.mz_source_statuses (id)",
13085 is_retained_metrics_object: false,
13086};
13087
13088pub const MZ_SINK_STATUSES_IND: BuiltinIndex = BuiltinIndex {
13089 name: "mz_sink_statuses_ind",
13090 schema: MZ_INTERNAL_SCHEMA,
13091 oid: oid::INDEX_MZ_SINK_STATUSES_IND_OID,
13092 sql: "IN CLUSTER mz_catalog_server
13093ON mz_internal.mz_sink_statuses (id)",
13094 is_retained_metrics_object: false,
13095};
13096
13097pub const MZ_SOURCE_STATUS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13098 name: "mz_source_status_history_ind",
13099 schema: MZ_INTERNAL_SCHEMA,
13100 oid: oid::INDEX_MZ_SOURCE_STATUS_HISTORY_IND_OID,
13101 sql: "IN CLUSTER mz_catalog_server
13102ON mz_internal.mz_source_status_history (source_id)",
13103 is_retained_metrics_object: false,
13104};
13105
13106pub const MZ_SINK_STATUS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13107 name: "mz_sink_status_history_ind",
13108 schema: MZ_INTERNAL_SCHEMA,
13109 oid: oid::INDEX_MZ_SINK_STATUS_HISTORY_IND_OID,
13110 sql: "IN CLUSTER mz_catalog_server
13111ON mz_internal.mz_sink_status_history (sink_id)",
13112 is_retained_metrics_object: false,
13113};
13114
13115pub const MZ_SHOW_CONTINUAL_TASKS_IND: BuiltinIndex = BuiltinIndex {
13116 name: "mz_show_continual_tasks_ind",
13117 schema: MZ_INTERNAL_SCHEMA,
13118 oid: oid::INDEX_MZ_SHOW_CONTINUAL_TASKS_OID,
13119 sql: "IN CLUSTER mz_catalog_server
13120ON mz_internal.mz_show_continual_tasks (id)",
13121 is_retained_metrics_object: false,
13122};
13123
13124pub static MZ_SOURCE_STATISTICS_WITH_HISTORY: LazyLock<BuiltinView> =
13137 LazyLock::new(|| BuiltinView {
13138 name: "mz_source_statistics_with_history",
13139 schema: MZ_INTERNAL_SCHEMA,
13140 oid: oid::VIEW_MZ_SOURCE_STATISTICS_WITH_HISTORY_OID,
13141 desc: RelationDesc::builder()
13142 .with_column("id", SqlScalarType::String.nullable(false))
13143 .with_column("replica_id", SqlScalarType::String.nullable(true))
13144 .with_column("messages_received", SqlScalarType::UInt64.nullable(false))
13145 .with_column("bytes_received", SqlScalarType::UInt64.nullable(false))
13146 .with_column("updates_staged", SqlScalarType::UInt64.nullable(false))
13147 .with_column("updates_committed", SqlScalarType::UInt64.nullable(false))
13148 .with_column("records_indexed", SqlScalarType::UInt64.nullable(false))
13149 .with_column("bytes_indexed", SqlScalarType::UInt64.nullable(false))
13150 .with_column(
13151 "rehydration_latency",
13152 SqlScalarType::Interval.nullable(true),
13153 )
13154 .with_column(
13155 "snapshot_records_known",
13156 SqlScalarType::UInt64.nullable(true),
13157 )
13158 .with_column(
13159 "snapshot_records_staged",
13160 SqlScalarType::UInt64.nullable(true),
13161 )
13162 .with_column("snapshot_committed", SqlScalarType::Bool.nullable(false))
13163 .with_column("offset_known", SqlScalarType::UInt64.nullable(true))
13164 .with_column("offset_committed", SqlScalarType::UInt64.nullable(true))
13165 .with_key(vec![0, 1])
13166 .finish(),
13167 column_comments: BTreeMap::new(),
13168 sql: "
13169WITH
13170 -- For each subsource, statistics are reported as its parent source
13171 subsource_to_parent AS
13172 (
13173 SELECT subsource.id AS id, parent.id AS report_id
13174 FROM mz_catalog.mz_sources AS subsource
13175 JOIN mz_internal.mz_object_dependencies AS dep ON subsource.id = dep.object_id
13176 JOIN mz_catalog.mz_sources AS parent ON parent.id = dep.referenced_object_id
13177 WHERE subsource.type = 'subsource'
13178 ),
13179 -- For each table from source, statistics are reported as its parent source
13180 table_to_parent AS
13181 (
13182 SELECT id, source_id AS report_id
13183 FROM mz_catalog.mz_tables
13184 WHERE source_id IS NOT NULL
13185 ),
13186 -- For each source and subsource, statistics are reported as itself
13187 source_refl AS
13188 (
13189 SELECT id, id AS report_id
13190 FROM mz_catalog.mz_sources
13191 WHERE type NOT IN ('progress', 'log')
13192 ),
13193 -- For each table from source, statistics are reported as itself
13194 table_refl AS
13195 (
13196 SELECT id, id AS report_id
13197 FROM mz_catalog.mz_tables
13198 WHERE source_id IS NOT NULL
13199 ),
13200 report_paths AS
13201 (
13202 SELECT id, report_id FROM subsource_to_parent
13203 UNION ALL SELECT id, report_id FROM table_to_parent
13204 UNION ALL SELECT id, report_id FROM source_refl
13205 UNION ALL SELECT id, report_id FROM table_refl
13206 )
13207SELECT
13208 report_paths.report_id AS id,
13209 replica_id,
13210 -- Counters
13211 SUM(messages_received)::uint8 AS messages_received,
13212 SUM(bytes_received)::uint8 AS bytes_received,
13213 SUM(updates_staged)::uint8 AS updates_staged,
13214 SUM(updates_committed)::uint8 AS updates_committed,
13215 -- Resetting Gauges
13216 SUM(records_indexed)::uint8 AS records_indexed,
13217 SUM(bytes_indexed)::uint8 AS bytes_indexed,
13218 -- Ensure we aggregate to NULL when not all workers are done rehydrating.
13219 CASE
13220 WHEN bool_or(rehydration_latency IS NULL) THEN NULL
13221 ELSE MAX(rehydration_latency)::interval
13222 END AS rehydration_latency,
13223 SUM(snapshot_records_known)::uint8 AS snapshot_records_known,
13224 SUM(snapshot_records_staged)::uint8 AS snapshot_records_staged,
13225 bool_and(snapshot_committed) as snapshot_committed,
13226 -- Gauges
13227 MAX(offset_known)::uint8 AS offset_known,
13228 MIN(offset_committed)::uint8 AS offset_committed
13229FROM mz_internal.mz_source_statistics_raw
13230 JOIN report_paths USING (id)
13231GROUP BY report_paths.report_id, replica_id",
13232 access: vec![PUBLIC_SELECT],
13233 });
13234
13235pub const MZ_SOURCE_STATISTICS_WITH_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13236 name: "mz_source_statistics_with_history_ind",
13237 schema: MZ_INTERNAL_SCHEMA,
13238 oid: oid::INDEX_MZ_SOURCE_STATISTICS_WITH_HISTORY_IND_OID,
13239 sql: "IN CLUSTER mz_catalog_server
13240ON mz_internal.mz_source_statistics_with_history (id, replica_id)",
13241 is_retained_metrics_object: true,
13242};
13243
13244pub static MZ_SOURCE_STATISTICS: LazyLock<BuiltinView> = LazyLock::new(|| {
13247 BuiltinView {
13248 name: "mz_source_statistics",
13249 schema: MZ_INTERNAL_SCHEMA,
13250 oid: oid::VIEW_MZ_SOURCE_STATISTICS_OID,
13251 desc: RelationDesc::builder()
13253 .with_column("id", SqlScalarType::String.nullable(false))
13254 .with_column("replica_id", SqlScalarType::String.nullable(true))
13255 .with_column("messages_received", SqlScalarType::UInt64.nullable(false))
13256 .with_column("bytes_received", SqlScalarType::UInt64.nullable(false))
13257 .with_column("updates_staged", SqlScalarType::UInt64.nullable(false))
13258 .with_column("updates_committed", SqlScalarType::UInt64.nullable(false))
13259 .with_column("records_indexed", SqlScalarType::UInt64.nullable(false))
13260 .with_column("bytes_indexed", SqlScalarType::UInt64.nullable(false))
13261 .with_column(
13262 "rehydration_latency",
13263 SqlScalarType::Interval.nullable(true),
13264 )
13265 .with_column(
13266 "snapshot_records_known",
13267 SqlScalarType::UInt64.nullable(true),
13268 )
13269 .with_column(
13270 "snapshot_records_staged",
13271 SqlScalarType::UInt64.nullable(true),
13272 )
13273 .with_column("snapshot_committed", SqlScalarType::Bool.nullable(false))
13274 .with_column("offset_known", SqlScalarType::UInt64.nullable(true))
13275 .with_column("offset_committed", SqlScalarType::UInt64.nullable(true))
13276 .with_key(vec![0, 1])
13277 .finish(),
13278 column_comments: BTreeMap::from_iter([
13279 (
13280 "id",
13281 "The ID of the source. Corresponds to `mz_catalog.mz_sources.id`.",
13282 ),
13283 (
13284 "replica_id",
13285 "The ID of a replica running the source. Corresponds to `mz_catalog.mz_cluster_replicas.id`.",
13286 ),
13287 (
13288 "messages_received",
13289 "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.",
13290 ),
13291 (
13292 "bytes_received",
13293 "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.",
13294 ),
13295 (
13296 "updates_staged",
13297 "The number of updates (insertions plus deletions) the source has written but not yet committed to the storage layer.",
13298 ),
13299 (
13300 "updates_committed",
13301 "The number of updates (insertions plus deletions) the source has committed to the storage layer.",
13302 ),
13303 (
13304 "records_indexed",
13305 "The number of individual records indexed in the source envelope state.",
13306 ),
13307 (
13308 "bytes_indexed",
13309 "The number of bytes stored in the source's internal index, if any.",
13310 ),
13311 (
13312 "rehydration_latency",
13313 "The amount of time it took for the source to rehydrate its internal index, if any, after the source last restarted.",
13314 ),
13315 (
13316 "snapshot_records_known",
13317 "The size of the source's snapshot, measured in number of records. See below to learn what constitutes a record.",
13318 ),
13319 (
13320 "snapshot_records_staged",
13321 "The number of records in the source's snapshot that Materialize has read. See below to learn what constitutes a record.",
13322 ),
13323 (
13324 "snapshot_committed",
13325 "Whether the source has committed the initial snapshot for a source.",
13326 ),
13327 (
13328 "offset_known",
13329 "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.",
13330 ),
13331 (
13332 "offset_committed",
13333 "The offset of the the data that Materialize has durably ingested. See below to learn what constitutes an offset.",
13334 ),
13335 ]),
13336 sql: "SELECT * FROM mz_internal.mz_source_statistics_with_history WHERE length(id) > 0",
13337 access: vec![PUBLIC_SELECT],
13338 }
13339});
13340
13341pub const MZ_SOURCE_STATISTICS_IND: BuiltinIndex = BuiltinIndex {
13342 name: "mz_source_statistics_ind",
13343 schema: MZ_INTERNAL_SCHEMA,
13344 oid: oid::INDEX_MZ_SOURCE_STATISTICS_IND_OID,
13345 sql: "IN CLUSTER mz_catalog_server
13346ON mz_internal.mz_source_statistics (id, replica_id)",
13347 is_retained_metrics_object: false,
13348};
13349
13350pub static MZ_SINK_STATISTICS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
13351 name: "mz_sink_statistics",
13352 schema: MZ_INTERNAL_SCHEMA,
13353 oid: oid::VIEW_MZ_SINK_STATISTICS_OID,
13354 desc: RelationDesc::builder()
13355 .with_column("id", SqlScalarType::String.nullable(false))
13356 .with_column("replica_id", SqlScalarType::String.nullable(true))
13357 .with_column("messages_staged", SqlScalarType::UInt64.nullable(false))
13358 .with_column("messages_committed", SqlScalarType::UInt64.nullable(false))
13359 .with_column("bytes_staged", SqlScalarType::UInt64.nullable(false))
13360 .with_column("bytes_committed", SqlScalarType::UInt64.nullable(false))
13361 .with_key(vec![0, 1])
13362 .finish(),
13363 column_comments: BTreeMap::from_iter([
13364 (
13365 "id",
13366 "The ID of the sink. Corresponds to `mz_catalog.mz_sources.id`.",
13367 ),
13368 (
13369 "replica_id",
13370 "The ID of a replica running the sink. Corresponds to `mz_catalog.mz_cluster_replicas.id`.",
13371 ),
13372 (
13373 "messages_staged",
13374 "The number of messages staged but possibly not committed to the sink.",
13375 ),
13376 (
13377 "messages_committed",
13378 "The number of messages committed to the sink.",
13379 ),
13380 (
13381 "bytes_staged",
13382 "The number of bytes staged but possibly not committed to the sink. This counts both keys and values, if applicable.",
13383 ),
13384 (
13385 "bytes_committed",
13386 "The number of bytes committed to the sink. This counts both keys and values, if applicable.",
13387 ),
13388 ]),
13389 sql: "
13390SELECT
13391 id,
13392 replica_id,
13393 SUM(messages_staged)::uint8 AS messages_staged,
13394 SUM(messages_committed)::uint8 AS messages_committed,
13395 SUM(bytes_staged)::uint8 AS bytes_staged,
13396 SUM(bytes_committed)::uint8 AS bytes_committed
13397FROM mz_internal.mz_sink_statistics_raw
13398GROUP BY id, replica_id",
13399 access: vec![PUBLIC_SELECT],
13400});
13401
13402pub const MZ_SINK_STATISTICS_IND: BuiltinIndex = BuiltinIndex {
13403 name: "mz_sink_statistics_ind",
13404 schema: MZ_INTERNAL_SCHEMA,
13405 oid: oid::INDEX_MZ_SINK_STATISTICS_IND_OID,
13406 sql: "IN CLUSTER mz_catalog_server
13407ON mz_internal.mz_sink_statistics (id, replica_id)",
13408 is_retained_metrics_object: true,
13409};
13410
13411pub const MZ_CLUSTER_REPLICAS_IND: BuiltinIndex = BuiltinIndex {
13412 name: "mz_cluster_replicas_ind",
13413 schema: MZ_CATALOG_SCHEMA,
13414 oid: oid::INDEX_MZ_CLUSTER_REPLICAS_IND_OID,
13415 sql: "IN CLUSTER mz_catalog_server
13416ON mz_catalog.mz_cluster_replicas (id)",
13417 is_retained_metrics_object: true,
13418};
13419
13420pub const MZ_CLUSTER_REPLICA_SIZES_IND: BuiltinIndex = BuiltinIndex {
13421 name: "mz_cluster_replica_sizes_ind",
13422 schema: MZ_CATALOG_SCHEMA,
13423 oid: oid::INDEX_MZ_CLUSTER_REPLICA_SIZES_IND_OID,
13424 sql: "IN CLUSTER mz_catalog_server
13425ON mz_catalog.mz_cluster_replica_sizes (size)",
13426 is_retained_metrics_object: true,
13427};
13428
13429pub const MZ_CLUSTER_REPLICA_STATUSES_IND: BuiltinIndex = BuiltinIndex {
13430 name: "mz_cluster_replica_statuses_ind",
13431 schema: MZ_INTERNAL_SCHEMA,
13432 oid: oid::INDEX_MZ_CLUSTER_REPLICA_STATUSES_IND_OID,
13433 sql: "IN CLUSTER mz_catalog_server
13434ON mz_internal.mz_cluster_replica_statuses (replica_id)",
13435 is_retained_metrics_object: false,
13436};
13437
13438pub const MZ_CLUSTER_REPLICA_STATUS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13439 name: "mz_cluster_replica_status_history_ind",
13440 schema: MZ_INTERNAL_SCHEMA,
13441 oid: oid::INDEX_MZ_CLUSTER_REPLICA_STATUS_HISTORY_IND_OID,
13442 sql: "IN CLUSTER mz_catalog_server
13443ON mz_internal.mz_cluster_replica_status_history (replica_id)",
13444 is_retained_metrics_object: false,
13445};
13446
13447pub const MZ_CLUSTER_REPLICA_METRICS_IND: BuiltinIndex = BuiltinIndex {
13448 name: "mz_cluster_replica_metrics_ind",
13449 schema: MZ_INTERNAL_SCHEMA,
13450 oid: oid::INDEX_MZ_CLUSTER_REPLICA_METRICS_IND_OID,
13451 sql: "IN CLUSTER mz_catalog_server
13452ON mz_internal.mz_cluster_replica_metrics (replica_id)",
13453 is_retained_metrics_object: false,
13454};
13455
13456pub const MZ_CLUSTER_REPLICA_METRICS_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13457 name: "mz_cluster_replica_metrics_history_ind",
13458 schema: MZ_INTERNAL_SCHEMA,
13459 oid: oid::INDEX_MZ_CLUSTER_REPLICA_METRICS_HISTORY_IND_OID,
13460 sql: "IN CLUSTER mz_catalog_server
13461ON mz_internal.mz_cluster_replica_metrics_history (replica_id)",
13462 is_retained_metrics_object: false,
13463};
13464
13465pub const MZ_CLUSTER_REPLICA_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13466 name: "mz_cluster_replica_history_ind",
13467 schema: MZ_INTERNAL_SCHEMA,
13468 oid: oid::INDEX_MZ_CLUSTER_REPLICA_HISTORY_IND_OID,
13469 sql: "IN CLUSTER mz_catalog_server
13470ON mz_internal.mz_cluster_replica_history (dropped_at)",
13471 is_retained_metrics_object: true,
13472};
13473
13474pub const MZ_CLUSTER_REPLICA_NAME_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13475 name: "mz_cluster_replica_name_history_ind",
13476 schema: MZ_INTERNAL_SCHEMA,
13477 oid: oid::INDEX_MZ_CLUSTER_REPLICA_NAME_HISTORY_IND_OID,
13478 sql: "IN CLUSTER mz_catalog_server
13479ON mz_internal.mz_cluster_replica_name_history (id)",
13480 is_retained_metrics_object: false,
13481};
13482
13483pub const MZ_OBJECT_LIFETIMES_IND: BuiltinIndex = BuiltinIndex {
13484 name: "mz_object_lifetimes_ind",
13485 schema: MZ_INTERNAL_SCHEMA,
13486 oid: oid::INDEX_MZ_OBJECT_LIFETIMES_IND_OID,
13487 sql: "IN CLUSTER mz_catalog_server
13488ON mz_internal.mz_object_lifetimes (id)",
13489 is_retained_metrics_object: false,
13490};
13491
13492pub const MZ_OBJECT_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13493 name: "mz_object_history_ind",
13494 schema: MZ_INTERNAL_SCHEMA,
13495 oid: oid::INDEX_MZ_OBJECT_HISTORY_IND_OID,
13496 sql: "IN CLUSTER mz_catalog_server
13497ON mz_internal.mz_object_history (id)",
13498 is_retained_metrics_object: false,
13499};
13500
13501pub const MZ_OBJECT_DEPENDENCIES_IND: BuiltinIndex = BuiltinIndex {
13502 name: "mz_object_dependencies_ind",
13503 schema: MZ_INTERNAL_SCHEMA,
13504 oid: oid::INDEX_MZ_OBJECT_DEPENDENCIES_IND_OID,
13505 sql: "IN CLUSTER mz_catalog_server
13506ON mz_internal.mz_object_dependencies (object_id)",
13507 is_retained_metrics_object: true,
13508};
13509
13510pub const MZ_COMPUTE_DEPENDENCIES_IND: BuiltinIndex = BuiltinIndex {
13511 name: "mz_compute_dependencies_ind",
13512 schema: MZ_INTERNAL_SCHEMA,
13513 oid: oid::INDEX_MZ_COMPUTE_DEPENDENCIES_IND_OID,
13514 sql: "IN CLUSTER mz_catalog_server
13515ON mz_internal.mz_compute_dependencies (dependency_id)",
13516 is_retained_metrics_object: false,
13517};
13518
13519pub const MZ_OBJECT_TRANSITIVE_DEPENDENCIES_IND: BuiltinIndex = BuiltinIndex {
13520 name: "mz_object_transitive_dependencies_ind",
13521 schema: MZ_INTERNAL_SCHEMA,
13522 oid: oid::INDEX_MZ_OBJECT_TRANSITIVE_DEPENDENCIES_IND_OID,
13523 sql: "IN CLUSTER mz_catalog_server
13524ON mz_internal.mz_object_transitive_dependencies (object_id)",
13525 is_retained_metrics_object: false,
13526};
13527
13528pub const MZ_FRONTIERS_IND: BuiltinIndex = BuiltinIndex {
13529 name: "mz_frontiers_ind",
13530 schema: MZ_INTERNAL_SCHEMA,
13531 oid: oid::INDEX_MZ_FRONTIERS_IND_OID,
13532 sql: "IN CLUSTER mz_catalog_server
13533ON mz_internal.mz_frontiers (object_id)",
13534 is_retained_metrics_object: false,
13535};
13536
13537pub const MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_IND: BuiltinIndex = BuiltinIndex {
13538 name: "mz_wallclock_global_lag_recent_history_ind",
13539 schema: MZ_INTERNAL_SCHEMA,
13540 oid: oid::INDEX_MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_IND_OID,
13541 sql: "IN CLUSTER mz_catalog_server
13542ON mz_internal.mz_wallclock_global_lag_recent_history (object_id)",
13543 is_retained_metrics_object: false,
13544};
13545
13546pub const MZ_RECENT_ACTIVITY_LOG_THINNED_IND: BuiltinIndex = BuiltinIndex {
13547 name: "mz_recent_activity_log_thinned_ind",
13548 schema: MZ_INTERNAL_SCHEMA,
13549 oid: oid::INDEX_MZ_RECENT_ACTIVITY_LOG_THINNED_IND_OID,
13550 sql: "IN CLUSTER mz_catalog_server
13551-- sql_hash because we plan to join
13552-- this against mz_internal.mz_sql_text
13553ON mz_internal.mz_recent_activity_log_thinned (sql_hash)",
13554 is_retained_metrics_object: false,
13555};
13556
13557pub const MZ_KAFKA_SOURCES_IND: BuiltinIndex = BuiltinIndex {
13558 name: "mz_kafka_sources_ind",
13559 schema: MZ_CATALOG_SCHEMA,
13560 oid: oid::INDEX_MZ_KAFKA_SOURCES_IND_OID,
13561 sql: "IN CLUSTER mz_catalog_server
13562ON mz_catalog.mz_kafka_sources (id)",
13563 is_retained_metrics_object: true,
13564};
13565
13566pub const MZ_WEBHOOK_SOURCES_IND: BuiltinIndex = BuiltinIndex {
13567 name: "mz_webhook_sources_ind",
13568 schema: MZ_INTERNAL_SCHEMA,
13569 oid: oid::INDEX_MZ_WEBHOOK_SOURCES_IND_OID,
13570 sql: "IN CLUSTER mz_catalog_server
13571ON mz_internal.mz_webhook_sources (id)",
13572 is_retained_metrics_object: true,
13573};
13574
13575pub const MZ_COMMENTS_IND: BuiltinIndex = BuiltinIndex {
13576 name: "mz_comments_ind",
13577 schema: MZ_INTERNAL_SCHEMA,
13578 oid: oid::INDEX_MZ_COMMENTS_IND_OID,
13579 sql: "IN CLUSTER mz_catalog_server
13580ON mz_internal.mz_comments (id)",
13581 is_retained_metrics_object: true,
13582};
13583
13584pub static MZ_ANALYTICS: BuiltinConnection = BuiltinConnection {
13585 name: "mz_analytics",
13586 schema: MZ_INTERNAL_SCHEMA,
13587 oid: oid::CONNECTION_MZ_ANALYTICS_OID,
13588 sql: "CREATE CONNECTION mz_internal.mz_analytics TO AWS (ASSUME ROLE ARN = '')",
13589 access: &[MzAclItem {
13590 grantee: MZ_SYSTEM_ROLE_ID,
13591 grantor: MZ_ANALYTICS_ROLE_ID,
13592 acl_mode: rbac::all_object_privileges(SystemObjectType::Object(ObjectType::Connection)),
13593 }],
13594 owner_id: &MZ_ANALYTICS_ROLE_ID,
13595 runtime_alterable: true,
13596};
13597
13598pub const MZ_SYSTEM_ROLE: BuiltinRole = BuiltinRole {
13599 id: MZ_SYSTEM_ROLE_ID,
13600 name: SYSTEM_USER_NAME,
13601 oid: oid::ROLE_MZ_SYSTEM_OID,
13602 attributes: RoleAttributesRaw::new().with_all(),
13603};
13604
13605pub const MZ_SUPPORT_ROLE: BuiltinRole = BuiltinRole {
13606 id: MZ_SUPPORT_ROLE_ID,
13607 name: SUPPORT_USER_NAME,
13608 oid: oid::ROLE_MZ_SUPPORT_OID,
13609 attributes: RoleAttributesRaw::new(),
13610};
13611
13612pub const MZ_ANALYTICS_ROLE: BuiltinRole = BuiltinRole {
13613 id: MZ_ANALYTICS_ROLE_ID,
13614 name: ANALYTICS_USER_NAME,
13615 oid: oid::ROLE_MZ_ANALYTICS_OID,
13616 attributes: RoleAttributesRaw::new(),
13617};
13618
13619pub const MZ_MONITOR_ROLE: BuiltinRole = BuiltinRole {
13622 id: MZ_MONITOR_ROLE_ID,
13623 name: "mz_monitor",
13624 oid: oid::ROLE_MZ_MONITOR_OID,
13625 attributes: RoleAttributesRaw::new(),
13626};
13627
13628pub const MZ_MONITOR_REDACTED: BuiltinRole = BuiltinRole {
13631 id: MZ_MONITOR_REDACTED_ROLE_ID,
13632 name: "mz_monitor_redacted",
13633 oid: oid::ROLE_MZ_MONITOR_REDACTED_OID,
13634 attributes: RoleAttributesRaw::new(),
13635};
13636
13637pub const MZ_SYSTEM_CLUSTER: BuiltinCluster = BuiltinCluster {
13638 name: SYSTEM_USER_NAME,
13639 owner_id: &MZ_SYSTEM_ROLE_ID,
13640 privileges: &[
13641 MzAclItem {
13642 grantee: MZ_SUPPORT_ROLE_ID,
13643 grantor: MZ_SYSTEM_ROLE_ID,
13644 acl_mode: AclMode::USAGE,
13645 },
13646 rbac::owner_privilege(ObjectType::Cluster, MZ_SYSTEM_ROLE_ID),
13647 ],
13648};
13649
13650pub const MZ_SYSTEM_CLUSTER_REPLICA: BuiltinClusterReplica = BuiltinClusterReplica {
13651 name: BUILTIN_CLUSTER_REPLICA_NAME,
13652 cluster_name: MZ_SYSTEM_CLUSTER.name,
13653};
13654
13655pub const MZ_CATALOG_SERVER_CLUSTER: BuiltinCluster = BuiltinCluster {
13656 name: "mz_catalog_server",
13657 owner_id: &MZ_SYSTEM_ROLE_ID,
13658 privileges: &[
13659 MzAclItem {
13660 grantee: RoleId::Public,
13661 grantor: MZ_SYSTEM_ROLE_ID,
13662 acl_mode: AclMode::USAGE,
13663 },
13664 MzAclItem {
13665 grantee: MZ_SUPPORT_ROLE_ID,
13666 grantor: MZ_SYSTEM_ROLE_ID,
13667 acl_mode: AclMode::USAGE.union(AclMode::CREATE),
13668 },
13669 rbac::owner_privilege(ObjectType::Cluster, MZ_SYSTEM_ROLE_ID),
13670 ],
13671};
13672
13673pub const MZ_CATALOG_SERVER_CLUSTER_REPLICA: BuiltinClusterReplica = BuiltinClusterReplica {
13674 name: BUILTIN_CLUSTER_REPLICA_NAME,
13675 cluster_name: MZ_CATALOG_SERVER_CLUSTER.name,
13676};
13677
13678pub const MZ_PROBE_CLUSTER: BuiltinCluster = BuiltinCluster {
13679 name: "mz_probe",
13680 owner_id: &MZ_SYSTEM_ROLE_ID,
13681 privileges: &[
13682 MzAclItem {
13683 grantee: MZ_SUPPORT_ROLE_ID,
13684 grantor: MZ_SYSTEM_ROLE_ID,
13685 acl_mode: AclMode::USAGE,
13686 },
13687 MzAclItem {
13688 grantee: MZ_MONITOR_ROLE_ID,
13689 grantor: MZ_SYSTEM_ROLE_ID,
13690 acl_mode: AclMode::USAGE,
13691 },
13692 rbac::owner_privilege(ObjectType::Cluster, MZ_SYSTEM_ROLE_ID),
13693 ],
13694};
13695pub const MZ_PROBE_CLUSTER_REPLICA: BuiltinClusterReplica = BuiltinClusterReplica {
13696 name: BUILTIN_CLUSTER_REPLICA_NAME,
13697 cluster_name: MZ_PROBE_CLUSTER.name,
13698};
13699
13700pub const MZ_SUPPORT_CLUSTER: BuiltinCluster = BuiltinCluster {
13701 name: "mz_support",
13702 owner_id: &MZ_SUPPORT_ROLE_ID,
13703 privileges: &[
13704 MzAclItem {
13705 grantee: MZ_SYSTEM_ROLE_ID,
13706 grantor: MZ_SUPPORT_ROLE_ID,
13707 acl_mode: rbac::all_object_privileges(SystemObjectType::Object(ObjectType::Cluster)),
13708 },
13709 rbac::owner_privilege(ObjectType::Cluster, MZ_SUPPORT_ROLE_ID),
13710 ],
13711};
13712
13713pub const MZ_ANALYTICS_CLUSTER: BuiltinCluster = BuiltinCluster {
13714 name: "mz_analytics",
13715 owner_id: &MZ_ANALYTICS_ROLE_ID,
13716 privileges: &[
13717 MzAclItem {
13718 grantee: MZ_SYSTEM_ROLE_ID,
13719 grantor: MZ_ANALYTICS_ROLE_ID,
13720 acl_mode: rbac::all_object_privileges(SystemObjectType::Object(ObjectType::Cluster)),
13721 },
13722 rbac::owner_privilege(ObjectType::Cluster, MZ_ANALYTICS_ROLE_ID),
13723 ],
13724};
13725
13726pub static BUILTINS_STATIC: LazyLock<Vec<Builtin<NameReference>>> = LazyLock::new(|| {
13728 let mut builtins = vec![
13729 Builtin::Type(&TYPE_ANY),
13730 Builtin::Type(&TYPE_ANYARRAY),
13731 Builtin::Type(&TYPE_ANYELEMENT),
13732 Builtin::Type(&TYPE_ANYNONARRAY),
13733 Builtin::Type(&TYPE_ANYRANGE),
13734 Builtin::Type(&TYPE_BOOL),
13735 Builtin::Type(&TYPE_BOOL_ARRAY),
13736 Builtin::Type(&TYPE_BYTEA),
13737 Builtin::Type(&TYPE_BYTEA_ARRAY),
13738 Builtin::Type(&TYPE_BPCHAR),
13739 Builtin::Type(&TYPE_BPCHAR_ARRAY),
13740 Builtin::Type(&TYPE_CHAR),
13741 Builtin::Type(&TYPE_CHAR_ARRAY),
13742 Builtin::Type(&TYPE_DATE),
13743 Builtin::Type(&TYPE_DATE_ARRAY),
13744 Builtin::Type(&TYPE_FLOAT4),
13745 Builtin::Type(&TYPE_FLOAT4_ARRAY),
13746 Builtin::Type(&TYPE_FLOAT8),
13747 Builtin::Type(&TYPE_FLOAT8_ARRAY),
13748 Builtin::Type(&TYPE_INT4),
13749 Builtin::Type(&TYPE_INT4_ARRAY),
13750 Builtin::Type(&TYPE_INT8),
13751 Builtin::Type(&TYPE_INT8_ARRAY),
13752 Builtin::Type(&TYPE_INTERVAL),
13753 Builtin::Type(&TYPE_INTERVAL_ARRAY),
13754 Builtin::Type(&TYPE_JSONB),
13755 Builtin::Type(&TYPE_JSONB_ARRAY),
13756 Builtin::Type(&TYPE_LIST),
13757 Builtin::Type(&TYPE_MAP),
13758 Builtin::Type(&TYPE_NAME),
13759 Builtin::Type(&TYPE_NAME_ARRAY),
13760 Builtin::Type(&TYPE_NUMERIC),
13761 Builtin::Type(&TYPE_NUMERIC_ARRAY),
13762 Builtin::Type(&TYPE_OID),
13763 Builtin::Type(&TYPE_OID_ARRAY),
13764 Builtin::Type(&TYPE_RECORD),
13765 Builtin::Type(&TYPE_RECORD_ARRAY),
13766 Builtin::Type(&TYPE_REGCLASS),
13767 Builtin::Type(&TYPE_REGCLASS_ARRAY),
13768 Builtin::Type(&TYPE_REGPROC),
13769 Builtin::Type(&TYPE_REGPROC_ARRAY),
13770 Builtin::Type(&TYPE_REGTYPE),
13771 Builtin::Type(&TYPE_REGTYPE_ARRAY),
13772 Builtin::Type(&TYPE_INT2),
13773 Builtin::Type(&TYPE_INT2_ARRAY),
13774 Builtin::Type(&TYPE_TEXT),
13775 Builtin::Type(&TYPE_TEXT_ARRAY),
13776 Builtin::Type(&TYPE_TIME),
13777 Builtin::Type(&TYPE_TIME_ARRAY),
13778 Builtin::Type(&TYPE_TIMESTAMP),
13779 Builtin::Type(&TYPE_TIMESTAMP_ARRAY),
13780 Builtin::Type(&TYPE_TIMESTAMPTZ),
13781 Builtin::Type(&TYPE_TIMESTAMPTZ_ARRAY),
13782 Builtin::Type(&TYPE_UUID),
13783 Builtin::Type(&TYPE_UUID_ARRAY),
13784 Builtin::Type(&TYPE_VARCHAR),
13785 Builtin::Type(&TYPE_VARCHAR_ARRAY),
13786 Builtin::Type(&TYPE_INT2_VECTOR),
13787 Builtin::Type(&TYPE_INT2_VECTOR_ARRAY),
13788 Builtin::Type(&TYPE_ANYCOMPATIBLE),
13789 Builtin::Type(&TYPE_ANYCOMPATIBLEARRAY),
13790 Builtin::Type(&TYPE_ANYCOMPATIBLENONARRAY),
13791 Builtin::Type(&TYPE_ANYCOMPATIBLELIST),
13792 Builtin::Type(&TYPE_ANYCOMPATIBLEMAP),
13793 Builtin::Type(&TYPE_ANYCOMPATIBLERANGE),
13794 Builtin::Type(&TYPE_UINT2),
13795 Builtin::Type(&TYPE_UINT2_ARRAY),
13796 Builtin::Type(&TYPE_UINT4),
13797 Builtin::Type(&TYPE_UINT4_ARRAY),
13798 Builtin::Type(&TYPE_UINT8),
13799 Builtin::Type(&TYPE_UINT8_ARRAY),
13800 Builtin::Type(&TYPE_MZ_TIMESTAMP),
13801 Builtin::Type(&TYPE_MZ_TIMESTAMP_ARRAY),
13802 Builtin::Type(&TYPE_INT4_RANGE),
13803 Builtin::Type(&TYPE_INT4_RANGE_ARRAY),
13804 Builtin::Type(&TYPE_INT8_RANGE),
13805 Builtin::Type(&TYPE_INT8_RANGE_ARRAY),
13806 Builtin::Type(&TYPE_DATE_RANGE),
13807 Builtin::Type(&TYPE_DATE_RANGE_ARRAY),
13808 Builtin::Type(&TYPE_NUM_RANGE),
13809 Builtin::Type(&TYPE_NUM_RANGE_ARRAY),
13810 Builtin::Type(&TYPE_TS_RANGE),
13811 Builtin::Type(&TYPE_TS_RANGE_ARRAY),
13812 Builtin::Type(&TYPE_TSTZ_RANGE),
13813 Builtin::Type(&TYPE_TSTZ_RANGE_ARRAY),
13814 Builtin::Type(&TYPE_MZ_ACL_ITEM),
13815 Builtin::Type(&TYPE_MZ_ACL_ITEM_ARRAY),
13816 Builtin::Type(&TYPE_ACL_ITEM),
13817 Builtin::Type(&TYPE_ACL_ITEM_ARRAY),
13818 Builtin::Type(&TYPE_INTERNAL),
13819 ];
13820 for (schema, funcs) in &[
13821 (PG_CATALOG_SCHEMA, &*mz_sql::func::PG_CATALOG_BUILTINS),
13822 (
13823 INFORMATION_SCHEMA,
13824 &*mz_sql::func::INFORMATION_SCHEMA_BUILTINS,
13825 ),
13826 (MZ_CATALOG_SCHEMA, &*mz_sql::func::MZ_CATALOG_BUILTINS),
13827 (MZ_INTERNAL_SCHEMA, &*mz_sql::func::MZ_INTERNAL_BUILTINS),
13828 (MZ_UNSAFE_SCHEMA, &*mz_sql::func::MZ_UNSAFE_BUILTINS),
13829 ] {
13830 for (name, func) in funcs.iter() {
13831 builtins.push(Builtin::Func(BuiltinFunc {
13832 name,
13833 schema,
13834 inner: func,
13835 }));
13836 }
13837 }
13838 builtins.append(&mut vec![
13839 Builtin::Log(&MZ_ARRANGEMENT_SHARING_RAW),
13840 Builtin::Log(&MZ_ARRANGEMENT_BATCHES_RAW),
13841 Builtin::Log(&MZ_ARRANGEMENT_RECORDS_RAW),
13842 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_RECORDS_RAW),
13843 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_SIZE_RAW),
13844 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_CAPACITY_RAW),
13845 Builtin::Log(&MZ_ARRANGEMENT_BATCHER_ALLOCATIONS_RAW),
13846 Builtin::Log(&MZ_DATAFLOW_CHANNELS_PER_WORKER),
13847 Builtin::Log(&MZ_DATAFLOW_OPERATORS_PER_WORKER),
13848 Builtin::Log(&MZ_DATAFLOW_ADDRESSES_PER_WORKER),
13849 Builtin::Log(&MZ_DATAFLOW_OPERATOR_REACHABILITY_RAW),
13850 Builtin::Log(&MZ_COMPUTE_EXPORTS_PER_WORKER),
13851 Builtin::Log(&MZ_COMPUTE_DATAFLOW_GLOBAL_IDS_PER_WORKER),
13852 Builtin::Log(&MZ_MESSAGE_COUNTS_RECEIVED_RAW),
13853 Builtin::Log(&MZ_MESSAGE_COUNTS_SENT_RAW),
13854 Builtin::Log(&MZ_MESSAGE_BATCH_COUNTS_RECEIVED_RAW),
13855 Builtin::Log(&MZ_MESSAGE_BATCH_COUNTS_SENT_RAW),
13856 Builtin::Log(&MZ_ACTIVE_PEEKS_PER_WORKER),
13857 Builtin::Log(&MZ_PEEK_DURATIONS_HISTOGRAM_RAW),
13858 Builtin::Log(&MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_RAW),
13859 Builtin::Log(&MZ_ARRANGEMENT_HEAP_CAPACITY_RAW),
13860 Builtin::Log(&MZ_ARRANGEMENT_HEAP_ALLOCATIONS_RAW),
13861 Builtin::Log(&MZ_ARRANGEMENT_HEAP_SIZE_RAW),
13862 Builtin::Log(&MZ_SCHEDULING_ELAPSED_RAW),
13863 Builtin::Log(&MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_RAW),
13864 Builtin::Log(&MZ_SCHEDULING_PARKS_HISTOGRAM_RAW),
13865 Builtin::Log(&MZ_COMPUTE_FRONTIERS_PER_WORKER),
13866 Builtin::Log(&MZ_COMPUTE_IMPORT_FRONTIERS_PER_WORKER),
13867 Builtin::Log(&MZ_COMPUTE_ERROR_COUNTS_RAW),
13868 Builtin::Log(&MZ_COMPUTE_HYDRATION_TIMES_PER_WORKER),
13869 Builtin::Log(&MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_PER_WORKER),
13870 Builtin::Table(&MZ_KAFKA_SINKS),
13871 Builtin::Table(&MZ_KAFKA_CONNECTIONS),
13872 Builtin::Table(&MZ_KAFKA_SOURCES),
13873 Builtin::Table(&MZ_OBJECT_DEPENDENCIES),
13874 Builtin::Table(&MZ_ICEBERG_SINKS),
13875 Builtin::Table(&MZ_DATABASES),
13876 Builtin::Table(&MZ_SCHEMAS),
13877 Builtin::Table(&MZ_COLUMNS),
13878 Builtin::Table(&MZ_INDEXES),
13879 Builtin::Table(&MZ_INDEX_COLUMNS),
13880 Builtin::Table(&MZ_TABLES),
13881 Builtin::Table(&MZ_SOURCES),
13882 Builtin::Table(&MZ_SOURCE_REFERENCES),
13883 Builtin::Table(&MZ_POSTGRES_SOURCES),
13884 Builtin::Table(&MZ_POSTGRES_SOURCE_TABLES),
13885 Builtin::Table(&MZ_MYSQL_SOURCE_TABLES),
13886 Builtin::Table(&MZ_SQL_SERVER_SOURCE_TABLES),
13887 Builtin::Table(&MZ_KAFKA_SOURCE_TABLES),
13888 Builtin::Table(&MZ_SINKS),
13889 Builtin::Table(&MZ_VIEWS),
13890 Builtin::Table(&MZ_MATERIALIZED_VIEWS),
13891 Builtin::Table(&MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES),
13892 Builtin::Table(&MZ_TYPES),
13893 Builtin::Table(&MZ_TYPE_PG_METADATA),
13894 Builtin::Table(&MZ_ARRAY_TYPES),
13895 Builtin::Table(&MZ_BASE_TYPES),
13896 Builtin::Table(&MZ_LIST_TYPES),
13897 Builtin::Table(&MZ_MAP_TYPES),
13898 Builtin::Table(&MZ_ROLES),
13899 Builtin::Table(&MZ_ROLE_AUTH),
13900 Builtin::Table(&MZ_ROLE_MEMBERS),
13901 Builtin::Table(&MZ_ROLE_PARAMETERS),
13902 Builtin::Table(&MZ_PSEUDO_TYPES),
13903 Builtin::Table(&MZ_FUNCTIONS),
13904 Builtin::Table(&MZ_OPERATORS),
13905 Builtin::Table(&MZ_AGGREGATES),
13906 Builtin::Table(&MZ_CLUSTERS),
13907 Builtin::Table(&MZ_CLUSTER_WORKLOAD_CLASSES),
13908 Builtin::Table(&MZ_CLUSTER_SCHEDULES),
13909 Builtin::Table(&MZ_SECRETS),
13910 Builtin::Table(&MZ_CONNECTIONS),
13911 Builtin::Table(&MZ_SSH_TUNNEL_CONNECTIONS),
13912 Builtin::Table(&MZ_CLUSTER_REPLICAS),
13913 Builtin::Source(&MZ_CLUSTER_REPLICA_METRICS_HISTORY),
13914 Builtin::View(&MZ_CLUSTER_REPLICA_METRICS),
13915 Builtin::Table(&MZ_CLUSTER_REPLICA_SIZES),
13916 Builtin::Source(&MZ_CLUSTER_REPLICA_STATUS_HISTORY),
13917 Builtin::View(&MZ_CLUSTER_REPLICA_STATUSES),
13918 Builtin::Table(&MZ_INTERNAL_CLUSTER_REPLICAS),
13919 Builtin::Table(&MZ_PENDING_CLUSTER_REPLICAS),
13920 Builtin::Table(&MZ_AUDIT_EVENTS),
13921 Builtin::Table(&MZ_STORAGE_USAGE_BY_SHARD),
13922 Builtin::Table(&MZ_EGRESS_IPS),
13923 Builtin::Table(&MZ_AWS_PRIVATELINK_CONNECTIONS),
13924 Builtin::Table(&MZ_AWS_CONNECTIONS),
13925 Builtin::Table(&MZ_SUBSCRIPTIONS),
13926 Builtin::Table(&MZ_SESSIONS),
13927 Builtin::Table(&MZ_DEFAULT_PRIVILEGES),
13928 Builtin::Table(&MZ_SYSTEM_PRIVILEGES),
13929 Builtin::Table(&MZ_COMMENTS),
13930 Builtin::Table(&MZ_WEBHOOKS_SOURCES),
13931 Builtin::Table(&MZ_HISTORY_RETENTION_STRATEGIES),
13932 Builtin::Table(&MZ_CONTINUAL_TASKS),
13933 Builtin::Table(&MZ_NETWORK_POLICIES),
13934 Builtin::Table(&MZ_NETWORK_POLICY_RULES),
13935 Builtin::Table(&MZ_LICENSE_KEYS),
13936 Builtin::Table(&MZ_REPLACEMENTS),
13937 Builtin::View(&MZ_RELATIONS),
13938 Builtin::View(&MZ_OBJECT_OID_ALIAS),
13939 Builtin::View(&MZ_OBJECTS),
13940 Builtin::View(&MZ_OBJECT_FULLY_QUALIFIED_NAMES),
13941 Builtin::View(&MZ_OBJECTS_ID_NAMESPACE_TYPES),
13942 Builtin::View(&MZ_OBJECT_HISTORY),
13943 Builtin::View(&MZ_OBJECT_LIFETIMES),
13944 Builtin::Table(&MZ_OBJECT_GLOBAL_IDS),
13945 Builtin::View(&MZ_ARRANGEMENT_SHARING_PER_WORKER),
13946 Builtin::View(&MZ_ARRANGEMENT_SHARING),
13947 Builtin::View(&MZ_ARRANGEMENT_SIZES_PER_WORKER),
13948 Builtin::View(&MZ_ARRANGEMENT_SIZES),
13949 Builtin::View(&MZ_DATAFLOWS_PER_WORKER),
13950 Builtin::View(&MZ_DATAFLOWS),
13951 Builtin::View(&MZ_DATAFLOW_ADDRESSES),
13952 Builtin::View(&MZ_DATAFLOW_CHANNELS),
13953 Builtin::View(&MZ_DATAFLOW_OPERATORS),
13954 Builtin::View(&MZ_DATAFLOW_GLOBAL_IDS),
13955 Builtin::View(&MZ_MAPPABLE_OBJECTS),
13956 Builtin::View(&MZ_DATAFLOW_OPERATOR_DATAFLOWS_PER_WORKER),
13957 Builtin::View(&MZ_DATAFLOW_OPERATOR_DATAFLOWS),
13958 Builtin::View(&MZ_OBJECT_TRANSITIVE_DEPENDENCIES),
13959 Builtin::View(&MZ_DATAFLOW_OPERATOR_REACHABILITY_PER_WORKER),
13960 Builtin::View(&MZ_DATAFLOW_OPERATOR_REACHABILITY),
13961 Builtin::View(&MZ_CLUSTER_REPLICA_UTILIZATION),
13962 Builtin::View(&MZ_CLUSTER_REPLICA_UTILIZATION_HISTORY),
13963 Builtin::View(&MZ_DATAFLOW_OPERATOR_PARENTS_PER_WORKER),
13964 Builtin::View(&MZ_DATAFLOW_OPERATOR_PARENTS),
13965 Builtin::View(&MZ_COMPUTE_EXPORTS),
13966 Builtin::View(&MZ_DATAFLOW_ARRANGEMENT_SIZES),
13967 Builtin::View(&MZ_EXPECTED_GROUP_SIZE_ADVICE),
13968 Builtin::View(&MZ_COMPUTE_FRONTIERS),
13969 Builtin::View(&MZ_DATAFLOW_CHANNEL_OPERATORS_PER_WORKER),
13970 Builtin::View(&MZ_DATAFLOW_CHANNEL_OPERATORS),
13971 Builtin::View(&MZ_COMPUTE_IMPORT_FRONTIERS),
13972 Builtin::View(&MZ_MESSAGE_COUNTS_PER_WORKER),
13973 Builtin::View(&MZ_MESSAGE_COUNTS),
13974 Builtin::View(&MZ_ACTIVE_PEEKS),
13975 Builtin::View(&MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM_PER_WORKER),
13976 Builtin::View(&MZ_COMPUTE_OPERATOR_DURATIONS_HISTOGRAM),
13977 Builtin::View(&MZ_RECORDS_PER_DATAFLOW_OPERATOR_PER_WORKER),
13978 Builtin::View(&MZ_RECORDS_PER_DATAFLOW_OPERATOR),
13979 Builtin::View(&MZ_RECORDS_PER_DATAFLOW_PER_WORKER),
13980 Builtin::View(&MZ_RECORDS_PER_DATAFLOW),
13981 Builtin::View(&MZ_PEEK_DURATIONS_HISTOGRAM_PER_WORKER),
13982 Builtin::View(&MZ_PEEK_DURATIONS_HISTOGRAM),
13983 Builtin::View(&MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM_PER_WORKER),
13984 Builtin::View(&MZ_DATAFLOW_SHUTDOWN_DURATIONS_HISTOGRAM),
13985 Builtin::View(&MZ_SCHEDULING_ELAPSED_PER_WORKER),
13986 Builtin::View(&MZ_SCHEDULING_ELAPSED),
13987 Builtin::View(&MZ_SCHEDULING_PARKS_HISTOGRAM_PER_WORKER),
13988 Builtin::View(&MZ_SCHEDULING_PARKS_HISTOGRAM),
13989 Builtin::View(&MZ_SHOW_ALL_OBJECTS),
13990 Builtin::View(&MZ_SHOW_COLUMNS),
13991 Builtin::View(&MZ_SHOW_CLUSTERS),
13992 Builtin::View(&MZ_SHOW_SECRETS),
13993 Builtin::View(&MZ_SHOW_DATABASES),
13994 Builtin::View(&MZ_SHOW_SCHEMAS),
13995 Builtin::View(&MZ_SHOW_TABLES),
13996 Builtin::View(&MZ_SHOW_VIEWS),
13997 Builtin::View(&MZ_SHOW_TYPES),
13998 Builtin::View(&MZ_SHOW_ROLES),
13999 Builtin::View(&MZ_SHOW_CONNECTIONS),
14000 Builtin::View(&MZ_SHOW_SOURCES),
14001 Builtin::View(&MZ_SHOW_SINKS),
14002 Builtin::View(&MZ_SHOW_MATERIALIZED_VIEWS),
14003 Builtin::View(&MZ_SHOW_INDEXES),
14004 Builtin::View(&MZ_SHOW_CONTINUAL_TASKS),
14005 Builtin::View(&MZ_CLUSTER_REPLICA_HISTORY),
14006 Builtin::View(&MZ_CLUSTER_REPLICA_NAME_HISTORY),
14007 Builtin::View(&MZ_TIMEZONE_NAMES),
14008 Builtin::View(&MZ_TIMEZONE_ABBREVIATIONS),
14009 Builtin::View(&PG_NAMESPACE_ALL_DATABASES),
14010 Builtin::Index(&PG_NAMESPACE_ALL_DATABASES_IND),
14011 Builtin::View(&PG_NAMESPACE),
14012 Builtin::View(&PG_CLASS_ALL_DATABASES),
14013 Builtin::Index(&PG_CLASS_ALL_DATABASES_IND),
14014 Builtin::View(&PG_CLASS),
14015 Builtin::View(&PG_DEPEND),
14016 Builtin::View(&PG_DATABASE),
14017 Builtin::View(&PG_INDEX),
14018 Builtin::View(&PG_TYPE_ALL_DATABASES),
14019 Builtin::Index(&PG_TYPE_ALL_DATABASES_IND),
14020 Builtin::View(&PG_TYPE),
14021 Builtin::View(&PG_DESCRIPTION_ALL_DATABASES),
14022 Builtin::Index(&PG_DESCRIPTION_ALL_DATABASES_IND),
14023 Builtin::View(&PG_DESCRIPTION),
14024 Builtin::View(&PG_ATTRIBUTE_ALL_DATABASES),
14025 Builtin::Index(&PG_ATTRIBUTE_ALL_DATABASES_IND),
14026 Builtin::View(&PG_ATTRIBUTE),
14027 Builtin::View(&PG_PROC),
14028 Builtin::View(&PG_OPERATOR),
14029 Builtin::View(&PG_RANGE),
14030 Builtin::View(&PG_ENUM),
14031 Builtin::View(&PG_ATTRDEF_ALL_DATABASES),
14032 Builtin::Index(&PG_ATTRDEF_ALL_DATABASES_IND),
14033 Builtin::View(&PG_ATTRDEF),
14034 Builtin::View(&PG_SETTINGS),
14035 Builtin::View(&PG_AUTH_MEMBERS),
14036 Builtin::View(&PG_CONSTRAINT),
14037 Builtin::View(&PG_TABLES),
14038 Builtin::View(&PG_TABLESPACE),
14039 Builtin::View(&PG_ACCESS_METHODS),
14040 Builtin::View(&PG_LOCKS),
14041 Builtin::View(&PG_AUTHID_CORE),
14042 Builtin::Index(&PG_AUTHID_CORE_IND),
14043 Builtin::View(&PG_AUTHID),
14044 Builtin::View(&PG_ROLES),
14045 Builtin::View(&PG_USER),
14046 Builtin::View(&PG_VIEWS),
14047 Builtin::View(&PG_MATVIEWS),
14048 Builtin::View(&PG_COLLATION),
14049 Builtin::View(&PG_POLICY),
14050 Builtin::View(&PG_INHERITS),
14051 Builtin::View(&PG_AGGREGATE),
14052 Builtin::View(&PG_TRIGGER),
14053 Builtin::View(&PG_REWRITE),
14054 Builtin::View(&PG_EXTENSION),
14055 Builtin::View(&PG_EVENT_TRIGGER),
14056 Builtin::View(&PG_LANGUAGE),
14057 Builtin::View(&PG_SHDESCRIPTION),
14058 Builtin::View(&PG_INDEXES),
14059 Builtin::View(&PG_TIMEZONE_ABBREVS),
14060 Builtin::View(&PG_TIMEZONE_NAMES),
14061 Builtin::View(&INFORMATION_SCHEMA_APPLICABLE_ROLES),
14062 Builtin::View(&INFORMATION_SCHEMA_COLUMNS),
14063 Builtin::View(&INFORMATION_SCHEMA_ENABLED_ROLES),
14064 Builtin::View(&INFORMATION_SCHEMA_KEY_COLUMN_USAGE),
14065 Builtin::View(&INFORMATION_SCHEMA_REFERENTIAL_CONSTRAINTS),
14066 Builtin::View(&INFORMATION_SCHEMA_ROUTINES),
14067 Builtin::View(&INFORMATION_SCHEMA_SCHEMATA),
14068 Builtin::View(&INFORMATION_SCHEMA_TABLES),
14069 Builtin::View(&INFORMATION_SCHEMA_TABLE_CONSTRAINTS),
14070 Builtin::View(&INFORMATION_SCHEMA_TABLE_PRIVILEGES),
14071 Builtin::View(&INFORMATION_SCHEMA_ROLE_TABLE_GRANTS),
14072 Builtin::View(&INFORMATION_SCHEMA_TRIGGERS),
14073 Builtin::View(&INFORMATION_SCHEMA_VIEWS),
14074 Builtin::View(&INFORMATION_SCHEMA_CHARACTER_SETS),
14075 Builtin::View(&MZ_SHOW_ROLE_MEMBERS),
14076 Builtin::View(&MZ_SHOW_MY_ROLE_MEMBERS),
14077 Builtin::View(&MZ_SHOW_SYSTEM_PRIVILEGES),
14078 Builtin::View(&MZ_SHOW_MY_SYSTEM_PRIVILEGES),
14079 Builtin::View(&MZ_SHOW_CLUSTER_PRIVILEGES),
14080 Builtin::View(&MZ_SHOW_MY_CLUSTER_PRIVILEGES),
14081 Builtin::View(&MZ_SHOW_DATABASE_PRIVILEGES),
14082 Builtin::View(&MZ_SHOW_MY_DATABASE_PRIVILEGES),
14083 Builtin::View(&MZ_SHOW_SCHEMA_PRIVILEGES),
14084 Builtin::View(&MZ_SHOW_MY_SCHEMA_PRIVILEGES),
14085 Builtin::View(&MZ_SHOW_OBJECT_PRIVILEGES),
14086 Builtin::View(&MZ_SHOW_MY_OBJECT_PRIVILEGES),
14087 Builtin::View(&MZ_SHOW_ALL_PRIVILEGES),
14088 Builtin::View(&MZ_SHOW_ALL_MY_PRIVILEGES),
14089 Builtin::View(&MZ_SHOW_DEFAULT_PRIVILEGES),
14090 Builtin::View(&MZ_SHOW_MY_DEFAULT_PRIVILEGES),
14091 Builtin::Source(&MZ_SINK_STATUS_HISTORY),
14092 Builtin::View(&MZ_SINK_STATUSES),
14093 Builtin::Source(&MZ_SOURCE_STATUS_HISTORY),
14094 Builtin::Source(&MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY),
14095 Builtin::View(&MZ_AWS_PRIVATELINK_CONNECTION_STATUSES),
14096 Builtin::Source(&MZ_STATEMENT_EXECUTION_HISTORY),
14097 Builtin::View(&MZ_STATEMENT_EXECUTION_HISTORY_REDACTED),
14098 Builtin::Source(&MZ_PREPARED_STATEMENT_HISTORY),
14099 Builtin::Source(&MZ_SESSION_HISTORY),
14100 Builtin::Source(&MZ_SQL_TEXT),
14101 Builtin::View(&MZ_SQL_TEXT_REDACTED),
14102 Builtin::View(&MZ_RECENT_SQL_TEXT),
14103 Builtin::View(&MZ_RECENT_SQL_TEXT_REDACTED),
14104 Builtin::Index(&MZ_RECENT_SQL_TEXT_IND),
14105 Builtin::View(&MZ_ACTIVITY_LOG_THINNED),
14106 Builtin::View(&MZ_RECENT_ACTIVITY_LOG_THINNED),
14107 Builtin::View(&MZ_RECENT_ACTIVITY_LOG),
14108 Builtin::View(&MZ_RECENT_ACTIVITY_LOG_REDACTED),
14109 Builtin::Index(&MZ_RECENT_ACTIVITY_LOG_THINNED_IND),
14110 Builtin::View(&MZ_SOURCE_STATUSES),
14111 Builtin::Source(&MZ_STATEMENT_LIFECYCLE_HISTORY),
14112 Builtin::Source(&MZ_STORAGE_SHARDS),
14113 Builtin::Source(&MZ_SOURCE_STATISTICS_RAW),
14114 Builtin::Source(&MZ_SINK_STATISTICS_RAW),
14115 Builtin::View(&MZ_SOURCE_STATISTICS_WITH_HISTORY),
14116 Builtin::Index(&MZ_SOURCE_STATISTICS_WITH_HISTORY_IND),
14117 Builtin::View(&MZ_SOURCE_STATISTICS),
14118 Builtin::Index(&MZ_SOURCE_STATISTICS_IND),
14119 Builtin::View(&MZ_SINK_STATISTICS),
14120 Builtin::Index(&MZ_SINK_STATISTICS_IND),
14121 Builtin::View(&MZ_STORAGE_USAGE),
14122 Builtin::Source(&MZ_FRONTIERS),
14123 Builtin::View(&MZ_GLOBAL_FRONTIERS),
14124 Builtin::Source(&MZ_WALLCLOCK_LAG_HISTORY),
14125 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG_HISTORY),
14126 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY),
14127 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG),
14128 Builtin::Source(&MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW),
14129 Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG_HISTOGRAM),
14130 Builtin::Source(&MZ_MATERIALIZED_VIEW_REFRESHES),
14131 Builtin::Source(&MZ_COMPUTE_DEPENDENCIES),
14132 Builtin::View(&MZ_MATERIALIZATION_DEPENDENCIES),
14133 Builtin::View(&MZ_MATERIALIZATION_LAG),
14134 Builtin::View(&MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW),
14135 Builtin::View(&MZ_COMPUTE_ERROR_COUNTS_PER_WORKER),
14136 Builtin::View(&MZ_COMPUTE_ERROR_COUNTS),
14137 Builtin::Source(&MZ_COMPUTE_ERROR_COUNTS_RAW_UNIFIED),
14138 Builtin::Source(&MZ_COMPUTE_HYDRATION_TIMES),
14139 Builtin::Log(&MZ_COMPUTE_LIR_MAPPING_PER_WORKER),
14140 Builtin::View(&MZ_LIR_MAPPING),
14141 Builtin::Source(&MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES),
14142 Builtin::Source(&MZ_CLUSTER_REPLICA_FRONTIERS),
14143 Builtin::View(&MZ_COMPUTE_HYDRATION_STATUSES),
14144 Builtin::View(&MZ_HYDRATION_STATUSES),
14145 Builtin::View(&MZ_SHOW_CLUSTER_REPLICAS),
14146 Builtin::View(&MZ_SHOW_NETWORK_POLICIES),
14147 Builtin::View(&MZ_CLUSTER_DEPLOYMENT_LINEAGE),
14148 Builtin::Index(&MZ_SHOW_DATABASES_IND),
14149 Builtin::Index(&MZ_SHOW_SCHEMAS_IND),
14150 Builtin::Index(&MZ_SHOW_CONNECTIONS_IND),
14151 Builtin::Index(&MZ_SHOW_TABLES_IND),
14152 Builtin::Index(&MZ_SHOW_SOURCES_IND),
14153 Builtin::Index(&MZ_SHOW_VIEWS_IND),
14154 Builtin::Index(&MZ_SHOW_MATERIALIZED_VIEWS_IND),
14155 Builtin::Index(&MZ_SHOW_SINKS_IND),
14156 Builtin::Index(&MZ_SHOW_TYPES_IND),
14157 Builtin::Index(&MZ_SHOW_ALL_OBJECTS_IND),
14158 Builtin::Index(&MZ_SHOW_INDEXES_IND),
14159 Builtin::Index(&MZ_SHOW_COLUMNS_IND),
14160 Builtin::Index(&MZ_SHOW_CLUSTERS_IND),
14161 Builtin::Index(&MZ_SHOW_CLUSTER_REPLICAS_IND),
14162 Builtin::Index(&MZ_SHOW_SECRETS_IND),
14163 Builtin::Index(&MZ_SHOW_ROLES_IND),
14164 Builtin::Index(&MZ_CLUSTERS_IND),
14165 Builtin::Index(&MZ_INDEXES_IND),
14166 Builtin::Index(&MZ_ROLES_IND),
14167 Builtin::Index(&MZ_SOURCES_IND),
14168 Builtin::Index(&MZ_SINKS_IND),
14169 Builtin::Index(&MZ_MATERIALIZED_VIEWS_IND),
14170 Builtin::Index(&MZ_CONTINUAL_TASKS_IND),
14171 Builtin::Index(&MZ_SOURCE_STATUSES_IND),
14172 Builtin::Index(&MZ_SOURCE_STATUS_HISTORY_IND),
14173 Builtin::Index(&MZ_SINK_STATUSES_IND),
14174 Builtin::Index(&MZ_SINK_STATUS_HISTORY_IND),
14175 Builtin::Index(&MZ_CLUSTER_REPLICAS_IND),
14176 Builtin::Index(&MZ_CLUSTER_REPLICA_SIZES_IND),
14177 Builtin::Index(&MZ_CLUSTER_REPLICA_STATUSES_IND),
14178 Builtin::Index(&MZ_CLUSTER_REPLICA_STATUS_HISTORY_IND),
14179 Builtin::Index(&MZ_CLUSTER_REPLICA_METRICS_IND),
14180 Builtin::Index(&MZ_CLUSTER_REPLICA_METRICS_HISTORY_IND),
14181 Builtin::Index(&MZ_CLUSTER_REPLICA_HISTORY_IND),
14182 Builtin::Index(&MZ_CLUSTER_REPLICA_NAME_HISTORY_IND),
14183 Builtin::Index(&MZ_OBJECT_LIFETIMES_IND),
14184 Builtin::Index(&MZ_OBJECT_HISTORY_IND),
14185 Builtin::Index(&MZ_OBJECT_DEPENDENCIES_IND),
14186 Builtin::Index(&MZ_COMPUTE_DEPENDENCIES_IND),
14187 Builtin::Index(&MZ_OBJECT_TRANSITIVE_DEPENDENCIES_IND),
14188 Builtin::Index(&MZ_FRONTIERS_IND),
14189 Builtin::Index(&MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY_IND),
14190 Builtin::Index(&MZ_KAFKA_SOURCES_IND),
14191 Builtin::Index(&MZ_WEBHOOK_SOURCES_IND),
14192 Builtin::Index(&MZ_COMMENTS_IND),
14193 Builtin::Index(&MZ_DATABASES_IND),
14194 Builtin::Index(&MZ_SCHEMAS_IND),
14195 Builtin::Index(&MZ_CONNECTIONS_IND),
14196 Builtin::Index(&MZ_TABLES_IND),
14197 Builtin::Index(&MZ_TYPES_IND),
14198 Builtin::Index(&MZ_OBJECTS_IND),
14199 Builtin::Index(&MZ_COLUMNS_IND),
14200 Builtin::Index(&MZ_SECRETS_IND),
14201 Builtin::Index(&MZ_VIEWS_IND),
14202 Builtin::Index(&MZ_CONSOLE_CLUSTER_UTILIZATION_OVERVIEW_IND),
14203 Builtin::Index(&MZ_CLUSTER_DEPLOYMENT_LINEAGE_IND),
14204 Builtin::Index(&MZ_CLUSTER_REPLICA_FRONTIERS_IND),
14205 Builtin::Index(&MZ_COMPUTE_HYDRATION_TIMES_IND),
14206 Builtin::View(&MZ_RECENT_STORAGE_USAGE),
14207 Builtin::Index(&MZ_RECENT_STORAGE_USAGE_IND),
14208 Builtin::Connection(&MZ_ANALYTICS),
14209 Builtin::ContinualTask(&MZ_CLUSTER_REPLICA_METRICS_HISTORY_CT),
14210 Builtin::ContinualTask(&MZ_CLUSTER_REPLICA_STATUS_HISTORY_CT),
14211 Builtin::ContinualTask(&MZ_WALLCLOCK_LAG_HISTORY_CT),
14212 Builtin::View(&MZ_INDEX_ADVICE),
14213 ]);
14214
14215 builtins.extend(notice::builtins());
14216
14217 builtins
14218});
14219pub const BUILTIN_ROLES: &[&BuiltinRole] = &[
14220 &MZ_SYSTEM_ROLE,
14221 &MZ_SUPPORT_ROLE,
14222 &MZ_ANALYTICS_ROLE,
14223 &MZ_MONITOR_ROLE,
14224 &MZ_MONITOR_REDACTED,
14225];
14226pub const BUILTIN_CLUSTERS: &[&BuiltinCluster] = &[
14227 &MZ_SYSTEM_CLUSTER,
14228 &MZ_CATALOG_SERVER_CLUSTER,
14229 &MZ_PROBE_CLUSTER,
14230 &MZ_SUPPORT_CLUSTER,
14231 &MZ_ANALYTICS_CLUSTER,
14232];
14233pub const BUILTIN_CLUSTER_REPLICAS: &[&BuiltinClusterReplica] = &[
14234 &MZ_SYSTEM_CLUSTER_REPLICA,
14235 &MZ_CATALOG_SERVER_CLUSTER_REPLICA,
14236 &MZ_PROBE_CLUSTER_REPLICA,
14237];
14238
14239#[allow(non_snake_case)]
14240pub mod BUILTINS {
14241 use mz_sql::catalog::BuiltinsConfig;
14242
14243 use super::*;
14244
14245 pub fn logs() -> impl Iterator<Item = &'static BuiltinLog> {
14246 BUILTINS_STATIC.iter().filter_map(|b| match b {
14247 Builtin::Log(log) => Some(*log),
14248 _ => None,
14249 })
14250 }
14251
14252 pub fn types() -> impl Iterator<Item = &'static BuiltinType<NameReference>> {
14253 BUILTINS_STATIC.iter().filter_map(|b| match b {
14254 Builtin::Type(typ) => Some(*typ),
14255 _ => None,
14256 })
14257 }
14258
14259 pub fn views() -> impl Iterator<Item = &'static BuiltinView> {
14260 BUILTINS_STATIC.iter().filter_map(|b| match b {
14261 Builtin::View(view) => Some(*view),
14262 _ => None,
14263 })
14264 }
14265
14266 pub fn funcs() -> impl Iterator<Item = &'static BuiltinFunc> {
14267 BUILTINS_STATIC.iter().filter_map(|b| match b {
14268 Builtin::Func(func) => Some(func),
14269 _ => None,
14270 })
14271 }
14272
14273 pub fn iter(cfg: &BuiltinsConfig) -> impl Iterator<Item = &'static Builtin<NameReference>> {
14274 let include_continual_tasks = cfg.include_continual_tasks;
14275 BUILTINS_STATIC.iter().filter(move |x| match x {
14276 Builtin::ContinualTask(_) if !include_continual_tasks => false,
14277 _ => true,
14278 })
14279 }
14280}
14281
14282pub static BUILTIN_LOG_LOOKUP: LazyLock<HashMap<&'static str, &'static BuiltinLog>> =
14283 LazyLock::new(|| BUILTINS::logs().map(|log| (log.name, log)).collect());
14284pub static BUILTIN_LOOKUP: LazyLock<
14287 HashMap<SystemObjectDescription, (usize, &'static Builtin<NameReference>)>,
14288> = LazyLock::new(|| {
14289 BUILTINS_STATIC
14294 .iter()
14295 .enumerate()
14296 .map(|(idx, builtin)| {
14297 (
14298 SystemObjectDescription {
14299 schema_name: builtin.schema().to_string(),
14300 object_type: builtin.catalog_item_type(),
14301 object_name: builtin.name().to_string(),
14302 },
14303 (idx, builtin),
14304 )
14305 })
14306 .collect()
14307});
14308
14309#[mz_ore::test]
14310#[cfg_attr(miri, ignore)] fn test_builtin_type_schema() {
14312 use mz_pgrepr::oid::FIRST_MATERIALIZE_OID;
14313
14314 for typ in BUILTINS::types() {
14315 if typ.oid < FIRST_MATERIALIZE_OID {
14316 assert_eq!(
14317 typ.schema, PG_CATALOG_SCHEMA,
14318 "{typ:?} should be in {PG_CATALOG_SCHEMA} schema"
14319 );
14320 } else {
14321 assert_eq!(
14324 typ.schema, MZ_CATALOG_SCHEMA,
14325 "{typ:?} should be in {MZ_CATALOG_SCHEMA} schema"
14326 );
14327 }
14328 }
14329}