From 1791550c9fffe5542bdcf5cc2ea17f5b206a8a53 Mon Sep 17 00:00:00 2001 From: SangJunBak Date: Mon, 16 Nov 2026 19:35:10 -0500 Subject: [PATCH 01/10] catalog: generate mz_builtin_types and stop packing type rows - Create mz_internal.mz_builtin_types to report builtin types. Essentially a move of the packing code from builtin_table_updates to make_builtin_types. The exception being.... - We extract `from_builtin_oid` from `name_from_oid` to get a mapping from a builtin catalog type to the pgwire typlen. We need `from_builtin_oid` since the builtin table way of getting the postgres type requires the catalog and SQLScalarTypes. This is because user types can be recursive. However our builtin types cannot be and we can use `from_builtin_oid`. To prevent drift, we add a test in catalog.rs that asserts `from_builtin_oid` against types via pgwire. --- .../content/sql/system-catalog/mz_internal.md | 1 + src/adapter/src/catalog.rs | 45 +++++ .../src/catalog/builtin_table_updates.rs | 166 +----------------- src/catalog/src/builtin.rs | 5 +- src/catalog/src/builtin/builtin.rs | 136 +++++++++++++- src/pgrepr-consts/src/oid.rs | 1 + src/pgrepr/src/types.rs | 37 ++-- 7 files changed, 212 insertions(+), 179 deletions(-) diff --git a/doc/user/content/sql/system-catalog/mz_internal.md b/doc/user/content/sql/system-catalog/mz_internal.md index e436c06a1b10d..6a579fa8b3256 100644 --- a/doc/user/content/sql/system-catalog/mz_internal.md +++ b/doc/user/content/sql/system-catalog/mz_internal.md @@ -1640,6 +1640,7 @@ The `mz_webhook_sources` table contains a row for each webhook source in the sys + diff --git a/src/adapter/src/catalog.rs b/src/adapter/src/catalog.rs index 03e0ef184f84f..86d2655538bde 100644 --- a/src/adapter/src/catalog.rs +++ b/src/adapter/src/catalog.rs @@ -4149,6 +4149,51 @@ mod tests { } } + // Make sure the typlen from `from_builtin_oid` equals the one pgwire sends. + #[mz_ore::test(tokio::test)] + #[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_client_method` on OS `linux` + async fn test_builtin_type_typlen_known_and_matches_pgwire() { + Catalog::with_debug(|catalog| async move { + let conn_catalog = catalog.for_system_session(); + + for ty in BUILTINS::types() { + let id = conn_catalog + .resolve_type(&PartialItemName { + database: None, + schema: Some(ty.schema.into()), + item: ty.name.to_string(), + }) + .expect("unable to resolve type") + .id(); + let builtin_type = mz_pgrepr::Type::from_builtin_oid(ty.oid); + if !matches!(ty.details.typ, CatalogType::Pseudo) { + assert!( + builtin_type.is_some(), + "mz_pgrepr::Type::from_builtin_oid does not know {}, so mz_builtin_types would report a NULL typlen for it", + ty.name + ); + } + let Some(builtin_type) = builtin_type else { + continue; + }; + let Ok(scalar_type) = + mz_sql::plan::scalar_type_from_catalog(&conn_catalog, id, &[]) + else { + continue; + }; + let pgwire_typlen = mz_pgrepr::Type::from(&scalar_type).typlen(); + let builtin_typlen = builtin_type.typlen(); + assert_eq!( + builtin_typlen, pgwire_typlen, + "type {} has typlen {} in mz_builtin_types but pgwire sends {}", + ty.name, builtin_typlen, pgwire_typlen, + ); + } + catalog.expire().await; + }) + .await; + } + // Make sure pg views don't use types that only exist in Materialize. #[mz_ore::test(tokio::test)] #[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_client_method` on OS `linux` diff --git a/src/adapter/src/catalog/builtin_table_updates.rs b/src/adapter/src/catalog/builtin_table_updates.rs index c15fc6592da2f..4d0d9192f7b2d 100644 --- a/src/adapter/src/catalog/builtin_table_updates.rs +++ b/src/adapter/src/catalog/builtin_table_updates.rs @@ -14,28 +14,22 @@ use ipnet::IpNet; use mz_audit_log::VersionedStorageUsage; use mz_catalog::SYSTEM_CONN_ID; use mz_catalog::builtin::{ - BuiltinTable, MZ_AGGREGATES, MZ_ARRAY_TYPES, MZ_BASE_TYPES, MZ_CLUSTER_REPLICA_SIZE_INTERNAL, - MZ_CLUSTER_REPLICA_SIZES, MZ_EGRESS_IPS, MZ_FUNCTIONS, MZ_LICENSE_KEYS, MZ_LIST_TYPES, - MZ_MAP_TYPES, MZ_OPERATORS, MZ_PSEUDO_TYPES, MZ_ROLE_AUTH, MZ_SESSIONS, - MZ_STORAGE_USAGE_BY_SHARD, MZ_SUBSCRIPTIONS, MZ_TYPE_PG_METADATA, MZ_TYPES, - MZ_WEBHOOKS_SOURCES, + BuiltinTable, MZ_AGGREGATES, MZ_CLUSTER_REPLICA_SIZE_INTERNAL, MZ_CLUSTER_REPLICA_SIZES, + MZ_EGRESS_IPS, MZ_FUNCTIONS, MZ_LICENSE_KEYS, MZ_OPERATORS, MZ_ROLE_AUTH, MZ_SESSIONS, + MZ_STORAGE_USAGE_BY_SHARD, MZ_SUBSCRIPTIONS, MZ_WEBHOOKS_SOURCES, }; use mz_catalog::memory::error::Error; -use mz_catalog::memory::objects::{CatalogItem, DataSourceDesc, Func, Type}; +use mz_catalog::memory::objects::{CatalogItem, DataSourceDesc, Func}; use mz_controller::clusters::ReplicaAllocation; use mz_license_keys::ValidatedLicenseKey; use mz_orchestrator::{CpuLimit, DiskLimit, MemoryLimit}; use mz_ore::cast::CastFrom; -use mz_ore::collections::CollectionExt; use mz_persist_client::batch::ProtoBatch; use mz_repr::adt::array::ArrayDimension; -use mz_repr::adt::mz_acl_item::PrivilegeMap; use mz_repr::role_id::RoleId; -use mz_repr::{CatalogItemId, Datum, Diff, GlobalId, Row, RowPacker}; -use mz_sql::catalog::{CatalogType, TypeCategory}; +use mz_repr::{CatalogItemId, Datum, Diff, GlobalId, Row}; use mz_sql::func::FuncImplCatalogDetails; use mz_sql::names::SchemaSpecifier; -use mz_sql_parser::ast::display::AstDisplay; use mz_storage_client::client::TableData; use smallvec::smallvec; use uuid::Uuid; @@ -122,7 +116,6 @@ impl CatalogState { diff: Diff, ) -> Vec> { let entry = self.get_entry(&id); - let oid = entry.oid(); let conn_id = entry.item().conn_id().unwrap_or(&SYSTEM_CONN_ID); let schema_id = &self .get_schema( @@ -133,8 +126,6 @@ impl CatalogState { .id; let name = &entry.name().item; let owner_id = entry.owner_id(); - let privileges_row = self.pack_privilege_array_row(entry.privileges()); - let privileges = privileges_row.unpack_first(); let updates = match entry.item() { CatalogItem::Source(source) => { match &source.data_source { @@ -155,20 +146,18 @@ impl CatalogState { // mz_sinks, mz_kafka_sinks and mz_iceberg_sinks read create_sql // out of mz_catalog_raw, so there is nothing to pack here. CatalogItem::Sink(_) => vec![], - CatalogItem::Type(ty) => { - self.pack_type_update(id, oid, schema_id, name, owner_id, privileges, ty, diff) - } CatalogItem::Func(func) => { self.pack_func_update(id, schema_id, name, owner_id, func, diff) } - // Tables, views, materialized views, indexes, and metric sinks - // are exposed through materialized views derived from + // Tables, views, materialized views, indexes, types and metric + // sinks are exposed through relations derived from // `mz_catalog_raw`, and logs and secrets never had builtin-table // rows, so none pack a row here. CatalogItem::Table(_) | CatalogItem::View(_) | CatalogItem::MaterializedView(_) | CatalogItem::Index(_) + | CatalogItem::Type(_) | CatalogItem::Log(_) | CatalogItem::Secret(_) | CatalogItem::MetricSink(_) => vec![], @@ -182,128 +171,6 @@ impl CatalogState { updates } - fn pack_type_update( - &self, - id: CatalogItemId, - oid: u32, - schema_id: &SchemaSpecifier, - name: &str, - owner_id: &RoleId, - privileges: Datum, - typ: &Type, - diff: Diff, - ) -> Vec> { - let mut out = vec![]; - - let redacted = typ.create_sql.as_ref().map(|create_sql| { - mz_sql::parse::parse(create_sql) - .unwrap_or_else(|_| panic!("create_sql cannot be invalid: {}", create_sql)) - .into_element() - .ast - .to_ast_string_redacted() - }); - - out.push(BuiltinTableUpdate::row( - &*MZ_TYPES, - Row::pack_slice(&[ - Datum::String(&id.to_string()), - Datum::UInt32(oid), - Datum::String(&schema_id.to_string()), - Datum::String(name), - Datum::String(&TypeCategory::from_catalog_type(&typ.details.typ).to_string()), - Datum::String(&owner_id.to_string()), - privileges, - if let Some(create_sql) = &typ.create_sql { - Datum::String(create_sql) - } else { - Datum::Null - }, - if let Some(redacted) = &redacted { - Datum::String(redacted) - } else { - Datum::Null - }, - ]), - diff, - )); - - let mut row = Row::default(); - let mut packer = row.packer(); - - fn append_modifier(packer: &mut RowPacker<'_>, mods: &[i64]) { - if mods.is_empty() { - packer.push(Datum::Null); - } else { - packer.push_list(mods.iter().map(|m| Datum::Int64(*m))); - } - } - - let index_id = match &typ.details.typ { - CatalogType::Array { - element_reference: element_id, - } => { - packer.push(Datum::String(&id.to_string())); - packer.push(Datum::String(&element_id.to_string())); - &MZ_ARRAY_TYPES - } - CatalogType::List { - element_reference: element_id, - element_modifiers, - } => { - packer.push(Datum::String(&id.to_string())); - packer.push(Datum::String(&element_id.to_string())); - append_modifier(&mut packer, element_modifiers); - &MZ_LIST_TYPES - } - CatalogType::Map { - key_reference: key_id, - value_reference: value_id, - key_modifiers, - value_modifiers, - } => { - packer.push(Datum::String(&id.to_string())); - packer.push(Datum::String(&key_id.to_string())); - packer.push(Datum::String(&value_id.to_string())); - append_modifier(&mut packer, key_modifiers); - append_modifier(&mut packer, value_modifiers); - &MZ_MAP_TYPES - } - CatalogType::Pseudo => { - packer.push(Datum::String(&id.to_string())); - &MZ_PSEUDO_TYPES - } - _ => { - packer.push(Datum::String(&id.to_string())); - &MZ_BASE_TYPES - } - }; - out.push(BuiltinTableUpdate::row(index_id, row, diff)); - - if let Some(pg_metadata) = &typ.details.pg_metadata { - // Resolved the same way as a column's wire type, so this matches the - // `type_len` pgwire sends in `RowDescription`. Pseudo-types and arrays - // of them (`_record`) have no scalar type, so their length is unknown. - let typlen = - match mz_sql::plan::scalar_type_from_catalog(&self.for_system_session(), id, &[]) { - Ok(scalar_type) => Datum::Int16(mz_pgrepr::Type::from(&scalar_type).typlen()), - Err(_) => Datum::Null, - }; - out.push(BuiltinTableUpdate::row( - &*MZ_TYPE_PG_METADATA, - Row::pack_slice(&[ - Datum::String(&id.to_string()), - Datum::UInt32(pg_metadata.typinput_oid), - Datum::UInt32(pg_metadata.typreceive_oid), - Datum::UInt32(pg_metadata.typsend_oid), - typlen, - ]), - diff, - )); - } - - out - } - fn pack_func_update( &self, id: CatalogItemId, @@ -566,23 +433,6 @@ impl CatalogState { ) } - fn pack_privilege_array_row(&self, privileges: &PrivilegeMap) -> Row { - let mut row = Row::default(); - let flat_privileges: Vec<_> = privileges.all_values_owned().collect(); - row.packer() - .try_push_array( - &[ArrayDimension { - lower_bound: 1, - length: flat_privileges.len(), - }], - flat_privileges - .into_iter() - .map(|mz_acl_item| Datum::MzAclItem(mz_acl_item.clone())), - ) - .expect("privileges is 1 dimensional, and its length is used for the array length"); - row - } - pub fn pack_webhook_source_update( &self, item_id: CatalogItemId, diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index 49b9504de623b..4b24be044c7c6 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -1571,7 +1571,8 @@ pub static BUILTINS_STATIC: LazyLock>> = LazyLock::ne // themselves. The real ones are built below. { let ontology_preview = ontology::generate_views(&builtin_items); - let builtin_reporter_preview: Vec<_> = builtin::builtins(&builtin_items).collect(); + let builtin_reporter_preview: Vec<_> = + builtin::builtins(&builtin_types, &builtin_items).collect(); let generator_input: Vec<_> = builtin_types .iter() .chain(builtin_funcs.iter()) @@ -1598,7 +1599,7 @@ pub static BUILTINS_STATIC: LazyLock>> = LazyLock::ne // Generate builtin relations reporting builtin objects last, since they need a complete view // of all other builtins. - let mut builtin_builtins = builtin::builtins(&builtin_items).collect(); + let mut builtin_builtins = builtin::builtins(&builtin_types, &builtin_items).collect(); // Construct the full list of builtins, retaining dependency order. let mut builtins = Vec::new(); diff --git a/src/catalog/src/builtin/builtin.rs b/src/catalog/src/builtin/builtin.rs index cf132d0ed2c5c..5952ceef2c1aa 100644 --- a/src/catalog/src/builtin/builtin.rs +++ b/src/catalog/src/builtin/builtin.rs @@ -22,16 +22,18 @@ use mz_repr::namespaces::MZ_INTERNAL_SCHEMA; use mz_repr::{RelationDesc, SqlScalarType}; use mz_sql::ast::Statement; use mz_sql::ast::display::{AstDisplay, escaped_string_literal}; -use mz_sql::catalog::{NameReference, ObjectType}; +use mz_sql::catalog::{CatalogType, NameReference, ObjectType, TypeCategory}; use mz_sql::rbac; use mz_sql::session::user::MZ_SYSTEM_ROLE_ID; -use crate::builtin::{Builtin, BuiltinView, PUBLIC_SELECT, assert_safe_builtin_name}; +use crate::builtin::{Builtin, BuiltinType, BuiltinView, PUBLIC_SELECT, assert_safe_builtin_name}; /// Generate builtin views reporting the given builtins. /// -/// Used in the [`super::BUILTINS_STATIC`] initializer. +/// Used in the [`super::BUILTINS_STATIC`] initializer, which keeps the +/// `Builtin::Type`s in `builtin_types` apart from the other `builtin_items`. pub(super) fn builtins( + builtin_types: &[Builtin], builtin_items: &[Builtin], ) -> impl Iterator> { let sources: &'static BuiltinView = Box::leak(Box::new(make_builtin_sources(builtin_items))); @@ -43,6 +45,7 @@ pub(super) fn builtins( Box::leak(Box::new(make_builtin_log_indexes(builtin_items))); let index_columns: &'static BuiltinView = Box::leak(Box::new(make_builtin_index_columns(builtin_items))); + let types: &'static BuiltinView = Box::leak(Box::new(make_builtin_types(builtin_types))); // The generated views above, and `mz_builtin_views` itself, are listed in // `mz_builtin_views` with placeholder SQL rather than their real @@ -63,6 +66,7 @@ pub(super) fn builtins( indexes, index_columns, &columns, + types, ], ))); make_builtin_columns_sql( @@ -74,6 +78,7 @@ pub(super) fn builtins( tables, indexes, index_columns, + types, views, ], &mut columns, @@ -90,6 +95,7 @@ pub(super) fn builtins( indexes, index_columns, columns, + types, views, ] .into_iter() @@ -440,6 +446,126 @@ FROM (VALUES {values}) AS v(oid, schema_name, name, col_list, privileges)" } } +/// Generates `mz_internal.mz_builtin_types`, which our builtin type relations +/// use to report builtin types. +fn make_builtin_types(builtin_types: &[Builtin]) -> BuiltinView { + let types: Vec<&BuiltinType> = builtin_types + .iter() + .filter_map(|b| match b { + Builtin::Type(t) => Some(*t), + _ => None, + }) + .collect(); + let by_name: BTreeMap<&str, &BuiltinType> = + types.iter().map(|t| (t.name, *t)).collect(); + // The privileges `apply_system_object_mapping_update` grants every builtin + // type. + let privileges = make_privileges_sql( + &[rbac::default_builtin_object_privilege(ObjectType::Type)], + &rbac::owner_privilege(ObjectType::Type, MZ_SYSTEM_ROLE_ID), + ); + let values = types + .iter() + .map(|t| { + assert_safe_builtin_name(t.name, "type"); + let (type_kind, element) = match &t.details.typ { + CatalogType::Array { element_reference } => ("array", Some(*element_reference)), + CatalogType::Pseudo => ("pseudo", None), + // `mz_list_types` and `mz_map_types` read only user-defined + // types, so a builtin list or map would go unreported. + CatalogType::List { .. } | CatalogType::Map { .. } => panic!( + "builtin type {} is a list or map, which mz_builtin_types cannot report", + t.name + ), + _ => ("base", None), + }; + // + let (element_schema_name, element_name) = match element { + Some(name) => { + let element = by_name.get(name).unwrap_or_else(|| { + panic!( + "builtin type {} references unknown builtin type {name}", + t.name + ) + }); + ( + escaped_string_literal(element.schema).to_string(), + escaped_string_literal(name).to_string(), + ) + } + None => ("NULL::text".to_string(), "NULL::text".to_string()), + }; + let category = TypeCategory::from_catalog_type(&t.details.typ).to_string(); + let (typinput, typreceive, typsend) = match &t.details.pg_metadata { + Some(pg) => ( + format!("{}::oid", pg.typinput_oid), + format!("{}::oid", pg.typreceive_oid), + format!("{}::oid", pg.typsend_oid), + ), + None => ( + "NULL::oid".to_string(), + "NULL::oid".to_string(), + "NULL::oid".to_string(), + ), + }; + // `typlen` is NULL for a type without a pgwire type. + let typlen = match mz_pgrepr::Type::from_builtin_oid(t.oid) { + Some(pg_type) => format!("{}::int2", pg_type.typlen()), + None => "NULL::int2".to_string(), + }; + format!( + "({}::oid, {}, {}, {}, '{type_kind}', {privileges}, {element_schema_name}, {element_name}, {typinput}, {typreceive}, {typsend}, {typlen})", + t.oid, + escaped_string_literal(t.schema), + escaped_string_literal(t.name), + escaped_string_literal(&category), + ) + }) + .join(","); + let sql = format!( + " +SELECT oid, schema_name, name, category, type_kind, privileges, element_schema_name, element_name, typinput, typreceive, typsend, typlen +FROM (VALUES {values}) AS v(oid, schema_name, name, category, type_kind, privileges, element_schema_name, element_name, typinput, typreceive, typsend, typlen)" + ); + + BuiltinView { + name: "mz_builtin_types", + schema: MZ_INTERNAL_SCHEMA, + oid: oid::VIEW_MZ_BUILTIN_TYPES_OID, + desc: RelationDesc::builder() + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_name", SqlScalarType::String.nullable(false)) + .with_column("name", SqlScalarType::String.nullable(false)) + .with_column("category", SqlScalarType::String.nullable(false)) + // The per-kind view a type belongs to: `array`, `pseudo`, + // or `base` for everything else, range types included. + .with_column("type_kind", SqlScalarType::String.nullable(false)) + .with_column( + "privileges", + SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), + ) + // `element_schema_name` and `element_name` are an array type's element type. + .with_column("element_schema_name", SqlScalarType::String.nullable(true)) + .with_column("element_name", SqlScalarType::String.nullable(true)) + .with_column("typinput", SqlScalarType::Oid.nullable(true)) + .with_column("typreceive", SqlScalarType::Oid.nullable(true)) + .with_column("typsend", SqlScalarType::Oid.nullable(true)) + .with_column("typlen", SqlScalarType::Int16.nullable(true)) + // NOTE: The declared keys must exactly match the keys the + // optimizer derives from the generated VALUES list + // (`verify_builtin_descs` enforces this). Builtin type names are + // unique across schemas, which `test_builtins_static_dependency_order` + // asserts, so `name` is a key. + .with_key(vec![0]) + .with_key(vec![2]) + .finish(), + column_comments: Default::default(), + sql: Box::leak(sql.into_boxed_str()), + access: vec![PUBLIC_SELECT], + ontology: None, + } +} + /// Generates `mz_internal.mz_builtin_views`, listing every builtin view, /// including itself and the `generated` views. /// @@ -460,7 +586,7 @@ FROM (VALUES {values}) AS v(oid, schema_name, name, col_list, privileges)" /// declared keys rely on. fn make_builtin_views( builtin_items: &[Builtin], - generated: [&BuiltinView; 7], + generated: [&BuiltinView; 8], ) -> BuiltinView { let iter = builtin_items.iter().filter_map(|b| match b { Builtin::View(x) => Some(*x), @@ -572,7 +698,7 @@ fn builtin_columns_view() -> BuiltinView { /// itself. fn make_builtin_columns_sql( builtin_items: &[Builtin], - generated: [&BuiltinView; 7], + generated: [&BuiltinView; 8], columns: &mut BuiltinView, ) { // Map to (schema, relation, desc) diff --git a/src/pgrepr-consts/src/oid.rs b/src/pgrepr-consts/src/oid.rs index 919bf45816c76..796155b61adab 100644 --- a/src/pgrepr-consts/src/oid.rs +++ b/src/pgrepr-consts/src/oid.rs @@ -857,3 +857,4 @@ pub const VIEW_MZ_CATALOG_ITEM_METADATA_OID: u32 = 17147; pub const INDEX_MZ_CATALOG_ITEM_METADATA_IND_OID: u32 = 17148; pub const VIEW_MZ_BUILTIN_OBJECT_MAPPINGS_OID: u32 = 17150; pub const INDEX_MZ_BUILTIN_OBJECT_MAPPINGS_IND_OID: u32 = 17151; +pub const VIEW_MZ_BUILTIN_TYPES_OID: u32 = 17152; diff --git a/src/pgrepr/src/types.rs b/src/pgrepr/src/types.rs index 3d8d15cd94cc1..8dc16b2bcd787 100644 --- a/src/pgrepr/src/types.rs +++ b/src/pgrepr/src/types.rs @@ -534,18 +534,13 @@ impl Type { Type::from_oid_and_typmod(oid, -1) } - /// The name of the type with OID `oid`. - /// - /// Our existing [`Type::from_oid`] only accepts `oid`s that `rust-postgres` - /// knows about, thus we need a match statement to handle our custom `oid`s. + /// The type with OID `oid`, for every OID a builtin type carries. /// - /// We use this function such that our builtin relation `mz_catalog.mz_columns` - /// can get a type's name from its durably stored `oid` using a SQL scalar function. - /// However, we can replace the scalar function with a join on `mz_builtin_types` once it's been - /// implemented. - /// - /// TODO(SQL-495): Remove this function once `mz_builtin_types` is merged. - pub fn name_from_oid(oid: u32) -> Option<&'static str> { + /// [`Type::from_oid`] accepts only the OIDs `rust-postgres` knows, so this + /// adds Materialize's own types. `None` for a pseudo-type with no wire + /// type, such as `list`, `map` and `anyelement`. `record` is a + /// [`Type::Record`] without fields. + pub fn from_builtin_oid(oid: u32) -> Option { let typ = match oid { oid::TYPE_NAME_OID => Type::Name, oid::TYPE_NAME_ARRAY_OID => Type::Array(Box::new(Type::Name)), @@ -565,11 +560,25 @@ impl Type { oid::TYPE_MZ_ACL_ITEM_ARRAY_OID => Type::Array(Box::new(Type::MzAclItem)), oid::TYPE_RECORD_OID => Type::Record(vec![]), oid::TYPE_RECORD_ARRAY_OID => Type::Array(Box::new(Type::Record(vec![]))), - oid::TYPE_LIST_OID => return Some(LIST.name()), - oid::TYPE_MAP_OID => return Some(MAP.name()), _ => Type::from_oid(oid).ok()?, }; - Some(typ.name()) + Some(typ) + } + + /// The name of the type with OID `oid`. + /// + /// We use this function such that our builtin relation `mz_catalog.mz_columns` + /// can get a type's name from its durably stored `oid` using a SQL scalar function. + /// However, we can replace the scalar function with a join on `mz_builtin_types` once it's been + /// implemented. + /// + /// TODO(SQL-495): Remove this function once `mz_builtin_types` is merged. + pub fn name_from_oid(oid: u32) -> Option<&'static str> { + match oid { + oid::TYPE_LIST_OID => Some(LIST.name()), + oid::TYPE_MAP_OID => Some(MAP.name()), + _ => Some(Type::from_builtin_oid(oid)?.name()), + } } /// Returns the `Type` corresponding to the provided OID and packed type From b1fec7389fbe45ddf0deffe1f8fc94301b99dcb1 Mon Sep 17 00:00:00 2001 From: SangJunBak Date: Mon, 16 Nov 2026 19:35:10 -0500 Subject: [PATCH 02/10] catalog: define the type relations as views over the catalog items - Adds decoding code for user types - Converts mz_types, mz_array_types, mz_base_types, mz_list_types, mz_map_types, mz_pseudo_types and mz_type_pg_metadata to builtin views --- src/catalog-decode/src/create_sql.rs | 155 +++++++++++++++++++++++-- src/catalog/src/builtin.rs | 14 +-- src/catalog/src/builtin/mz_catalog.rs | 149 ++++++++++++++++++++---- src/catalog/src/builtin/mz_internal.rs | 21 +++- src/pgrepr-consts/src/oid.rs | 14 +-- 5 files changed, 307 insertions(+), 46 deletions(-) diff --git a/src/catalog-decode/src/create_sql.rs b/src/catalog-decode/src/create_sql.rs index 629ed3f351f1c..9d3d599e6cce9 100644 --- a/src/catalog-decode/src/create_sql.rs +++ b/src/catalog-decode/src/create_sql.rs @@ -22,12 +22,12 @@ use mz_sql_parser::ast::item_refs::collect_item_references; use mz_sql_parser::ast::{ AstInfo, AvroSchema, ColumnOption, ConnectionOption, ConnectionOptionName, CreateConnectionType, CreateSinkConnection, CreateSourceOptionName, CreateSubsourceOptionName, - Expr, Format, FormatSpecifier, IcebergSinkConfigOptionName, IcebergSinkMode, IndexOptionName, - KafkaSinkConfigOptionName, KafkaSourceConfigOptionName, MaterializedViewOptionName, - PgConfigOptionName, ProtobufSchema, Raw, RawClusterName, RawItemName, RefreshAtOptionValue, - RefreshEveryOptionValue, RefreshOptionValue, SinkEnvelope, SourceEnvelope, SourceErrorPolicy, - Statement, TableFromSourceOptionName, TableOptionName, UnresolvedItemName, Value, - WithOptionValue, + CreateTypeAs, CreateTypeListOptionName, CreateTypeMapOptionName, Expr, Format, FormatSpecifier, + IcebergSinkConfigOptionName, IcebergSinkMode, IndexOptionName, KafkaSinkConfigOptionName, + KafkaSourceConfigOptionName, MaterializedViewOptionName, PgConfigOptionName, ProtobufSchema, + Raw, RawClusterName, RawDataType, RawItemName, RefreshAtOptionValue, RefreshEveryOptionValue, + RefreshOptionValue, SinkEnvelope, SourceEnvelope, SourceErrorPolicy, Statement, + TableFromSourceOptionName, TableOptionName, UnresolvedItemName, Value, WithOptionValue, }; use prost::Message as _; use serde_json::json; @@ -152,6 +152,43 @@ fn is_null_literal(expr: &Expr) -> bool { } } +/// The item id and type modifiers of a `CREATE TYPE` option. +fn type_option( + value: Option>, + option: &str, +) -> Result<(String, Vec), String> { + // `plan_create_type` only accepts named types for list elements, map keys and + // values, and record fields, so a persisted statement always carries a + // `RawDataType::Other` whose name is an item id. + match value { + Some(WithOptionValue::DataType(RawDataType::Other { name, typ_mod })) => { + Ok((item_id(name)?, typ_mod)) + } + _ => Err(format!("{option} is not a named data type")), + } +} + +/// Records a type reference as `id_key`, plus `modifiers_key` when the reference +/// carries type modifiers. Modifiers are rendered as a `bigint list` literal +/// (`{38,2}`) for the views to cast, and an absent key is how `mz_list_types` +/// and `mz_map_types` report a reference without modifiers as NULL. +fn insert_type_reference( + info: &mut BTreeMap<&str, serde_json::Value>, + id_key: &'static str, + modifiers_key: &'static str, + (id, modifiers): (String, Vec), +) { + info.insert(id_key, json!(id)); + if !modifiers.is_empty() { + let modifiers = modifiers + .iter() + .map(|m| m.to_string()) + .collect::>() + .join(","); + info.insert(modifiers_key, json!(format!("{{{modifiers}}}"))); + } +} + /// Records the `REFRESH` options among `options` as `refresh` in `info`, one entry per option in /// statement order. fn insert_refresh_strategies<'a, T: AstInfo + 'a>( @@ -561,7 +598,40 @@ pub fn item_details(a: &str) -> Result { info.insert("key_parts", json!(key_parts)); "index" } - CreateType(_) => "type", + CreateType(stmt) => { + let (type_kind, category) = match stmt.as_type { + CreateTypeAs::List { options } => { + let element = options + .into_iter() + .find(|o| o.name == CreateTypeListOptionName::ElementType) + .and_then(|o| o.value); + let element = type_option(element, "ELEMENT TYPE")?; + insert_type_reference(&mut info, "element_id", "element_modifiers", element); + ("list", "list") + } + CreateTypeAs::Map { options } => { + let mut key = None; + let mut value = None; + for option in options { + match option.name { + CreateTypeMapOptionName::KeyType => key = option.value, + CreateTypeMapOptionName::ValueType => value = option.value, + } + } + let key = type_option(key, "KEY TYPE")?; + let value = type_option(value, "VALUE TYPE")?; + insert_type_reference(&mut info, "key_id", "key_modifiers", key); + insert_type_reference(&mut info, "value_id", "value_modifiers", value); + ("map", "pseudo") + } + CreateTypeAs::Record { .. } => ("record", "composite"), + }; + info.insert("type_kind", json!(type_kind)); + // Mirrors `TypeCategory::from_catalog_type` in `mz_sql` for the three + // kinds `CREATE TYPE` can produce. + info.insert("category", json!(category)); + "type" + } // NOTE: every statement that creates a catalog item needs an arm above. These // catalog views run this over every item row before their type filter drops the // unwanted rows, so one unclassified `create_sql` takes out `mz_objects`, @@ -1942,7 +2012,7 @@ mod tests { "index", ), ( - "CREATE TYPE \"materialize\".\"public\".\"ty\" AS LIST (ELEMENT TYPE = int4)", + "CREATE TYPE \"materialize\".\"public\".\"ty\" AS LIST (ELEMENT TYPE = [s20 AS pg_catalog.int4])", "type", ), ( @@ -2344,4 +2414,73 @@ mod tests { let out = super::item_details(mv_sql_with_replacement).expect("ok"); assert_eq!(out["replacement_target"], json!("u7")); } + + // --- parse_catalog_create_sql, CreateType arm ---------------------------- + + #[mz_ore::test] + fn catalog_type_list() { + let sql = "CREATE TYPE \"materialize\".\"public\".\"int4_list\" \ + AS LIST (ELEMENT TYPE = [s20 AS \"pg_catalog\".\"int4\"])"; + let out = super::item_details(sql).expect("ok"); + assert_eq!( + out, + json!({ + "type": "type", + "type_kind": "list", + "category": "list", + "element_id": "s20", + }) + ); + } + + #[mz_ore::test] + fn catalog_type_list_with_modifiers() { + let sql = "CREATE TYPE \"materialize\".\"public\".\"nums\" \ + AS LIST (ELEMENT TYPE = [s27 AS \"pg_catalog\".\"numeric\"](38, 2))"; + let out = super::item_details(sql).expect("ok"); + assert_eq!(out["element_id"], json!("s27")); + assert_eq!(out["element_modifiers"], json!("{38,2}")); + } + + #[mz_ore::test] + fn catalog_type_map() { + let sql = "CREATE TYPE \"materialize\".\"public\".\"m\" \ + AS MAP (KEY TYPE = [s46 AS \"pg_catalog\".\"text\"], \ + VALUE TYPE = [s27 AS \"pg_catalog\".\"numeric\"](5, 2))"; + let out = super::item_details(sql).expect("ok"); + assert_eq!( + out, + json!({ + "type": "type", + "type_kind": "map", + "category": "pseudo", + "key_id": "s46", + "value_id": "s27", + "value_modifiers": "{5,2}", + }) + ); + } + + #[mz_ore::test] + fn catalog_type_record() { + let sql = "CREATE TYPE \"materialize\".\"public\".\"y1\" \ + AS (\"id\" [s20 AS \"pg_catalog\".\"int4\"], \ + \"name\" [s46 AS \"pg_catalog\".\"text\"])"; + let out = super::item_details(sql).expect("ok"); + assert_eq!( + out, + json!({ + "type": "type", + "type_kind": "record", + "category": "composite", + }) + ); + } + + #[mz_ore::test] + fn catalog_type_unresolved_element_is_an_error() { + let sql = "CREATE TYPE \"materialize\".\"public\".\"l\" AS LIST (ELEMENT TYPE = int4)"; + let err = super::item_details(sql).unwrap_err(); + assert!(err.contains("unresolved item name"), "{err}"); + } } diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index 4b24be044c7c6..7ce58fb813ac3 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -1211,17 +1211,17 @@ pub static BUILTINS_STATIC: LazyLock>> = LazyLock::ne Builtin::MaterializedView(&MZ_KAFKA_SOURCE_TABLES), Builtin::MaterializedView(&MZ_SINKS), Builtin::MaterializedView(&MZ_VIEWS), - Builtin::Table(&MZ_TYPES), - Builtin::Table(&MZ_TYPE_PG_METADATA), - Builtin::Table(&MZ_ARRAY_TYPES), - Builtin::Table(&MZ_BASE_TYPES), - Builtin::Table(&MZ_LIST_TYPES), - Builtin::Table(&MZ_MAP_TYPES), + Builtin::View(&MZ_TYPES), + Builtin::View(&MZ_TYPE_PG_METADATA), + Builtin::View(&MZ_ARRAY_TYPES), + Builtin::View(&MZ_BASE_TYPES), + Builtin::View(&MZ_LIST_TYPES), + Builtin::View(&MZ_MAP_TYPES), Builtin::MaterializedView(&MZ_ROLES), Builtin::Table(&MZ_ROLE_AUTH), Builtin::MaterializedView(&MZ_ROLE_MEMBERS), Builtin::MaterializedView(&MZ_ROLE_PARAMETERS), - Builtin::Table(&MZ_PSEUDO_TYPES), + Builtin::View(&MZ_PSEUDO_TYPES), Builtin::Table(&MZ_FUNCTIONS), Builtin::Table(&MZ_OPERATORS), Builtin::Table(&MZ_AGGREGATES), diff --git a/src/catalog/src/builtin/mz_catalog.rs b/src/catalog/src/builtin/mz_catalog.rs index f392f2fc9c8cb..9a2405357dcf4 100644 --- a/src/catalog/src/builtin/mz_catalog.rs +++ b/src/catalog/src/builtin/mz_catalog.rs @@ -2109,10 +2109,10 @@ SELECT * FROM builtin_mvs").into_boxed_str()), }), } }); -pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { +pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinView { name: "mz_types", schema: MZ_CATALOG_SCHEMA, - oid: oid::TABLE_MZ_TYPES_OID, + oid: oid::VIEW_MZ_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) .with_column("oid", SqlScalarType::Oid.nullable(false)) @@ -2126,8 +2126,6 @@ pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { ) .with_column("create_sql", SqlScalarType::String.nullable(true)) .with_column("redacted_create_sql", SqlScalarType::String.nullable(true)) - .with_key(vec![0]) - .with_key(vec![1]) .finish(), column_comments: BTreeMap::from_iter([ ("id", "Materialize's unique ID for the type."), @@ -2149,7 +2147,47 @@ pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { "The redacted `CREATE` SQL statement for the type.", ), ]), - is_retained_metrics_object: false, + sql: Box::leak( + format!( + " +WITH + user_types AS ( + SELECT + id, + oid, + schema_id, + name, + COALESCE(details->>'category', '') AS category, + owner_id, + privileges, + create_sql, + redacted_create_sql + FROM mz_internal.mz_catalog_items + WHERE type = 'type' + ), + builtin_types AS ( + SELECT + m.id, + t.oid, + s.id AS schema_id, + t.name, + t.category, + '{MZ_SYSTEM_ROLE_ID}' AS owner_id, + t.privileges, + NULL::text AS create_sql, + NULL::text AS redacted_create_sql + FROM mz_internal.mz_builtin_types t + JOIN mz_internal.mz_builtin_object_mappings m + ON m.schema_name = t.schema_name AND m.name = t.name AND m.object_type = {object_type} + JOIN mz_catalog.mz_schemas s ON s.name = t.schema_name AND s.database_id IS NULL + ) +SELECT * FROM user_types +UNION ALL +SELECT * FROM builtin_types", + object_type = gid_mapping_object_type(CatalogItemType::Type), + ) + .into_boxed_str(), + ), access: vec![PUBLIC_SELECT], ontology: Some(Ontology { entity_name: "type", @@ -2180,10 +2218,11 @@ pub static MZ_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { }, }), }); -pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { +pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| { + BuiltinView { name: "mz_array_types", schema: MZ_CATALOG_SCHEMA, - oid: oid::TABLE_MZ_ARRAY_TYPES_OID, + oid: oid::VIEW_MZ_ARRAY_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) .with_column("element_id", SqlScalarType::String.nullable(false)) @@ -2192,7 +2231,20 @@ pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| BuiltinTabl ("id", "The ID of the array type."), ("element_id", "The ID of the array's element type."), ]), - is_retained_metrics_object: false, + sql: Box::leak( + format!( + " +SELECT m.id, e.id AS element_id +FROM mz_internal.mz_builtin_types t +JOIN mz_internal.mz_builtin_object_mappings m + ON m.schema_name = t.schema_name AND m.name = t.name AND m.object_type = {object_type} +JOIN mz_internal.mz_builtin_object_mappings e + ON e.schema_name = t.element_schema_name AND e.name = t.element_name AND e.object_type = {object_type} +WHERE t.type_kind = 'array'", + object_type = gid_mapping_object_type(CatalogItemType::Type), + ) + .into_boxed_str(), + ), access: vec![PUBLIC_SELECT], ontology: Some(Ontology { entity_name: "array_type", @@ -2218,16 +2270,36 @@ pub static MZ_ARRAY_TYPES: LazyLock = LazyLock::new(|| BuiltinTabl ] }, }), +} }); -pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { +pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinView { name: "mz_base_types", schema: MZ_CATALOG_SCHEMA, - oid: oid::TABLE_MZ_BASE_TYPES_OID, + oid: oid::VIEW_MZ_BASE_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]), - is_retained_metrics_object: false, + sql: Box::leak( + format!( + " +WITH + user_types AS ( + SELECT id, details + FROM mz_internal.mz_catalog_item_metadata + WHERE type = 'type' + ) +SELECT m.id +FROM mz_internal.mz_builtin_types t +JOIN mz_internal.mz_builtin_object_mappings m + ON m.schema_name = t.schema_name AND m.name = t.name AND m.object_type = {object_type} +WHERE t.type_kind = 'base' +UNION ALL +SELECT id FROM user_types WHERE details->>'type_kind' = 'record'", + object_type = gid_mapping_object_type(CatalogItemType::Type), + ) + .into_boxed_str(), + ), access: vec![PUBLIC_SELECT], ontology: Some(Ontology { entity_name: "base_type", @@ -2236,10 +2308,10 @@ pub static MZ_BASE_TYPES: LazyLock = LazyLock::new(|| BuiltinTable column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); -pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { +pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinView { name: "mz_list_types", schema: MZ_CATALOG_SCHEMA, - oid: oid::TABLE_MZ_LIST_TYPES_OID, + oid: oid::VIEW_MZ_LIST_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) .with_column("element_id", SqlScalarType::String.nullable(false)) @@ -2260,7 +2332,19 @@ pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable "The element type modifiers, or `NULL` if none.", ), ]), - is_retained_metrics_object: false, + sql: " +WITH + user_types AS ( + SELECT id, details + FROM mz_internal.mz_catalog_item_metadata + WHERE type = 'type' + ) +SELECT + id, + COALESCE(details->>'element_id', '') AS element_id, + (details->>'element_modifiers')::bigint list AS element_modifiers +FROM user_types +WHERE details->>'type_kind' = 'list'", access: vec![PUBLIC_SELECT], ontology: Some(Ontology { entity_name: "list_type", @@ -2287,10 +2371,10 @@ pub static MZ_LIST_TYPES: LazyLock = LazyLock::new(|| BuiltinTable }, }), }); -pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { +pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinView { name: "mz_map_types", schema: MZ_CATALOG_SCHEMA, - oid: oid::TABLE_MZ_MAP_TYPES_OID, + oid: oid::VIEW_MZ_MAP_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) .with_column("key_id", SqlScalarType::String.nullable(false)) @@ -2325,7 +2409,21 @@ pub static MZ_MAP_TYPES: LazyLock = LazyLock::new(|| BuiltinTable "The value type modifiers, or `NULL` if none.", ), ]), - is_retained_metrics_object: false, + sql: " +WITH + user_types AS ( + SELECT id, details + FROM mz_internal.mz_catalog_item_metadata + WHERE type = 'type' + ) +SELECT + id, + COALESCE(details->>'key_id', '') AS key_id, + COALESCE(details->>'value_id', '') AS value_id, + (details->>'key_modifiers')::bigint list AS key_modifiers, + (details->>'value_modifiers')::bigint list AS value_modifiers +FROM user_types +WHERE details->>'type_kind' = 'map'", access: vec![PUBLIC_SELECT], ontology: Some(Ontology { entity_name: "map_type", @@ -2595,15 +2693,26 @@ pub static MZ_ROLE_AUTH: LazyLock = LazyLock::new(|| BuiltinTable access: vec![rbac::owner_privilege(ObjectType::Table, MZ_SYSTEM_ROLE_ID)], ontology: None, }); -pub static MZ_PSEUDO_TYPES: LazyLock = LazyLock::new(|| BuiltinTable { +pub static MZ_PSEUDO_TYPES: LazyLock = LazyLock::new(|| BuiltinView { name: "mz_pseudo_types", schema: MZ_CATALOG_SCHEMA, - oid: oid::TABLE_MZ_PSEUDO_TYPES_OID, + oid: oid::VIEW_MZ_PSEUDO_TYPES_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) .finish(), column_comments: BTreeMap::from_iter([("id", "The ID of the type.")]), - is_retained_metrics_object: false, + sql: Box::leak( + format!( + " +SELECT m.id +FROM mz_internal.mz_builtin_types t +JOIN mz_internal.mz_builtin_object_mappings m + ON m.schema_name = t.schema_name AND m.name = t.name AND m.object_type = {object_type} +WHERE t.type_kind = 'pseudo'", + object_type = gid_mapping_object_type(CatalogItemType::Type), + ) + .into_boxed_str(), + ), access: vec![PUBLIC_SELECT], ontology: Some(Ontology { entity_name: "pseudo_type", diff --git a/src/catalog/src/builtin/mz_internal.rs b/src/catalog/src/builtin/mz_internal.rs index 7b8292aebfbc9..bebb9b06cc988 100644 --- a/src/catalog/src/builtin/mz_internal.rs +++ b/src/catalog/src/builtin/mz_internal.rs @@ -1054,11 +1054,11 @@ WHERE data->>'kind' = 'Cluster' }); /// PostgreSQL-specific metadata about types that doesn't make sense to expose -/// in the `mz_types` table as part of our public, stable API. -pub static MZ_TYPE_PG_METADATA: LazyLock = LazyLock::new(|| BuiltinTable { +/// in `mz_types` as part of our public, stable API. +pub static MZ_TYPE_PG_METADATA: LazyLock = LazyLock::new(|| BuiltinView { name: "mz_type_pg_metadata", schema: MZ_INTERNAL_SCHEMA, - oid: oid::TABLE_MZ_TYPE_PG_METADATA_OID, + oid: oid::VIEW_MZ_TYPE_PG_METADATA_OID, desc: RelationDesc::builder() .with_column("id", SqlScalarType::String.nullable(false)) .with_column("typinput", SqlScalarType::Oid.nullable(false)) @@ -1071,7 +1071,20 @@ pub static MZ_TYPE_PG_METADATA: LazyLock = LazyLock::new(|| Builti .with_column("typlen", SqlScalarType::Int16.nullable(true)) .finish(), column_comments: BTreeMap::new(), - is_retained_metrics_object: false, + sql: Box::leak( + format!( + " +SELECT m.id, t.typinput, t.typreceive, t.typsend, t.typlen +FROM mz_internal.mz_builtin_types t +JOIN mz_internal.mz_builtin_object_mappings m + ON m.schema_name = t.schema_name AND m.name = t.name AND m.object_type = {object_type} +WHERE t.typinput IS NOT NULL AND t.typreceive IS NOT NULL AND t.typsend IS NOT NULL", + object_type = super::builtin::gid_mapping_object_type( + mz_catalog_protos::objects::CatalogItemType::Type + ), + ) + .into_boxed_str(), + ), access: vec![PUBLIC_SELECT], ontology: None, }); diff --git a/src/pgrepr-consts/src/oid.rs b/src/pgrepr-consts/src/oid.rs index 796155b61adab..b43f6ff03af0c 100644 --- a/src/pgrepr-consts/src/oid.rs +++ b/src/pgrepr-consts/src/oid.rs @@ -436,15 +436,15 @@ pub const MV_MZ_SOURCES_OID: u32 = 16710; pub const MV_MZ_SINKS_OID: u32 = 16711; pub const MV_MZ_VIEWS_OID: u32 = 16712; pub const MV_MZ_MATERIALIZED_VIEWS_OID: u32 = 16713; -pub const TABLE_MZ_TYPES_OID: u32 = 16714; -pub const TABLE_MZ_TYPE_PG_METADATA_OID: u32 = 16715; -pub const TABLE_MZ_ARRAY_TYPES_OID: u32 = 16716; -pub const TABLE_MZ_BASE_TYPES_OID: u32 = 16717; -pub const TABLE_MZ_LIST_TYPES_OID: u32 = 16718; -pub const TABLE_MZ_MAP_TYPES_OID: u32 = 16719; +pub const VIEW_MZ_TYPES_OID: u32 = 16714; +pub const VIEW_MZ_TYPE_PG_METADATA_OID: u32 = 16715; +pub const VIEW_MZ_ARRAY_TYPES_OID: u32 = 16716; +pub const VIEW_MZ_BASE_TYPES_OID: u32 = 16717; +pub const VIEW_MZ_LIST_TYPES_OID: u32 = 16718; +pub const VIEW_MZ_MAP_TYPES_OID: u32 = 16719; pub const MV_MZ_ROLES_OID: u32 = 16720; pub const MV_MZ_ROLE_MEMBERS_OID: u32 = 16721; -pub const TABLE_MZ_PSEUDO_TYPES_OID: u32 = 16722; +pub const VIEW_MZ_PSEUDO_TYPES_OID: u32 = 16722; pub const TABLE_MZ_FUNCTIONS_OID: u32 = 16723; pub const TABLE_MZ_OPERATORS_OID: u32 = 16724; pub const TABLE_MZ_AGGREGATES_OID: u32 = 16725; From c78ca2ebb52214b005458d3dd8bc878b53681e5e Mon Sep 17 00:00:00 2001 From: SangJunBak Date: Mon, 16 Nov 2026 19:35:10 -0500 Subject: [PATCH 03/10] test: create SLTs for type relations - Creates tests for each builtin type relations such that it maintains parity with our previous builtin type relations - Creates a test on `try_decode_catalog_create_sql` and assert how errors affect the relation --- test/sqllogictest/type_relations.slt | 260 +++++++++++++++++++++++++++ 1 file changed, 260 insertions(+) create mode 100644 test/sqllogictest/type_relations.slt diff --git a/test/sqllogictest/type_relations.slt b/test/sqllogictest/type_relations.slt new file mode 100644 index 0000000000000..9682f020fd901 --- /dev/null +++ b/test/sqllogictest/type_relations.slt @@ -0,0 +1,260 @@ +# Copyright Materialize, Inc. and contributors. All rights reserved. +# +# Use of this software is governed by the Business Source License +# included in the LICENSE file at the root of this repository. +# +# As of the Change Date specified in that file, in accordance with +# the Business Source License, use of this software will be governed +# by the Apache License, Version 2.0. + +mode cockroach + +reset-server + +# --- user types --------------------------------------------------------------- + +# `int4_list` is the first object created after the reset, so it is u1. +statement ok +CREATE TYPE int4_list AS LIST (ELEMENT TYPE = int4) + +query TT +SELECT id, category FROM mz_types WHERE name = 'int4_list' +---- +u1 list + +query T +SELECT schema_id = (SELECT id FROM mz_schemas WHERE name = 'public' AND database_id IS NOT NULL) +FROM mz_types WHERE name = 'int4_list' +---- +true + +query T +SELECT owner_id = (SELECT id FROM mz_roles WHERE name = 'materialize') +FROM mz_types WHERE name = 'int4_list' +---- +true + +query T rowsort +SELECT unnest(privileges)::text FROM mz_types WHERE name = 'int4_list' +---- +=U/materialize +materialize=U/materialize + +query T multiline +SELECT create_sql FROM mz_types WHERE name = 'int4_list' +---- +CREATE TYPE "materialize"."public"."int4_list" AS LIST (ELEMENT TYPE = [s20 AS "pg_catalog"."int4"]) +EOF + +query T multiline +SELECT redacted_create_sql FROM mz_types WHERE name = 'int4_list' +---- +CREATE TYPE materialize.public.int4_list AS LIST (ELEMENT TYPE = [s20 AS pg_catalog.int4]) +EOF + +# The oid column is read out of the durable JSON, while a regtype cast resolves +# the name through the in-memory catalog. Two independent paths that must agree. +query T +SELECT oid = 'int4_list'::regtype::oid FROM mz_types WHERE name = 'int4_list' +---- +true + +# --- mz_list_types ------------------------------------------------------------ + +query TT +SELECT element_id = (SELECT id FROM mz_types WHERE name = 'int4'), element_modifiers IS NULL +FROM mz_list_types WHERE id = 'u1' +---- +true true + +# Element type modifiers come back as a bigint list. +statement ok +CREATE TYPE numeric_list AS LIST (ELEMENT TYPE = numeric(38, 2)) + +query TT +SELECT element_modifiers::text, pg_typeof(element_modifiers)::text = 'bigint list' +FROM mz_list_types l JOIN mz_types t USING (id) WHERE t.name = 'numeric_list' +---- +{38,2} true + +# --- mz_map_types ------------------------------------------------------------- + +statement ok +CREATE TYPE text_numeric_map AS MAP (KEY TYPE = text, VALUE TYPE = numeric(5, 2)) + +# A map's category is pseudo, as TypeCategory::from_catalog_type reports it. +query T +SELECT category FROM mz_types WHERE name = 'text_numeric_map' +---- +pseudo + +query TTTT +SELECT + key_id = (SELECT id FROM mz_types WHERE name = 'text'), + value_id = (SELECT id FROM mz_types WHERE name = 'numeric'), + key_modifiers IS NULL, + value_modifiers::text +FROM mz_map_types m JOIN mz_types t USING (id) WHERE t.name = 'text_numeric_map' +---- +true true true {5,2} + +# --- record types ------------------------------------------------------------- + +# A record type has no per-kind relation of its own and is reported as a base +# type. +statement ok +CREATE TYPE rec AS (a int4, b text) + +query T +SELECT category FROM mz_types WHERE name = 'rec' +---- +composite + +query I +SELECT count(*) FROM mz_base_types b JOIN mz_types t USING (id) WHERE t.name = 'rec' +---- +1 + +# User-defined types never carry PostgreSQL metadata. +query I +SELECT count(*) +FROM mz_internal.mz_type_pg_metadata m JOIN mz_types t USING (id) +WHERE t.id LIKE 'u%' +---- +0 + +# --- builtin types ------------------------------------------------------------ + +query TTTTT +SELECT id LIKE 's%', owner_id, create_sql IS NULL, redacted_create_sql IS NULL, category +FROM mz_types WHERE name = 'int4' +---- +true s1 true true numeric + +query T +SELECT schema_id = (SELECT id FROM mz_schemas WHERE name = 'pg_catalog' AND database_id IS NULL) +FROM mz_types WHERE name = 'int4' +---- +true + +query T +SELECT schema_id = (SELECT id FROM mz_schemas WHERE name = 'mz_catalog' AND database_id IS NULL) +FROM mz_types WHERE name = 'uint2' +---- +true + +# The oid is the compiled-in PostgreSQL oid, and the regtype cast agrees. +query IT +SELECT oid, oid = 'int4'::regtype::oid FROM mz_types WHERE name = 'int4' +---- +23 true + +query T rowsort +SELECT unnest(privileges)::text FROM mz_types WHERE name = 'int4' +---- +=U/mz_system +mz_system=U/mz_system + +# Exactly once: the user and builtin branches must not both claim a row. +query I +SELECT count(*) FROM mz_types WHERE name = 'int4' +---- +1 + +# --- mz_array_types ----------------------------------------------------------- + +# Array types are all builtin; element references resolve to the element's id. +query T +SELECT t.name +FROM mz_array_types a +JOIN mz_types arr ON a.id = arr.id +JOIN mz_types t ON a.element_id = t.id +WHERE arr.name = '_int4' +---- +int4 + +query I +SELECT count(*) FROM mz_array_types WHERE id LIKE 'u%' +---- +0 + +# --- mz_pseudo_types and mz_base_types ---------------------------------------- + +query T rowsort +SELECT t.name +FROM mz_pseudo_types p JOIN mz_types t USING (id) +WHERE t.name IN ('anyelement', 'record', 'list', 'map', 'int4') +---- +anyelement +list +map +record + +# Range types have no per-kind relation of their own and are base types. +query T rowsort +SELECT t.name +FROM mz_base_types b JOIN mz_types t USING (id) +WHERE t.name IN ('int4', 'int4range', '_int4', 'anyelement') +---- +int4 +int4range + +# --- mz_type_pg_metadata ------------------------------------------------------ + +query IIII +SELECT typinput, typreceive, typsend, typlen +FROM mz_internal.mz_type_pg_metadata m JOIN mz_types t USING (id) +WHERE t.name = 'int4' +---- +42 2406 2407 4 + +# typlen is the length pgwire reports for a column of the type: -1 for +# variable-length types, NULL for a pseudo-type with no pgwire type. +query TT rowsort +SELECT t.name, m.typlen::text +FROM mz_internal.mz_type_pg_metadata m JOIN mz_types t USING (id) +WHERE t.name IN ('_int4', 'text', 'record', '_record', 'anyelement', 'int4range') +---- +_int4 -1 +_record -1 +anyelement NULL +int4range -1 +record -1 +text -1 + +# A type without PostgreSQL metadata has no row. +query I +SELECT count(*) +FROM mz_internal.mz_type_pg_metadata m JOIN mz_types t USING (id) +WHERE t.name = 'uint2' +---- +0 + +# --- pg_type reads through all seven relations -------------------------------- + +query TTTII rowsort +SELECT typname, typtype::text, typcategory::text, typlen, typelem +FROM pg_type +WHERE typname IN ('int4', '_int4', 'anyelement', 'int4_list', 'text_numeric_map', 'rec') +---- +_int4 b A -1 23 +anyelement p P NULL 0 +int4 b N 4 0 +int4_list l U NULL 23 +rec b C NULL 0 +text_numeric_map m P NULL 0 + +# --- Lifecycle ---------------------------------------------------------------- + +statement ok +DROP TYPE rec + +query I +SELECT count(*) FROM mz_types WHERE name = 'rec' +---- +0 + +query I +SELECT count(*) FROM mz_base_types WHERE id LIKE 'u%' +---- +0 From 0fe4961be080b2a120c03a986b3563320d761302 Mon Sep 17 00:00:00 2001 From: SangJunBak Date: Mon, 16 Nov 2026 19:35:10 -0500 Subject: [PATCH 04/10] test: regenerate the catalog SLTs --- test/cluster/mzcompose.py | 4 +- .../autogenerated/mz_internal.slt | 1 + test/sqllogictest/catalog_server_explain.slt | 436 ++++++++++++++---- test/sqllogictest/github-2514.slt | 9 +- .../information_schema_tables.slt | 18 +- .../mz_catalog_server_index_accounting.slt | 180 ++++---- test/sqllogictest/mz_views.slt | 1 + test/sqllogictest/oid.slt | 1 + test/sqllogictest/transactions.slt | 9 +- test/testdrive/catalog.td | 17 +- 10 files changed, 464 insertions(+), 212 deletions(-) diff --git a/test/cluster/mzcompose.py b/test/cluster/mzcompose.py index e7790657e678e..3fcc665b1c5b8 100644 --- a/test/cluster/mzcompose.py +++ b/test/cluster/mzcompose.py @@ -6565,9 +6565,9 @@ def workflow_test_adhoc_system_indexes( WHERE i.name = 'mz_test_idx1' """) assert output[0] == ("u1", "mz_tables", "mz_catalog_server"), output - output = c.sql_query("EXPLAIN SELECT * FROM mz_tables WHERE char_length(name) = 8") + output = c.sql_query("EXPLAIN SELECT * FROM mz_tables WHERE char_length(name) = 12") assert "mz_test_idx1" in output[0][0], output - output = c.sql_query("SELECT * FROM mz_tables WHERE char_length(name) = 8") + output = c.sql_query("SELECT * FROM mz_tables WHERE char_length(name) = 12") assert len(output) > 0 # The system user should be able to create a new index on an unstable diff --git a/test/sqllogictest/autogenerated/mz_internal.slt b/test/sqllogictest/autogenerated/mz_internal.slt index ba23a8c189c5f..00d63a6de1a88 100644 --- a/test/sqllogictest/autogenerated/mz_internal.slt +++ b/test/sqllogictest/autogenerated/mz_internal.slt @@ -820,6 +820,7 @@ mz_builtin_materialized_views mz_builtin_object_mappings mz_builtin_sources mz_builtin_tables +mz_builtin_types mz_builtin_views mz_catalog_item_metadata mz_catalog_items diff --git a/test/sqllogictest/catalog_server_explain.slt b/test/sqllogictest/catalog_server_explain.slt index 3929141b227b9..b456a3e81da0c 100644 --- a/test/sqllogictest/catalog_server_explain.slt +++ b/test/sqllogictest/catalog_server_explain.slt @@ -469,7 +469,45 @@ mz_catalog.mz_types_ind: →Arrange (#2{schema_id}) →Stream mz_catalog.mz_types -Source mz_catalog.mz_types +mz_catalog.mz_types: + →Union + →Read mz_internal.mz_catalog_items + →Delta Join [%0[#1{schema_name}, #2{name}] » %1:mz_builtin_object_mappings[#0{schema_name}, #1{name}] » %2:mz_schemas[#1{name}]] [%1:mz_builtin_object_mappings[#0{schema_name}] » %0[#1{schema_name}, #2{name}] » %2:mz_schemas[#1{name}]] [%2:mz_schemas[#1{name}] » %1:mz_builtin_object_mappings[#0{schema_name}] » %0[#1{schema_name}, #2{name}]] + path %0: + Final closure: + Project: #3, #0, #4, #1, #2, #6, #5, #7, #7 + Map: {=U/s1, s1=U/s1}, "s1", null + path %1: + Final closure: + Project: #3, #0, #4, #1, #2, #6, #5, #7, #7 + Map: {=U/s1, s1=U/s1}, "s1", null + path %2: + Final closure: + Project: #3, #0, #4, #1, #2, #6, #5, #7, #7 + Map: {=U/s1, s1=U/s1}, "s1", null + →Arrange (#1{schema_name}, #2{name}) + →Constant (90 rows) + →Arrange (#0{schema_name}) (#0{schema_name}, #1{name}) + →Fused with Child Map/Filter/Project + Project: #0, #1, #3 + Filter: (#2{object_type} = "7") + →Arranged mz_internal.mz_builtin_object_mappings + Key: (#0{schema_name}, #1{name}) + →Arrange (#1{name}) + →Fused with Child Map/Filter/Project + Project: #1, #3 + Filter: (#0{database_id}) IS NULL + →Arranged mz_catalog.mz_schemas + Key: (#2{database_id}) + +Source mz_internal.mz_catalog_items + project=(#0, #2..=#4, #12, #5, #6, #9, #10) + filter=((#8{type} = "type")) + map=(coalesce((#11{details} ->> "category"), "")) + +Used Indexes: + - mz_internal.mz_builtin_object_mappings_ind (*** full scan ***) + - mz_catalog.mz_schemas_ind (*** full scan ***) Target cluster: mz_catalog_server @@ -2982,10 +3020,10 @@ mz_internal.mz_show_types: →Arranged mz_catalog.mz_types Key: (#2{schema_id}) cte l1 = - →Differential Join %0:l0[#0{id}] » %1:mz_comments[#0{id}] - after %1: - Project: #0..=#2, #5 - Filter: (#3{object_type} = "type") AND (#4{object_sub_id}) IS NULL + →Differential Join %1:mz_comments[#0{id}] » %0:l0[#0{id}] + after %0: + Project: #0, #4, #5, #3 + Filter: (#1{object_type} = "type") AND (#2{object_sub_id}) IS NULL →Arranged l0 →Arranged mz_internal.mz_comments →Return @@ -4360,16 +4398,45 @@ mz_internal.pg_type_all_databases_ind: mz_internal.pg_type_all_databases: →With cte l0 = + →Arranged mz_internal.mz_builtin_object_mappings + cte l1 = + →Delta Join [%0[#0{schema_name}, #1{name}] » %1:l0[#0{schema_name}, #1{name}] » %2:l0[#0{schema_name}, #1{name}]] [%1:l0[#0{schema_name}, #1{name}] » %0[#0{schema_name}, #1{name}] » %2:l0[#0{schema_name}, #1{name}]] [%2:l0[#0{schema_name}, #1{name}] » %0[#2{element_schema_name}, #3{element_name}] » %1:l0[#0{schema_name}, #1{name}]] + path %0: + after %1: + Project: #2, #3, #5 + Filter: (#4{object_type} = "7") + after %2: + Project: #2, #4 + Filter: (#3{object_type} = "7") + path %1: + after %2: + Project: #2, #4 + Filter: (#3{object_type} = "7") + path %2: + after %1: + Project: #4, #2 + Filter: (#3{object_type} = "7") + →Arrange (#0{schema_name}, #1{name}) (#2{element_schema_name}, #3{element_name}) + →Constant (38 rows) + →Arranged l0 + →Arranged l0 + cte l2 = →Arrange (#0{id}) →Fused with Parent Map/Filter/Project Project: #1, #2, #0, #3..=#8 →Arranged mz_catalog.mz_types - cte l1 = - →Differential Join %0:l0[#0{id}] » %1:mz_type_pg_metadata[#0{id}] - →Arranged l0 - →Arrange (#0{id}) - →Stream mz_internal.mz_type_pg_metadata - cte l2 = + cte l3 = + →Delta Join [%0:l2[#0{id}] » %2:mz_builtin_object_mappings[#2{id}] » %1[#0{schema_name}, #1{name}]] [%1[#0{schema_name}, #1{name}] » %2:mz_builtin_object_mappings[#0{schema_name}, #1{name}] » %0:l2[#0{id}]] [%2:mz_builtin_object_mappings[#0{schema_name}, #1{name}] » %1[#0{schema_name}, #1{name}] » %0:l2[#0{id}]] + →Arranged l2 + →Arrange (#0{schema_name}, #1{name}) + →Constant (77 rows) + →Arrange (#0{schema_name}, #1{name}) (#2{id}) + →Fused with Child Map/Filter/Project + Project: #0, #1, #3 + Filter: (#2{object_type} = "7") + →Arranged mz_internal.mz_builtin_object_mappings + Key: (#0{schema_name}, #1{name}) + cte l4 = →Delta Join [%0[#0{id}] » %1:mz_schemas[#0{id}] » %2[#0{id}]] [%1:mz_schemas[#0{id}] » %0[#2{schema_id}] » %2[#0{id}]] [%2[#0{id}] » %0[#0{id}] » %1:mz_schemas[#0{id}]] →Arrange (#0{id}) (#2{schema_id}) →Union @@ -4378,19 +4445,19 @@ mz_internal.pg_type_all_databases: Map: null, null, null, null, null →Consolidating Union →Negate Diffs - →Differential Join %1[#0] » %0:l0[#0{id}] - →Arranged l0 + →Differential Join %1[#0] » %0:l2[#0{id}] + →Arranged l2 →Distinct GroupAggregate →Fused with Child Map/Filter/Project Project: #0 - →Read l1 + →Read l3 →Unarranged Raw Stream →Fused with Parent Map/Filter/Project Project: #1, #2, #0, #3..=#8 →Arranged mz_catalog.mz_types →Fused with Child Map/Filter/Project Project: #0..=#8, #0, #9..=#12 - →Read l1 + →Read l3 →Arrange (#0{id}) →Fused with Parent Map/Filter/Project Project: #1, #2, #0, #3..=#5 @@ -4400,25 +4467,56 @@ mz_internal.pg_type_all_databases: →Fused with Child Map/Filter/Project Project: #0, #2 Map: "a" - →Read mz_catalog.mz_array_types - →Read mz_catalog.mz_base_types + →Read l1 + →Map/Filter/Project + Project: #0, #1 + Map: "b" + →Union + →Differential Join %0[#0{schema_name}, #1{name}] » %1:l0[#0{schema_name}, #1{name}] + after %1: + Project: #3 + Filter: (#2{object_type} = "7") + →Arrange (#0{schema_name}, #1{name}) + →Constant (37 rows) + →Arranged l0 + →Fused with Child Map/Filter/Project + Project: #0 + Filter: (#8{type} = "type") AND ("record" = (#9{details} ->> "type_kind")) + →Arranged mz_internal.mz_catalog_item_metadata + Key: (#0{id}) →Fused with Child Map/Filter/Project - Project: #0, #2 + Project: #0, #10 + Filter: (#8{type} = "type") AND ("list" = (#9{details} ->> "type_kind")) Map: "l" - →Read mz_catalog.mz_list_types - →Read mz_catalog.mz_map_types - →Read mz_catalog.mz_pseudo_types - cte l3 = - →Differential Join %1:mz_databases[#0] » %0:l2[#15{database_id}] + →Arranged mz_internal.mz_catalog_item_metadata + Key: (#0{id}) + →Fused with Child Map/Filter/Project + Project: #0, #10 + Filter: (#8{type} = "type") AND ("map" = (#9{details} ->> "type_kind")) + Map: "m" + →Arranged mz_internal.mz_catalog_item_metadata + Key: (#0{id}) + →Differential Join %0[#0{schema_name}, #1{name}] » %1:l0[#0{schema_name}, #1{name}] + after %1: + Project: #3 + Filter: (#2{object_type} = "7") + Final closure: + Project: #0, #1 + Map: "p" + →Arrange (#0{schema_name}, #1{name}) + →Constant (15 rows) + →Arranged l0 + cte l5 = + →Differential Join %1:mz_databases[#0] » %0:l4[#15{database_id}] →Arrange (#15{database_id}) →Fused with Child Map/Filter/Project Filter: (#15{database_id}) IS NOT NULL - →Read l2 + →Read l4 →Arrange (#0) →Fused with Parent Map/Filter/Project Project: #1, #2, #0, #3, #4 →Arranged mz_catalog.mz_databases - cte l4 = + cte l6 = →Differential Join %1:mz_roles[#0{id}] » %0[#5{owner_id}] →Arrange (#5{owner_id}) →Union @@ -4429,42 +4527,42 @@ mz_internal.pg_type_all_databases: →Negate Diffs →Fused with Child Map/Filter/Project Project: #0..=#13, #2, #14..=#18, #0, #19 - →Read l3 + →Read l5 →Fused with Child Map/Filter/Project Project: #0..=#13, #2, #14..=#18, #0, #19 - →Read l2 + →Read l4 →Fused with Child Map/Filter/Project Project: #0..=#13, #2, #14..=#18, #0, #19, #15, #20..=#23 - →Read l3 + →Read l5 →Arranged mz_catalog.mz_roles - cte l5 = + cte l7 = →Distinct GroupAggregate - →Stream l4 - cte l6 = + →Stream l6 + cte l8 = →Distinct GroupAggregate →Fused with Child Map/Filter/Project Project: #0 - →Arranged l5 + →Arranged l7 Key: (#0..=#31) - cte l7 = - →Arranged l6 - cte l8 = - →Arrange (#0{id}) (#1{element_id}) - →Stream mz_catalog.mz_array_types cte l9 = + →Arranged l8 + cte l10 = + →Arrange (#0{id}) (#1{element_id}) + →Stream l1 + cte l11 = →Arrange (#0{id}) →Fused with Child Map/Filter/Project Project: #1, #2 →Arranged mz_catalog.mz_types Key: (#2{schema_id}) - cte l10 = - →Delta Join [%0:l7[#0] » %1:l8[#0{id}] » %2:l9[#0{id}]] [%1:l8[#0{id}] » %0:l7[#0] » %2:l9[#0{id}]] [%2:l9[#0{id}] » %1:l8[#1{element_id}] » %0:l7[#0]] - →Arranged l7 - →Arranged l8 + cte l12 = + →Delta Join [%0:l9[#0] » %1:l10[#0{id}] » %2:l11[#0{id}]] [%1:l10[#0{id}] » %0:l9[#0] » %2:l11[#0{id}]] [%2:l11[#0{id}] » %1:l10[#1{element_id}] » %0:l9[#0]] →Arranged l9 - cte l11 = + →Arranged l10 + →Arranged l11 + cte l13 = →Union - →Stream l10 + →Stream l12 →Fused with Child Map/Filter/Project Project: #0, #2 →Table Function guard_subquery_size(#1) @@ -4472,16 +4570,21 @@ mz_internal.pg_type_all_databases: Simple aggregates: count(*) →Fused with Child Map/Filter/Project Project: #0 - →Read l10 - cte l12 = - →Delta Join [%0:l7[#0] » %1:mz_list_types[#0{id}] » %2:l9[#0{id}]] [%1:mz_list_types[#0{id}] » %0:l7[#0] » %2:l9[#0{id}]] [%2:l9[#0{id}] » %1:mz_list_types[#1{element_id}] » %0:l7[#0]] - →Arranged l7 - →Arrange (#0{id}) (#1{element_id}) - →Read mz_catalog.mz_list_types + →Read l12 + cte l14 = + →Delta Join [%0:l9[#0] » %1:mz_catalog_item_metadata[#0{id}] » %2:l11[#0{id}]] [%1:mz_catalog_item_metadata[#0{id}] » %0:l9[#0] » %2:l11[#0{id}]] [%2:l11[#0{id}] » %1:mz_catalog_item_metadata[#1{element_id}] » %0:l9[#0]] →Arranged l9 - cte l13 = + →Arrange (#0{id}) (#1{element_id}) + →Fused with Child Map/Filter/Project + Project: #0, #10 + Filter: (#8{type} = "type") AND ("list" = (#9{details} ->> "type_kind")) + Map: coalesce((#9{details} ->> "element_id"), "") + →Arranged mz_internal.mz_catalog_item_metadata + Key: (#0{id}) + →Arranged l11 + cte l15 = →Union - →Stream l12 + →Stream l14 →Fused with Child Map/Filter/Project Project: #0, #2 →Table Function guard_subquery_size(#1) @@ -4489,20 +4592,20 @@ mz_internal.pg_type_all_databases: Simple aggregates: count(*) →Fused with Child Map/Filter/Project Project: #0 - →Read l12 - cte l14 = + →Read l14 + cte l16 = →Distinct GroupAggregate →Fused with Child Map/Filter/Project Project: #0 - →Read l4 - cte l15 = - →Delta Join [%0:l14[#0] » %1:l8[#1{element_id}] » %2:l9[#0{id}]] [%1:l8[#0{id}] » %0:l14[#0] » %2:l9[#0{id}]] [%2:l9[#0{id}] » %1:l8[#0{id}] » %0:l14[#0]] - →Arranged l14 - →Arranged l8 - →Arranged l9 - cte l16 = + →Read l6 + cte l17 = + →Delta Join [%0:l16[#0] » %1:l10[#1{element_id}] » %2:l11[#0{id}]] [%1:l10[#0{id}] » %0:l16[#0] » %2:l11[#0{id}]] [%2:l11[#0{id}] » %1:l10[#0{id}] » %0:l16[#0]] + →Arranged l16 + →Arranged l10 + →Arranged l11 + cte l18 = →Union - →Stream l15 + →Stream l17 →Fused with Child Map/Filter/Project Project: #0, #2 →Table Function guard_subquery_size(#1) @@ -4510,9 +4613,9 @@ mz_internal.pg_type_all_databases: Simple aggregates: count(*) →Fused with Child Map/Filter/Project Project: #0 - →Read l15 + →Read l17 →Return - →Delta Join [%0:l4[#0..=#31] » %1:l5[#0..=#31] » %2[#0] » %3[#0] » %4[#0]] [%1:l5[#0] » %0:l4[#0..=#31] » %2[#0] » %3[#0] » %4[#0]] [%2[#0] » %1:l5[#0] » %0:l4[#0..=#31] » %3[#0] » %4[#0]] [%3[#0] » %1:l5[#0] » %0:l4[#0..=#31] » %2[#0] » %4[#0]] [%4[#0] » %1:l5[#0] » %0:l4[#0..=#31] » %2[#0] » %3[#0]] + →Delta Join [%0:l6[#0..=#31] » %1:l7[#0..=#31] » %2[#0] » %3[#0] » %4[#0]] [%1:l7[#0] » %0:l6[#0..=#31] » %2[#0] » %3[#0] » %4[#0]] [%2[#0] » %1:l7[#0] » %0:l6[#0..=#31] » %3[#0] » %4[#0]] [%3[#0] » %1:l7[#0] » %0:l6[#0..=#31] » %2[#0] » %4[#0]] [%4[#0] » %1:l7[#0] » %0:l6[#0..=#31] » %2[#0] » %3[#0]] path %0: after %3: Project: #0..=#6, #8..=#12, #14 @@ -4573,15 +4676,15 @@ mz_internal.pg_type_all_databases: Project: #0, #1, #3, #5, #2, #7, #8, #13, #14, #12, #6, #9, #10, #15, #14, #16, #14, #17, #4, #11 Map: 44, 0, false, -1, null →Arrange (#0..=#31) - →Stream l4 + →Stream l6 →Arrange (#0) (#0..=#31) →Fused with Child Map/Filter/Project Filter: (#5 = #5) - →Arranged l5 + →Arranged l7 Key: (#0..=#31) →Arrange (#0) →Union - →Stream l11 + →Stream l13 →Map/Filter/Project Project: #0, #1 Map: null @@ -4591,12 +4694,12 @@ mz_internal.pg_type_all_databases: →Distinct GroupAggregate →Fused with Child Map/Filter/Project Project: #0 - →Read l11 + →Read l13 →Unarranged Raw Stream - →Arranged l6 + →Arranged l8 →Arrange (#0) →Union - →Stream l13 + →Stream l15 →Map/Filter/Project Project: #0, #1 Map: null @@ -4606,12 +4709,12 @@ mz_internal.pg_type_all_databases: →Distinct GroupAggregate →Fused with Child Map/Filter/Project Project: #0 - →Read l13 + →Read l15 →Unarranged Raw Stream - →Arranged l6 + →Arranged l8 →Arrange (#0) →Union - →Stream l16 + →Stream l18 →Map/Filter/Project Project: #0, #1 Map: null @@ -4621,25 +4724,13 @@ mz_internal.pg_type_all_databases: →Distinct GroupAggregate →Fused with Child Map/Filter/Project Project: #0 - →Read l16 + →Read l18 →Unarranged Raw Stream - →Arranged l14 - -Source mz_internal.mz_type_pg_metadata -Source mz_catalog.mz_array_types -Source mz_catalog.mz_base_types - project=(#0, #1) - map=("b") -Source mz_catalog.mz_list_types - project=(#0, #1) -Source mz_catalog.mz_map_types - project=(#0, #5) - map=("m") -Source mz_catalog.mz_pseudo_types - project=(#0, #1) - map=("p") + →Arranged l16 Used Indexes: + - mz_internal.mz_catalog_item_metadata_ind (*** full scan ***) + - mz_internal.mz_builtin_object_mappings_ind (*** full scan ***, differential join, delta join lookup) - mz_catalog.mz_roles_ind (differential join) - mz_catalog.mz_databases_ind (*** full scan ***) - mz_catalog.mz_schemas_ind (*** full scan ***) @@ -4986,7 +5077,7 @@ mz_catalog.mz_columns: Project: #6, #0..=#3, #7, #4, #5 Map: null →Arrange (#0{schema_name}, #1{relation_name}) - →Constant (1985 rows) + →Constant (1997 rows) →Arrange (#1{schema_name}, #2{name}) →Fused with Child Map/Filter/Project Project: #6, #4, #3 @@ -5744,7 +5835,7 @@ mz_catalog.mz_tables: Project: #3, #0, #4, #1, #5, #2, #6, #6, #6 Map: "s1", null →Arrange (#1{schema_name}, #2{name}) - →Constant (23 rows) + →Constant (16 rows) →Arrange (#0{schema_name}) (#0{schema_name}, #1{name}) →Fused with Child Map/Filter/Project Project: #5, #4, #6 @@ -5799,7 +5890,7 @@ mz_catalog.mz_views: Project: #5, #0, #6, #1, #2, #8, #3, #4, #7 Map: "s1" →Arrange (#1{schema_name}, #2{name}) - →Constant (201 rows) + →Constant (209 rows) →Arrange (#0{schema_name}) (#0{schema_name}, #1{name}) →Fused with Child Map/Filter/Project Project: #5, #4, #6 @@ -5970,7 +6061,7 @@ mz_internal.mz_history_retention_strategies: Project: #3, #5 Map: ("s" || ((#4{data} -> "value") ->> "catalog_id")) →Arrange (#2{name}, #0{object_type}, #1{schema_name}) - →Constant (187 rows) + →Constant (180 rows) →Arrange (((#0{data} -> "key") ->> "object_name"), ((#0{data} -> "key") ->> "object_type"), ((#0{data} -> "key") ->> "schema_name")) →Fused with Child Map/Filter/Project Project: #0 @@ -6316,7 +6407,7 @@ mz_internal.mz_object_dependencies: Project: #4..=#6, #2 Filter: case when (#7{ref_kind} = "func") then (#3{object_type} = "8") else case when (#7{ref_kind} = "type") then (#3{object_type} = "7") else ((#3{object_type} != "7") AND (#3{object_type} != "8")) end end →Arrange (#0{object_schema}..=#2{object_type}) (#3{ref_schema}, #4{ref_name}) - →Constant (1118 rows) + →Constant (1140 rows) →Arrange (#1{schema_name}..=#3{object_type}) →Fused with Child Map/Filter/Project Project: #5, #4, #2, #3 @@ -8759,6 +8850,94 @@ Target cluster: mz_catalog_server EOF +query T multiline +EXPLAIN SELECT * FROM "mz_catalog"."mz_array_types"; +---- +Explained Query: + →With + cte l0 = + →Arranged mz_internal.mz_builtin_object_mappings + →Return + →One-Shot Delta Join [%0 » %1:l0[#0{schema_name}, #1{name}] » %2:l0[#0{schema_name}, #1{name}]] + path %0: + after %1: + Project: #2, #3, #5 + Filter: (#4{object_type} = "7") + after %2: + Project: #2, #4 + Filter: (#3{object_type} = "7") + →Unarranged Raw Stream + →Constant (38 rows) + →Arranged l0 + →Arranged l0 + +Used Indexes: + - mz_internal.mz_builtin_object_mappings_ind (delta join lookup) + +Target cluster: mz_catalog_server + +EOF + +query T multiline +EXPLAIN SELECT * FROM "mz_catalog"."mz_base_types"; +---- +Explained Query: + →Union + →Differential Join %0[#0{schema_name}, #1{name}] » %1:mz_builtin_object_mappings[#0{schema_name}, #1{name}] + after %1: + Project: #3 + Filter: (#2{object_type} = "7") + →Arrange (#0{schema_name}, #1{name}) + →Constant (37 rows) + →Arranged mz_internal.mz_builtin_object_mappings + →Fused with Child Map/Filter/Project + Project: #0 + Filter: (#8{type} = "type") AND ("record" = (#9{details} ->> "type_kind")) + →Arranged mz_internal.mz_catalog_item_metadata + Key: (#0{id}) + +Used Indexes: + - mz_internal.mz_catalog_item_metadata_ind (*** full scan ***) + - mz_internal.mz_builtin_object_mappings_ind (differential join) + +Target cluster: mz_catalog_server + +EOF + +query T multiline +EXPLAIN SELECT * FROM "mz_catalog"."mz_list_types"; +---- +Explained Query (fast path): + →Map/Filter/Project + Project: #0, #10, #11 + Filter: (#8{type} = "type") AND ("list" = (#9{details} ->> "type_kind")) + Map: coalesce((#9{details} ->> "element_id"), ""), strtolist((#9{details} ->> "element_modifiers")) + →Indexed mz_internal.mz_catalog_item_metadata (using mz_internal.mz_catalog_item_metadata_ind) + +Used Indexes: + - mz_internal.mz_catalog_item_metadata_ind (*** full scan ***) + +Target cluster: mz_catalog_server + +EOF + +query T multiline +EXPLAIN SELECT * FROM "mz_catalog"."mz_map_types"; +---- +Explained Query (fast path): + →Map/Filter/Project + Project: #0, #10..=#13 + Filter: (#8{type} = "type") AND ("map" = (#9{details} ->> "type_kind")) + Map: coalesce((#9{details} ->> "key_id"), ""), coalesce((#9{details} ->> "value_id"), ""), strtolist((#9{details} ->> "key_modifiers")), strtolist((#9{details} ->> "value_modifiers")) + →Indexed mz_internal.mz_catalog_item_metadata (using mz_internal.mz_catalog_item_metadata_ind) + +Used Indexes: + - mz_internal.mz_catalog_item_metadata_ind (*** full scan ***) + +Target cluster: mz_catalog_server + +EOF + query T multiline EXPLAIN SELECT * FROM "mz_catalog"."mz_objects"; ---- @@ -8774,6 +8953,25 @@ Target cluster: mz_catalog_server EOF +query T multiline +EXPLAIN SELECT * FROM "mz_catalog"."mz_pseudo_types"; +---- +Explained Query: + →Differential Join %0[#0{schema_name}, #1{name}] » %1:mz_builtin_object_mappings[#0{schema_name}, #1{name}] + after %1: + Project: #3 + Filter: (#2{object_type} = "7") + →Arrange (#0{schema_name}, #1{name}) + →Constant (15 rows) + →Arranged mz_internal.mz_builtin_object_mappings + +Used Indexes: + - mz_internal.mz_builtin_object_mappings_ind (differential join) + +Target cluster: mz_catalog_server + +EOF + query T multiline EXPLAIN SELECT * FROM "mz_catalog"."mz_recent_storage_usage"; ---- @@ -8870,6 +9068,21 @@ Target cluster: mz_catalog_server EOF +query T multiline +EXPLAIN SELECT * FROM "mz_catalog"."mz_types"; +---- +Explained Query (fast path): + →Map/Filter/Project + Project: #1, #2, #0, #3..=#8 + →Indexed mz_catalog.mz_types (using mz_catalog.mz_types_ind) + +Used Indexes: + - mz_catalog.mz_types_ind (*** full scan ***) + +Target cluster: mz_catalog_server + +EOF + query T multiline EXPLAIN SELECT * FROM "mz_internal"."mz_activity_log_thinned"; ---- @@ -8929,7 +9142,7 @@ query T multiline EXPLAIN SELECT * FROM "mz_internal"."mz_builtin_columns"; ---- Explained Query (fast path): - →Constant (1985 rows) + →Constant (1997 rows) Target cluster: mz_catalog_server @@ -9003,7 +9216,17 @@ query T multiline EXPLAIN SELECT * FROM "mz_internal"."mz_builtin_tables"; ---- Explained Query (fast path): - →Constant (23 rows) + →Constant (16 rows) + +Target cluster: mz_catalog_server + +EOF + +query T multiline +EXPLAIN SELECT * FROM "mz_internal"."mz_builtin_types"; +---- +Explained Query (fast path): + →Constant (90 rows) Target cluster: mz_catalog_server @@ -9013,7 +9236,7 @@ query T multiline EXPLAIN SELECT * FROM "mz_internal"."mz_builtin_views"; ---- Explained Query (fast path): - →Constant (201 rows) + →Constant (209 rows) Target cluster: mz_catalog_server @@ -10978,7 +11201,7 @@ Explained Query: Project: #3, #4 Filter: case when (#2{ref_kind} = "func") then (#5{object_type} = "8") else case when (#2{ref_kind} = "type") then (#5{object_type} = "7") else ((#5{object_type} != "7") AND (#5{object_type} != "8")) end end →Unarranged Raw Stream - →Constant (1118 rows) + →Constant (1140 rows) →Arrange (#1{schema_name}..=#3{object_type}) →Fused with Child Map/Filter/Project Project: #5, #4, #2, #3 @@ -14385,6 +14608,25 @@ Target cluster: mz_catalog_server EOF +query T multiline +EXPLAIN SELECT * FROM "mz_internal"."mz_type_pg_metadata"; +---- +Explained Query: + →Differential Join %0[#0{schema_name}, #1{name}] » %1:mz_builtin_object_mappings[#0{schema_name}, #1{name}] + after %1: + Project: #7, #2..=#5 + Filter: (#6{object_type} = "7") + →Arrange (#0{schema_name}, #1{name}) + →Constant (77 rows) + →Arranged mz_internal.mz_builtin_object_mappings + +Used Indexes: + - mz_internal.mz_builtin_object_mappings_ind (differential join) + +Target cluster: mz_catalog_server + +EOF + query T multiline EXPLAIN SELECT * FROM "mz_internal"."mz_wallclock_global_lag"; ---- diff --git a/test/sqllogictest/github-2514.slt b/test/sqllogictest/github-2514.slt index 7180d6172a2fa..5bb42618a3412 100644 --- a/test/sqllogictest/github-2514.slt +++ b/test/sqllogictest/github-2514.slt @@ -39,19 +39,14 @@ DETAIL: The following relations in the query are outside the transaction's time "materialize.public.i2" Only the following relations are available: "materialize.public.i1" -"mz_catalog.mz_array_types" -"mz_catalog.mz_base_types" "mz_catalog.mz_columns" "mz_catalog.mz_connections" "mz_catalog.mz_databases" "mz_catalog.mz_functions" "mz_catalog.mz_index_columns" "mz_catalog.mz_indexes" -"mz_catalog.mz_list_types" -"mz_catalog.mz_map_types" "mz_catalog.mz_materialized_views" "mz_catalog.mz_operators" -"mz_catalog.mz_pseudo_types" "mz_catalog.mz_role_auth" "mz_catalog.mz_role_members" "mz_catalog.mz_role_parameters" @@ -62,10 +57,10 @@ Only the following relations are available: "mz_catalog.mz_sources" "mz_catalog.mz_system_privileges" "mz_catalog.mz_tables" -"mz_catalog.mz_types" "mz_catalog.mz_views" "mz_internal.mz_aggregates" +"mz_internal.mz_catalog_items" +"mz_internal.mz_catalog_state" "mz_internal.mz_comments" "mz_internal.mz_metric_sinks" "mz_internal.mz_object_dependencies" -"mz_internal.mz_type_pg_metadata" diff --git a/test/sqllogictest/information_schema_tables.slt b/test/sqllogictest/information_schema_tables.slt index 12a990ca960c4..948a1805b4a1a 100644 --- a/test/sqllogictest/information_schema_tables.slt +++ b/test/sqllogictest/information_schema_tables.slt @@ -94,7 +94,7 @@ VIEW materialize mz_catalog mz_array_types -BASE TABLE +VIEW materialize mz_catalog mz_audit_events @@ -106,7 +106,7 @@ MATERIALIZED VIEW materialize mz_catalog mz_base_types -BASE TABLE +VIEW materialize mz_catalog mz_cluster_replica_frontiers @@ -174,11 +174,11 @@ MATERIALIZED VIEW materialize mz_catalog mz_list_types -BASE TABLE +VIEW materialize mz_catalog mz_map_types -BASE TABLE +VIEW materialize mz_catalog mz_materialized_views @@ -194,7 +194,7 @@ BASE TABLE materialize mz_catalog mz_pseudo_types -BASE TABLE +VIEW materialize mz_catalog mz_recent_storage_usage @@ -262,7 +262,7 @@ VIEW materialize mz_catalog mz_types -BASE TABLE +VIEW materialize mz_catalog mz_views @@ -321,6 +321,10 @@ mz_builtin_tables VIEW materialize mz_internal +mz_builtin_types +VIEW +materialize +mz_internal mz_builtin_views VIEW materialize @@ -874,7 +878,7 @@ BASE TABLE materialize mz_internal mz_type_pg_metadata -BASE TABLE +VIEW materialize mz_internal mz_wallclock_global_lag diff --git a/test/sqllogictest/mz_catalog_server_index_accounting.slt b/test/sqllogictest/mz_catalog_server_index_accounting.slt index a40c89714335e..02f57d5a75b87 100644 --- a/test/sqllogictest/mz_catalog_server_index_accounting.slt +++ b/test/sqllogictest/mz_catalog_server_index_accounting.slt @@ -37,112 +37,112 @@ mz_arrangement_heap_capacity_raw_s2_primary_idx CREATE␠INDEX␠"mz_arrangemen mz_arrangement_heap_size_raw_s2_primary_idx CREATE␠INDEX␠"mz_arrangement_heap_size_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_arrangement_heap_size_raw"␠("operator_id",␠"worker_id") mz_arrangement_records_raw_s2_primary_idx CREATE␠INDEX␠"mz_arrangement_records_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_arrangement_records_raw"␠("operator_id",␠"worker_id") mz_arrangement_sharing_raw_s2_primary_idx CREATE␠INDEX␠"mz_arrangement_sharing_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_arrangement_sharing_raw"␠("operator_id",␠"worker_id") -mz_builtin_object_mappings_ind CREATE␠INDEX␠"mz_builtin_object_mappings_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s459␠AS␠"mz_internal"."mz_builtin_object_mappings"]␠("schema_name",␠"name") -mz_catalog_item_metadata_ind CREATE␠INDEX␠"mz_catalog_item_metadata_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s457␠AS␠"mz_internal"."mz_catalog_item_metadata"]␠("id") -mz_cluster_auto_scaling_strategies_ind CREATE␠INDEX␠"mz_cluster_auto_scaling_strategies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s534␠AS␠"mz_internal"."mz_cluster_auto_scaling_strategies"]␠("cluster_id") -mz_cluster_deployment_lineage_ind CREATE␠INDEX␠"mz_cluster_deployment_lineage_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s787␠AS␠"mz_internal"."mz_cluster_deployment_lineage"]␠("cluster_id") +mz_builtin_object_mappings_ind CREATE␠INDEX␠"mz_builtin_object_mappings_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s460␠AS␠"mz_internal"."mz_builtin_object_mappings"]␠("schema_name",␠"name") +mz_catalog_item_metadata_ind CREATE␠INDEX␠"mz_catalog_item_metadata_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s458␠AS␠"mz_internal"."mz_catalog_item_metadata"]␠("id") +mz_cluster_auto_scaling_strategies_ind CREATE␠INDEX␠"mz_cluster_auto_scaling_strategies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s535␠AS␠"mz_internal"."mz_cluster_auto_scaling_strategies"]␠("cluster_id") +mz_cluster_deployment_lineage_ind CREATE␠INDEX␠"mz_cluster_deployment_lineage_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s788␠AS␠"mz_internal"."mz_cluster_deployment_lineage"]␠("cluster_id") mz_cluster_prometheus_metrics_s2_primary_idx CREATE␠INDEX␠"mz_cluster_prometheus_metrics_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_cluster_prometheus_metrics"␠("process_id",␠"metric_name",␠"labels") -mz_cluster_reconfigurations_ind CREATE␠INDEX␠"mz_cluster_reconfigurations_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s533␠AS␠"mz_internal"."mz_cluster_reconfigurations"]␠("cluster_id") -mz_cluster_replica_frontiers_ind CREATE␠INDEX␠"mz_cluster_replica_frontiers_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s780␠AS␠"mz_catalog"."mz_cluster_replica_frontiers"]␠("object_id") -mz_cluster_replica_history_ind CREATE␠INDEX␠"mz_cluster_replica_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s635␠AS␠"mz_internal"."mz_cluster_replica_history"]␠("dropped_at") -mz_cluster_replica_metrics_history_ind CREATE␠INDEX␠"mz_cluster_replica_metrics_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s539␠AS␠"mz_internal"."mz_cluster_replica_metrics_history"]␠("replica_id") -mz_cluster_replica_metrics_ind CREATE␠INDEX␠"mz_cluster_replica_metrics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s540␠AS␠"mz_internal"."mz_cluster_replica_metrics"]␠("replica_id") -mz_cluster_replica_name_history_ind CREATE␠INDEX␠"mz_cluster_replica_name_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s636␠AS␠"mz_internal"."mz_cluster_replica_name_history"]␠("id") +mz_cluster_reconfigurations_ind CREATE␠INDEX␠"mz_cluster_reconfigurations_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s534␠AS␠"mz_internal"."mz_cluster_reconfigurations"]␠("cluster_id") +mz_cluster_replica_frontiers_ind CREATE␠INDEX␠"mz_cluster_replica_frontiers_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s781␠AS␠"mz_catalog"."mz_cluster_replica_frontiers"]␠("object_id") +mz_cluster_replica_history_ind CREATE␠INDEX␠"mz_cluster_replica_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s636␠AS␠"mz_internal"."mz_cluster_replica_history"]␠("dropped_at") +mz_cluster_replica_metrics_history_ind CREATE␠INDEX␠"mz_cluster_replica_metrics_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s540␠AS␠"mz_internal"."mz_cluster_replica_metrics_history"]␠("replica_id") +mz_cluster_replica_metrics_ind CREATE␠INDEX␠"mz_cluster_replica_metrics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s541␠AS␠"mz_internal"."mz_cluster_replica_metrics"]␠("replica_id") +mz_cluster_replica_name_history_ind CREATE␠INDEX␠"mz_cluster_replica_name_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s637␠AS␠"mz_internal"."mz_cluster_replica_name_history"]␠("id") mz_cluster_replica_resource_usage_s2_primary_idx CREATE␠INDEX␠"mz_cluster_replica_resource_usage_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_cluster_replica_resource_usage"␠("process_id",␠"source",␠"metric") -mz_cluster_replica_size_internal_ind CREATE␠INDEX␠"mz_cluster_replica_size_internal_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s529␠AS␠"mz_internal"."mz_cluster_replica_size_internal"]␠("size") -mz_cluster_replica_sizes_ind CREATE␠INDEX␠"mz_cluster_replica_sizes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s528␠AS␠"mz_catalog"."mz_cluster_replica_sizes"]␠("size") -mz_cluster_replica_status_history_ind CREATE␠INDEX␠"mz_cluster_replica_status_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s541␠AS␠"mz_internal"."mz_cluster_replica_status_history"]␠("replica_id") -mz_cluster_replica_statuses_ind CREATE␠INDEX␠"mz_cluster_replica_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s542␠AS␠"mz_internal"."mz_cluster_replica_statuses"]␠("replica_id") -mz_cluster_replicas_ind CREATE␠INDEX␠"mz_cluster_replicas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s538␠AS␠"mz_catalog"."mz_cluster_replicas"]␠("id") -mz_clusters_ind CREATE␠INDEX␠"mz_clusters_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s530␠AS␠"mz_catalog"."mz_clusters"]␠("id") -mz_columns_ind CREATE␠INDEX␠"mz_columns_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s501␠AS␠"mz_catalog"."mz_columns"]␠("name") -mz_comments_ind CREATE␠INDEX␠"mz_comments_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s557␠AS␠"mz_internal"."mz_comments"]␠("id") +mz_cluster_replica_size_internal_ind CREATE␠INDEX␠"mz_cluster_replica_size_internal_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s530␠AS␠"mz_internal"."mz_cluster_replica_size_internal"]␠("size") +mz_cluster_replica_sizes_ind CREATE␠INDEX␠"mz_cluster_replica_sizes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s529␠AS␠"mz_catalog"."mz_cluster_replica_sizes"]␠("size") +mz_cluster_replica_status_history_ind CREATE␠INDEX␠"mz_cluster_replica_status_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s542␠AS␠"mz_internal"."mz_cluster_replica_status_history"]␠("replica_id") +mz_cluster_replica_statuses_ind CREATE␠INDEX␠"mz_cluster_replica_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s543␠AS␠"mz_internal"."mz_cluster_replica_statuses"]␠("replica_id") +mz_cluster_replicas_ind CREATE␠INDEX␠"mz_cluster_replicas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s539␠AS␠"mz_catalog"."mz_cluster_replicas"]␠("id") +mz_clusters_ind CREATE␠INDEX␠"mz_clusters_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s531␠AS␠"mz_catalog"."mz_clusters"]␠("id") +mz_columns_ind CREATE␠INDEX␠"mz_columns_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s502␠AS␠"mz_catalog"."mz_columns"]␠("name") +mz_comments_ind CREATE␠INDEX␠"mz_comments_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s558␠AS␠"mz_internal"."mz_comments"]␠("id") mz_compute_dataflow_global_ids_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_dataflow_global_ids_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_dataflow_global_ids_per_worker"␠("id",␠"worker_id",␠"global_id") -mz_compute_dependencies_ind CREATE␠INDEX␠"mz_compute_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s761␠AS␠"mz_internal"."mz_compute_dependencies"]␠("dependency_id") +mz_compute_dependencies_ind CREATE␠INDEX␠"mz_compute_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s762␠AS␠"mz_internal"."mz_compute_dependencies"]␠("dependency_id") mz_compute_error_counts_raw_s2_primary_idx CREATE␠INDEX␠"mz_compute_error_counts_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_error_counts_raw"␠("export_id",␠"worker_id") mz_compute_exports_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_exports_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_exports_per_worker"␠("export_id",␠"worker_id") mz_compute_frontiers_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_frontiers_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_frontiers_per_worker"␠("export_id",␠"worker_id") -mz_compute_hydration_times_ind CREATE␠INDEX␠"mz_compute_hydration_times_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s771␠AS␠"mz_internal"."mz_compute_hydration_times"]␠("replica_id") +mz_compute_hydration_times_ind CREATE␠INDEX␠"mz_compute_hydration_times_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s772␠AS␠"mz_internal"."mz_compute_hydration_times"]␠("replica_id") mz_compute_hydration_times_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_hydration_times_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_hydration_times_per_worker"␠("export_id",␠"worker_id") mz_compute_import_frontiers_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_import_frontiers_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_import_frontiers_per_worker"␠("export_id",␠"import_id",␠"worker_id") mz_compute_lir_mapping_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_lir_mapping_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_lir_mapping_per_worker"␠("global_id",␠"lir_id",␠"worker_id") mz_compute_operator_durations_histogram_raw_s2_primary_idx CREATE␠INDEX␠"mz_compute_operator_durations_histogram_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_operator_durations_histogram_raw"␠("id",␠"worker_id",␠"duration_ns") mz_compute_operator_hydration_statuses_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_operator_hydration_statuses_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_operator_hydration_statuses_per_worker"␠("export_id",␠"lir_id",␠"worker_id") -mz_connections_ind CREATE␠INDEX␠"mz_connections_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s536␠AS␠"mz_catalog"."mz_connections"]␠("schema_id") -mz_console_cluster_utilization_overview_24h_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_24h_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s767␠AS␠"mz_internal"."mz_console_cluster_utilization_overview_24h"]␠("cluster_id") -mz_console_cluster_utilization_overview_3h_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_3h_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s766␠AS␠"mz_internal"."mz_console_cluster_utilization_overview_3h"]␠("cluster_id") -mz_console_cluster_utilization_overview_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s765␠AS␠"mz_internal"."mz_console_cluster_utilization_overview"]␠("cluster_id") -mz_databases_ind CREATE␠INDEX␠"mz_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s499␠AS␠"mz_catalog"."mz_databases"]␠("name") +mz_connections_ind CREATE␠INDEX␠"mz_connections_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s537␠AS␠"mz_catalog"."mz_connections"]␠("schema_id") +mz_console_cluster_utilization_overview_24h_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_24h_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s768␠AS␠"mz_internal"."mz_console_cluster_utilization_overview_24h"]␠("cluster_id") +mz_console_cluster_utilization_overview_3h_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_3h_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s767␠AS␠"mz_internal"."mz_console_cluster_utilization_overview_3h"]␠("cluster_id") +mz_console_cluster_utilization_overview_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s766␠AS␠"mz_internal"."mz_console_cluster_utilization_overview"]␠("cluster_id") +mz_databases_ind CREATE␠INDEX␠"mz_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s500␠AS␠"mz_catalog"."mz_databases"]␠("name") mz_dataflow_addresses_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_dataflow_addresses_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_dataflow_addresses_per_worker"␠("id",␠"worker_id") mz_dataflow_channels_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_dataflow_channels_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_dataflow_channels_per_worker"␠("id",␠"worker_id") mz_dataflow_operator_reachability_raw_s2_primary_idx CREATE␠INDEX␠"mz_dataflow_operator_reachability_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_dataflow_operator_reachability_raw"␠("id",␠"worker_id",␠"source",␠"port",␠"update_type",␠"time") mz_dataflow_operators_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_dataflow_operators_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_dataflow_operators_per_worker"␠("id",␠"worker_id") -mz_frontiers_ind CREATE␠INDEX␠"mz_frontiers_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s752␠AS␠"mz_internal"."mz_frontiers"]␠("object_id") -mz_hydration_statuses_ind CREATE␠INDEX␠"mz_hydration_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s782␠AS␠"mz_internal"."mz_hydration_statuses"]␠("object_id",␠"replica_id") -mz_indexes_ind CREATE␠INDEX␠"mz_indexes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s502␠AS␠"mz_catalog"."mz_indexes"]␠("id") -mz_kafka_sources_ind CREATE␠INDEX␠"mz_kafka_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s495␠AS␠"mz_catalog"."mz_kafka_sources"]␠("id") -mz_materialized_views_ind CREATE␠INDEX␠"mz_materialized_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s561␠AS␠"mz_catalog"."mz_materialized_views"]␠("id") +mz_frontiers_ind CREATE␠INDEX␠"mz_frontiers_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s753␠AS␠"mz_internal"."mz_frontiers"]␠("object_id") +mz_hydration_statuses_ind CREATE␠INDEX␠"mz_hydration_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s783␠AS␠"mz_internal"."mz_hydration_statuses"]␠("object_id",␠"replica_id") +mz_indexes_ind CREATE␠INDEX␠"mz_indexes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s503␠AS␠"mz_catalog"."mz_indexes"]␠("id") +mz_kafka_sources_ind CREATE␠INDEX␠"mz_kafka_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s496␠AS␠"mz_catalog"."mz_kafka_sources"]␠("id") +mz_materialized_views_ind CREATE␠INDEX␠"mz_materialized_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s562␠AS␠"mz_catalog"."mz_materialized_views"]␠("id") mz_message_batch_counts_received_raw_s2_primary_idx CREATE␠INDEX␠"mz_message_batch_counts_received_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_message_batch_counts_received_raw"␠("channel_id",␠"from_worker_id",␠"to_worker_id") mz_message_batch_counts_sent_raw_s2_primary_idx CREATE␠INDEX␠"mz_message_batch_counts_sent_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_message_batch_counts_sent_raw"␠("channel_id",␠"from_worker_id",␠"to_worker_id") mz_message_counts_received_raw_s2_primary_idx CREATE␠INDEX␠"mz_message_counts_received_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_message_counts_received_raw"␠("channel_id",␠"from_worker_id",␠"to_worker_id") mz_message_counts_sent_raw_s2_primary_idx CREATE␠INDEX␠"mz_message_counts_sent_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_message_counts_sent_raw"␠("channel_id",␠"from_worker_id",␠"to_worker_id") -mz_metric_sinks_ind CREATE␠INDEX␠"mz_metric_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s559␠AS␠"mz_internal"."mz_metric_sinks"]␠("id") -mz_notices_ind CREATE␠INDEX␠"mz_notices_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s861␠AS␠"mz_internal"."mz_notices"]␠("id") -mz_object_arrangement_size_history_object_ind CREATE␠INDEX␠"mz_object_arrangement_size_history_object_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s774␠AS␠"mz_internal"."mz_object_arrangement_size_history"]␠("object_id") -mz_object_arrangement_size_history_ts_ind CREATE␠INDEX␠"mz_object_arrangement_size_history_ts_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s774␠AS␠"mz_internal"."mz_object_arrangement_size_history"]␠("collection_timestamp") -mz_object_arrangement_sizes_ind CREATE␠INDEX␠"mz_object_arrangement_sizes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s772␠AS␠"mz_internal"."mz_object_arrangement_sizes"]␠("replica_id") -mz_object_dependencies_ind CREATE␠INDEX␠"mz_object_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s497␠AS␠"mz_internal"."mz_object_dependencies"]␠("object_id") -mz_object_graph_edges_ind CREATE␠INDEX␠"mz_object_graph_edges_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s763␠AS␠"mz_internal"."mz_object_graph_edges"]␠("object_id") -mz_object_history_ind CREATE␠INDEX␠"mz_object_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s575␠AS␠"mz_internal"."mz_object_history"]␠("id") -mz_object_lifetimes_ind CREATE␠INDEX␠"mz_object_lifetimes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s576␠AS␠"mz_internal"."mz_object_lifetimes"]␠("id") -mz_object_transitive_dependencies_ind CREATE␠INDEX␠"mz_object_transitive_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s592␠AS␠"mz_internal"."mz_object_transitive_dependencies"]␠("object_id") -mz_objects_ind CREATE␠INDEX␠"mz_objects_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s572␠AS␠"mz_catalog"."mz_objects"]␠("schema_id") +mz_metric_sinks_ind CREATE␠INDEX␠"mz_metric_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s560␠AS␠"mz_internal"."mz_metric_sinks"]␠("id") +mz_notices_ind CREATE␠INDEX␠"mz_notices_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s862␠AS␠"mz_internal"."mz_notices"]␠("id") +mz_object_arrangement_size_history_object_ind CREATE␠INDEX␠"mz_object_arrangement_size_history_object_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s775␠AS␠"mz_internal"."mz_object_arrangement_size_history"]␠("object_id") +mz_object_arrangement_size_history_ts_ind CREATE␠INDEX␠"mz_object_arrangement_size_history_ts_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s775␠AS␠"mz_internal"."mz_object_arrangement_size_history"]␠("collection_timestamp") +mz_object_arrangement_sizes_ind CREATE␠INDEX␠"mz_object_arrangement_sizes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s773␠AS␠"mz_internal"."mz_object_arrangement_sizes"]␠("replica_id") +mz_object_dependencies_ind CREATE␠INDEX␠"mz_object_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s498␠AS␠"mz_internal"."mz_object_dependencies"]␠("object_id") +mz_object_graph_edges_ind CREATE␠INDEX␠"mz_object_graph_edges_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s764␠AS␠"mz_internal"."mz_object_graph_edges"]␠("object_id") +mz_object_history_ind CREATE␠INDEX␠"mz_object_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s576␠AS␠"mz_internal"."mz_object_history"]␠("id") +mz_object_lifetimes_ind CREATE␠INDEX␠"mz_object_lifetimes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s577␠AS␠"mz_internal"."mz_object_lifetimes"]␠("id") +mz_object_transitive_dependencies_ind CREATE␠INDEX␠"mz_object_transitive_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s593␠AS␠"mz_internal"."mz_object_transitive_dependencies"]␠("object_id") +mz_objects_ind CREATE␠INDEX␠"mz_objects_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s573␠AS␠"mz_catalog"."mz_objects"]␠("schema_id") mz_peek_durations_histogram_raw_s2_primary_idx CREATE␠INDEX␠"mz_peek_durations_histogram_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_peek_durations_histogram_raw"␠("worker_id",␠"type",␠"duration_ns") -mz_recent_activity_log_thinned_ind CREATE␠INDEX␠"mz_recent_activity_log_thinned_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s736␠AS␠"mz_internal"."mz_recent_activity_log_thinned"]␠("sql_hash") -mz_recent_sql_text_ind CREATE␠INDEX␠"mz_recent_sql_text_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s732␠AS␠"mz_internal"."mz_recent_sql_text"]␠("sql_hash") -mz_recent_storage_usage_ind CREATE␠INDEX␠"mz_recent_storage_usage_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s852␠AS␠"mz_catalog"."mz_recent_storage_usage"]␠("object_id") -mz_roles_ind CREATE␠INDEX␠"mz_roles_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s520␠AS␠"mz_catalog"."mz_roles"]␠("id") +mz_recent_activity_log_thinned_ind CREATE␠INDEX␠"mz_recent_activity_log_thinned_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s737␠AS␠"mz_internal"."mz_recent_activity_log_thinned"]␠("sql_hash") +mz_recent_sql_text_ind CREATE␠INDEX␠"mz_recent_sql_text_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s733␠AS␠"mz_internal"."mz_recent_sql_text"]␠("sql_hash") +mz_recent_storage_usage_ind CREATE␠INDEX␠"mz_recent_storage_usage_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s853␠AS␠"mz_catalog"."mz_recent_storage_usage"]␠("object_id") +mz_roles_ind CREATE␠INDEX␠"mz_roles_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s521␠AS␠"mz_catalog"."mz_roles"]␠("id") mz_scheduling_elapsed_raw_s2_primary_idx CREATE␠INDEX␠"mz_scheduling_elapsed_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_scheduling_elapsed_raw"␠("id",␠"worker_id") mz_scheduling_parks_histogram_raw_s2_primary_idx CREATE␠INDEX␠"mz_scheduling_parks_histogram_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_scheduling_parks_histogram_raw"␠("worker_id",␠"slept_for_ns",␠"requested_ns") -mz_schemas_ind CREATE␠INDEX␠"mz_schemas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s500␠AS␠"mz_catalog"."mz_schemas"]␠("database_id") -mz_secrets_ind CREATE␠INDEX␠"mz_secrets_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s535␠AS␠"mz_catalog"."mz_secrets"]␠("name") -mz_show_all_objects_ind CREATE␠INDEX␠"mz_show_all_objects_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s620␠AS␠"mz_internal"."mz_show_all_objects"]␠("schema_id") -mz_show_cluster_replicas_ind CREATE␠INDEX␠"mz_show_cluster_replicas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s784␠AS␠"mz_internal"."mz_show_cluster_replicas"]␠("cluster") -mz_show_clusters_ind CREATE␠INDEX␠"mz_show_clusters_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s622␠AS␠"mz_internal"."mz_show_clusters"]␠("name") -mz_show_columns_ind CREATE␠INDEX␠"mz_show_columns_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s621␠AS␠"mz_internal"."mz_show_columns"]␠("id") -mz_show_connections_ind CREATE␠INDEX␠"mz_show_connections_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s630␠AS␠"mz_internal"."mz_show_connections"]␠("schema_id") -mz_show_databases_ind CREATE␠INDEX␠"mz_show_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s624␠AS␠"mz_internal"."mz_show_databases"]␠("name") -mz_show_indexes_ind CREATE␠INDEX␠"mz_show_indexes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s634␠AS␠"mz_internal"."mz_show_indexes"]␠("schema_id") -mz_show_materialized_views_ind CREATE␠INDEX␠"mz_show_materialized_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s633␠AS␠"mz_internal"."mz_show_materialized_views"]␠("schema_id") -mz_show_roles_ind CREATE␠INDEX␠"mz_show_roles_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s629␠AS␠"mz_internal"."mz_show_roles"]␠("name") -mz_show_schemas_ind CREATE␠INDEX␠"mz_show_schemas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s625␠AS␠"mz_internal"."mz_show_schemas"]␠("database_id") -mz_show_secrets_ind CREATE␠INDEX␠"mz_show_secrets_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s623␠AS␠"mz_internal"."mz_show_secrets"]␠("schema_id") -mz_show_sinks_ind CREATE␠INDEX␠"mz_show_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s632␠AS␠"mz_internal"."mz_show_sinks"]␠("schema_id") -mz_show_sources_ind CREATE␠INDEX␠"mz_show_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s631␠AS␠"mz_internal"."mz_show_sources"]␠("schema_id") -mz_show_tables_ind CREATE␠INDEX␠"mz_show_tables_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s626␠AS␠"mz_internal"."mz_show_tables"]␠("schema_id") -mz_show_types_ind CREATE␠INDEX␠"mz_show_types_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s628␠AS␠"mz_internal"."mz_show_types"]␠("schema_id") -mz_show_views_ind CREATE␠INDEX␠"mz_show_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s627␠AS␠"mz_internal"."mz_show_views"]␠("schema_id") -mz_sink_statistics_ind CREATE␠INDEX␠"mz_sink_statistics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s749␠AS␠"mz_internal"."mz_sink_statistics"]␠("id",␠"replica_id") -mz_sink_status_history_ind CREATE␠INDEX␠"mz_sink_status_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s721␠AS␠"mz_internal"."mz_sink_status_history"]␠("sink_id") -mz_sink_statuses_ind CREATE␠INDEX␠"mz_sink_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s722␠AS␠"mz_internal"."mz_sink_statuses"]␠("id") -mz_sinks_ind CREATE␠INDEX␠"mz_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s512␠AS␠"mz_catalog"."mz_sinks"]␠("id") -mz_source_statistics_ind CREATE␠INDEX␠"mz_source_statistics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s747␠AS␠"mz_internal"."mz_source_statistics"]␠("id",␠"replica_id") -mz_source_statistics_with_history_ind CREATE␠INDEX␠"mz_source_statistics_with_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s745␠AS␠"mz_internal"."mz_source_statistics_with_history"]␠("id",␠"replica_id") -mz_source_status_history_ind CREATE␠INDEX␠"mz_source_status_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s723␠AS␠"mz_internal"."mz_source_status_history"]␠("source_id") -mz_source_statuses_ind CREATE␠INDEX␠"mz_source_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s740␠AS␠"mz_internal"."mz_source_statuses"]␠("id") -mz_sources_ind CREATE␠INDEX␠"mz_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s505␠AS␠"mz_catalog"."mz_sources"]␠("id") -mz_tables_ind CREATE␠INDEX␠"mz_tables_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s504␠AS␠"mz_catalog"."mz_tables"]␠("schema_id") -mz_types_ind CREATE␠INDEX␠"mz_types_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s514␠AS␠"mz_catalog"."mz_types"]␠("schema_id") -mz_views_ind CREATE␠INDEX␠"mz_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s513␠AS␠"mz_catalog"."mz_views"]␠("schema_id") -mz_wallclock_global_lag_recent_history_ind CREATE␠INDEX␠"mz_wallclock_global_lag_recent_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s756␠AS␠"mz_internal"."mz_wallclock_global_lag_recent_history"]␠("object_id") -mz_webhook_sources_ind CREATE␠INDEX␠"mz_webhook_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s558␠AS␠"mz_internal"."mz_webhook_sources"]␠("id") -pg_attrdef_all_databases_ind CREATE␠INDEX␠"pg_attrdef_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s661␠AS␠"mz_internal"."pg_attrdef_all_databases"]␠("oid",␠"adrelid",␠"adnum",␠"adbin",␠"adsrc") -pg_attribute_all_databases_ind CREATE␠INDEX␠"pg_attribute_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s654␠AS␠"mz_internal"."pg_attribute_all_databases"]␠("attrelid") -pg_authid_core_ind CREATE␠INDEX␠"pg_authid_core_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s671␠AS␠"mz_internal"."pg_authid_core"]␠("rolname") -pg_class_all_databases_ind CREATE␠INDEX␠"pg_class_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s642␠AS␠"mz_internal"."pg_class_all_databases"]␠("relname") -pg_description_all_databases_ind CREATE␠INDEX␠"pg_description_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s651␠AS␠"mz_internal"."pg_description_all_databases"]␠("objoid",␠"classoid",␠"objsubid",␠"description",␠"oid_database_name",␠"class_database_name") -pg_namespace_all_databases_ind CREATE␠INDEX␠"pg_namespace_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s639␠AS␠"mz_internal"."pg_namespace_all_databases"]␠("nspname") -pg_type_all_databases_ind CREATE␠INDEX␠"pg_type_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s648␠AS␠"mz_internal"."pg_type_all_databases"]␠("oid") +mz_schemas_ind CREATE␠INDEX␠"mz_schemas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s501␠AS␠"mz_catalog"."mz_schemas"]␠("database_id") +mz_secrets_ind CREATE␠INDEX␠"mz_secrets_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s536␠AS␠"mz_catalog"."mz_secrets"]␠("name") +mz_show_all_objects_ind CREATE␠INDEX␠"mz_show_all_objects_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s621␠AS␠"mz_internal"."mz_show_all_objects"]␠("schema_id") +mz_show_cluster_replicas_ind CREATE␠INDEX␠"mz_show_cluster_replicas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s785␠AS␠"mz_internal"."mz_show_cluster_replicas"]␠("cluster") +mz_show_clusters_ind CREATE␠INDEX␠"mz_show_clusters_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s623␠AS␠"mz_internal"."mz_show_clusters"]␠("name") +mz_show_columns_ind CREATE␠INDEX␠"mz_show_columns_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s622␠AS␠"mz_internal"."mz_show_columns"]␠("id") +mz_show_connections_ind CREATE␠INDEX␠"mz_show_connections_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s631␠AS␠"mz_internal"."mz_show_connections"]␠("schema_id") +mz_show_databases_ind CREATE␠INDEX␠"mz_show_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s625␠AS␠"mz_internal"."mz_show_databases"]␠("name") +mz_show_indexes_ind CREATE␠INDEX␠"mz_show_indexes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s635␠AS␠"mz_internal"."mz_show_indexes"]␠("schema_id") +mz_show_materialized_views_ind CREATE␠INDEX␠"mz_show_materialized_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s634␠AS␠"mz_internal"."mz_show_materialized_views"]␠("schema_id") +mz_show_roles_ind CREATE␠INDEX␠"mz_show_roles_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s630␠AS␠"mz_internal"."mz_show_roles"]␠("name") +mz_show_schemas_ind CREATE␠INDEX␠"mz_show_schemas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s626␠AS␠"mz_internal"."mz_show_schemas"]␠("database_id") +mz_show_secrets_ind CREATE␠INDEX␠"mz_show_secrets_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s624␠AS␠"mz_internal"."mz_show_secrets"]␠("schema_id") +mz_show_sinks_ind CREATE␠INDEX␠"mz_show_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s633␠AS␠"mz_internal"."mz_show_sinks"]␠("schema_id") +mz_show_sources_ind CREATE␠INDEX␠"mz_show_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s632␠AS␠"mz_internal"."mz_show_sources"]␠("schema_id") +mz_show_tables_ind CREATE␠INDEX␠"mz_show_tables_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s627␠AS␠"mz_internal"."mz_show_tables"]␠("schema_id") +mz_show_types_ind CREATE␠INDEX␠"mz_show_types_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s629␠AS␠"mz_internal"."mz_show_types"]␠("schema_id") +mz_show_views_ind CREATE␠INDEX␠"mz_show_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s628␠AS␠"mz_internal"."mz_show_views"]␠("schema_id") +mz_sink_statistics_ind CREATE␠INDEX␠"mz_sink_statistics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s750␠AS␠"mz_internal"."mz_sink_statistics"]␠("id",␠"replica_id") +mz_sink_status_history_ind CREATE␠INDEX␠"mz_sink_status_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s722␠AS␠"mz_internal"."mz_sink_status_history"]␠("sink_id") +mz_sink_statuses_ind CREATE␠INDEX␠"mz_sink_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s723␠AS␠"mz_internal"."mz_sink_statuses"]␠("id") +mz_sinks_ind CREATE␠INDEX␠"mz_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s513␠AS␠"mz_catalog"."mz_sinks"]␠("id") +mz_source_statistics_ind CREATE␠INDEX␠"mz_source_statistics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s748␠AS␠"mz_internal"."mz_source_statistics"]␠("id",␠"replica_id") +mz_source_statistics_with_history_ind CREATE␠INDEX␠"mz_source_statistics_with_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s746␠AS␠"mz_internal"."mz_source_statistics_with_history"]␠("id",␠"replica_id") +mz_source_status_history_ind CREATE␠INDEX␠"mz_source_status_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s724␠AS␠"mz_internal"."mz_source_status_history"]␠("source_id") +mz_source_statuses_ind CREATE␠INDEX␠"mz_source_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s741␠AS␠"mz_internal"."mz_source_statuses"]␠("id") +mz_sources_ind CREATE␠INDEX␠"mz_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s506␠AS␠"mz_catalog"."mz_sources"]␠("id") +mz_tables_ind CREATE␠INDEX␠"mz_tables_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s505␠AS␠"mz_catalog"."mz_tables"]␠("schema_id") +mz_types_ind CREATE␠INDEX␠"mz_types_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s515␠AS␠"mz_catalog"."mz_types"]␠("schema_id") +mz_views_ind CREATE␠INDEX␠"mz_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s514␠AS␠"mz_catalog"."mz_views"]␠("schema_id") +mz_wallclock_global_lag_recent_history_ind CREATE␠INDEX␠"mz_wallclock_global_lag_recent_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s757␠AS␠"mz_internal"."mz_wallclock_global_lag_recent_history"]␠("object_id") +mz_webhook_sources_ind CREATE␠INDEX␠"mz_webhook_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s559␠AS␠"mz_internal"."mz_webhook_sources"]␠("id") +pg_attrdef_all_databases_ind CREATE␠INDEX␠"pg_attrdef_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s662␠AS␠"mz_internal"."pg_attrdef_all_databases"]␠("oid",␠"adrelid",␠"adnum",␠"adbin",␠"adsrc") +pg_attribute_all_databases_ind CREATE␠INDEX␠"pg_attribute_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s655␠AS␠"mz_internal"."pg_attribute_all_databases"]␠("attrelid") +pg_authid_core_ind CREATE␠INDEX␠"pg_authid_core_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s672␠AS␠"mz_internal"."pg_authid_core"]␠("rolname") +pg_class_all_databases_ind CREATE␠INDEX␠"pg_class_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s643␠AS␠"mz_internal"."pg_class_all_databases"]␠("relname") +pg_description_all_databases_ind CREATE␠INDEX␠"pg_description_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s652␠AS␠"mz_internal"."pg_description_all_databases"]␠("objoid",␠"classoid",␠"objsubid",␠"description",␠"oid_database_name",␠"class_database_name") +pg_namespace_all_databases_ind CREATE␠INDEX␠"pg_namespace_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s640␠AS␠"mz_internal"."pg_namespace_all_databases"]␠("nspname") +pg_type_all_databases_ind CREATE␠INDEX␠"pg_type_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s649␠AS␠"mz_internal"."pg_type_all_databases"]␠("oid") # Record all transitive dependencies (tables, sources, views, mvs) of indexes on # the mz_catalog_server cluster. @@ -276,6 +276,18 @@ mz_builtin_tables object_type mz_builtin_tables oid mz_builtin_tables privileges mz_builtin_tables schema_name +mz_builtin_types category +mz_builtin_types element_name +mz_builtin_types element_schema_name +mz_builtin_types name +mz_builtin_types oid +mz_builtin_types privileges +mz_builtin_types schema_name +mz_builtin_types type_kind +mz_builtin_types typinput +mz_builtin_types typlen +mz_builtin_types typreceive +mz_builtin_types typsend mz_builtin_views create_sql mz_builtin_views definition mz_builtin_views name diff --git a/test/sqllogictest/mz_views.slt b/test/sqllogictest/mz_views.slt index 35f6d61fad51b..cd6839245a35c 100644 --- a/test/sqllogictest/mz_views.slt +++ b/test/sqllogictest/mz_views.slt @@ -196,6 +196,7 @@ mz_builtin_log_indexes mz_builtin_materialized_views mz_builtin_sources mz_builtin_tables +mz_builtin_types mz_builtin_views query T multiline diff --git a/test/sqllogictest/oid.slt b/test/sqllogictest/oid.slt index cc00776df3af1..cf5a64237feac 100644 --- a/test/sqllogictest/oid.slt +++ b/test/sqllogictest/oid.slt @@ -1277,3 +1277,4 @@ SELECT oid, name FROM mz_objects WHERE id LIKE 's%' AND oid < 20000 ORDER BY oid 17148 mz_catalog_item_metadata_ind 17150 mz_builtin_object_mappings 17151 mz_builtin_object_mappings_ind +17152 mz_builtin_types diff --git a/test/sqllogictest/transactions.slt b/test/sqllogictest/transactions.slt index d6007d74a20b2..9be9affcc02c4 100644 --- a/test/sqllogictest/transactions.slt +++ b/test/sqllogictest/transactions.slt @@ -296,19 +296,14 @@ DETAIL: The following relations in the query are outside the transaction's time Only the following relations are available: "materialize.public.t" "materialize.public.t5727" -"mz_catalog.mz_array_types" -"mz_catalog.mz_base_types" "mz_catalog.mz_columns" "mz_catalog.mz_connections" "mz_catalog.mz_databases" "mz_catalog.mz_functions" "mz_catalog.mz_index_columns" "mz_catalog.mz_indexes" -"mz_catalog.mz_list_types" -"mz_catalog.mz_map_types" "mz_catalog.mz_materialized_views" "mz_catalog.mz_operators" -"mz_catalog.mz_pseudo_types" "mz_catalog.mz_role_auth" "mz_catalog.mz_role_members" "mz_catalog.mz_role_parameters" @@ -319,13 +314,13 @@ Only the following relations are available: "mz_catalog.mz_sources" "mz_catalog.mz_system_privileges" "mz_catalog.mz_tables" -"mz_catalog.mz_types" "mz_catalog.mz_views" "mz_internal.mz_aggregates" +"mz_internal.mz_catalog_items" +"mz_internal.mz_catalog_state" "mz_internal.mz_comments" "mz_internal.mz_metric_sinks" "mz_internal.mz_object_dependencies" -"mz_internal.mz_type_pg_metadata" # Verify that changed tables and views don't change during a transaction. diff --git a/test/testdrive/catalog.td b/test/testdrive/catalog.td index 944f55e7e1ea8..fc424ca5acf82 100644 --- a/test/testdrive/catalog.td +++ b/test/testdrive/catalog.td @@ -510,27 +510,27 @@ mz_cluster_replica_frontiers source "" > SHOW TABLES FROM mz_catalog name comment -------------------------------------- -mz_array_types "" -mz_base_types "" mz_cluster_replica_sizes "" mz_egress_ips "" mz_functions "" -mz_list_types "" -mz_map_types "" mz_operators "" -mz_pseudo_types "" mz_role_auth "" -mz_types "" > SHOW VIEWS FROM mz_catalog name comment ----------------------------------- +mz_array_types "" +mz_base_types "" +mz_list_types "" +mz_map_types "" mz_objects "" +mz_pseudo_types "" mz_relations "" mz_recent_storage_usage "" mz_storage_usage "" mz_timezone_abbreviations "" mz_timezone_names "" +mz_types "" > SHOW MATERIALIZED VIEWS FROM mz_catalog name cluster comment @@ -612,7 +612,6 @@ mz_replica_hydration_history "" mz_sessions "" mz_storage_usage_by_shard "" mz_subscriptions "" -mz_type_pg_metadata "" mz_webhook_sources "" > SHOW VIEWS FROM mz_internal @@ -627,6 +626,7 @@ mz_builtin_materialized_views "" mz_builtin_object_mappings "" mz_builtin_sources "" mz_builtin_tables "" +mz_builtin_types "" mz_builtin_views "" mz_catalog_item_metadata "" mz_cluster_deployment_lineage "" @@ -708,6 +708,7 @@ mz_source_statuses "" mz_sql_text_redacted "" mz_aws_privatelink_connection_statuses "" mz_statement_execution_history_redacted "" +mz_type_pg_metadata "" mz_wallclock_global_lag "" mz_wallclock_global_lag_histogram "" mz_wallclock_global_lag_history "" @@ -850,7 +851,7 @@ test_table "" # `SHOW TABLES` and `mz_tables` should agree. > SELECT COUNT(*) FROM mz_tables WHERE id LIKE 's%' -23 +16 # There is one entry in mz_indexes for each field_number/expression of the index. > SELECT COUNT(id) FROM mz_indexes WHERE id LIKE 's%' From f7f546c19f7dc51e19c44442ce02b4e20cb5c059 Mon Sep 17 00:00:00 2001 From: SangJunBak Date: Tue, 17 Nov 2026 15:37:12 -0500 Subject: [PATCH 05/10] test: correct typlen of _record In postgres, _record has a typlen of -1 rather than NULL and this was previously a bug. Because we use `from_oid` now, this corrects that behavior. --- test/sqllogictest/pg_catalog_attribute.slt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/sqllogictest/pg_catalog_attribute.slt b/test/sqllogictest/pg_catalog_attribute.slt index 349b8977fe1d9..0c0967b1885a4 100644 --- a/test/sqllogictest/pg_catalog_attribute.slt +++ b/test/sqllogictest/pg_catalog_attribute.slt @@ -218,8 +218,8 @@ WHERE typname = 'list'; list 0 # pg_type.typlen matches PostgreSQL. JDBC derives its identifier length limit -# from typlen of `name`. Types with no PostgreSQL counterpart, pseudo-types, -# and user-defined types report NULL. +# from typlen of `name`. Pseudo-types with no pgwire type and user-defined +# types report NULL. query TI SELECT typname, typlen FROM pg_type @@ -230,7 +230,7 @@ WHERE typname IN ( ORDER BY typname; ---- _int4 -1 -_record NULL +_record -1 anyelement NULL bool 1 char 1 From a8161bd6f80cb3fa969df2e08143e84948e85f6e Mon Sep 17 00:00:00 2001 From: SangJunBak Date: Wed, 18 Nov 2026 02:09:35 -0500 Subject: [PATCH 06/10] adapter: drop the type relations' shards on upgrade --- .../checks/all_checks/builtin_version_pin.py | 12 +-- .../catalog/open/builtin_schema_migration.rs | 94 +++++++++++++++---- 2 files changed, 82 insertions(+), 24 deletions(-) diff --git a/misc/python/materialize/checks/all_checks/builtin_version_pin.py b/misc/python/materialize/checks/all_checks/builtin_version_pin.py index cee0fa71346f7..18c77edbf471b 100644 --- a/misc/python/materialize/checks/all_checks/builtin_version_pin.py +++ b/misc/python/materialize/checks/all_checks/builtin_version_pin.py @@ -34,10 +34,10 @@ # dependencies, so conversions there cannot poison customer catalogs. # mz_role_auth is excluded because only mz_system can read it. _STABLE_BUILTINS: dict[str, MzVersion | None] = { - "mz_array_types": None, + "mz_array_types": MzVersion.parse_mz("v26.52.0"), "mz_audit_events": MzVersion.parse_mz("v26.33.0"), "mz_aws_privatelink_connections": MzVersion.parse_mz("v26.37.0"), - "mz_base_types": None, + "mz_base_types": MzVersion.parse_mz("v26.52.0"), "mz_cluster_replica_sizes": None, "mz_cluster_replicas": MzVersion.parse_mz("v26.30.0"), "mz_clusters": MzVersion.parse_mz("v26.30.0"), @@ -50,15 +50,15 @@ "mz_kafka_connections": MzVersion.parse_mz("v26.37.0"), "mz_kafka_sinks": MzVersion.parse_mz("v26.38.0"), "mz_kafka_sources": MzVersion.parse_mz("v26.34.0"), - "mz_list_types": None, - "mz_map_types": None, + "mz_list_types": MzVersion.parse_mz("v26.52.0"), + "mz_map_types": MzVersion.parse_mz("v26.52.0"), "mz_operators": None, - "mz_pseudo_types": None, + "mz_pseudo_types": MzVersion.parse_mz("v26.52.0"), "mz_sinks": MzVersion.parse_mz("v26.38.0"), "mz_ssh_tunnel_connections": MzVersion.parse_mz("v26.37.0"), "mz_system_privileges": MzVersion.parse_mz("v26.30.0"), "mz_tables": MzVersion.parse_mz("v26.39.0"), - "mz_types": None, + "mz_types": MzVersion.parse_mz("v26.52.0"), "mz_views": MzVersion.parse_mz("v26.39.0"), } diff --git a/src/adapter/src/catalog/open/builtin_schema_migration.rs b/src/adapter/src/catalog/open/builtin_schema_migration.rs index f8a0cd251a0ac..6716bc9374117 100644 --- a/src/adapter/src/catalog/open/builtin_schema_migration.rs +++ b/src/adapter/src/catalog/open/builtin_schema_migration.rs @@ -330,24 +330,6 @@ static MIGRATIONS: LazyLock> = LazyLock::new(|| { MZ_INTERNAL_SCHEMA, "mz_kafka_source_tables", ), - // `mz_type_pg_metadata` gained a trailing `typsend` column. See the NOTE - // above: this version must stay at the workspace's current dev version - // until the change ships. - MigrationStep::replacement( - "26.40.0-dev.0", - CatalogItemType::Table, - MZ_INTERNAL_SCHEMA, - "mz_type_pg_metadata", - ), - // `mz_type_pg_metadata` gained a trailing `typlen` column. See the NOTE - // above: this version must stay at the workspace's current dev version - // until the change ships. - MigrationStep::replacement( - "26.47.0-dev.0", - CatalogItemType::Table, - MZ_INTERNAL_SCHEMA, - "mz_type_pg_metadata", - ), // Converting the connection-detail builtin tables to materialized views // changes their catalog fingerprint, so each needs an explicit // replacement step. @@ -604,6 +586,69 @@ static MIGRATIONS: LazyLock> = LazyLock::new(|| { MZ_INTERNAL_SCHEMA, "mz_comments", ), + // Converting `mz_types` from a builtin table to a builtin + // view. This doesn't replace the shard with anything and + // simply drops the shard. + MigrationStep::drop( + "26.52.0-dev.0", + CatalogItemType::View, + MZ_CATALOG_SCHEMA, + "mz_types", + ), + // Converting `mz_type_pg_metadata` from a builtin table to a builtin + // view. This doesn't replace the shard with anything and + // simply drops the shard. + MigrationStep::drop( + "26.52.0-dev.0", + CatalogItemType::View, + MZ_INTERNAL_SCHEMA, + "mz_type_pg_metadata", + ), + // Converting `mz_array_types` from a builtin table to a builtin + // view. This doesn't replace the shard with anything and + // simply drops the shard. + MigrationStep::drop( + "26.52.0-dev.0", + CatalogItemType::View, + MZ_CATALOG_SCHEMA, + "mz_array_types", + ), + // Converting `mz_base_types` from a builtin table to a builtin + // view. This doesn't replace the shard with anything and + // simply drops the shard. + MigrationStep::drop( + "26.52.0-dev.0", + CatalogItemType::View, + MZ_CATALOG_SCHEMA, + "mz_base_types", + ), + // Converting `mz_list_types` from a builtin table to a builtin + // view. This doesn't replace the shard with anything and + // simply drops the shard. + MigrationStep::drop( + "26.52.0-dev.0", + CatalogItemType::View, + MZ_CATALOG_SCHEMA, + "mz_list_types", + ), + // Converting `mz_map_types` from a builtin table to a builtin + // view. This doesn't replace the shard with anything and + // simply drops the shard. + MigrationStep::drop( + "26.52.0-dev.0", + CatalogItemType::View, + MZ_CATALOG_SCHEMA, + "mz_map_types", + ), + // Converting `mz_pseudo_types` from a builtin table to a builtin + // view. This doesn't replace the shard with anything and + // simply drops the shard. + MigrationStep::drop( + "26.52.0-dev.0", + CatalogItemType::View, + MZ_CATALOG_SCHEMA, + "mz_pseudo_types", + ), ] }); @@ -644,6 +689,19 @@ impl MigrationStep { mechanism: Mechanism::Replacement, } } + + /// Helper to construct a `Drop` migration step. + fn drop(version: &str, type_: CatalogItemType, schema: &str, name: &str) -> Self { + Self { + version: Version::parse(version).expect("valid"), + object: SystemObjectDescription { + schema_name: schema.into(), + object_type: type_, + object_name: name.into(), + }, + mechanism: Mechanism::Drop, + } + } } /// The mechanism to use to migrate the schema of a builtin collection. From e1b9c9fdde8b7ded82c635298b5a0a6dd17b248b Mon Sep 17 00:00:00 2001 From: SangJunBak Date: Mon, 16 Nov 2026 19:36:08 -0500 Subject: [PATCH 07/10] catalog: define the function and operator relations as views mz_functions, mz_operators and mz_aggregates were builtin tables packed by the adapter from the function registry at every catalog open. They are now views over the generated mz_internal.mz_builtin_functions and mz_internal.mz_builtin_operators views, one row per implementation, with the type names of a signature resolved to catalog ids through mz_builtin_object_mappings. pack_item_update no longer packs rows for functions, catalog open no longer packs a row per operator, and the builtin version pin records the conversion, as does a Replacement step per relation in MIGRATIONS. pg_aggregate declares the oid key it now derives through mz_aggregates. Co-Authored-By: Claude Fable 5.1 Co-Authored-By: Claude Opus 5.5 resolve rebase conflicts: catalog: define the function and operator relations as views --- .../content/sql/system-catalog/mz_internal.md | 2 + .../checks/all_checks/builtin_version_pin.py | 4 +- .../src/catalog/builtin_table_updates.rs | 148 +-------- src/adapter/src/catalog/open.rs | 16 - src/catalog/src/builtin.rs | 11 +- src/catalog/src/builtin/builtin.rs | 197 +++++++++++- src/catalog/src/builtin/mz_catalog.rs | 295 +++++++++++------- src/catalog/src/builtin/mz_internal.rs | 12 +- src/catalog/src/builtin/pg_catalog.rs | 1 + src/pgrepr-consts/src/oid.rs | 8 +- test/sqllogictest/mz_functions.slt | 173 ++++++++++ test/sqllogictest/mz_views.slt | 2 + test/testdrive/catalog.td | 10 +- 13 files changed, 586 insertions(+), 293 deletions(-) create mode 100644 test/sqllogictest/mz_functions.slt diff --git a/doc/user/content/sql/system-catalog/mz_internal.md b/doc/user/content/sql/system-catalog/mz_internal.md index 6a579fa8b3256..a130fa0c4add9 100644 --- a/doc/user/content/sql/system-catalog/mz_internal.md +++ b/doc/user/content/sql/system-catalog/mz_internal.md @@ -1633,11 +1633,13 @@ The `mz_webhook_sources` table contains a row for each webhook source in the sys + + diff --git a/misc/python/materialize/checks/all_checks/builtin_version_pin.py b/misc/python/materialize/checks/all_checks/builtin_version_pin.py index 18c77edbf471b..641d3fbeaa9f3 100644 --- a/misc/python/materialize/checks/all_checks/builtin_version_pin.py +++ b/misc/python/materialize/checks/all_checks/builtin_version_pin.py @@ -44,7 +44,7 @@ "mz_columns": MzVersion.parse_mz("v26.49.0"), "mz_default_privileges": MzVersion.parse_mz("v26.30.0"), "mz_egress_ips": None, - "mz_functions": None, + "mz_functions": MzVersion.parse_mz("v26.52.0"), "mz_iceberg_sinks": MzVersion.parse_mz("v26.38.0"), "mz_index_columns": MzVersion.parse_mz("v26.49.0"), "mz_kafka_connections": MzVersion.parse_mz("v26.37.0"), @@ -52,7 +52,7 @@ "mz_kafka_sources": MzVersion.parse_mz("v26.34.0"), "mz_list_types": MzVersion.parse_mz("v26.52.0"), "mz_map_types": MzVersion.parse_mz("v26.52.0"), - "mz_operators": None, + "mz_operators": MzVersion.parse_mz("v26.52.0"), "mz_pseudo_types": MzVersion.parse_mz("v26.52.0"), "mz_sinks": MzVersion.parse_mz("v26.38.0"), "mz_ssh_tunnel_connections": MzVersion.parse_mz("v26.37.0"), diff --git a/src/adapter/src/catalog/builtin_table_updates.rs b/src/adapter/src/catalog/builtin_table_updates.rs index 4d0d9192f7b2d..e6c8e2af864ff 100644 --- a/src/adapter/src/catalog/builtin_table_updates.rs +++ b/src/adapter/src/catalog/builtin_table_updates.rs @@ -12,24 +12,20 @@ mod notice; use bytesize::ByteSize; use ipnet::IpNet; use mz_audit_log::VersionedStorageUsage; -use mz_catalog::SYSTEM_CONN_ID; use mz_catalog::builtin::{ - BuiltinTable, MZ_AGGREGATES, MZ_CLUSTER_REPLICA_SIZE_INTERNAL, MZ_CLUSTER_REPLICA_SIZES, - MZ_EGRESS_IPS, MZ_FUNCTIONS, MZ_LICENSE_KEYS, MZ_OPERATORS, MZ_ROLE_AUTH, MZ_SESSIONS, - MZ_STORAGE_USAGE_BY_SHARD, MZ_SUBSCRIPTIONS, MZ_WEBHOOKS_SOURCES, + BuiltinTable, MZ_CLUSTER_REPLICA_SIZE_INTERNAL, MZ_CLUSTER_REPLICA_SIZES, MZ_EGRESS_IPS, + MZ_LICENSE_KEYS, MZ_ROLE_AUTH, MZ_SESSIONS, MZ_STORAGE_USAGE_BY_SHARD, MZ_SUBSCRIPTIONS, + MZ_WEBHOOKS_SOURCES, }; use mz_catalog::memory::error::Error; -use mz_catalog::memory::objects::{CatalogItem, DataSourceDesc, Func}; +use mz_catalog::memory::objects::{CatalogItem, DataSourceDesc}; use mz_controller::clusters::ReplicaAllocation; use mz_license_keys::ValidatedLicenseKey; use mz_orchestrator::{CpuLimit, DiskLimit, MemoryLimit}; use mz_ore::cast::CastFrom; use mz_persist_client::batch::ProtoBatch; -use mz_repr::adt::array::ArrayDimension; use mz_repr::role_id::RoleId; use mz_repr::{CatalogItemId, Datum, Diff, GlobalId, Row}; -use mz_sql::func::FuncImplCatalogDetails; -use mz_sql::names::SchemaSpecifier; use mz_storage_client::client::TableData; use smallvec::smallvec; use uuid::Uuid; @@ -116,16 +112,6 @@ impl CatalogState { diff: Diff, ) -> Vec> { let entry = self.get_entry(&id); - let conn_id = entry.item().conn_id().unwrap_or(&SYSTEM_CONN_ID); - let schema_id = &self - .get_schema( - &entry.name().qualifiers.database_spec, - &entry.name().qualifiers.schema_spec, - conn_id, - ) - .id; - let name = &entry.name().item; - let owner_id = entry.owner_id(); let updates = match entry.item() { CatalogItem::Source(source) => { match &source.data_source { @@ -146,18 +132,16 @@ impl CatalogState { // mz_sinks, mz_kafka_sinks and mz_iceberg_sinks read create_sql // out of mz_catalog_raw, so there is nothing to pack here. CatalogItem::Sink(_) => vec![], - CatalogItem::Func(func) => { - self.pack_func_update(id, schema_id, name, owner_id, func, diff) - } - // Tables, views, materialized views, indexes, types and metric - // sinks are exposed through relations derived from - // `mz_catalog_raw`, and logs and secrets never had builtin-table - // rows, so none pack a row here. + // Tables, views, materialized views, indexes, types, functions + // and metric sinks are exposed through materialized views derived + // from `mz_catalog_raw`, and logs and secrets never had + // builtin-table rows, so none pack a row here. CatalogItem::Table(_) | CatalogItem::View(_) | CatalogItem::MaterializedView(_) | CatalogItem::Index(_) | CatalogItem::Type(_) + | CatalogItem::Func(_) | CatalogItem::Log(_) | CatalogItem::Secret(_) | CatalogItem::MetricSink(_) => vec![], @@ -171,120 +155,6 @@ impl CatalogState { updates } - fn pack_func_update( - &self, - id: CatalogItemId, - schema_id: &SchemaSpecifier, - name: &str, - owner_id: &RoleId, - func: &Func, - diff: Diff, - ) -> Vec> { - let mut updates = vec![]; - for func_impl_details in func.inner.func_impls() { - let arg_type_ids = func_impl_details - .arg_typs - .iter() - .map(|typ| self.get_system_type(typ).id().to_string()) - .collect::>(); - - let mut row = Row::default(); - row.packer() - .try_push_array( - &[ArrayDimension { - lower_bound: 1, - length: arg_type_ids.len(), - }], - arg_type_ids.iter().map(|id| Datum::String(id)), - ) - .expect( - "arg_type_ids is 1 dimensional, and its length is used for the array length", - ); - let arg_type_ids = row.unpack_first(); - - updates.push(BuiltinTableUpdate::row( - &*MZ_FUNCTIONS, - Row::pack_slice(&[ - Datum::String(&id.to_string()), - Datum::UInt32(func_impl_details.oid), - Datum::String(&schema_id.to_string()), - Datum::String(name), - arg_type_ids, - Datum::from( - func_impl_details - .variadic_typ - .map(|typ| self.get_system_type(typ).id().to_string()) - .as_deref(), - ), - Datum::from( - func_impl_details - .return_typ - .map(|typ| self.get_system_type(typ).id().to_string()) - .as_deref(), - ), - func_impl_details.return_is_set.into(), - Datum::String(&owner_id.to_string()), - ]), - diff, - )); - - if let mz_sql::func::Func::Aggregate(_) = func.inner { - updates.push(BuiltinTableUpdate::row( - &*MZ_AGGREGATES, - Row::pack_slice(&[ - Datum::UInt32(func_impl_details.oid), - // TODO(database-issues#1064): Support ordered-set aggregate functions. - Datum::String("n"), - Datum::Int16(0), - ]), - diff, - )); - } - } - updates - } - - pub fn pack_op_update( - &self, - operator: &str, - func_impl_details: FuncImplCatalogDetails, - diff: Diff, - ) -> BuiltinTableUpdate<&'static BuiltinTable> { - let arg_type_ids = func_impl_details - .arg_typs - .iter() - .map(|typ| self.get_system_type(typ).id().to_string()) - .collect::>(); - - let mut row = Row::default(); - row.packer() - .try_push_array( - &[ArrayDimension { - lower_bound: 1, - length: arg_type_ids.len(), - }], - arg_type_ids.iter().map(|id| Datum::String(id)), - ) - .expect("arg_type_ids is 1 dimensional, and its length is used for the array length"); - let arg_type_ids = row.unpack_first(); - - BuiltinTableUpdate::row( - &*MZ_OPERATORS, - Row::pack_slice(&[ - Datum::UInt32(func_impl_details.oid), - Datum::String(operator), - arg_type_ids, - Datum::from( - func_impl_details - .return_typ - .map(|typ| self.get_system_type(typ).id().to_string()) - .as_deref(), - ), - ]), - diff, - ) - } - pub fn pack_storage_usage_update( &self, VersionedStorageUsage::V1(event): VersionedStorageUsage, diff --git a/src/adapter/src/catalog/open.rs b/src/adapter/src/catalog/open.rs index c3b37f4ef468c..d1b070ee38ffc 100644 --- a/src/adapter/src/catalog/open.rs +++ b/src/adapter/src/catalog/open.rs @@ -55,7 +55,6 @@ use mz_repr::adt::mz_acl_item::PrivilegeMap; use mz_repr::namespaces::is_unstable_schema; use mz_repr::{CatalogItemId, Diff, GlobalId, RelationVersion, Timestamp}; use mz_sql::catalog::{CatalogError as SqlCatalogError, CatalogItemType, RoleMembership, RoleVars}; -use mz_sql::func::OP_IMPLS; use mz_sql::names::CommentObjectId; use mz_sql::rbac; use mz_sql::session::user::{MZ_SYSTEM_ROLE_ID, SYSTEM_USER}; @@ -623,21 +622,6 @@ impl Catalog { storage: Arc::new(tokio::sync::Mutex::new(storage)), }; - // Operators aren't stored in the catalog, but we would like them in - // introspection views. - for (op, func) in OP_IMPLS.iter() { - match func { - mz_sql::func::Func::Scalar(impls) => { - for imp in impls { - builtin_table_updates.push(catalog.state.resolve_builtin_table_update( - catalog.state.pack_op_update(op, imp.details(), Diff::ONE), - )); - } - } - _ => unreachable!("all operators must be scalar functions"), - } - } - for ip in &catalog.state.egress_addresses { builtin_table_updates.push( catalog diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index 7ce58fb813ac3..884031e19762e 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -1222,9 +1222,9 @@ pub static BUILTINS_STATIC: LazyLock>> = LazyLock::ne Builtin::MaterializedView(&MZ_ROLE_MEMBERS), Builtin::MaterializedView(&MZ_ROLE_PARAMETERS), Builtin::View(&MZ_PSEUDO_TYPES), - Builtin::Table(&MZ_FUNCTIONS), - Builtin::Table(&MZ_OPERATORS), - Builtin::Table(&MZ_AGGREGATES), + Builtin::View(&MZ_FUNCTIONS), + Builtin::View(&MZ_OPERATORS), + Builtin::View(&MZ_AGGREGATES), Builtin::Table(&MZ_CLUSTER_REPLICA_SIZES), Builtin::Table(&MZ_CLUSTER_REPLICA_SIZE_INTERNAL), Builtin::MaterializedView(&MZ_CLUSTERS), @@ -1572,7 +1572,7 @@ pub static BUILTINS_STATIC: LazyLock>> = LazyLock::ne { let ontology_preview = ontology::generate_views(&builtin_items); let builtin_reporter_preview: Vec<_> = - builtin::builtins(&builtin_types, &builtin_items).collect(); + builtin::builtins(&builtin_types, &builtin_funcs, &builtin_items).collect(); let generator_input: Vec<_> = builtin_types .iter() .chain(builtin_funcs.iter()) @@ -1599,7 +1599,8 @@ pub static BUILTINS_STATIC: LazyLock>> = LazyLock::ne // Generate builtin relations reporting builtin objects last, since they need a complete view // of all other builtins. - let mut builtin_builtins = builtin::builtins(&builtin_types, &builtin_items).collect(); + let mut builtin_builtins = + builtin::builtins(&builtin_types, &builtin_funcs, &builtin_items).collect(); // Construct the full list of builtins, retaining dependency order. let mut builtins = Vec::new(); diff --git a/src/catalog/src/builtin/builtin.rs b/src/catalog/src/builtin/builtin.rs index 5952ceef2c1aa..834ee8278454a 100644 --- a/src/catalog/src/builtin/builtin.rs +++ b/src/catalog/src/builtin/builtin.rs @@ -10,7 +10,7 @@ //! Constant builtin views exposing information about builtin objects. use std::borrow::Cow; -use std::collections::BTreeMap; +use std::collections::{BTreeMap, BTreeSet}; use itertools::Itertools; use mz_catalog_protos::objects::CatalogItemType; @@ -31,9 +31,11 @@ use crate::builtin::{Builtin, BuiltinType, BuiltinView, PUBLIC_SELECT, assert_sa /// Generate builtin views reporting the given builtins. /// /// Used in the [`super::BUILTINS_STATIC`] initializer, which keeps the -/// `Builtin::Type`s in `builtin_types` apart from the other `builtin_items`. +/// `Builtin::Type`s in `builtin_types` and the `Builtin::Func`s in +/// `builtin_funcs` apart from the other `builtin_items`. pub(super) fn builtins( builtin_types: &[Builtin], + builtin_funcs: &[Builtin], builtin_items: &[Builtin], ) -> impl Iterator> { let sources: &'static BuiltinView = Box::leak(Box::new(make_builtin_sources(builtin_items))); @@ -46,6 +48,12 @@ pub(super) fn builtins( let index_columns: &'static BuiltinView = Box::leak(Box::new(make_builtin_index_columns(builtin_items))); let types: &'static BuiltinView = Box::leak(Box::new(make_builtin_types(builtin_types))); + let functions: &'static BuiltinView = Box::leak(Box::new(make_builtin_functions( + builtin_types, + builtin_funcs, + ))); + let operators: &'static BuiltinView = + Box::leak(Box::new(make_builtin_operators(builtin_types))); // The generated views above, and `mz_builtin_views` itself, are listed in // `mz_builtin_views` with placeholder SQL rather than their real @@ -67,6 +75,8 @@ pub(super) fn builtins( index_columns, &columns, types, + functions, + operators, ], ))); make_builtin_columns_sql( @@ -79,6 +89,8 @@ pub(super) fn builtins( indexes, index_columns, types, + functions, + operators, views, ], &mut columns, @@ -96,6 +108,8 @@ pub(super) fn builtins( index_columns, columns, types, + functions, + operators, views, ] .into_iter() @@ -566,6 +580,181 @@ FROM (VALUES {values}) AS v(oid, schema_name, name, category, type_kind, privile } } +/// Generates `mz_internal.mz_builtin_functions`, one row per implementation of +/// each builtin function, which `mz_catalog.mz_functions` and +/// `mz_internal.mz_aggregates` read. `mz_functions` resolves the type names it +/// reports to catalog ids through `mz_internal.mz_builtin_object_mappings`. +/// +/// `kind` is the function's [`mz_sql::func::Func::class`]: `scalar`, +/// `aggregate`, `table` or `window`. The argument, variadic and return types +/// are named as the function registry names them, by the builtin type's name +/// without its schema. +fn make_builtin_functions( + builtin_types: &[Builtin], + builtin_funcs: &[Builtin], +) -> BuiltinView { + let type_names = builtin_type_names(builtin_types); + let type_names = &type_names; + let values = builtin_funcs + .iter() + .filter_map(|b| match b { + Builtin::Func(f) => Some(f), + _ => None, + }) + .flat_map(|func| { + assert_safe_builtin_name(func.name, "function"); + let kind = func.inner.class(); + func.inner.func_impls().into_iter().map(move |imp| { + format!( + "({}::oid, {}, {}, '{kind}', {}, {}, {}, {})", + imp.oid, + escaped_string_literal(func.schema), + escaped_string_literal(func.name), + type_names_sql(&imp.arg_typs, type_names), + type_name_sql(imp.variadic_typ, type_names), + type_name_sql(imp.return_typ, type_names), + imp.return_is_set, + ) + }) + }) + .join(","); + let sql = format!( + " +SELECT oid, schema_name, name, kind, argument_type_names, variadic_argument_type_name, return_type_name, returns_set +FROM (VALUES {values}) AS v(oid, schema_name, name, kind, argument_type_names, variadic_argument_type_name, return_type_name, returns_set)" + ); + + BuiltinView { + name: "mz_builtin_functions", + schema: MZ_INTERNAL_SCHEMA, + oid: oid::VIEW_MZ_BUILTIN_FUNCTIONS_OID, + desc: RelationDesc::builder() + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_name", SqlScalarType::String.nullable(false)) + .with_column("name", SqlScalarType::String.nullable(false)) + .with_column("kind", SqlScalarType::String.nullable(false)) + .with_column( + "argument_type_names", + SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), + ) + .with_column( + "variadic_argument_type_name", + SqlScalarType::String.nullable(true), + ) + .with_column("return_type_name", SqlScalarType::String.nullable(true)) + .with_column("returns_set", SqlScalarType::Bool.nullable(false)) + // NOTE: The declared keys must exactly match the keys the + // optimizer derives from the generated VALUES list + // (`verify_builtin_descs` enforces this). Every implementation has + // its own oid, which `test_compare_builtins_postgres` asserts, so + // `oid` is a key. + .with_key(vec![0]) + .finish(), + column_comments: Default::default(), + sql: Box::leak(sql.into_boxed_str()), + access: vec![PUBLIC_SELECT], + ontology: None, + } +} + +/// Generates `mz_internal.mz_builtin_operators`, one row per implementation of +/// each operator in [`mz_sql::func::OP_IMPLS`], which `mz_catalog.mz_operators` +/// reads. Operators are not catalog items, so they have no `GidMapping` record +/// and no catalog id, and this view is the only place that lists them. +fn make_builtin_operators(builtin_types: &[Builtin]) -> BuiltinView { + let type_names = builtin_type_names(builtin_types); + let type_names = &type_names; + let values = mz_sql::func::OP_IMPLS + .iter() + .flat_map(|(op, func)| { + assert!( + matches!(func, mz_sql::func::Func::Scalar(_)), + "operator {op} is not a scalar function" + ); + func.func_impls().into_iter().map(move |imp| { + format!( + "({}::oid, {}, {}, {})", + imp.oid, + escaped_string_literal(op), + type_names_sql(&imp.arg_typs, type_names), + type_name_sql(imp.return_typ, type_names), + ) + }) + }) + .join(","); + let sql = format!( + " +SELECT oid, name, argument_type_names, return_type_name +FROM (VALUES {values}) AS v(oid, name, argument_type_names, return_type_name)" + ); + + BuiltinView { + name: "mz_builtin_operators", + schema: MZ_INTERNAL_SCHEMA, + oid: oid::VIEW_MZ_BUILTIN_OPERATORS_OID, + desc: RelationDesc::builder() + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("name", SqlScalarType::String.nullable(false)) + .with_column( + "argument_type_names", + SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), + ) + .with_column("return_type_name", SqlScalarType::String.nullable(false)) + // NOTE: The declared keys must exactly match the keys the + // optimizer derives from the generated VALUES list + // (`verify_builtin_descs` enforces this). Every implementation has + // its own oid, which `test_compare_builtins_postgres` asserts, so + // `oid` is a key. + .with_key(vec![0]) + .finish(), + column_comments: Default::default(), + sql: Box::leak(sql.into_boxed_str()), + access: vec![PUBLIC_SELECT], + ontology: None, + } +} + +/// The names of the builtin types, which the function registry references +/// without a schema. They are unique across schemas, see [`make_builtin_types`]. +fn builtin_type_names(builtin_types: &[Builtin]) -> BTreeSet<&str> { + builtin_types + .iter() + .filter_map(|b| match b { + Builtin::Type(t) => Some(t.name), + _ => None, + }) + .collect() +} + +/// `name` as a SQL string literal, or NULL for no type. A name that is not a +/// builtin type's panics here, since the join to +/// `mz_internal.mz_builtin_object_mappings` in `mz_functions` would otherwise +/// drop the signature silently. +fn type_name_sql(name: Option<&str>, type_names: &BTreeSet<&str>) -> String { + match name { + Some(name) => { + assert!( + type_names.contains(name), + "function signature references unknown builtin type {name}" + ); + escaped_string_literal(name).to_string() + } + None => "NULL::text".to_string(), + } +} + +/// `names` as a SQL `text[]` literal, see [`type_name_sql`]. +fn type_names_sql(names: &[&str], type_names: &BTreeSet<&str>) -> String { + if names.is_empty() { + return "ARRAY[]::text[]".to_string(); + } + let names = names + .iter() + .map(|name| type_name_sql(Some(name), type_names)) + .join(", "); + format!("ARRAY[{names}]") +} + /// Generates `mz_internal.mz_builtin_views`, listing every builtin view, /// including itself and the `generated` views. /// @@ -586,7 +775,7 @@ FROM (VALUES {values}) AS v(oid, schema_name, name, category, type_kind, privile /// declared keys rely on. fn make_builtin_views( builtin_items: &[Builtin], - generated: [&BuiltinView; 8], + generated: [&BuiltinView; 10], ) -> BuiltinView { let iter = builtin_items.iter().filter_map(|b| match b { Builtin::View(x) => Some(*x), @@ -698,7 +887,7 @@ fn builtin_columns_view() -> BuiltinView { /// itself. fn make_builtin_columns_sql( builtin_items: &[Builtin], - generated: [&BuiltinView; 8], + generated: [&BuiltinView; 10], columns: &mut BuiltinView, ) { // Map to (schema, relation, desc) diff --git a/src/catalog/src/builtin/mz_catalog.rs b/src/catalog/src/builtin/mz_catalog.rs index 9a2405357dcf4..5512ae72fc204 100644 --- a/src/catalog/src/builtin/mz_catalog.rs +++ b/src/catalog/src/builtin/mz_catalog.rs @@ -2721,145 +2721,206 @@ WHERE t.type_kind = 'pseudo'", column_semantic_types: &[("id", SemanticType::CatalogItemId)], }), }); -pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| { - BuiltinTable { - name: "mz_functions", - schema: MZ_CATALOG_SCHEMA, - oid: oid::TABLE_MZ_FUNCTIONS_OID, - desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) // not a key! - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_column("name", SqlScalarType::String.nullable(false)) - .with_column( - "argument_type_ids", - SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), - ) - .with_column( - "variadic_argument_type_id", - SqlScalarType::String.nullable(true), - ) - .with_column("return_type_id", SqlScalarType::String.nullable(true)) - .with_column("returns_set", SqlScalarType::Bool.nullable(false)) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .finish(), - column_comments: BTreeMap::from_iter([ - ("id", "Materialize's unique ID for the function."), - ("oid", "A PostgreSQL-compatible OID for the function."), - ( - "schema_id", - "The ID of the schema to which the function belongs. Corresponds to `mz_schemas.id`.", - ), - ("name", "The name of the function."), - ( - "argument_type_ids", - "The ID of each argument's type. Each entry refers to `mz_types.id`.", - ), - ( - "variadic_argument_type_id", - "The ID of the variadic argument's type, or `NULL` if the function does not have a variadic argument. Refers to `mz_types.id`.", - ), - ( - "return_type_id", - "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`].", - ), - ( - "returns_set", - "Whether the function returns a set, i.e. the function is a table function.", - ), - ( - "owner_id", - "The role ID of the owner of the function. Corresponds to `mz_roles.id`.", - ), - ]), - is_retained_metrics_object: false, - access: vec![PUBLIC_SELECT], - ontology: Some(Ontology { - entity_name: "function", - description: "A built-in or user-defined function", - links: &const { - [ - OntologyLink { - name: "in_schema", - target: "schema", - properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "owned_by", - target: "role", - properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), - }, - OntologyLink { - name: "returns_type", - target: "type", - properties: LinkProperties::fk_nullable( - "return_type_id", - "id", - Cardinality::ManyToOne, - ), - }, - OntologyLink { - name: "has_variadic_arg_type", - target: "type", - properties: LinkProperties::fk_nullable( - "variadic_argument_type_id", - "id", - Cardinality::ManyToOne, - ), - }, - ] - }, - column_semantic_types: &const { - [ - ("id", SemanticType::CatalogItemId), - ("oid", SemanticType::OID), - ("schema_id", SemanticType::SchemaId), - ("variadic_argument_type_id", SemanticType::CatalogItemId), - ("return_type_id", SemanticType::CatalogItemId), - ("owner_id", SemanticType::RoleId), - ] - }, - }), - } -}); -pub static MZ_OPERATORS: LazyLock = LazyLock::new(|| BuiltinTable { - name: "mz_operators", +pub static MZ_FUNCTIONS: LazyLock = LazyLock::new(|| BuiltinView { + name: "mz_functions", schema: MZ_CATALOG_SCHEMA, - oid: oid::TABLE_MZ_OPERATORS_OID, + oid: oid::VIEW_MZ_FUNCTIONS_OID, desc: RelationDesc::builder() + .with_column("id", SqlScalarType::String.nullable(false)) // not a key! .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_id", SqlScalarType::String.nullable(false)) .with_column("name", SqlScalarType::String.nullable(false)) .with_column( "argument_type_ids", SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), ) + .with_column( + "variadic_argument_type_id", + SqlScalarType::String.nullable(true), + ) .with_column("return_type_id", SqlScalarType::String.nullable(true)) + .with_column("returns_set", SqlScalarType::Bool.nullable(false)) + .with_column("owner_id", SqlScalarType::String.nullable(false)) .finish(), - column_comments: BTreeMap::new(), - is_retained_metrics_object: false, + column_comments: BTreeMap::from_iter([ + ("id", "Materialize's unique ID for the function."), + ("oid", "A PostgreSQL-compatible OID for the function."), + ( + "schema_id", + "The ID of the schema to which the function belongs. Corresponds to `mz_schemas.id`.", + ), + ("name", "The name of the function."), + ( + "argument_type_ids", + "The ID of each argument's type. Each entry refers to `mz_types.id`.", + ), + ( + "variadic_argument_type_id", + "The ID of the variadic argument's type, or `NULL` if the function does not have a variadic argument. Refers to `mz_types.id`.", + ), + ( + "return_type_id", + "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`].", + ), + ( + "returns_set", + "Whether the function returns a set, i.e. the function is a table function.", + ), + ( + "owner_id", + "The role ID of the owner of the function. Corresponds to `mz_roles.id`.", + ), + ]), + // Every function is builtin, there is no `CREATE FUNCTION`. Rows come from + // the generated `mz_builtin_functions` view, ids from the functions' and + // types' `mz_builtin_object_mappings` rows. See `make_builtin_functions`. + sql: Box::leak( + format!( + " +WITH + argument_type_ids AS ( + SELECT f.oid, array_agg(t.id ORDER BY a.ordinality) AS argument_type_ids + FROM + mz_internal.mz_builtin_functions f, + unnest(f.argument_type_names) WITH ORDINALITY AS a (name, ordinality), + mz_internal.mz_builtin_object_mappings t + WHERE t.object_type = {ty} AND t.name = a.name + GROUP BY f.oid + ) +SELECT + m.id, + f.oid, + s.id AS schema_id, + f.name, + COALESCE(a.argument_type_ids, ARRAY[]::text[]) AS argument_type_ids, + v.id AS variadic_argument_type_id, + r.id AS return_type_id, + f.returns_set, + '{MZ_SYSTEM_ROLE_ID}' AS owner_id +FROM mz_internal.mz_builtin_functions f +JOIN mz_internal.mz_builtin_object_mappings m + ON m.schema_name = f.schema_name AND m.name = f.name AND m.object_type = {func} +JOIN mz_catalog.mz_schemas s ON s.name = f.schema_name AND s.database_id IS NULL +LEFT JOIN argument_type_ids a ON a.oid = f.oid +LEFT JOIN mz_internal.mz_builtin_object_mappings v + ON v.object_type = {ty} AND v.name = f.variadic_argument_type_name +LEFT JOIN mz_internal.mz_builtin_object_mappings r + ON r.object_type = {ty} AND r.name = f.return_type_name", + ty = gid_mapping_object_type(CatalogItemType::Type), + func = gid_mapping_object_type(CatalogItemType::Func), + ) + .into_boxed_str(), + ), access: vec![PUBLIC_SELECT], ontology: Some(Ontology { - entity_name: "operator", - description: "A built-in SQL operator", + entity_name: "function", + description: "A built-in or user-defined function", links: &const { - [OntologyLink { - name: "returns_type", - target: "type", - properties: LinkProperties::fk_nullable( - "return_type_id", - "id", - Cardinality::ManyToOne, - ), - }] + [ + OntologyLink { + name: "in_schema", + target: "schema", + properties: LinkProperties::fk("schema_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "owned_by", + target: "role", + properties: LinkProperties::fk("owner_id", "id", Cardinality::ManyToOne), + }, + OntologyLink { + name: "returns_type", + target: "type", + properties: LinkProperties::fk_nullable( + "return_type_id", + "id", + Cardinality::ManyToOne, + ), + }, + OntologyLink { + name: "has_variadic_arg_type", + target: "type", + properties: LinkProperties::fk_nullable( + "variadic_argument_type_id", + "id", + Cardinality::ManyToOne, + ), + }, + ] }, column_semantic_types: &const { [ + ("id", SemanticType::CatalogItemId), ("oid", SemanticType::OID), + ("schema_id", SemanticType::SchemaId), + ("variadic_argument_type_id", SemanticType::CatalogItemId), ("return_type_id", SemanticType::CatalogItemId), + ("owner_id", SemanticType::RoleId), ] }, }), }); +pub static MZ_OPERATORS: LazyLock = LazyLock::new(|| { + BuiltinView { + name: "mz_operators", + schema: MZ_CATALOG_SCHEMA, + oid: oid::VIEW_MZ_OPERATORS_OID, + desc: RelationDesc::builder() + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("name", SqlScalarType::String.nullable(false)) + .with_column( + "argument_type_ids", + SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false), + ) + .with_column("return_type_id", SqlScalarType::String.nullable(true)) + .finish(), + column_comments: BTreeMap::new(), + // See `make_builtin_operators`; type ids resolve as for `mz_functions`. + sql: Box::leak( + format!( + " +WITH + argument_type_ids AS ( + SELECT o.oid, array_agg(t.id ORDER BY a.ordinality) AS argument_type_ids + FROM + mz_internal.mz_builtin_operators o, + unnest(o.argument_type_names) WITH ORDINALITY AS a (name, ordinality), + mz_internal.mz_builtin_object_mappings t + WHERE t.object_type = {ty} AND t.name = a.name + GROUP BY o.oid + ) +SELECT o.oid, o.name, COALESCE(a.argument_type_ids, ARRAY[]::text[]) AS argument_type_ids, r.id AS return_type_id +FROM mz_internal.mz_builtin_operators o +JOIN argument_type_ids a ON a.oid = o.oid +LEFT JOIN mz_internal.mz_builtin_object_mappings r + ON r.object_type = {ty} AND r.name = o.return_type_name", + ty = gid_mapping_object_type(CatalogItemType::Type), + ) + .into_boxed_str(), + ), + access: vec![PUBLIC_SELECT], + ontology: Some(Ontology { + entity_name: "operator", + description: "A built-in SQL operator", + links: &const { + [OntologyLink { + name: "returns_type", + target: "type", + properties: LinkProperties::fk_nullable( + "return_type_id", + "id", + Cardinality::ManyToOne, + ), + }] + }, + column_semantic_types: &const { + [ + ("oid", SemanticType::OID), + ("return_type_id", SemanticType::CatalogItemId), + ] + }, + }), +} +}); pub static MZ_CLUSTERS: LazyLock = LazyLock::new(|| { BuiltinMaterializedView { diff --git a/src/catalog/src/builtin/mz_internal.rs b/src/catalog/src/builtin/mz_internal.rs index bebb9b06cc988..d70660c3e6889 100644 --- a/src/catalog/src/builtin/mz_internal.rs +++ b/src/catalog/src/builtin/mz_internal.rs @@ -1088,17 +1088,23 @@ WHERE t.typinput IS NOT NULL AND t.typreceive IS NOT NULL AND t.typsend IS NOT N access: vec![PUBLIC_SELECT], ontology: None, }); -pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinTable { +pub static MZ_AGGREGATES: LazyLock = LazyLock::new(|| BuiltinView { name: "mz_aggregates", schema: MZ_INTERNAL_SCHEMA, - oid: oid::TABLE_MZ_AGGREGATES_OID, + oid: oid::VIEW_MZ_AGGREGATES_OID, desc: RelationDesc::builder() .with_column("oid", SqlScalarType::Oid.nullable(false)) .with_column("agg_kind", SqlScalarType::String.nullable(false)) .with_column("agg_num_direct_args", SqlScalarType::Int16.nullable(false)) + .with_key(vec![0]) .finish(), column_comments: BTreeMap::new(), - is_retained_metrics_object: false, + // TODO(database-issues#1064): Support ordered-set aggregate functions, + // which have an agg_kind of 'o' and direct arguments. + sql: " +SELECT oid, 'n' AS agg_kind, 0::int2 AS agg_num_direct_args +FROM mz_internal.mz_builtin_functions +WHERE kind = 'aggregate'", access: vec![PUBLIC_SELECT], ontology: Some(Ontology { entity_name: "aggregate", diff --git a/src/catalog/src/builtin/pg_catalog.rs b/src/catalog/src/builtin/pg_catalog.rs index 72f2a52511484..2fd0d495940b4 100644 --- a/src/catalog/src/builtin/pg_catalog.rs +++ b/src/catalog/src/builtin/pg_catalog.rs @@ -2493,6 +2493,7 @@ pub static PG_AGGREGATE: LazyLock = LazyLock::new(|| BuiltinView { .with_column("aggmtransspace", SqlScalarType::Int32.nullable(true)) .with_column("agginitval", SqlScalarType::String.nullable(true)) .with_column("aggminitval", SqlScalarType::String.nullable(true)) + .with_key(vec![0]) .finish(), column_comments: BTreeMap::new(), sql: "SELECT diff --git a/src/pgrepr-consts/src/oid.rs b/src/pgrepr-consts/src/oid.rs index b43f6ff03af0c..d188333928c86 100644 --- a/src/pgrepr-consts/src/oid.rs +++ b/src/pgrepr-consts/src/oid.rs @@ -445,9 +445,9 @@ pub const VIEW_MZ_MAP_TYPES_OID: u32 = 16719; pub const MV_MZ_ROLES_OID: u32 = 16720; pub const MV_MZ_ROLE_MEMBERS_OID: u32 = 16721; pub const VIEW_MZ_PSEUDO_TYPES_OID: u32 = 16722; -pub const TABLE_MZ_FUNCTIONS_OID: u32 = 16723; -pub const TABLE_MZ_OPERATORS_OID: u32 = 16724; -pub const TABLE_MZ_AGGREGATES_OID: u32 = 16725; +pub const VIEW_MZ_FUNCTIONS_OID: u32 = 16723; +pub const VIEW_MZ_OPERATORS_OID: u32 = 16724; +pub const VIEW_MZ_AGGREGATES_OID: u32 = 16725; pub const MV_MZ_CLUSTERS_OID: u32 = 16726; pub const MV_MZ_SECRETS_OID: u32 = 16727; pub const MV_MZ_CLUSTER_REPLICAS_OID: u32 = 16728; @@ -858,3 +858,5 @@ pub const INDEX_MZ_CATALOG_ITEM_METADATA_IND_OID: u32 = 17148; pub const VIEW_MZ_BUILTIN_OBJECT_MAPPINGS_OID: u32 = 17150; pub const INDEX_MZ_BUILTIN_OBJECT_MAPPINGS_IND_OID: u32 = 17151; pub const VIEW_MZ_BUILTIN_TYPES_OID: u32 = 17152; +pub const VIEW_MZ_BUILTIN_FUNCTIONS_OID: u32 = 17153; +pub const VIEW_MZ_BUILTIN_OPERATORS_OID: u32 = 17154; diff --git a/test/sqllogictest/mz_functions.slt b/test/sqllogictest/mz_functions.slt new file mode 100644 index 0000000000000..6cbae9205a1c7 --- /dev/null +++ b/test/sqllogictest/mz_functions.slt @@ -0,0 +1,173 @@ +# Copyright Materialize, Inc. and contributors. All rights reserved. +# +# Use of this software is governed by the Business Source License +# included in the LICENSE file at the root of this repository. +# +# As of the Change Date specified in that file, in accordance with +# the Business Source License, use of this software will be governed +# by the Apache License, Version 2.0. + +mode cockroach + +# --- mz_builtin_functions ------------------------------------------------------ + +# A signature as the function registry reports it: type names, not ids. +query TTTTTTT +SELECT schema_name, name, kind, argument_type_names::text, variadic_argument_type_name, return_type_name, returns_set +FROM mz_internal.mz_builtin_functions WHERE name = 'concat' +---- +pg_catalog concat scalar {any} any text false + +# --- mz_functions ------------------------------------------------------------ + +# Every implementation of an overloaded function shares the function's id. +query I +SELECT count(DISTINCT id) FROM mz_functions WHERE name = 'abs' +---- +1 + +query T +SELECT count(*) > 1 FROM mz_functions WHERE name = 'abs' +---- +true + +# The id comes from the function's GidMapping record, the schema from +# mz_schemas, and the owner is mz_system. +query TTT +SELECT + id LIKE 's%', + schema_id = (SELECT id FROM mz_schemas WHERE name = 'pg_catalog' AND database_id IS NULL), + owner_id +FROM mz_functions WHERE name = 'now' +---- +true true s1 + +# The oid is the compiled-in PostgreSQL oid, read out of the generated view, +# while a regproc cast resolves the name through the in-memory catalog. Two +# independent paths that must agree. +query IT +SELECT oid, oid = 'now'::regproc::oid FROM mz_functions WHERE name = 'now' +---- +1299 true + +# Argument types resolve to mz_types ids in argument order. +query TT rowsort +SELECT a1.name, a2.name +FROM mz_functions f +JOIN mz_types a1 ON a1.id = f.argument_type_ids[1] +JOIN mz_types a2 ON a2.id = f.argument_type_ids[2] +WHERE f.name = 'date_trunc' AND array_length(f.argument_type_ids, 1) = 2 +---- +text interval +text timestamp +text timestamptz + +# A nullary function has an empty argument array. +query T +SELECT argument_type_ids::text FROM mz_functions WHERE name = 'now' +---- +{} + +# A variadic function names its variadic argument's type, which is also its +# last argument; every other function reports NULL. +query TTT +SELECT a.name, v.name, r.name +FROM mz_functions f +JOIN mz_types a ON a.id = f.argument_type_ids[1] +JOIN mz_types v ON v.id = f.variadic_argument_type_id +JOIN mz_types r ON r.id = f.return_type_id +WHERE f.name = 'concat' +---- +any any text + +query I +SELECT count(*) FROM mz_functions WHERE name = 'now' AND variadic_argument_type_id IS NOT NULL +---- +0 + +# Table functions return a set. +query TT +SELECT returns_set, r.name +FROM mz_functions f JOIN mz_types r ON r.id = f.return_type_id +WHERE f.name = 'jsonb_array_elements' +---- +true jsonb + +# Only a function that returns no value has no return type. +query TT +SELECT name, returns_set FROM mz_functions WHERE return_type_id IS NULL ORDER BY name +---- +repeat_row true +repeat_row_non_negative true + +# Functions live in the system schemas. +query T +SELECT s.name +FROM mz_functions f JOIN mz_schemas s ON s.id = f.schema_id +GROUP BY s.name ORDER BY s.name +---- +information_schema +mz_catalog +mz_internal +mz_unsafe +pg_catalog + +# --- mz_operators ------------------------------------------------------------ + +# Binary operators list their arguments in order, and the oid is PostgreSQL's. +query ITTT +SELECT o.oid, l.name, r.name, ret.name +FROM mz_operators o +JOIN mz_types l ON l.id = o.argument_type_ids[1] +JOIN mz_types r ON r.id = o.argument_type_ids[2] +JOIN mz_types ret ON ret.id = o.return_type_id +WHERE o.name = '->' AND l.name = 'jsonb' AND r.name = 'text' +---- +3211 jsonb text jsonb + +# Unary operators have one argument. +query T +SELECT ret.name +FROM mz_operators o +JOIN mz_types l ON l.id = o.argument_type_ids[1] +JOIN mz_types ret ON ret.id = o.return_type_id +WHERE o.name = '-' AND array_length(o.argument_type_ids, 1) = 1 AND l.name = 'int4' +---- +int4 + +# --- mz_aggregates ----------------------------------------------------------- + +# Every implementation of an aggregate function has a row, and no other +# function does. +query TI rowsort +SELECT a.agg_kind, a.agg_num_direct_args +FROM mz_internal.mz_aggregates a JOIN mz_functions f USING (oid) +WHERE f.name = 'count' +---- +n 0 +n 0 + +# --- pg_catalog --------------------------------------------------------------- + +query TI +SELECT proname, prorettype FROM pg_proc WHERE oid = 1299 +---- +now 1184 + +query T +SELECT pg_function_is_visible(1299) +---- +true + +query TII +SELECT oprname, oprleft, oprright FROM pg_operator WHERE oid = 3211 +---- +-> 3802 25 + +query TI rowsort +SELECT aggkind, aggnumdirectargs +FROM pg_aggregate +WHERE aggfnoid IN (SELECT oid FROM mz_functions WHERE name = 'count') +---- +n 0 +n 0 diff --git a/test/sqllogictest/mz_views.slt b/test/sqllogictest/mz_views.slt index cd6839245a35c..16fd67609c09e 100644 --- a/test/sqllogictest/mz_views.slt +++ b/test/sqllogictest/mz_views.slt @@ -190,10 +190,12 @@ query T SELECT name FROM mz_views WHERE definition LIKE '%definition elided%' AND id LIKE 's%' ORDER BY name ---- mz_builtin_columns +mz_builtin_functions mz_builtin_index_columns mz_builtin_indexes mz_builtin_log_indexes mz_builtin_materialized_views +mz_builtin_operators mz_builtin_sources mz_builtin_tables mz_builtin_types diff --git a/test/testdrive/catalog.td b/test/testdrive/catalog.td index fc424ca5acf82..65df879026a10 100644 --- a/test/testdrive/catalog.td +++ b/test/testdrive/catalog.td @@ -512,8 +512,6 @@ name comment -------------------------------------- mz_cluster_replica_sizes "" mz_egress_ips "" -mz_functions "" -mz_operators "" mz_role_auth "" > SHOW VIEWS FROM mz_catalog @@ -521,9 +519,11 @@ name comment ----------------------------------- mz_array_types "" mz_base_types "" +mz_functions "" mz_list_types "" mz_map_types "" mz_objects "" +mz_operators "" mz_pseudo_types "" mz_relations "" mz_recent_storage_usage "" @@ -602,7 +602,6 @@ mz_wallclock_lag_history source "" > SHOW TABLES FROM mz_internal name comment ------------------------------------------------ -mz_aggregates "" mz_cluster_replica_size_internal "" mz_license_keys "" mz_object_arrangement_size_history "" @@ -618,12 +617,15 @@ mz_webhook_sources "" name comment ------------------------------------------------ mz_activity_log_thinned "" +mz_aggregates "" mz_builtin_columns "" +mz_builtin_functions "" mz_builtin_index_columns "" mz_builtin_indexes "" mz_builtin_log_indexes "" mz_builtin_materialized_views "" mz_builtin_object_mappings "" +mz_builtin_operators "" mz_builtin_sources "" mz_builtin_tables "" mz_builtin_types "" @@ -851,7 +853,7 @@ test_table "" # `SHOW TABLES` and `mz_tables` should agree. > SELECT COUNT(*) FROM mz_tables WHERE id LIKE 's%' -16 +13 # There is one entry in mz_indexes for each field_number/expression of the index. > SELECT COUNT(id) FROM mz_indexes WHERE id LIKE 's%' From c7095fe820ffa1f994cc93541d2ec829847a16dd Mon Sep 17 00:00:00 2001 From: SangJunBak Date: Wed, 18 Nov 2026 02:09:52 -0500 Subject: [PATCH 08/10] adapter: drop the function relations' shards on upgrade mz_functions, mz_operators and mz_aggregates became views, so a Drop step at the conversion version sends each of their shards to finalization. Co-Authored-By: Claude Fable 5.1 --- .../catalog/open/builtin_schema_migration.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/adapter/src/catalog/open/builtin_schema_migration.rs b/src/adapter/src/catalog/open/builtin_schema_migration.rs index 6716bc9374117..7c25150b5fd0f 100644 --- a/src/adapter/src/catalog/open/builtin_schema_migration.rs +++ b/src/adapter/src/catalog/open/builtin_schema_migration.rs @@ -649,6 +649,27 @@ static MIGRATIONS: LazyLock> = LazyLock::new(|| { MZ_CATALOG_SCHEMA, "mz_pseudo_types", ), + // The function and operator relations became views, so their shards + // are dropped. See the NOTE above: this version must stay at the + // workspace's current dev version until the change ships. + MigrationStep::drop( + "26.52.0-dev.0", + CatalogItemType::View, + MZ_CATALOG_SCHEMA, + "mz_functions", + ), + MigrationStep::drop( + "26.52.0-dev.0", + CatalogItemType::View, + MZ_CATALOG_SCHEMA, + "mz_operators", + ), + MigrationStep::drop( + "26.52.0-dev.0", + CatalogItemType::View, + MZ_INTERNAL_SCHEMA, + "mz_aggregates", + ), ] }); From bc264e3510edf9ab106ff0110f0f7f7bd9400f93 Mon Sep 17 00:00:00 2001 From: SangJunBak Date: Mon, 16 Nov 2026 15:26:21 -0500 Subject: [PATCH 09/10] test: regenerate the catalog goldens and function registry snapshots The catalog changes below this one leave every generated test output at its main version. This change holds all of them for the stack: the sqllogictest goldens listing builtin objects, their OIDs, columns and catalog server plans, the two error messages that list the available relations, and the scalar function registry and LIR snapshots. ci/test/lint-docs-catalog.py bin/sqllogictest -- --rewrite-results REWRITE=1 cargo test -p mz-compute-types --test func_registry REWRITE=1 cargo test -p mz-compute-types --test lir_schema Co-Authored-By: Claude Fable 5.1 --- test/sqllogictest/github-2514.slt | 3 --- test/sqllogictest/transactions.slt | 3 --- 2 files changed, 6 deletions(-) diff --git a/test/sqllogictest/github-2514.slt b/test/sqllogictest/github-2514.slt index 5bb42618a3412..3fa3938b32de0 100644 --- a/test/sqllogictest/github-2514.slt +++ b/test/sqllogictest/github-2514.slt @@ -42,11 +42,9 @@ Only the following relations are available: "mz_catalog.mz_columns" "mz_catalog.mz_connections" "mz_catalog.mz_databases" -"mz_catalog.mz_functions" "mz_catalog.mz_index_columns" "mz_catalog.mz_indexes" "mz_catalog.mz_materialized_views" -"mz_catalog.mz_operators" "mz_catalog.mz_role_auth" "mz_catalog.mz_role_members" "mz_catalog.mz_role_parameters" @@ -58,7 +56,6 @@ Only the following relations are available: "mz_catalog.mz_system_privileges" "mz_catalog.mz_tables" "mz_catalog.mz_views" -"mz_internal.mz_aggregates" "mz_internal.mz_catalog_items" "mz_internal.mz_catalog_state" "mz_internal.mz_comments" diff --git a/test/sqllogictest/transactions.slt b/test/sqllogictest/transactions.slt index 9be9affcc02c4..8ec44df7cac85 100644 --- a/test/sqllogictest/transactions.slt +++ b/test/sqllogictest/transactions.slt @@ -299,11 +299,9 @@ Only the following relations are available: "mz_catalog.mz_columns" "mz_catalog.mz_connections" "mz_catalog.mz_databases" -"mz_catalog.mz_functions" "mz_catalog.mz_index_columns" "mz_catalog.mz_indexes" "mz_catalog.mz_materialized_views" -"mz_catalog.mz_operators" "mz_catalog.mz_role_auth" "mz_catalog.mz_role_members" "mz_catalog.mz_role_parameters" @@ -315,7 +313,6 @@ Only the following relations are available: "mz_catalog.mz_system_privileges" "mz_catalog.mz_tables" "mz_catalog.mz_views" -"mz_internal.mz_aggregates" "mz_internal.mz_catalog_items" "mz_internal.mz_catalog_state" "mz_internal.mz_comments" From 1023d894f74c77122e34341956fbaae988790b83 Mon Sep 17 00:00:00 2001 From: SangJunBak Date: Wed, 18 Nov 2026 01:56:22 -0500 Subject: [PATCH 10/10] test: regenerate the goldens for the function relation views mz_functions, mz_operators and mz_aggregates are views now, and the two generated views they read, mz_builtin_functions and mz_builtin_operators, are new builtins. That adds five EXPLAIN queries to catalog_server_explain.slt, flips the three relations to VIEW in information_schema_tables.slt, lists the new views in the autogenerated mz_internal.slt and oid.slt, and shifts the catalog server index ids by two. The func_registry and lir_schema snapshots are unchanged. ci/test/lint-docs-catalog.py bin/sqllogictest -- --rewrite-results REWRITE=1 cargo test -p mz-compute-types --test func_registry --test lir_schema Co-Authored-By: Claude Opus 5.5 resolve rebase conflicts: test: regenerate the goldens for the function relation views resolve rebase conflicts: test: regenerate the goldens for the function relation views --- .../autogenerated/mz_internal.slt | 2 + test/sqllogictest/catalog_server_explain.slt | 567 ++++++++++++++---- .../information_schema_tables.slt | 14 +- .../mz_catalog_server_index_accounting.slt | 176 +++--- test/sqllogictest/oid.slt | 2 + 5 files changed, 572 insertions(+), 189 deletions(-) diff --git a/test/sqllogictest/autogenerated/mz_internal.slt b/test/sqllogictest/autogenerated/mz_internal.slt index 00d63a6de1a88..b0ac5edf13df8 100644 --- a/test/sqllogictest/autogenerated/mz_internal.slt +++ b/test/sqllogictest/autogenerated/mz_internal.slt @@ -813,11 +813,13 @@ mz_aws_connections mz_aws_privatelink_connection_status_history mz_aws_privatelink_connection_statuses mz_builtin_columns +mz_builtin_functions mz_builtin_index_columns mz_builtin_indexes mz_builtin_log_indexes mz_builtin_materialized_views mz_builtin_object_mappings +mz_builtin_operators mz_builtin_sources mz_builtin_tables mz_builtin_types diff --git a/test/sqllogictest/catalog_server_explain.slt b/test/sqllogictest/catalog_server_explain.slt index b456a3e81da0c..564a46879be09 100644 --- a/test/sqllogictest/catalog_server_explain.slt +++ b/test/sqllogictest/catalog_server_explain.slt @@ -219,6 +219,62 @@ mz_catalog.mz_objects_ind: mz_catalog.mz_objects: →With cte l0 = + →Delta Join [%0[#1{schema_name}, #2{name}] » %1:mz_builtin_object_mappings[#0{schema_name}, #1{name}] » %2:mz_schemas[#1{name}]] [%1:mz_builtin_object_mappings[#0{schema_name}] » %0[#1{schema_name}, #2{name}] » %2:mz_schemas[#1{name}]] [%2:mz_schemas[#1{name}] » %1:mz_builtin_object_mappings[#0{schema_name}] » %0[#1{schema_name}, #2{name}]] + →Arrange (#1{schema_name}, #2{name}) + →Constant (639 rows) + →Arrange (#0{schema_name}) (#0{schema_name}, #1{name}) + →Fused with Child Map/Filter/Project + Project: #0, #1, #3 + Filter: (#2{object_type} = "8") + →Arranged mz_internal.mz_builtin_object_mappings + Key: (#0{schema_name}, #1{name}) + →Arrange (#1{name}) + →Fused with Child Map/Filter/Project + Project: #1, #3 + Filter: (#0{database_id}) IS NULL + →Arranged mz_catalog.mz_schemas + Key: (#2{database_id}) + cte l1 = + →Arrange (#2{variadic_argument_type_name}) + →Fused with Child Map/Filter/Project + Filter: (#2{variadic_argument_type_name}) IS NOT NULL + →Read l0 + cte l2 = + →Arrange (#0{name}) + →Fused with Child Map/Filter/Project + Project: #1 + Filter: (#2{object_type} = "7") + →Arranged mz_internal.mz_builtin_object_mappings + Key: (#0{schema_name}, #1{name}) + cte l3 = + →Differential Join %1:l2[#0{name}] » %0:l1[#2{variadic_argument_type_name}] + →Arranged l1 + →Arranged l2 + cte l4 = + →Consolidating Union + →Negate Diffs + →Differential Join %1[#0] » %0:l1[#2{variadic_argument_type_name}] + →Arranged l1 + →Distinct GroupAggregate + →Fused with Child Map/Filter/Project + Project: #2 + →Read l3 + →Fused with Child Map/Filter/Project + Project: #0, #1, #3..=#5 + →Read l0 + →Fused with Child Map/Filter/Project + Project: #0, #1, #3..=#5 + →Read l3 + cte l5 = + →Arrange (#2{return_type_name}) + →Fused with Child Map/Filter/Project + Filter: (#2{return_type_name}) IS NOT NULL + →Read l4 + cte l6 = + →Differential Join %1:l2[#0{name}] » %0:l5[#2{return_type_name}] + →Arranged l5 + →Arranged l2 + cte l7 = →Union →Fused with Child Map/Filter/Project Project: #1, #2, #0, #3, #9, #4, #10, #5 @@ -242,7 +298,7 @@ mz_catalog.mz_objects: Key: (#0{id}) →Return →Union - →Stream l0 + →Stream l7 →Fused with Child Map/Filter/Project Project: #0..=#3, #15, #12, #11, #16 Map: "sink", null @@ -253,7 +309,7 @@ mz_catalog.mz_objects: Map: "metric-sink", null →Arranged mz_internal.mz_metric_sinks Key: (#0{id}) - →Differential Join %0:mz_indexes[#3{on_id}] » %1:l0[#0{id}] + →Differential Join %0:mz_indexes[#3{on_id}] » %1:l7[#0{id}] Final closure: Project: #0, #1, #5, #2, #6, #4, #3, #7 Map: "index", null @@ -265,7 +321,7 @@ mz_catalog.mz_objects: →Arrange (#0{id}) →Fused with Child Map/Filter/Project Project: #0, #2 - →Read l0 + →Read l7 →Fused with Child Map/Filter/Project Project: #1, #2, #0, #3, #9, #5, #10, #6 Map: "connection", null @@ -276,23 +332,37 @@ mz_catalog.mz_objects: Map: "type", null →Arranged mz_catalog.mz_types Key: (#2{schema_id}) - →Read mz_catalog.mz_functions + →Map/Filter/Project + Project: #2, #0, #3, #1, #5, #4, #6, #7 + Map: "s1", "function", null, null + →Consolidating Union + →Negate Diffs + →Differential Join %1[#0] » %0:l5[#2{return_type_name}] + →Arranged l5 + →Distinct GroupAggregate + →Fused with Child Map/Filter/Project + Project: #2 + →Read l6 + →Fused with Child Map/Filter/Project + Project: #0, #1, #3, #4 + →Read l4 + →Fused with Child Map/Filter/Project + Project: #0, #1, #3, #4 + →Read l6 →Fused with Child Map/Filter/Project Project: #1..=#3, #0, #6, #4, #7, #5 Map: "secret", null →Arranged mz_catalog.mz_secrets Key: (#3{name}) -Source mz_catalog.mz_functions - project=(#0..=#3, #9, #8, #10, #11) - map=("function", null, null) - Used Indexes: + - mz_internal.mz_builtin_object_mappings_ind (*** full scan ***) - mz_catalog.mz_indexes_ind (*** full scan ***) - mz_catalog.mz_sources_ind (*** full scan ***) - mz_catalog.mz_sinks_ind (*** full scan ***) - mz_internal.mz_metric_sinks_ind (*** full scan ***) - mz_catalog.mz_materialized_views_ind (*** full scan ***) + - mz_catalog.mz_schemas_ind (*** full scan ***) - mz_catalog.mz_connections_ind (*** full scan ***) - mz_catalog.mz_tables_ind (*** full scan ***) - mz_catalog.mz_types_ind (*** full scan ***) @@ -545,19 +615,6 @@ Target cluster: mz_catalog_server EOF -query T multiline -EXPLAIN INDEX "mz_internal"."mz_cluster_auto_scaling_strategies_ind"; ----- -mz_internal.mz_cluster_auto_scaling_strategies_ind: - →Arrange (#0{cluster_id}) - →Stream mz_internal.mz_cluster_auto_scaling_strategies - -Source mz_internal.mz_cluster_auto_scaling_strategies - -Target cluster: mz_catalog_server - -EOF - query T multiline EXPLAIN INDEX "mz_internal"."mz_catalog_item_metadata_ind"; ---- @@ -576,6 +633,19 @@ Target cluster: mz_catalog_server EOF +query T multiline +EXPLAIN INDEX "mz_internal"."mz_cluster_auto_scaling_strategies_ind"; +---- +mz_internal.mz_cluster_auto_scaling_strategies_ind: + →Arrange (#0{cluster_id}) + →Stream mz_internal.mz_cluster_auto_scaling_strategies + +Source mz_internal.mz_cluster_auto_scaling_strategies + +Target cluster: mz_catalog_server + +EOF + query T multiline EXPLAIN INDEX "mz_internal"."mz_cluster_deployment_lineage_ind"; ---- @@ -5077,7 +5147,7 @@ mz_catalog.mz_columns: Project: #6, #0..=#3, #7, #4, #5 Map: null →Arrange (#0{schema_name}, #1{relation_name}) - →Constant (1997 rows) + →Constant (2009 rows) →Arrange (#1{schema_name}, #2{name}) →Fused with Child Map/Filter/Project Project: #6, #4, #3 @@ -5835,7 +5905,7 @@ mz_catalog.mz_tables: Project: #3, #0, #4, #1, #5, #2, #6, #6, #6 Map: "s1", null →Arrange (#1{schema_name}, #2{name}) - →Constant (16 rows) + →Constant (13 rows) →Arrange (#0{schema_name}) (#0{schema_name}, #1{name}) →Fused with Child Map/Filter/Project Project: #5, #4, #6 @@ -5890,7 +5960,7 @@ mz_catalog.mz_views: Project: #5, #0, #6, #1, #2, #8, #3, #4, #7 Map: "s1" →Arrange (#1{schema_name}, #2{name}) - →Constant (209 rows) + →Constant (214 rows) →Arrange (#0{schema_name}) (#0{schema_name}, #1{name}) →Fused with Child Map/Filter/Project Project: #5, #4, #6 @@ -6061,7 +6131,7 @@ mz_internal.mz_history_retention_strategies: Project: #3, #5 Map: ("s" || ((#4{data} -> "value") ->> "catalog_id")) →Arrange (#2{name}, #0{object_type}, #1{schema_name}) - →Constant (180 rows) + →Constant (177 rows) →Arrange (((#0{data} -> "key") ->> "object_name"), ((#0{data} -> "key") ->> "object_type"), ((#0{data} -> "key") ->> "schema_name")) →Fused with Child Map/Filter/Project Project: #0 @@ -6407,7 +6477,7 @@ mz_internal.mz_object_dependencies: Project: #4..=#6, #2 Filter: case when (#7{ref_kind} = "func") then (#3{object_type} = "8") else case when (#7{ref_kind} = "type") then (#3{object_type} = "7") else ((#3{object_type} != "7") AND (#3{object_type} != "8")) end end →Arrange (#0{object_schema}..=#2{object_type}) (#3{ref_schema}, #4{ref_name}) - →Constant (1140 rows) + →Constant (1157 rows) →Arrange (#1{schema_name}..=#3{object_type}) →Fused with Child Map/Filter/Project Project: #5, #4, #2, #3 @@ -7941,39 +8011,82 @@ EXPLAIN SELECT * FROM "information_schema"."routines"; Explained Query: →With cte l0 = - →Differential Join %1:mz_schemas[#0{id}] » %0:mz_functions[#0{schema_id}] - →Arrange (#0{schema_id}) - →Read mz_catalog.mz_functions - →Arrange (#0{id}) + →One-Shot Delta Join [%0 » %1:mz_builtin_object_mappings[#0{schema_name}, #1{name}] » %2:mz_schemas[#0{name}]] + →Unarranged Raw Stream + →Constant (458 rows) + →Arrange (#0{schema_name}) (#0{schema_name}, #1{name}) →Fused with Child Map/Filter/Project - Project: #1, #0, #3 + Project: #0, #1 + Filter: (#2{object_type} = "8") + →Arranged mz_internal.mz_builtin_object_mappings + Key: (#0{schema_name}, #1{name}) + →Arrange (#0{name}) + →Fused with Child Map/Filter/Project + Project: #3 + Filter: (#0{database_id}) IS NULL →Arranged mz_catalog.mz_schemas Key: (#2{database_id}) + cte l1 = + →Arrange (#1{variadic_argument_type_name}) + →Fused with Child Map/Filter/Project + Filter: (#1{variadic_argument_type_name}) IS NOT NULL + →Read l0 + cte l2 = + →Arrange (#0{name}) + →Fused with Child Map/Filter/Project + Project: #1 + Filter: (#2{object_type} = "7") + →Arranged mz_internal.mz_builtin_object_mappings + Key: (#0{schema_name}, #1{name}) + cte l3 = + →Differential Join %1:l2[#0{name}] » %0:l1[#1{variadic_argument_type_name}] + →Arranged l1 + →Arranged l2 + cte l4 = + →Consolidating Union + →Negate Diffs + →Differential Join %1[#0] » %0:l1[#1{variadic_argument_type_name}] + →Arranged l1 + →Distinct GroupAggregate + →Fused with Child Map/Filter/Project + Project: #1 + →Read l3 + →Fused with Child Map/Filter/Project + Project: #0, #2, #3 + →Read l0 + →Fused with Child Map/Filter/Project + Project: #0, #2, #3 + →Read l3 + cte l5 = + →Arrange (#1{return_type_name}) + →Fused with Child Map/Filter/Project + Filter: (#1{return_type_name}) IS NOT NULL + →Read l4 + cte l6 = + →Differential Join %1:l2[#0{name}] » %0:l5[#1{return_type_name}] + →Arranged l5 + →Arranged l2 →Return →Map/Filter/Project Project: #2, #1, #0, #3, #4 Map: "materialize", "FUNCTION", null - →Union + →Consolidating Union + →Negate Diffs + →Differential Join %1[#0] » %0:l5[#1{return_type_name}] + →Arranged l5 + →Distinct GroupAggregate + →Fused with Child Map/Filter/Project + Project: #1 + →Read l6 →Fused with Child Map/Filter/Project Project: #0, #2 - Filter: (null OR (#1{database_id}) IS NULL) - →Read l0 - →Differential Join %1[#0{id}] » %0:l0[#1{database_id}] - →Arrange (#1{database_id}) - →Fused with Child Map/Filter/Project - Filter: (#1{database_id}) IS NOT NULL - →Read l0 - →Arrange (#0{id}) - →Differential Join %1[#0] » %0:mz_databases[#2{name}] - →Arranged mz_catalog.mz_databases - →Arrange (#0) - →Constant (1 row) - -Source mz_catalog.mz_functions - project=(#2, #3) + →Read l4 + →Fused with Child Map/Filter/Project + Project: #0, #2 + →Read l6 Used Indexes: - - mz_catalog.mz_databases_ind (lookup) + - mz_internal.mz_builtin_object_mappings_ind (*** full scan ***) - mz_catalog.mz_schemas_ind (*** full scan ***) Target cluster: mz_catalog_server @@ -8904,6 +9017,126 @@ Target cluster: mz_catalog_server EOF +query T multiline +EXPLAIN SELECT * FROM "mz_catalog"."mz_functions"; +---- +Explained Query: + →With + cte l0 = + →One-Shot Delta Join [%0 » %1:mz_builtin_object_mappings[#0{schema_name}, #1{name}] » %2:mz_schemas[#1{name}]] + →Unarranged Raw Stream + →Constant (639 rows) + →Arrange (#0{schema_name}) (#0{schema_name}, #1{name}) + →Fused with Child Map/Filter/Project + Project: #0, #1, #3 + Filter: (#2{object_type} = "8") + →Arranged mz_internal.mz_builtin_object_mappings + Key: (#0{schema_name}, #1{name}) + →Arrange (#1{name}) + →Fused with Child Map/Filter/Project + Project: #1, #3 + Filter: (#0{database_id}) IS NULL + →Arranged mz_catalog.mz_schemas + Key: (#2{database_id}) + cte l1 = + →Arrange (#0{name}) + →Fused with Child Map/Filter/Project + Project: #1, #3 + Filter: (#2{object_type} = "7") + →Arranged mz_internal.mz_builtin_object_mappings + Key: (#0{schema_name}, #1{name}) + cte l2 = + →Differential Join %1[#0] » %0:l0[#0{oid}] + →Arrange (#0{oid}) + →Stream l0 + →Non-incremental GroupAggregate + Aggregation: array_agg[order_by=[#0 asc nulls_last]](row(array[#2{id}], #1{ordinality})) + Key: + Project: #0 + →Differential Join %1:l1[#0{name}] » %0[#1{name}] + →Arrange (#1{name}) + →Constant (937 rows) + →Arranged l1 + cte l3 = + →Union + →Map/Filter/Project + Project: #0..=#7 + Map: null + →Consolidating Union + →Negate Diffs + →Fused with Child Map/Filter/Project + Project: #0..=#6 + →Read l2 + →Stream l0 + →Stream l2 + cte l4 = + →Arrange (#2{variadic_argument_type_name}) + →Fused with Child Map/Filter/Project + Filter: (#2{variadic_argument_type_name}) IS NOT NULL + →Read l3 + cte l5 = + →Differential Join %1:l1[#0{name}] » %0:l4[#2{variadic_argument_type_name}] + →Arranged l4 + →Arranged l1 + cte l6 = + →Union + →Map/Filter/Project + Project: #0..=#7 + Map: null + →Consolidating Union + →Negate Diffs + →Differential Join %1[#0] » %0:l4[#2{variadic_argument_type_name}] + →Arranged l4 + →Distinct GroupAggregate + →Fused with Child Map/Filter/Project + Project: #2 + →Read l5 + →Fused with Child Map/Filter/Project + Project: #0, #1, #3..=#7 + →Read l3 + →Fused with Child Map/Filter/Project + Project: #0, #1, #3..=#8 + →Read l5 + cte l7 = + →Arrange (#2{return_type_name}) + →Fused with Child Map/Filter/Project + Filter: (#2{return_type_name}) IS NOT NULL + →Read l6 + cte l8 = + →Differential Join %1:l1[#0{name}] » %0:l7[#2{return_type_name}] + →Arranged l7 + →Arranged l1 + →Return + →Map/Filter/Project + Project: #3, #0, #4, #1, #8, #6, #7, #2, #9 + Map: coalesce(#5{argument_type_ids}, {}), "s1" + →Union + →Map/Filter/Project + Project: #0..=#7 + Map: null + →Consolidating Union + →Negate Diffs + →Differential Join %1[#0] » %0:l7[#2{return_type_name}] + →Arranged l7 + →Distinct GroupAggregate + →Fused with Child Map/Filter/Project + Project: #2 + →Read l8 + →Fused with Child Map/Filter/Project + Project: #0, #1, #3..=#7 + →Read l6 + →Fused with Child Map/Filter/Project + Project: #0, #1, #3..=#8 + →Read l8 + +Used Indexes: + - mz_internal.mz_builtin_object_mappings_ind (*** full scan ***) + - mz_catalog.mz_schemas_ind (*** full scan ***) + +Target cluster: mz_catalog_server + +EOF + query T multiline EXPLAIN SELECT * FROM "mz_catalog"."mz_list_types"; ---- @@ -8953,6 +9186,64 @@ Target cluster: mz_catalog_server EOF +query T multiline +EXPLAIN SELECT * FROM "mz_catalog"."mz_operators"; +---- +Explained Query: + →With + cte l0 = + →Arrange (#0{name}) + →Fused with Child Map/Filter/Project + Project: #1, #3 + Filter: (#2{object_type} = "7") + →Arranged mz_internal.mz_builtin_object_mappings + Key: (#0{schema_name}, #1{name}) + cte l1 = + →Differential Join %1[#0] » %0[#0{oid}] + →Arrange (#0{oid}) + →Constant (344 rows) + →Non-incremental GroupAggregate + Aggregation: array_agg[order_by=[#0 asc nulls_last]](row(array[#2{id}], #1{ordinality})) + Key: + Project: #0 + →Differential Join %1:l0[#0{name}] » %0[#1{name}] + →Arrange (#1{name}) + →Constant (674 rows) + →Arranged l0 + cte l2 = + →Arrange (#2{return_type_name}) + →Stream l1 + cte l3 = + →Differential Join %1:l0[#0{name}] » %0:l2[#2{return_type_name}] + →Arranged l2 + →Arranged l0 + →Return + →Union + →Map/Filter/Project + Project: #0..=#3 + Map: null + →Consolidating Union + →Negate Diffs + →Differential Join %1[#0] » %0:l2[#2{return_type_name}] + →Arranged l2 + →Distinct GroupAggregate + →Fused with Child Map/Filter/Project + Project: #2 + →Read l3 + →Fused with Child Map/Filter/Project + Project: #0, #1, #3 + →Read l1 + →Fused with Child Map/Filter/Project + Project: #0, #1, #3, #4 + →Read l3 + +Used Indexes: + - mz_internal.mz_builtin_object_mappings_ind (*** full scan ***) + +Target cluster: mz_catalog_server + +EOF + query T multiline EXPLAIN SELECT * FROM "mz_catalog"."mz_pseudo_types"; ---- @@ -9103,6 +9394,16 @@ Target cluster: mz_catalog_server EOF +query T multiline +EXPLAIN SELECT * FROM "mz_internal"."mz_aggregates"; +---- +Explained Query (fast path): + →Constant (65 rows) + +Target cluster: mz_catalog_server + +EOF + query T multiline EXPLAIN SELECT * FROM "mz_internal"."mz_aws_privatelink_connection_statuses"; ---- @@ -9142,7 +9443,17 @@ query T multiline EXPLAIN SELECT * FROM "mz_internal"."mz_builtin_columns"; ---- Explained Query (fast path): - →Constant (1997 rows) + →Constant (2009 rows) + +Target cluster: mz_catalog_server + +EOF + +query T multiline +EXPLAIN SELECT * FROM "mz_internal"."mz_builtin_functions"; +---- +Explained Query (fast path): + →Constant (639 rows) Target cluster: mz_catalog_server @@ -9202,6 +9513,16 @@ Target cluster: mz_catalog_server EOF +query T multiline +EXPLAIN SELECT * FROM "mz_internal"."mz_builtin_operators"; +---- +Explained Query (fast path): + →Constant (344 rows) + +Target cluster: mz_catalog_server + +EOF + query T multiline EXPLAIN SELECT * FROM "mz_internal"."mz_builtin_sources"; ---- @@ -9216,7 +9537,7 @@ query T multiline EXPLAIN SELECT * FROM "mz_internal"."mz_builtin_tables"; ---- Explained Query (fast path): - →Constant (16 rows) + →Constant (13 rows) Target cluster: mz_catalog_server @@ -9236,7 +9557,7 @@ query T multiline EXPLAIN SELECT * FROM "mz_internal"."mz_builtin_views"; ---- Explained Query (fast path): - →Constant (209 rows) + →Constant (214 rows) Target cluster: mz_catalog_server @@ -11201,7 +11522,7 @@ Explained Query: Project: #3, #4 Filter: case when (#2{ref_kind} = "func") then (#5{object_type} = "8") else case when (#2{ref_kind} = "type") then (#5{object_type} = "7") else ((#5{object_type} != "7") AND (#5{object_type} != "8")) end end →Unarranged Raw Stream - →Constant (1140 rows) + →Constant (1157 rows) →Arrange (#1{schema_name}..=#3{object_type}) →Fused with Child Map/Filter/Project Project: #5, #4, #2, #3 @@ -18359,12 +18680,8 @@ EOF query T multiline EXPLAIN SELECT * FROM "pg_catalog"."pg_aggregate"; ---- -Explained Query: - →Read mz_internal.mz_aggregates - -Source mz_internal.mz_aggregates - project=(#0..=#2, #4, #3, #3, #3, #3, #3, #3, #3, #5..=#7, #7..=#10, #8, #10, #11, #11) - map=(0, null, false, false, null, 0, null, null, null) +Explained Query (fast path): + →Constant (65 rows) Target cluster: mz_catalog_server @@ -20124,6 +20441,29 @@ EXPLAIN SELECT * FROM "pg_catalog"."pg_operator"; Explained Query: →With cte l0 = + →Arrange (#0{name}) + →Fused with Child Map/Filter/Project + Project: #1, #3 + Filter: (#2{object_type} = "7") + →Arranged mz_internal.mz_builtin_object_mappings + Key: (#0{schema_name}, #1{name}) + cte l1 = + →One-Shot Delta Join [%0 » %1[#0] » %2:l0[#0{name}]] + path %0: + after %1: + Filter: (array_index(#3{argument_type_ids}, 1)) IS NOT NULL + →Unarranged Raw Stream + →Constant (344 rows) + →Non-incremental GroupAggregate + Aggregation: array_agg[order_by=[#0 asc nulls_last]](row(array[#2{id}], #1{ordinality})) + Key: + Project: #0 + →Differential Join %1:l0[#0{name}] » %0[#1{name}] + →Arrange (#1{name}) + →Constant (674 rows) + →Arranged l0 + →Arranged l0 + cte l2 = →Arrange (#0{id}) →Fused with Child Map/Filter/Project Project: #1, #2 @@ -20132,34 +20472,28 @@ Explained Query: →Return →Distinct GroupAggregate →Union - →One-Shot Delta Join [%0:mz_operators » %1:l0[#0{id}] » %2:l0[#0{id}] » %3:l0[#0{id}]] + →One-Shot Delta Join [%0:l1 » %1:l2[#0{id}] » %2:l2[#0{id}] » %3:l2[#0{id}]] →Unarranged Raw Stream →Fused with Child Map/Filter/Project - Project: #0..=#3 - Filter: (array_index(#2{argument_type_ids}, 2)) IS NOT NULL AND (2 = #4) - →Read mz_catalog.mz_operators - →Arranged l0 - →Arranged l0 - →Arranged l0 - →One-Shot Delta Join [%0:mz_operators » %1:l0[#0{id}] » %2:l0[#0{id}]] + Filter: (2 = array_length(#2{argument_type_ids}, 1)) AND (array_index(#2{argument_type_ids}, 2)) IS NOT NULL + →Read l1 + →Arranged l2 + →Arranged l2 + →Arranged l2 + →One-Shot Delta Join [%0:l1 » %1:l2[#0{id}] » %2:l2[#0{id}]] path %0: Final closure: Project: #0..=#2, #4, #3 Map: 0 →Unarranged Raw Stream →Fused with Child Map/Filter/Project - Project: #0..=#3 - Filter: (1 = #4) - →Read mz_catalog.mz_operators - →Arranged l0 - →Arranged l0 - -Source mz_catalog.mz_operators - project=(#0..=#4) - filter=((array_index(#2{argument_type_ids}, 1)) IS NOT NULL AND (#3{return_type_id}) IS NOT NULL) - map=(array_length(#2{argument_type_ids}, 1)) + Filter: (1 = array_length(#2{argument_type_ids}, 1)) + →Read l1 + →Arranged l2 + →Arranged l2 Used Indexes: + - mz_internal.mz_builtin_object_mappings_ind (*** full scan ***) - mz_catalog.mz_types_ind (*** full scan ***) Target cluster: mz_catalog_server @@ -20182,50 +20516,79 @@ EXPLAIN SELECT * FROM "pg_catalog"."pg_proc"; Explained Query: →With cte l0 = - →Differential Join %1:mz_schemas[#0{id}] » %0:mz_functions[#1{schema_id}] - →Arrange (#1{schema_id}) - →Read mz_catalog.mz_functions - →Arrange (#0{id}) + →One-Shot Delta Join [%0 » %1:mz_builtin_object_mappings[#0{schema_name}, #1{name}] » %2:mz_schemas[#1{name}]] + →Unarranged Raw Stream + →Constant (639 rows) + →Arrange (#0{schema_name}) (#0{schema_name}, #1{name}) →Fused with Child Map/Filter/Project - Project: #1, #2, #0 + Project: #0, #1 + Filter: (#2{object_type} = "8") + →Arranged mz_internal.mz_builtin_object_mappings + Key: (#0{schema_name}, #1{name}) + →Arrange (#1{name}) + →Fused with Child Map/Filter/Project + Project: #2, #3 + Filter: (#0{database_id}) IS NULL →Arranged mz_catalog.mz_schemas Key: (#2{database_id}) + cte l1 = + →Fused with Child Map/Filter/Project + Project: #1, #3 + Filter: (#2{object_type} = "7") + →Arranged mz_internal.mz_builtin_object_mappings + Key: (#0{schema_name}, #1{name}) + cte l2 = + →Differential Join %1:l1[#0{name}] » %0:l0[#2{variadic_argument_type_name}] + →Arrange (#2{variadic_argument_type_name}) + →Fused with Child Map/Filter/Project + Filter: (#2{variadic_argument_type_name}) IS NOT NULL + →Read l0 + →Arrange (#0{name}) + →Fused with Child Map/Filter/Project + Project: #0 + →Read l1 →Return - →One-Shot Delta Join [%0 » %2:mz_roles[#0{id}] » %1:mz_types[#0{id}]] + →One-Shot Delta Cross Join [%0 » %1:l1[#0{name}] » %2:mz_types[#0{id}] » %3[×]] path %0: Final closure: Project: #0..=#2, #4, #5, #3 Map: null →Unarranged Raw Stream - →Union + →Consolidating Union + →Negate Diffs + →Differential Join %1[#0] » %0:l0[#2{variadic_argument_type_name}] + →Arrange (#2{variadic_argument_type_name}) + →Fused with Child Map/Filter/Project + Filter: (#2{variadic_argument_type_name}) IS NOT NULL AND (#3{return_type_name}) IS NOT NULL + →Read l0 + →Distinct GroupAggregate + →Fused with Child Map/Filter/Project + Project: #2 + →Read l2 →Fused with Child Map/Filter/Project - Project: #0..=#4 - Filter: (null OR (#5{database_id}) IS NULL) + Project: #0, #1, #3, #4 + Filter: (#3{return_type_name}) IS NOT NULL →Read l0 - →Differential Join %1[#0{id}] » %0:l0[#5{database_id}] - →Arrange (#5{database_id}) - →Fused with Child Map/Filter/Project - Filter: (#5{database_id}) IS NOT NULL - →Read l0 - →Arrange (#0{id}) - →Differential Join %1[#0] » %0:mz_databases[#2{name}] - →Arranged mz_catalog.mz_databases - →Arrange (#0) - →Constant (1 row) + →Fused with Child Map/Filter/Project + Project: #0, #1, #3, #4 + Filter: (#3{return_type_name}) IS NOT NULL + →Read l2 + →Arrange (empty key) (#0{name}) (#1{return_type_id}) + →Stream l1 →Arrange (#0{id}) →Fused with Child Map/Filter/Project Project: #1, #2 →Arranged mz_catalog.mz_types Key: (#2{schema_id}) - →Arranged mz_catalog.mz_roles - -Source mz_catalog.mz_functions - project=(#1..=#3, #6, #8) - filter=((#6{return_type_id}) IS NOT NULL) + →Arrange (empty key) + →Differential Join %1[#0] » %0:mz_roles[#0{id}] + →Arranged mz_catalog.mz_roles + →Arrange (#0) + →Constant (1 row) Used Indexes: - - mz_catalog.mz_roles_ind (delta join lookup) - - mz_catalog.mz_databases_ind (lookup) + - mz_internal.mz_builtin_object_mappings_ind (*** full scan ***) + - mz_catalog.mz_roles_ind (lookup) - mz_catalog.mz_schemas_ind (*** full scan ***) - mz_catalog.mz_types_ind (*** full scan ***) diff --git a/test/sqllogictest/information_schema_tables.slt b/test/sqllogictest/information_schema_tables.slt index 948a1805b4a1a..8b14e1deb2fe6 100644 --- a/test/sqllogictest/information_schema_tables.slt +++ b/test/sqllogictest/information_schema_tables.slt @@ -146,7 +146,7 @@ BASE TABLE materialize mz_catalog mz_functions -BASE TABLE +VIEW materialize mz_catalog mz_iceberg_sinks @@ -190,7 +190,7 @@ VIEW materialize mz_catalog mz_operators -BASE TABLE +VIEW materialize mz_catalog mz_pseudo_types @@ -274,7 +274,7 @@ VIEW materialize mz_internal mz_aggregates -BASE TABLE +VIEW materialize mz_internal mz_aws_connections @@ -293,6 +293,10 @@ mz_builtin_columns VIEW materialize mz_internal +mz_builtin_functions +VIEW +materialize +mz_internal mz_builtin_index_columns VIEW materialize @@ -313,6 +317,10 @@ mz_builtin_object_mappings VIEW materialize mz_internal +mz_builtin_operators +VIEW +materialize +mz_internal mz_builtin_sources VIEW materialize diff --git a/test/sqllogictest/mz_catalog_server_index_accounting.slt b/test/sqllogictest/mz_catalog_server_index_accounting.slt index 02f57d5a75b87..c301b75e35e87 100644 --- a/test/sqllogictest/mz_catalog_server_index_accounting.slt +++ b/test/sqllogictest/mz_catalog_server_index_accounting.slt @@ -37,112 +37,112 @@ mz_arrangement_heap_capacity_raw_s2_primary_idx CREATE␠INDEX␠"mz_arrangemen mz_arrangement_heap_size_raw_s2_primary_idx CREATE␠INDEX␠"mz_arrangement_heap_size_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_arrangement_heap_size_raw"␠("operator_id",␠"worker_id") mz_arrangement_records_raw_s2_primary_idx CREATE␠INDEX␠"mz_arrangement_records_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_arrangement_records_raw"␠("operator_id",␠"worker_id") mz_arrangement_sharing_raw_s2_primary_idx CREATE␠INDEX␠"mz_arrangement_sharing_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_arrangement_sharing_raw"␠("operator_id",␠"worker_id") -mz_builtin_object_mappings_ind CREATE␠INDEX␠"mz_builtin_object_mappings_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s460␠AS␠"mz_internal"."mz_builtin_object_mappings"]␠("schema_name",␠"name") -mz_catalog_item_metadata_ind CREATE␠INDEX␠"mz_catalog_item_metadata_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s458␠AS␠"mz_internal"."mz_catalog_item_metadata"]␠("id") -mz_cluster_auto_scaling_strategies_ind CREATE␠INDEX␠"mz_cluster_auto_scaling_strategies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s535␠AS␠"mz_internal"."mz_cluster_auto_scaling_strategies"]␠("cluster_id") -mz_cluster_deployment_lineage_ind CREATE␠INDEX␠"mz_cluster_deployment_lineage_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s788␠AS␠"mz_internal"."mz_cluster_deployment_lineage"]␠("cluster_id") +mz_builtin_object_mappings_ind CREATE␠INDEX␠"mz_builtin_object_mappings_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s462␠AS␠"mz_internal"."mz_builtin_object_mappings"]␠("schema_name",␠"name") +mz_catalog_item_metadata_ind CREATE␠INDEX␠"mz_catalog_item_metadata_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s460␠AS␠"mz_internal"."mz_catalog_item_metadata"]␠("id") +mz_cluster_auto_scaling_strategies_ind CREATE␠INDEX␠"mz_cluster_auto_scaling_strategies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s537␠AS␠"mz_internal"."mz_cluster_auto_scaling_strategies"]␠("cluster_id") +mz_cluster_deployment_lineage_ind CREATE␠INDEX␠"mz_cluster_deployment_lineage_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s790␠AS␠"mz_internal"."mz_cluster_deployment_lineage"]␠("cluster_id") mz_cluster_prometheus_metrics_s2_primary_idx CREATE␠INDEX␠"mz_cluster_prometheus_metrics_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_cluster_prometheus_metrics"␠("process_id",␠"metric_name",␠"labels") -mz_cluster_reconfigurations_ind CREATE␠INDEX␠"mz_cluster_reconfigurations_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s534␠AS␠"mz_internal"."mz_cluster_reconfigurations"]␠("cluster_id") -mz_cluster_replica_frontiers_ind CREATE␠INDEX␠"mz_cluster_replica_frontiers_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s781␠AS␠"mz_catalog"."mz_cluster_replica_frontiers"]␠("object_id") -mz_cluster_replica_history_ind CREATE␠INDEX␠"mz_cluster_replica_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s636␠AS␠"mz_internal"."mz_cluster_replica_history"]␠("dropped_at") -mz_cluster_replica_metrics_history_ind CREATE␠INDEX␠"mz_cluster_replica_metrics_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s540␠AS␠"mz_internal"."mz_cluster_replica_metrics_history"]␠("replica_id") -mz_cluster_replica_metrics_ind CREATE␠INDEX␠"mz_cluster_replica_metrics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s541␠AS␠"mz_internal"."mz_cluster_replica_metrics"]␠("replica_id") -mz_cluster_replica_name_history_ind CREATE␠INDEX␠"mz_cluster_replica_name_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s637␠AS␠"mz_internal"."mz_cluster_replica_name_history"]␠("id") +mz_cluster_reconfigurations_ind CREATE␠INDEX␠"mz_cluster_reconfigurations_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s536␠AS␠"mz_internal"."mz_cluster_reconfigurations"]␠("cluster_id") +mz_cluster_replica_frontiers_ind CREATE␠INDEX␠"mz_cluster_replica_frontiers_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s783␠AS␠"mz_catalog"."mz_cluster_replica_frontiers"]␠("object_id") +mz_cluster_replica_history_ind CREATE␠INDEX␠"mz_cluster_replica_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s638␠AS␠"mz_internal"."mz_cluster_replica_history"]␠("dropped_at") +mz_cluster_replica_metrics_history_ind CREATE␠INDEX␠"mz_cluster_replica_metrics_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s542␠AS␠"mz_internal"."mz_cluster_replica_metrics_history"]␠("replica_id") +mz_cluster_replica_metrics_ind CREATE␠INDEX␠"mz_cluster_replica_metrics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s543␠AS␠"mz_internal"."mz_cluster_replica_metrics"]␠("replica_id") +mz_cluster_replica_name_history_ind CREATE␠INDEX␠"mz_cluster_replica_name_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s639␠AS␠"mz_internal"."mz_cluster_replica_name_history"]␠("id") mz_cluster_replica_resource_usage_s2_primary_idx CREATE␠INDEX␠"mz_cluster_replica_resource_usage_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_cluster_replica_resource_usage"␠("process_id",␠"source",␠"metric") -mz_cluster_replica_size_internal_ind CREATE␠INDEX␠"mz_cluster_replica_size_internal_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s530␠AS␠"mz_internal"."mz_cluster_replica_size_internal"]␠("size") -mz_cluster_replica_sizes_ind CREATE␠INDEX␠"mz_cluster_replica_sizes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s529␠AS␠"mz_catalog"."mz_cluster_replica_sizes"]␠("size") -mz_cluster_replica_status_history_ind CREATE␠INDEX␠"mz_cluster_replica_status_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s542␠AS␠"mz_internal"."mz_cluster_replica_status_history"]␠("replica_id") -mz_cluster_replica_statuses_ind CREATE␠INDEX␠"mz_cluster_replica_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s543␠AS␠"mz_internal"."mz_cluster_replica_statuses"]␠("replica_id") -mz_cluster_replicas_ind CREATE␠INDEX␠"mz_cluster_replicas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s539␠AS␠"mz_catalog"."mz_cluster_replicas"]␠("id") -mz_clusters_ind CREATE␠INDEX␠"mz_clusters_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s531␠AS␠"mz_catalog"."mz_clusters"]␠("id") -mz_columns_ind CREATE␠INDEX␠"mz_columns_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s502␠AS␠"mz_catalog"."mz_columns"]␠("name") -mz_comments_ind CREATE␠INDEX␠"mz_comments_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s558␠AS␠"mz_internal"."mz_comments"]␠("id") +mz_cluster_replica_size_internal_ind CREATE␠INDEX␠"mz_cluster_replica_size_internal_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s532␠AS␠"mz_internal"."mz_cluster_replica_size_internal"]␠("size") +mz_cluster_replica_sizes_ind CREATE␠INDEX␠"mz_cluster_replica_sizes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s531␠AS␠"mz_catalog"."mz_cluster_replica_sizes"]␠("size") +mz_cluster_replica_status_history_ind CREATE␠INDEX␠"mz_cluster_replica_status_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s544␠AS␠"mz_internal"."mz_cluster_replica_status_history"]␠("replica_id") +mz_cluster_replica_statuses_ind CREATE␠INDEX␠"mz_cluster_replica_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s545␠AS␠"mz_internal"."mz_cluster_replica_statuses"]␠("replica_id") +mz_cluster_replicas_ind CREATE␠INDEX␠"mz_cluster_replicas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s541␠AS␠"mz_catalog"."mz_cluster_replicas"]␠("id") +mz_clusters_ind CREATE␠INDEX␠"mz_clusters_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s533␠AS␠"mz_catalog"."mz_clusters"]␠("id") +mz_columns_ind CREATE␠INDEX␠"mz_columns_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s504␠AS␠"mz_catalog"."mz_columns"]␠("name") +mz_comments_ind CREATE␠INDEX␠"mz_comments_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s560␠AS␠"mz_internal"."mz_comments"]␠("id") mz_compute_dataflow_global_ids_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_dataflow_global_ids_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_dataflow_global_ids_per_worker"␠("id",␠"worker_id",␠"global_id") -mz_compute_dependencies_ind CREATE␠INDEX␠"mz_compute_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s762␠AS␠"mz_internal"."mz_compute_dependencies"]␠("dependency_id") +mz_compute_dependencies_ind CREATE␠INDEX␠"mz_compute_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s764␠AS␠"mz_internal"."mz_compute_dependencies"]␠("dependency_id") mz_compute_error_counts_raw_s2_primary_idx CREATE␠INDEX␠"mz_compute_error_counts_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_error_counts_raw"␠("export_id",␠"worker_id") mz_compute_exports_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_exports_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_exports_per_worker"␠("export_id",␠"worker_id") mz_compute_frontiers_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_frontiers_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_frontiers_per_worker"␠("export_id",␠"worker_id") -mz_compute_hydration_times_ind CREATE␠INDEX␠"mz_compute_hydration_times_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s772␠AS␠"mz_internal"."mz_compute_hydration_times"]␠("replica_id") +mz_compute_hydration_times_ind CREATE␠INDEX␠"mz_compute_hydration_times_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s774␠AS␠"mz_internal"."mz_compute_hydration_times"]␠("replica_id") mz_compute_hydration_times_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_hydration_times_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_hydration_times_per_worker"␠("export_id",␠"worker_id") mz_compute_import_frontiers_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_import_frontiers_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_import_frontiers_per_worker"␠("export_id",␠"import_id",␠"worker_id") mz_compute_lir_mapping_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_lir_mapping_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_lir_mapping_per_worker"␠("global_id",␠"lir_id",␠"worker_id") mz_compute_operator_durations_histogram_raw_s2_primary_idx CREATE␠INDEX␠"mz_compute_operator_durations_histogram_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_operator_durations_histogram_raw"␠("id",␠"worker_id",␠"duration_ns") mz_compute_operator_hydration_statuses_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_operator_hydration_statuses_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_operator_hydration_statuses_per_worker"␠("export_id",␠"lir_id",␠"worker_id") -mz_connections_ind CREATE␠INDEX␠"mz_connections_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s537␠AS␠"mz_catalog"."mz_connections"]␠("schema_id") -mz_console_cluster_utilization_overview_24h_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_24h_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s768␠AS␠"mz_internal"."mz_console_cluster_utilization_overview_24h"]␠("cluster_id") -mz_console_cluster_utilization_overview_3h_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_3h_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s767␠AS␠"mz_internal"."mz_console_cluster_utilization_overview_3h"]␠("cluster_id") -mz_console_cluster_utilization_overview_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s766␠AS␠"mz_internal"."mz_console_cluster_utilization_overview"]␠("cluster_id") -mz_databases_ind CREATE␠INDEX␠"mz_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s500␠AS␠"mz_catalog"."mz_databases"]␠("name") +mz_connections_ind CREATE␠INDEX␠"mz_connections_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s539␠AS␠"mz_catalog"."mz_connections"]␠("schema_id") +mz_console_cluster_utilization_overview_24h_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_24h_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s770␠AS␠"mz_internal"."mz_console_cluster_utilization_overview_24h"]␠("cluster_id") +mz_console_cluster_utilization_overview_3h_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_3h_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s769␠AS␠"mz_internal"."mz_console_cluster_utilization_overview_3h"]␠("cluster_id") +mz_console_cluster_utilization_overview_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s768␠AS␠"mz_internal"."mz_console_cluster_utilization_overview"]␠("cluster_id") +mz_databases_ind CREATE␠INDEX␠"mz_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s502␠AS␠"mz_catalog"."mz_databases"]␠("name") mz_dataflow_addresses_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_dataflow_addresses_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_dataflow_addresses_per_worker"␠("id",␠"worker_id") mz_dataflow_channels_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_dataflow_channels_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_dataflow_channels_per_worker"␠("id",␠"worker_id") mz_dataflow_operator_reachability_raw_s2_primary_idx CREATE␠INDEX␠"mz_dataflow_operator_reachability_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_dataflow_operator_reachability_raw"␠("id",␠"worker_id",␠"source",␠"port",␠"update_type",␠"time") mz_dataflow_operators_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_dataflow_operators_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_dataflow_operators_per_worker"␠("id",␠"worker_id") -mz_frontiers_ind CREATE␠INDEX␠"mz_frontiers_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s753␠AS␠"mz_internal"."mz_frontiers"]␠("object_id") -mz_hydration_statuses_ind CREATE␠INDEX␠"mz_hydration_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s783␠AS␠"mz_internal"."mz_hydration_statuses"]␠("object_id",␠"replica_id") -mz_indexes_ind CREATE␠INDEX␠"mz_indexes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s503␠AS␠"mz_catalog"."mz_indexes"]␠("id") -mz_kafka_sources_ind CREATE␠INDEX␠"mz_kafka_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s496␠AS␠"mz_catalog"."mz_kafka_sources"]␠("id") -mz_materialized_views_ind CREATE␠INDEX␠"mz_materialized_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s562␠AS␠"mz_catalog"."mz_materialized_views"]␠("id") +mz_frontiers_ind CREATE␠INDEX␠"mz_frontiers_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s755␠AS␠"mz_internal"."mz_frontiers"]␠("object_id") +mz_hydration_statuses_ind CREATE␠INDEX␠"mz_hydration_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s785␠AS␠"mz_internal"."mz_hydration_statuses"]␠("object_id",␠"replica_id") +mz_indexes_ind CREATE␠INDEX␠"mz_indexes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s505␠AS␠"mz_catalog"."mz_indexes"]␠("id") +mz_kafka_sources_ind CREATE␠INDEX␠"mz_kafka_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s498␠AS␠"mz_catalog"."mz_kafka_sources"]␠("id") +mz_materialized_views_ind CREATE␠INDEX␠"mz_materialized_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s564␠AS␠"mz_catalog"."mz_materialized_views"]␠("id") mz_message_batch_counts_received_raw_s2_primary_idx CREATE␠INDEX␠"mz_message_batch_counts_received_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_message_batch_counts_received_raw"␠("channel_id",␠"from_worker_id",␠"to_worker_id") mz_message_batch_counts_sent_raw_s2_primary_idx CREATE␠INDEX␠"mz_message_batch_counts_sent_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_message_batch_counts_sent_raw"␠("channel_id",␠"from_worker_id",␠"to_worker_id") mz_message_counts_received_raw_s2_primary_idx CREATE␠INDEX␠"mz_message_counts_received_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_message_counts_received_raw"␠("channel_id",␠"from_worker_id",␠"to_worker_id") mz_message_counts_sent_raw_s2_primary_idx CREATE␠INDEX␠"mz_message_counts_sent_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_message_counts_sent_raw"␠("channel_id",␠"from_worker_id",␠"to_worker_id") -mz_metric_sinks_ind CREATE␠INDEX␠"mz_metric_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s560␠AS␠"mz_internal"."mz_metric_sinks"]␠("id") -mz_notices_ind CREATE␠INDEX␠"mz_notices_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s862␠AS␠"mz_internal"."mz_notices"]␠("id") -mz_object_arrangement_size_history_object_ind CREATE␠INDEX␠"mz_object_arrangement_size_history_object_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s775␠AS␠"mz_internal"."mz_object_arrangement_size_history"]␠("object_id") -mz_object_arrangement_size_history_ts_ind CREATE␠INDEX␠"mz_object_arrangement_size_history_ts_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s775␠AS␠"mz_internal"."mz_object_arrangement_size_history"]␠("collection_timestamp") -mz_object_arrangement_sizes_ind CREATE␠INDEX␠"mz_object_arrangement_sizes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s773␠AS␠"mz_internal"."mz_object_arrangement_sizes"]␠("replica_id") -mz_object_dependencies_ind CREATE␠INDEX␠"mz_object_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s498␠AS␠"mz_internal"."mz_object_dependencies"]␠("object_id") -mz_object_graph_edges_ind CREATE␠INDEX␠"mz_object_graph_edges_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s764␠AS␠"mz_internal"."mz_object_graph_edges"]␠("object_id") -mz_object_history_ind CREATE␠INDEX␠"mz_object_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s576␠AS␠"mz_internal"."mz_object_history"]␠("id") -mz_object_lifetimes_ind CREATE␠INDEX␠"mz_object_lifetimes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s577␠AS␠"mz_internal"."mz_object_lifetimes"]␠("id") -mz_object_transitive_dependencies_ind CREATE␠INDEX␠"mz_object_transitive_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s593␠AS␠"mz_internal"."mz_object_transitive_dependencies"]␠("object_id") -mz_objects_ind CREATE␠INDEX␠"mz_objects_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s573␠AS␠"mz_catalog"."mz_objects"]␠("schema_id") +mz_metric_sinks_ind CREATE␠INDEX␠"mz_metric_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s562␠AS␠"mz_internal"."mz_metric_sinks"]␠("id") +mz_notices_ind CREATE␠INDEX␠"mz_notices_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s864␠AS␠"mz_internal"."mz_notices"]␠("id") +mz_object_arrangement_size_history_object_ind CREATE␠INDEX␠"mz_object_arrangement_size_history_object_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s777␠AS␠"mz_internal"."mz_object_arrangement_size_history"]␠("object_id") +mz_object_arrangement_size_history_ts_ind CREATE␠INDEX␠"mz_object_arrangement_size_history_ts_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s777␠AS␠"mz_internal"."mz_object_arrangement_size_history"]␠("collection_timestamp") +mz_object_arrangement_sizes_ind CREATE␠INDEX␠"mz_object_arrangement_sizes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s775␠AS␠"mz_internal"."mz_object_arrangement_sizes"]␠("replica_id") +mz_object_dependencies_ind CREATE␠INDEX␠"mz_object_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s500␠AS␠"mz_internal"."mz_object_dependencies"]␠("object_id") +mz_object_graph_edges_ind CREATE␠INDEX␠"mz_object_graph_edges_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s766␠AS␠"mz_internal"."mz_object_graph_edges"]␠("object_id") +mz_object_history_ind CREATE␠INDEX␠"mz_object_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s578␠AS␠"mz_internal"."mz_object_history"]␠("id") +mz_object_lifetimes_ind CREATE␠INDEX␠"mz_object_lifetimes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s579␠AS␠"mz_internal"."mz_object_lifetimes"]␠("id") +mz_object_transitive_dependencies_ind CREATE␠INDEX␠"mz_object_transitive_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s595␠AS␠"mz_internal"."mz_object_transitive_dependencies"]␠("object_id") +mz_objects_ind CREATE␠INDEX␠"mz_objects_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s575␠AS␠"mz_catalog"."mz_objects"]␠("schema_id") mz_peek_durations_histogram_raw_s2_primary_idx CREATE␠INDEX␠"mz_peek_durations_histogram_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_peek_durations_histogram_raw"␠("worker_id",␠"type",␠"duration_ns") -mz_recent_activity_log_thinned_ind CREATE␠INDEX␠"mz_recent_activity_log_thinned_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s737␠AS␠"mz_internal"."mz_recent_activity_log_thinned"]␠("sql_hash") -mz_recent_sql_text_ind CREATE␠INDEX␠"mz_recent_sql_text_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s733␠AS␠"mz_internal"."mz_recent_sql_text"]␠("sql_hash") -mz_recent_storage_usage_ind CREATE␠INDEX␠"mz_recent_storage_usage_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s853␠AS␠"mz_catalog"."mz_recent_storage_usage"]␠("object_id") -mz_roles_ind CREATE␠INDEX␠"mz_roles_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s521␠AS␠"mz_catalog"."mz_roles"]␠("id") +mz_recent_activity_log_thinned_ind CREATE␠INDEX␠"mz_recent_activity_log_thinned_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s739␠AS␠"mz_internal"."mz_recent_activity_log_thinned"]␠("sql_hash") +mz_recent_sql_text_ind CREATE␠INDEX␠"mz_recent_sql_text_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s735␠AS␠"mz_internal"."mz_recent_sql_text"]␠("sql_hash") +mz_recent_storage_usage_ind CREATE␠INDEX␠"mz_recent_storage_usage_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s855␠AS␠"mz_catalog"."mz_recent_storage_usage"]␠("object_id") +mz_roles_ind CREATE␠INDEX␠"mz_roles_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s523␠AS␠"mz_catalog"."mz_roles"]␠("id") mz_scheduling_elapsed_raw_s2_primary_idx CREATE␠INDEX␠"mz_scheduling_elapsed_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_scheduling_elapsed_raw"␠("id",␠"worker_id") mz_scheduling_parks_histogram_raw_s2_primary_idx CREATE␠INDEX␠"mz_scheduling_parks_histogram_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_scheduling_parks_histogram_raw"␠("worker_id",␠"slept_for_ns",␠"requested_ns") -mz_schemas_ind CREATE␠INDEX␠"mz_schemas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s501␠AS␠"mz_catalog"."mz_schemas"]␠("database_id") -mz_secrets_ind CREATE␠INDEX␠"mz_secrets_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s536␠AS␠"mz_catalog"."mz_secrets"]␠("name") -mz_show_all_objects_ind CREATE␠INDEX␠"mz_show_all_objects_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s621␠AS␠"mz_internal"."mz_show_all_objects"]␠("schema_id") -mz_show_cluster_replicas_ind CREATE␠INDEX␠"mz_show_cluster_replicas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s785␠AS␠"mz_internal"."mz_show_cluster_replicas"]␠("cluster") -mz_show_clusters_ind CREATE␠INDEX␠"mz_show_clusters_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s623␠AS␠"mz_internal"."mz_show_clusters"]␠("name") -mz_show_columns_ind CREATE␠INDEX␠"mz_show_columns_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s622␠AS␠"mz_internal"."mz_show_columns"]␠("id") -mz_show_connections_ind CREATE␠INDEX␠"mz_show_connections_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s631␠AS␠"mz_internal"."mz_show_connections"]␠("schema_id") -mz_show_databases_ind CREATE␠INDEX␠"mz_show_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s625␠AS␠"mz_internal"."mz_show_databases"]␠("name") -mz_show_indexes_ind CREATE␠INDEX␠"mz_show_indexes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s635␠AS␠"mz_internal"."mz_show_indexes"]␠("schema_id") -mz_show_materialized_views_ind CREATE␠INDEX␠"mz_show_materialized_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s634␠AS␠"mz_internal"."mz_show_materialized_views"]␠("schema_id") -mz_show_roles_ind CREATE␠INDEX␠"mz_show_roles_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s630␠AS␠"mz_internal"."mz_show_roles"]␠("name") -mz_show_schemas_ind CREATE␠INDEX␠"mz_show_schemas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s626␠AS␠"mz_internal"."mz_show_schemas"]␠("database_id") -mz_show_secrets_ind CREATE␠INDEX␠"mz_show_secrets_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s624␠AS␠"mz_internal"."mz_show_secrets"]␠("schema_id") -mz_show_sinks_ind CREATE␠INDEX␠"mz_show_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s633␠AS␠"mz_internal"."mz_show_sinks"]␠("schema_id") -mz_show_sources_ind CREATE␠INDEX␠"mz_show_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s632␠AS␠"mz_internal"."mz_show_sources"]␠("schema_id") -mz_show_tables_ind CREATE␠INDEX␠"mz_show_tables_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s627␠AS␠"mz_internal"."mz_show_tables"]␠("schema_id") -mz_show_types_ind CREATE␠INDEX␠"mz_show_types_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s629␠AS␠"mz_internal"."mz_show_types"]␠("schema_id") -mz_show_views_ind CREATE␠INDEX␠"mz_show_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s628␠AS␠"mz_internal"."mz_show_views"]␠("schema_id") -mz_sink_statistics_ind CREATE␠INDEX␠"mz_sink_statistics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s750␠AS␠"mz_internal"."mz_sink_statistics"]␠("id",␠"replica_id") -mz_sink_status_history_ind CREATE␠INDEX␠"mz_sink_status_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s722␠AS␠"mz_internal"."mz_sink_status_history"]␠("sink_id") -mz_sink_statuses_ind CREATE␠INDEX␠"mz_sink_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s723␠AS␠"mz_internal"."mz_sink_statuses"]␠("id") -mz_sinks_ind CREATE␠INDEX␠"mz_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s513␠AS␠"mz_catalog"."mz_sinks"]␠("id") -mz_source_statistics_ind CREATE␠INDEX␠"mz_source_statistics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s748␠AS␠"mz_internal"."mz_source_statistics"]␠("id",␠"replica_id") -mz_source_statistics_with_history_ind CREATE␠INDEX␠"mz_source_statistics_with_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s746␠AS␠"mz_internal"."mz_source_statistics_with_history"]␠("id",␠"replica_id") -mz_source_status_history_ind CREATE␠INDEX␠"mz_source_status_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s724␠AS␠"mz_internal"."mz_source_status_history"]␠("source_id") -mz_source_statuses_ind CREATE␠INDEX␠"mz_source_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s741␠AS␠"mz_internal"."mz_source_statuses"]␠("id") -mz_sources_ind CREATE␠INDEX␠"mz_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s506␠AS␠"mz_catalog"."mz_sources"]␠("id") -mz_tables_ind CREATE␠INDEX␠"mz_tables_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s505␠AS␠"mz_catalog"."mz_tables"]␠("schema_id") -mz_types_ind CREATE␠INDEX␠"mz_types_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s515␠AS␠"mz_catalog"."mz_types"]␠("schema_id") -mz_views_ind CREATE␠INDEX␠"mz_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s514␠AS␠"mz_catalog"."mz_views"]␠("schema_id") -mz_wallclock_global_lag_recent_history_ind CREATE␠INDEX␠"mz_wallclock_global_lag_recent_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s757␠AS␠"mz_internal"."mz_wallclock_global_lag_recent_history"]␠("object_id") -mz_webhook_sources_ind CREATE␠INDEX␠"mz_webhook_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s559␠AS␠"mz_internal"."mz_webhook_sources"]␠("id") -pg_attrdef_all_databases_ind CREATE␠INDEX␠"pg_attrdef_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s662␠AS␠"mz_internal"."pg_attrdef_all_databases"]␠("oid",␠"adrelid",␠"adnum",␠"adbin",␠"adsrc") -pg_attribute_all_databases_ind CREATE␠INDEX␠"pg_attribute_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s655␠AS␠"mz_internal"."pg_attribute_all_databases"]␠("attrelid") -pg_authid_core_ind CREATE␠INDEX␠"pg_authid_core_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s672␠AS␠"mz_internal"."pg_authid_core"]␠("rolname") -pg_class_all_databases_ind CREATE␠INDEX␠"pg_class_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s643␠AS␠"mz_internal"."pg_class_all_databases"]␠("relname") -pg_description_all_databases_ind CREATE␠INDEX␠"pg_description_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s652␠AS␠"mz_internal"."pg_description_all_databases"]␠("objoid",␠"classoid",␠"objsubid",␠"description",␠"oid_database_name",␠"class_database_name") -pg_namespace_all_databases_ind CREATE␠INDEX␠"pg_namespace_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s640␠AS␠"mz_internal"."pg_namespace_all_databases"]␠("nspname") -pg_type_all_databases_ind CREATE␠INDEX␠"pg_type_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s649␠AS␠"mz_internal"."pg_type_all_databases"]␠("oid") +mz_schemas_ind CREATE␠INDEX␠"mz_schemas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s503␠AS␠"mz_catalog"."mz_schemas"]␠("database_id") +mz_secrets_ind CREATE␠INDEX␠"mz_secrets_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s538␠AS␠"mz_catalog"."mz_secrets"]␠("name") +mz_show_all_objects_ind CREATE␠INDEX␠"mz_show_all_objects_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s623␠AS␠"mz_internal"."mz_show_all_objects"]␠("schema_id") +mz_show_cluster_replicas_ind CREATE␠INDEX␠"mz_show_cluster_replicas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s787␠AS␠"mz_internal"."mz_show_cluster_replicas"]␠("cluster") +mz_show_clusters_ind CREATE␠INDEX␠"mz_show_clusters_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s625␠AS␠"mz_internal"."mz_show_clusters"]␠("name") +mz_show_columns_ind CREATE␠INDEX␠"mz_show_columns_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s624␠AS␠"mz_internal"."mz_show_columns"]␠("id") +mz_show_connections_ind CREATE␠INDEX␠"mz_show_connections_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s633␠AS␠"mz_internal"."mz_show_connections"]␠("schema_id") +mz_show_databases_ind CREATE␠INDEX␠"mz_show_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s627␠AS␠"mz_internal"."mz_show_databases"]␠("name") +mz_show_indexes_ind CREATE␠INDEX␠"mz_show_indexes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s637␠AS␠"mz_internal"."mz_show_indexes"]␠("schema_id") +mz_show_materialized_views_ind CREATE␠INDEX␠"mz_show_materialized_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s636␠AS␠"mz_internal"."mz_show_materialized_views"]␠("schema_id") +mz_show_roles_ind CREATE␠INDEX␠"mz_show_roles_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s632␠AS␠"mz_internal"."mz_show_roles"]␠("name") +mz_show_schemas_ind CREATE␠INDEX␠"mz_show_schemas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s628␠AS␠"mz_internal"."mz_show_schemas"]␠("database_id") +mz_show_secrets_ind CREATE␠INDEX␠"mz_show_secrets_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s626␠AS␠"mz_internal"."mz_show_secrets"]␠("schema_id") +mz_show_sinks_ind CREATE␠INDEX␠"mz_show_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s635␠AS␠"mz_internal"."mz_show_sinks"]␠("schema_id") +mz_show_sources_ind CREATE␠INDEX␠"mz_show_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s634␠AS␠"mz_internal"."mz_show_sources"]␠("schema_id") +mz_show_tables_ind CREATE␠INDEX␠"mz_show_tables_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s629␠AS␠"mz_internal"."mz_show_tables"]␠("schema_id") +mz_show_types_ind CREATE␠INDEX␠"mz_show_types_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s631␠AS␠"mz_internal"."mz_show_types"]␠("schema_id") +mz_show_views_ind CREATE␠INDEX␠"mz_show_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s630␠AS␠"mz_internal"."mz_show_views"]␠("schema_id") +mz_sink_statistics_ind CREATE␠INDEX␠"mz_sink_statistics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s752␠AS␠"mz_internal"."mz_sink_statistics"]␠("id",␠"replica_id") +mz_sink_status_history_ind CREATE␠INDEX␠"mz_sink_status_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s724␠AS␠"mz_internal"."mz_sink_status_history"]␠("sink_id") +mz_sink_statuses_ind CREATE␠INDEX␠"mz_sink_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s725␠AS␠"mz_internal"."mz_sink_statuses"]␠("id") +mz_sinks_ind CREATE␠INDEX␠"mz_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s515␠AS␠"mz_catalog"."mz_sinks"]␠("id") +mz_source_statistics_ind CREATE␠INDEX␠"mz_source_statistics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s750␠AS␠"mz_internal"."mz_source_statistics"]␠("id",␠"replica_id") +mz_source_statistics_with_history_ind CREATE␠INDEX␠"mz_source_statistics_with_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s748␠AS␠"mz_internal"."mz_source_statistics_with_history"]␠("id",␠"replica_id") +mz_source_status_history_ind CREATE␠INDEX␠"mz_source_status_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s726␠AS␠"mz_internal"."mz_source_status_history"]␠("source_id") +mz_source_statuses_ind CREATE␠INDEX␠"mz_source_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s743␠AS␠"mz_internal"."mz_source_statuses"]␠("id") +mz_sources_ind CREATE␠INDEX␠"mz_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s508␠AS␠"mz_catalog"."mz_sources"]␠("id") +mz_tables_ind CREATE␠INDEX␠"mz_tables_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s507␠AS␠"mz_catalog"."mz_tables"]␠("schema_id") +mz_types_ind CREATE␠INDEX␠"mz_types_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s517␠AS␠"mz_catalog"."mz_types"]␠("schema_id") +mz_views_ind CREATE␠INDEX␠"mz_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s516␠AS␠"mz_catalog"."mz_views"]␠("schema_id") +mz_wallclock_global_lag_recent_history_ind CREATE␠INDEX␠"mz_wallclock_global_lag_recent_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s759␠AS␠"mz_internal"."mz_wallclock_global_lag_recent_history"]␠("object_id") +mz_webhook_sources_ind CREATE␠INDEX␠"mz_webhook_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s561␠AS␠"mz_internal"."mz_webhook_sources"]␠("id") +pg_attrdef_all_databases_ind CREATE␠INDEX␠"pg_attrdef_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s664␠AS␠"mz_internal"."pg_attrdef_all_databases"]␠("oid",␠"adrelid",␠"adnum",␠"adbin",␠"adsrc") +pg_attribute_all_databases_ind CREATE␠INDEX␠"pg_attribute_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s657␠AS␠"mz_internal"."pg_attribute_all_databases"]␠("attrelid") +pg_authid_core_ind CREATE␠INDEX␠"pg_authid_core_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s674␠AS␠"mz_internal"."pg_authid_core"]␠("rolname") +pg_class_all_databases_ind CREATE␠INDEX␠"pg_class_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s645␠AS␠"mz_internal"."pg_class_all_databases"]␠("relname") +pg_description_all_databases_ind CREATE␠INDEX␠"pg_description_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s654␠AS␠"mz_internal"."pg_description_all_databases"]␠("objoid",␠"classoid",␠"objsubid",␠"description",␠"oid_database_name",␠"class_database_name") +pg_namespace_all_databases_ind CREATE␠INDEX␠"pg_namespace_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s642␠AS␠"mz_internal"."pg_namespace_all_databases"]␠("nspname") +pg_type_all_databases_ind CREATE␠INDEX␠"pg_type_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s651␠AS␠"mz_internal"."pg_type_all_databases"]␠("oid") # Record all transitive dependencies (tables, sources, views, mvs) of indexes on # the mz_catalog_server cluster. @@ -231,6 +231,14 @@ mz_builtin_columns schema_name mz_builtin_columns type mz_builtin_columns type_mod mz_builtin_columns type_oid +mz_builtin_functions argument_type_names +mz_builtin_functions kind +mz_builtin_functions name +mz_builtin_functions oid +mz_builtin_functions return_type_name +mz_builtin_functions returns_set +mz_builtin_functions schema_name +mz_builtin_functions variadic_argument_type_name mz_builtin_index_columns index_position mz_builtin_index_columns name mz_builtin_index_columns nullable diff --git a/test/sqllogictest/oid.slt b/test/sqllogictest/oid.slt index cf5a64237feac..2d4f3e381d74f 100644 --- a/test/sqllogictest/oid.slt +++ b/test/sqllogictest/oid.slt @@ -1278,3 +1278,5 @@ SELECT oid, name FROM mz_objects WHERE id LIKE 's%' AND oid < 20000 ORDER BY oid 17150 mz_builtin_object_mappings 17151 mz_builtin_object_mappings_ind 17152 mz_builtin_types +17153 mz_builtin_functions +17154 mz_builtin_operators