From 8488959f59b8bd1bab448092257d79c91029a772 Mon Sep 17 00:00:00 2001 From: Jan Teske Date: Tue, 31 Mar 2026 12:42:21 +0200 Subject: [PATCH 1/3] catalog: builtin view exposing builtin materialized views This commit adds the first constant builtin view exposing builtin objects to the catalog. Specifically, `mz_builtin_materialized_views` reports what builtin materialized views exist. It is required to define `mz_materialized_views` as a view over the catalog, since the catalog does not contain builtin objects. Further builtin views exposing other builtin object types will be added as needed to support converting more builtin tables. --- .../reference/system-catalog/mz_internal.md | 1 + src/catalog/src/builtin.rs | 25 ++++- src/catalog/src/builtin/builtin.rs | 106 ++++++++++++++++++ src/pgrepr-consts/src/oid.rs | 1 + .../autogenerated/mz_internal.slt | 1 + test/sqllogictest/oid.slt | 1 + 6 files changed, 130 insertions(+), 5 deletions(-) create mode 100644 src/catalog/src/builtin/builtin.rs diff --git a/doc/user/content/reference/system-catalog/mz_internal.md b/doc/user/content/reference/system-catalog/mz_internal.md index a5f6a07688ff2..f2c38b08f80d6 100644 --- a/doc/user/content/reference/system-catalog/mz_internal.md +++ b/doc/user/content/reference/system-catalog/mz_internal.md @@ -1386,6 +1386,7 @@ The `mz_webhook_sources` table contains a row for each webhook source in the sys [`timestamp with time zone`]: /sql/types/timestamp + diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index 4b7e770788405..621c11d5b03d2 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -22,6 +22,7 @@ //! More information about builtin system tables and types can be found in //! . +mod builtin; pub mod notice; use std::collections::BTreeMap; @@ -14068,7 +14069,7 @@ pub const MZ_ANALYTICS_CLUSTER: BuiltinCluster = BuiltinCluster { /// List of all builtin objects sorted topologically by dependency. pub static BUILTINS_STATIC: LazyLock>> = LazyLock::new(|| { - let mut builtins = vec![ + let mut builtin_types = vec![ Builtin::Type(&TYPE_ANY), Builtin::Type(&TYPE_ANYARRAY), Builtin::Type(&TYPE_ANYELEMENT), @@ -14160,6 +14161,8 @@ pub static BUILTINS_STATIC: LazyLock>> = LazyLock::ne Builtin::Type(&TYPE_ACL_ITEM_ARRAY), Builtin::Type(&TYPE_INTERNAL), ]; + + let mut builtin_funcs = Vec::new(); for (schema, funcs) in &[ (PG_CATALOG_SCHEMA, &*mz_sql::func::PG_CATALOG_BUILTINS), ( @@ -14171,14 +14174,15 @@ pub static BUILTINS_STATIC: LazyLock>> = LazyLock::ne (MZ_UNSAFE_SCHEMA, &*mz_sql::func::MZ_UNSAFE_BUILTINS), ] { for (name, func) in funcs.iter() { - builtins.push(Builtin::Func(BuiltinFunc { + builtin_funcs.push(Builtin::Func(BuiltinFunc { name, schema, inner: func, })); } } - builtins.append(&mut vec![ + + let mut builtin_items = vec![ Builtin::Source(&MZ_CATALOG_RAW), Builtin::Log(&MZ_ARRANGEMENT_SHARING_RAW), Builtin::Log(&MZ_ARRANGEMENT_BATCHES_RAW), @@ -14555,9 +14559,20 @@ pub static BUILTINS_STATIC: LazyLock>> = LazyLock::ne Builtin::View(&MZ_INDEX_ADVICE), Builtin::View(&MZ_MCP_DATA_PRODUCTS), Builtin::View(&MZ_MCP_DATA_PRODUCT_DETAILS), - ]); + ]; + + builtin_items.extend(notice::builtins()); + + // 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(); - builtins.extend(notice::builtins()); + // Construct the full list of builtins, retaining dependency order. + let mut builtins = Vec::new(); + builtins.append(&mut builtin_types); + builtins.append(&mut builtin_funcs); + builtins.append(&mut builtin_builtins); + builtins.append(&mut builtin_items); builtins }); diff --git a/src/catalog/src/builtin/builtin.rs b/src/catalog/src/builtin/builtin.rs new file mode 100644 index 0000000000000..c3050a9f30511 --- /dev/null +++ b/src/catalog/src/builtin/builtin.rs @@ -0,0 +1,106 @@ +// Copyright Materialize, Inc. and contributors. All rights reserved. +// +// Use of this software is governed by the Business Source License +// included in the LICENSE file. +// +// 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. + +//! Constant builtin views exposing information about builtin objects. + +use itertools::Itertools; +use mz_ore::collections::CollectionExt; +use mz_pgrepr::oid; +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; + +use crate::builtin::{Builtin, BuiltinMaterializedView, BuiltinView, PUBLIC_SELECT}; + +/// Generate builtin views reporting the given builtins. +/// +/// Used in the [`super::BUILTINS_STATIC`] initializer. +pub(super) fn builtins( + builtin_items: &[Builtin], +) -> impl Iterator> { + let mv_iter = builtin_items.iter().filter_map(|b| match b { + Builtin::MaterializedView(x) => Some(*x), + _ => None, + }); + let materialized_views = make_builtin_materialized_views(mv_iter); + + [materialized_views].into_iter().map(|v| { + let static_ref = Box::leak(Box::new(v)); + Builtin::View(static_ref) + }) +} + +fn make_builtin_materialized_views<'a>( + iter: impl Iterator, +) -> BuiltinView { + let values = iter + .map(|mv| { + let stmt = mz_sql::parse::parse(&mv.create_sql()) + .expect("valid sql") + .into_element() + .ast; + let Statement::CreateMaterializedView(stmt) = stmt else { + panic!("invalid builtin MV SQL"); + }; + + let definition = format!("{};", stmt.query.to_ast_string_stable()); + let definition = escaped_string_literal(&definition); + let create_sql = stmt.to_ast_string_stable(); + let create_sql = escaped_string_literal(&create_sql); + + let cluster_name = stmt.in_cluster.expect("builtin MV has cluster"); + + let mut privs = mv.access.iter().map(|acl| { + let mode = acl.acl_mode.explode().join(","); + format!( + "mz_internal.make_mz_aclitem('{}', '{}', '{}')", + acl.grantee, acl.grantor, mode + ) + }); + let priv_array = format!("ARRAY[{}]", privs.join(",")); + + format!( + "({}::oid, '{}', '{}', '{}', {}, {}, {})", + mv.oid, mv.schema, mv.name, cluster_name, definition, priv_array, create_sql + ) + }) + .join(","); + let sql = format!( + " +SELECT oid, schema_name, name, cluster_name, definition, privileges, create_sql +FROM (VALUES {values}) AS v(oid, schema_name, name, cluster_name, definition, privileges, create_sql)" + ); + + BuiltinView { + name: "mz_builtin_materialized_views", + schema: MZ_INTERNAL_SCHEMA, + oid: oid::VIEW_MZ_BUILTIN_MATERIALIZED_VIEWS_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("cluster_name", SqlScalarType::String.nullable(false)) + .with_column("definition", SqlScalarType::String.nullable(false)) + .with_column( + "privileges", + SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), + ) + .with_column("create_sql", SqlScalarType::String.nullable(false)) + .with_key(vec![0]) + .with_key(vec![2]) + .with_key(vec![4]) + .with_key(vec![6]) + .finish(), + column_comments: Default::default(), + sql: Box::leak(sql.into_boxed_str()), + access: vec![PUBLIC_SELECT], + } +} diff --git a/src/pgrepr-consts/src/oid.rs b/src/pgrepr-consts/src/oid.rs index 3702d82c4ff92..162f70a1e555b 100644 --- a/src/pgrepr-consts/src/oid.rs +++ b/src/pgrepr-consts/src/oid.rs @@ -789,3 +789,4 @@ pub const LOG_MZ_CLUSTER_PROMETHEUS_METRICS_OID: u32 = 17068; pub const FUNC_PARSE_CATALOG_ID_OID: u32 = 17069; pub const FUNC_PARSE_CATALOG_PRIVILEGES_OID: u32 = 17070; pub const VIEW_MZ_MCP_DATA_PRODUCT_DETAILS_OID: u32 = 17071; +pub const VIEW_MZ_BUILTIN_MATERIALIZED_VIEWS_OID: u32 = 17072; diff --git a/test/sqllogictest/autogenerated/mz_internal.slt b/test/sqllogictest/autogenerated/mz_internal.slt index b2e55b22bbaad..f3d1a2e7bfb50 100644 --- a/test/sqllogictest/autogenerated/mz_internal.slt +++ b/test/sqllogictest/autogenerated/mz_internal.slt @@ -740,6 +740,7 @@ mz_aggregates mz_aws_connections mz_aws_privatelink_connection_status_history mz_aws_privatelink_connection_statuses +mz_builtin_materialized_views mz_catalog_raw mz_cluster_deployment_lineage mz_cluster_replica_history diff --git a/test/sqllogictest/oid.slt b/test/sqllogictest/oid.slt index f5bded4ddf950..4e5fb02f9bbb8 100644 --- a/test/sqllogictest/oid.slt +++ b/test/sqllogictest/oid.slt @@ -1179,3 +1179,4 @@ SELECT oid, name FROM mz_objects WHERE id LIKE 's%' AND oid < 20000 ORDER BY oid 17069 parse_catalog_id 17070 parse_catalog_privileges 17071 mz_mcp_data_product_details +17072 mz_builtin_materialized_views From 18bd36d5efd7c96c5b794d4635f824a78f6284fd Mon Sep 17 00:00:00 2001 From: Jan Teske Date: Tue, 31 Mar 2026 14:50:39 +0200 Subject: [PATCH 2/3] sql,expr: add sqlfuncs to support mz_materialized_views conversion This commit adds two new internal sqlfuncs to support converting `mz_materialzied_views` into a view over the catalog. * `parse_catalog_create_sql` parses a create_sql string and returns information extracted from it as JSON * `redact_sql` redacts a given SQL statement --- src/expr/src/scalar.proto | 1 + src/expr/src/scalar.rs | 4 ++ src/expr/src/scalar/func.rs | 14 +++++- src/expr/src/scalar/func/impls/jsonb.rs | 64 +++++++++++++++++++++++++ src/expr/src/scalar/func/unary.rs | 3 ++ src/pgrepr-consts/src/oid.rs | 2 + src/sql/src/func.rs | 26 ++++++---- src/storage-types/src/errors.rs | 3 ++ test/sqllogictest/oid.slt | 2 + 9 files changed, 109 insertions(+), 10 deletions(-) diff --git a/src/expr/src/scalar.proto b/src/expr/src/scalar.proto index 62fe4f0a273bf..4ef985f02c34f 100644 --- a/src/expr/src/scalar.proto +++ b/src/expr/src/scalar.proto @@ -163,5 +163,6 @@ message ProtoEvalError { google.protobuf.Empty neg_limit = 79; google.protobuf.Empty key_cannot_be_null = 80; string invalid_catalog_json = 81; + string redact_error = 82; } } diff --git a/src/expr/src/scalar.rs b/src/expr/src/scalar.rs index 077e8a6da1102..d3b69d6e764aa 100644 --- a/src/expr/src/scalar.rs +++ b/src/expr/src/scalar.rs @@ -2721,6 +2721,7 @@ pub enum EvalError { AclArrayNullElement, MzAclArrayNullElement, PrettyError(Box), + RedactError(Box), } impl fmt::Display for EvalError { @@ -2830,6 +2831,7 @@ impl fmt::Display for EvalError { } EvalError::Parse(e) => e.fmt(f), EvalError::PrettyError(e) => e.fmt(f), + EvalError::RedactError(e) => e.fmt(f), EvalError::ParseHex(e) => e.fmt(f), EvalError::Internal(s) => write!(f, "internal error: {}", s), EvalError::InfinityOutOfDomain(s) => { @@ -3133,6 +3135,7 @@ impl RustType for EvalError { EvalError::UnterminatedLikeEscapeSequence => UnterminatedLikeEscapeSequence(()), EvalError::Parse(error) => Parse(error.into_proto()), EvalError::PrettyError(error) => PrettyError(error.into_proto()), + EvalError::RedactError(error) => RedactError(error.into_proto()), EvalError::ParseHex(error) => ParseHex(error.into_proto()), EvalError::Internal(v) => Internal(v.into_proto()), EvalError::InfinityOutOfDomain(v) => InfinityOutOfDomain(v.into_proto()), @@ -3319,6 +3322,7 @@ impl RustType for EvalError { MzAclArrayNullElement(()) => Ok(EvalError::MzAclArrayNullElement), InvalidIanaTimezoneId(s) => Ok(EvalError::InvalidIanaTimezoneId(s.into())), PrettyError(s) => Ok(EvalError::PrettyError(s.into())), + RedactError(s) => Ok(EvalError::RedactError(s.into())), }, None => Err(TryFromProtoError::missing_field("ProtoEvalError::kind")), } diff --git a/src/expr/src/scalar/func.rs b/src/expr/src/scalar/func.rs index 1ccb94f55e95b..1419b0dbd85b7 100644 --- a/src/expr/src/scalar/func.rs +++ b/src/expr/src/scalar/func.rs @@ -44,7 +44,7 @@ use mz_repr::{ ArrayRustType, Datum, DatumList, DatumMap, ExcludeNull, FromDatum, InputDatumType, Row, RowArena, SqlScalarType, strconv, }; -use mz_sql_parser::ast::display::FormatMode; +use mz_sql_parser::ast::display::{AstDisplay, FormatMode}; use mz_sql_pretty::{PrettyConfig, pretty_str}; use num::traits::CheckedNeg; use sha1::Sha1; @@ -2318,6 +2318,18 @@ fn pretty_sql<'a>(sql: &str, width: i32, temp_storage: &'a RowArena) -> Result<& Ok(pretty) } +#[sqlfunc] +fn redact_sql(sql: &str) -> Result { + let stmts = mz_sql_parser::parser::parse_statements(sql) + .map_err(|e| EvalError::RedactError(e.to_string().into()))?; + match stmts.len() { + 1 => Ok(stmts[0].ast.to_ast_string_redacted()), + n => Err(EvalError::RedactError( + format!("expected a single statement, found {n}").into(), + )), + } +} + #[sqlfunc(propagates_nulls = true)] fn starts_with(a: &str, b: &str) -> bool { a.starts_with(b) diff --git a/src/expr/src/scalar/func/impls/jsonb.rs b/src/expr/src/scalar/func/impls/jsonb.rs index 57f0a5e483656..c08d2313076b0 100644 --- a/src/expr/src/scalar/func/impls/jsonb.rs +++ b/src/expr/src/scalar/func/impls/jsonb.rs @@ -7,6 +7,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. +use std::collections::BTreeMap; use std::fmt; use mz_expr_derive::sqlfunc; @@ -16,7 +17,10 @@ use mz_repr::adt::mz_acl_item::{AclMode, MzAclItem}; use mz_repr::adt::numeric::{self, Numeric, NumericMaxScale}; use mz_repr::role_id::RoleId; use mz_repr::{ArrayRustType, Datum, Row, RowPacker, SqlColumnType, SqlScalarType, strconv}; +use mz_sql_parser::ast::RawClusterName; +use mz_sql_parser::ast::display::AstDisplay; use serde::{Deserialize, Serialize}; +use serde_json::json; use crate::EvalError; use crate::scalar::func::EagerUnaryFunc; @@ -354,3 +358,63 @@ fn parse_catalog_privileges<'a>(a: JsonbRef<'a>) -> Result(a: &'a str) -> Result { + let parse = || -> Result { + let mut stmts = mz_sql_parser::parser::parse_statements(a) + .map_err(|e| format!("failed to parse create_sql: {e}"))?; + let stmt = match stmts.len() { + 1 => stmts.remove(0).ast, + n => return Err(format!("expected a single statement, found {n}")), + }; + + let mut info = BTreeMap::<&str, serde_json::Value>::new(); + + use mz_sql_parser::ast::Statement::*; + let item_type = match stmt { + CreateSecret(_) => "secret", + CreateConnection(_) => "connection", + CreateView(_) => "view", + CreateMaterializedView(stmt) => { + let Some(in_cluster) = stmt.in_cluster else { + return Err("missing IN CLUSTER".into()); + }; + let cluster_id = match in_cluster { + RawClusterName::Unresolved(ident) => ident.into_string(), + RawClusterName::Resolved(s) => s, + }; + info.insert("cluster_id", json!(cluster_id)); + + let mut definition = stmt.query.to_ast_string_stable(); + definition.push(';'); + info.insert("definition", json!(definition)); + + "materialized-view" + } + CreateContinualTask(_) => "continual-task", + CreateTable(_) | CreateTableFromSource(_) => "table", + CreateSource(_) | CreateWebhookSource(_) => "source", + CreateSubsource(_) => "subsource", + CreateSink(_) => "sink", + CreateIndex(_) => "index", + CreateType(_) => "type", + _ => return Err("not a CREATE item statement".into()), + }; + info.insert("type", json!(item_type)); + + let info = info.into_iter().map(|(k, v)| (k.to_string(), v)).collect(); + Ok(info) + }; + + let val = parse().map_err(|e| EvalError::InvalidCatalogJson(e.into()))?; + let jsonb = Jsonb::from_serde_json(val).expect("valid JSONB"); + Ok(jsonb) +} diff --git a/src/expr/src/scalar/func/unary.rs b/src/expr/src/scalar/func/unary.rs index 01dfda0db280b..0e3a8d1d7404c 100644 --- a/src/expr/src/scalar/func/unary.rs +++ b/src/expr/src/scalar/func/unary.rs @@ -17,6 +17,7 @@ use std::{fmt, str}; use mz_repr::{Datum, InputDatumType, OutputDatumType, ReprColumnType, RowArena, SqlColumnType}; +use crate::scalar::func::RedactSql; use crate::scalar::func::impls::*; use crate::{EvalError, MirScalarExpr}; @@ -461,8 +462,10 @@ derive_unary!( JsonbTypeof, JsonbStripNulls, JsonbPretty, + ParseCatalogCreateSql, ParseCatalogId, ParseCatalogPrivileges, + RedactSql, RoundFloat32, RoundFloat64, RoundNumeric, diff --git a/src/pgrepr-consts/src/oid.rs b/src/pgrepr-consts/src/oid.rs index 162f70a1e555b..9a18bec344457 100644 --- a/src/pgrepr-consts/src/oid.rs +++ b/src/pgrepr-consts/src/oid.rs @@ -790,3 +790,5 @@ pub const FUNC_PARSE_CATALOG_ID_OID: u32 = 17069; pub const FUNC_PARSE_CATALOG_PRIVILEGES_OID: u32 = 17070; pub const VIEW_MZ_MCP_DATA_PRODUCT_DETAILS_OID: u32 = 17071; pub const VIEW_MZ_BUILTIN_MATERIALIZED_VIEWS_OID: u32 = 17072; +pub const FUNC_PARSE_CATALOG_CREATE_SQL_OID: u32 = 17073; +pub const FUNC_REDACT_SQL_OID: u32 = 17074; diff --git a/src/sql/src/func.rs b/src/sql/src/func.rs index 7697e6879591b..de61b8811c0de 100644 --- a/src/sql/src/func.rs +++ b/src/sql/src/func.rs @@ -4832,15 +4832,6 @@ pub static MZ_INTERNAL_BUILTINS: LazyLock> = LazyLo params!(String, String, String) => VariadicFunc::from(variadic::MakeMzAclItem) => MzAclItem, oid::FUNC_MAKE_MZ_ACL_ITEM_OID; }, - "parse_catalog_id" => Scalar { - params!(Jsonb) => UnaryFunc::ParseCatalogId(func::ParseCatalogId) - => String, oid::FUNC_PARSE_CATALOG_ID_OID; - }, - "parse_catalog_privileges" => Scalar { - params!(Jsonb) => UnaryFunc::ParseCatalogPrivileges(func::ParseCatalogPrivileges) - => SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)), - oid::FUNC_PARSE_CATALOG_PRIVILEGES_OID; - }, "mz_acl_item_contains_privilege" => Scalar { params!(MzAclItem, String) => BinaryFunc::from(func::MzAclItemContainsPrivilege) @@ -5235,6 +5226,23 @@ pub static MZ_INTERNAL_BUILTINS: LazyLock> = LazyLo params!(String) => UnaryFunc::MzValidateRolePrivilege( func::MzValidateRolePrivilege, ) => Bool, oid::FUNC_MZ_VALIDATE_ROLE_PRIVILEGE_OID; + }, + "parse_catalog_create_sql" => Scalar { + params!(String) => UnaryFunc::ParseCatalogCreateSql(func::ParseCatalogCreateSql) + => Jsonb, oid::FUNC_PARSE_CATALOG_CREATE_SQL_OID; + }, + "parse_catalog_id" => Scalar { + params!(Jsonb) => UnaryFunc::ParseCatalogId(func::ParseCatalogId) + => String, oid::FUNC_PARSE_CATALOG_ID_OID; + }, + "parse_catalog_privileges" => Scalar { + params!(Jsonb) => UnaryFunc::ParseCatalogPrivileges(func::ParseCatalogPrivileges) + => SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)), + oid::FUNC_PARSE_CATALOG_PRIVILEGES_OID; + }, + "redact_sql" => Scalar { + params!(String) => UnaryFunc::RedactSql(func::RedactSql) + => String, oid::FUNC_REDACT_SQL_OID; } } }); diff --git a/src/storage-types/src/errors.rs b/src/storage-types/src/errors.rs index 00fbc7548e07a..2959e53c8be53 100644 --- a/src/storage-types/src/errors.rs +++ b/src/storage-types/src/errors.rs @@ -870,6 +870,9 @@ mod columnation { EvalError::PrettyError(x) => { EvalError::PrettyError(self.string_region.copy(x)) } + EvalError::RedactError(x) => { + EvalError::RedactError(self.string_region.copy(x)) + } }; let reference = self.eval_error_region.copy_iter(once(err)); let boxed = unsafe { Box::from_raw(reference.as_mut_ptr()) }; diff --git a/test/sqllogictest/oid.slt b/test/sqllogictest/oid.slt index 4e5fb02f9bbb8..319b8507359f9 100644 --- a/test/sqllogictest/oid.slt +++ b/test/sqllogictest/oid.slt @@ -1180,3 +1180,5 @@ SELECT oid, name FROM mz_objects WHERE id LIKE 's%' AND oid < 20000 ORDER BY oid 17070 parse_catalog_privileges 17071 mz_mcp_data_product_details 17072 mz_builtin_materialized_views +17073 parse_catalog_create_sql +17074 redact_sql From b37834f961755c02c143b25ce923ccfc8b776e38 Mon Sep 17 00:00:00 2001 From: Jan Teske Date: Tue, 31 Mar 2026 14:26:53 +0200 Subject: [PATCH 3/3] catalog: convert mz_materialized_views into a view over the catalog --- .../src/catalog/builtin_table_updates.rs | 61 +----- .../catalog/open/builtin_schema_migration.rs | 6 + src/catalog/src/builtin.rs | 188 ++++++++++++------ src/pgrepr-consts/src/oid.rs | 2 +- test/0dt/mzcompose.py | 13 -- ...istinct_arrangements_mz_catalog_server.slt | 5 +- .../information_schema_tables.slt | 6 +- .../mz_catalog_server_index_accounting.slt | 153 +++++++------- test/sqlsmith/Dockerfile | 2 +- test/testdrive/catalog.td | 5 +- 10 files changed, 235 insertions(+), 206 deletions(-) diff --git a/src/adapter/src/catalog/builtin_table_updates.rs b/src/adapter/src/catalog/builtin_table_updates.rs index e056cbbab9200..a6ac617bc6628 100644 --- a/src/adapter/src/catalog/builtin_table_updates.rs +++ b/src/adapter/src/catalog/builtin_table_updates.rs @@ -21,13 +21,12 @@ use mz_catalog::builtin::{ MZ_DEFAULT_PRIVILEGES, MZ_EGRESS_IPS, MZ_FUNCTIONS, MZ_HISTORY_RETENTION_STRATEGIES, MZ_ICEBERG_SINKS, MZ_INDEX_COLUMNS, MZ_INDEXES, MZ_KAFKA_CONNECTIONS, MZ_KAFKA_SINKS, MZ_KAFKA_SOURCE_TABLES, MZ_KAFKA_SOURCES, MZ_LICENSE_KEYS, MZ_LIST_TYPES, MZ_MAP_TYPES, - MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES, MZ_MATERIALIZED_VIEWS, MZ_MYSQL_SOURCE_TABLES, - MZ_OBJECT_DEPENDENCIES, MZ_OBJECT_GLOBAL_IDS, MZ_OPERATORS, MZ_POSTGRES_SOURCE_TABLES, - MZ_POSTGRES_SOURCES, MZ_PSEUDO_TYPES, MZ_REPLACEMENTS, MZ_ROLE_AUTH, MZ_ROLE_PARAMETERS, - MZ_ROLES, MZ_SECRETS, MZ_SESSIONS, MZ_SINKS, MZ_SOURCE_REFERENCES, MZ_SOURCES, - MZ_SQL_SERVER_SOURCE_TABLES, MZ_SSH_TUNNEL_CONNECTIONS, MZ_STORAGE_USAGE_BY_SHARD, - MZ_SUBSCRIPTIONS, MZ_SYSTEM_PRIVILEGES, MZ_TABLES, MZ_TYPE_PG_METADATA, MZ_TYPES, MZ_VIEWS, - MZ_WEBHOOKS_SOURCES, + MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES, MZ_MYSQL_SOURCE_TABLES, MZ_OBJECT_DEPENDENCIES, + MZ_OBJECT_GLOBAL_IDS, MZ_OPERATORS, MZ_POSTGRES_SOURCE_TABLES, MZ_POSTGRES_SOURCES, + MZ_PSEUDO_TYPES, MZ_REPLACEMENTS, MZ_ROLE_AUTH, MZ_ROLE_PARAMETERS, MZ_ROLES, MZ_SECRETS, + MZ_SESSIONS, MZ_SINKS, MZ_SOURCE_REFERENCES, MZ_SOURCES, MZ_SQL_SERVER_SOURCE_TABLES, + MZ_SSH_TUNNEL_CONNECTIONS, MZ_STORAGE_USAGE_BY_SHARD, MZ_SUBSCRIPTIONS, MZ_SYSTEM_PRIVILEGES, + MZ_TABLES, MZ_TYPE_PG_METADATA, MZ_TYPES, MZ_VIEWS, MZ_WEBHOOKS_SOURCES, }; use mz_catalog::config::AwsPrincipalContext; use mz_catalog::durable::SourceReferences; @@ -636,9 +635,9 @@ impl CatalogState { CatalogItem::View(view) => { self.pack_view_update(id, oid, schema_id, name, owner_id, privileges, view, diff) } - CatalogItem::MaterializedView(mview) => self.pack_materialized_view_update( - id, oid, schema_id, name, owner_id, privileges, mview, diff, - ), + CatalogItem::MaterializedView(mview) => { + self.pack_materialized_view_update(id, mview, diff) + } CatalogItem::Sink(sink) => { self.pack_sink_update(id, oid, schema_id, name, owner_id, sink, diff) } @@ -1271,53 +1270,11 @@ impl CatalogState { fn pack_materialized_view_update( &self, id: CatalogItemId, - oid: u32, - schema_id: &SchemaSpecifier, - name: &str, - owner_id: &RoleId, - privileges: Datum, mview: &MaterializedView, diff: Diff, ) -> Vec> { - let create_stmt = mz_sql::parse::parse(&mview.create_sql) - .unwrap_or_else(|e| { - panic!( - "create_sql cannot be invalid: `{}` --- error: `{}`", - mview.create_sql, e - ) - }) - .into_element() - .ast; - let query_string = match &create_stmt { - Statement::CreateMaterializedView(stmt) => { - let mut query_string = stmt.query.to_ast_string_stable(); - // PostgreSQL appends a semicolon in `pg_matviews.definition`, we - // do the same for compatibility's sake. - query_string.push(';'); - query_string - } - _ => unreachable!(), - }; - let mut updates = Vec::new(); - updates.push(BuiltinTableUpdate::row( - &*MZ_MATERIALIZED_VIEWS, - Row::pack_slice(&[ - Datum::String(&id.to_string()), - Datum::UInt32(oid), - Datum::String(&schema_id.to_string()), - Datum::String(name), - Datum::String(&mview.cluster_id.to_string()), - Datum::String(&query_string), - Datum::String(&owner_id.to_string()), - privileges, - Datum::String(&mview.create_sql), - Datum::String(&create_stmt.to_ast_string_redacted()), - ]), - diff, - )); - if let Some(refresh_schedule) = &mview.refresh_schedule { // This can't be `ON COMMIT`, because that is represented by a `None` instead of an // empty `RefreshSchedule`. diff --git a/src/adapter/src/catalog/open/builtin_schema_migration.rs b/src/adapter/src/catalog/open/builtin_schema_migration.rs index 6ee52dfdb53d4..cca92c75233d7 100644 --- a/src/adapter/src/catalog/open/builtin_schema_migration.rs +++ b/src/adapter/src/catalog/open/builtin_schema_migration.rs @@ -152,6 +152,12 @@ static MIGRATIONS: LazyLock> = LazyLock::new(|| { MZ_INTERNAL_SCHEMA, "mz_pending_cluster_replicas", ), + MigrationStep::replacement( + "26.19.0-dev.0", + CatalogItemType::MaterializedView, + MZ_CATALOG_SCHEMA, + "mz_materialized_views", + ), ] }); diff --git a/src/catalog/src/builtin.rs b/src/catalog/src/builtin.rs index 621c11d5b03d2..e4c83cf8d22b0 100644 --- a/src/catalog/src/builtin.rs +++ b/src/catalog/src/builtin.rs @@ -2875,66 +2875,132 @@ pub static MZ_VIEWS: LazyLock = LazyLock::new(|| BuiltinTable { is_retained_metrics_object: false, access: vec![PUBLIC_SELECT], }); -pub static MZ_MATERIALIZED_VIEWS: LazyLock = LazyLock::new(|| BuiltinTable { - name: "mz_materialized_views", - schema: MZ_CATALOG_SCHEMA, - oid: oid::TABLE_MZ_MATERIALIZED_VIEWS_OID, - desc: RelationDesc::builder() - .with_column("id", SqlScalarType::String.nullable(false)) - .with_column("oid", SqlScalarType::Oid.nullable(false)) - .with_column("schema_id", SqlScalarType::String.nullable(false)) - .with_column("name", SqlScalarType::String.nullable(false)) - .with_column("cluster_id", SqlScalarType::String.nullable(false)) - .with_column("definition", SqlScalarType::String.nullable(false)) - .with_column("owner_id", SqlScalarType::String.nullable(false)) - .with_column( - "privileges", - SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), - ) - .with_column("create_sql", SqlScalarType::String.nullable(false)) - .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) - .with_key(vec![0]) - .with_key(vec![1]) - .finish(), - column_comments: BTreeMap::from_iter([ - ("id", "Materialize's unique ID for the materialized view."), - ( - "oid", - "A PostgreSQL-compatible OID for the materialized view.", - ), - ( - "schema_id", - "The ID of the schema to which the materialized view belongs. Corresponds to `mz_schemas.id`.", - ), - ("name", "The name of the materialized view."), - ( - "cluster_id", - "The ID of the cluster maintaining the materialized view. Corresponds to `mz_clusters.id`.", - ), - ( - "definition", - "The materialized view definition (a `SELECT` query).", - ), - ( - "owner_id", - "The role ID of the owner of the materialized view. Corresponds to `mz_roles.id`.", - ), - ( - "privileges", - "The privileges belonging to the materialized view.", - ), - ( - "create_sql", - "The `CREATE` SQL statement for the materialized view.", - ), - ( - "redacted_create_sql", - "The redacted `CREATE` SQL statement for the materialized view.", - ), - ]), - is_retained_metrics_object: false, - access: vec![PUBLIC_SELECT], + +pub static MZ_MATERIALIZED_VIEWS: LazyLock = LazyLock::new(|| { + BuiltinMaterializedView { + name: "mz_materialized_views", + schema: MZ_CATALOG_SCHEMA, + oid: oid::MV_MZ_MATERIALIZED_VIEWS_OID, + desc: RelationDesc::builder() + .with_column("id", SqlScalarType::String.nullable(false)) + .with_column("oid", SqlScalarType::Oid.nullable(false)) + .with_column("schema_id", SqlScalarType::String.nullable(false)) + .with_column("name", SqlScalarType::String.nullable(false)) + .with_column("cluster_id", SqlScalarType::String.nullable(false)) + .with_column("definition", SqlScalarType::String.nullable(false)) + .with_column("owner_id", SqlScalarType::String.nullable(false)) + .with_column( + "privileges", + SqlScalarType::Array(Box::new(SqlScalarType::MzAclItem)).nullable(false), + ) + .with_column("create_sql", SqlScalarType::String.nullable(false)) + .with_column("redacted_create_sql", SqlScalarType::String.nullable(false)) + .with_key(vec![0]) + .with_key(vec![1]) + .finish(), + column_comments: BTreeMap::from_iter([ + ("id", "Materialize's unique ID for the materialized view."), + ( + "oid", + "A PostgreSQL-compatible OID for the materialized view.", + ), + ( + "schema_id", + "The ID of the schema to which the materialized view belongs. Corresponds to `mz_schemas.id`.", + ), + ("name", "The name of the materialized view."), + ( + "cluster_id", + "The ID of the cluster maintaining the materialized view. Corresponds to `mz_clusters.id`.", + ), + ( + "definition", + "The materialized view definition (a `SELECT` query).", + ), + ( + "owner_id", + "The role ID of the owner of the materialized view. Corresponds to `mz_roles.id`.", + ), + ( + "privileges", + "The privileges belonging to the materialized view.", + ), + ( + "create_sql", + "The `CREATE` SQL statement for the materialized view.", + ), + ( + "redacted_create_sql", + "The redacted `CREATE` SQL statement for the materialized view.", + ), + ]), + sql: Box::leak(format!(" +IN CLUSTER mz_catalog_server +WITH ( + ASSERT NOT NULL id, + ASSERT NOT NULL oid, + ASSERT NOT NULL schema_id, + ASSERT NOT NULL name, + ASSERT NOT NULL cluster_id, + ASSERT NOT NULL definition, + ASSERT NOT NULL owner_id, + ASSERT NOT NULL privileges, + ASSERT NOT NULL create_sql, + ASSERT NOT NULL redacted_create_sql +) AS +WITH + user_mvs AS ( + SELECT + mz_internal.parse_catalog_id(data->'key'->'gid') AS id, + (data->'value'->>'oid')::oid AS oid, + mz_internal.parse_catalog_id(data->'value'->'schema_id') AS schema_id, + data->'value'->>'name' AS name, + mz_internal.parse_catalog_create_sql(data->'value'->'definition'->'V1'->>'create_sql')->>'cluster_id' AS cluster_id, + mz_internal.parse_catalog_create_sql(data->'value'->'definition'->'V1'->>'create_sql')->>'definition' AS definition, + mz_internal.parse_catalog_id(data->'value'->'owner_id') AS owner_id, + mz_internal.parse_catalog_privileges(data->'value'->'privileges') AS privileges, + data->'value'->'definition'->'V1'->>'create_sql' AS create_sql, + mz_internal.redact_sql(data->'value'->'definition'->'V1'->>'create_sql') AS redacted_create_sql + FROM mz_internal.mz_catalog_raw + WHERE + data->>'kind' = 'Item' AND + mz_internal.parse_catalog_create_sql(data->'value'->'definition'->'V1'->>'create_sql')->>'type' = 'materialized-view' + ), + builtin_mappings AS ( + SELECT + data->'key'->>'schema_name' AS schema_name, + data->'key'->>'object_name' AS name, + 's' || (data->'value'->>'catalog_id') AS id + FROM mz_internal.mz_catalog_raw + WHERE + data->>'kind' = 'GidMapping' AND + data->'key'->>'object_type' = '5' + ), + builtin_mvs AS ( + SELECT + m.id, + mv.oid, + s.id AS schema_id, + mv.name, + c.id AS cluster_id, + mv.definition, + '{MZ_SYSTEM_ROLE_ID}' AS owner_id, + mv.privileges, + mv.create_sql, + mz_internal.redact_sql(mv.create_sql) AS redacted_create_sql + FROM mz_internal.mz_builtin_materialized_views mv + JOIN builtin_mappings m USING (schema_name, name) + JOIN mz_schemas s ON s.name = mv.schema_name + JOIN mz_clusters c ON c.name = mv.cluster_name + WHERE s.database_id IS NULL + ) +SELECT * FROM user_mvs +UNION ALL +SELECT * FROM builtin_mvs").into_boxed_str()), + access: vec![PUBLIC_SELECT], + } }); + pub static MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES: LazyLock = LazyLock::new(|| { BuiltinTable { name: "mz_materialized_view_refresh_strategies", @@ -14235,8 +14301,6 @@ pub static BUILTINS_STATIC: LazyLock>> = LazyLock::ne Builtin::Table(&MZ_KAFKA_SOURCE_TABLES), Builtin::Table(&MZ_SINKS), Builtin::Table(&MZ_VIEWS), - Builtin::Table(&MZ_MATERIALIZED_VIEWS), - Builtin::Table(&MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES), Builtin::Table(&MZ_TYPES), Builtin::Table(&MZ_TYPE_PG_METADATA), Builtin::Table(&MZ_ARRAY_TYPES), @@ -14277,6 +14341,8 @@ pub static BUILTINS_STATIC: LazyLock>> = LazyLock::ne Builtin::Table(&MZ_COMMENTS), Builtin::Table(&MZ_WEBHOOKS_SOURCES), Builtin::Table(&MZ_HISTORY_RETENTION_STRATEGIES), + Builtin::MaterializedView(&MZ_MATERIALIZED_VIEWS), + Builtin::Table(&MZ_MATERIALIZED_VIEW_REFRESH_STRATEGIES), Builtin::Table(&MZ_CONTINUAL_TASKS), Builtin::MaterializedView(&MZ_NETWORK_POLICIES), Builtin::MaterializedView(&MZ_NETWORK_POLICY_RULES), diff --git a/src/pgrepr-consts/src/oid.rs b/src/pgrepr-consts/src/oid.rs index 9a18bec344457..f80b943f98b69 100644 --- a/src/pgrepr-consts/src/oid.rs +++ b/src/pgrepr-consts/src/oid.rs @@ -435,7 +435,7 @@ pub const TABLE_MZ_SSH_TUNNEL_CONNECTIONS_OID: u32 = 16709; pub const TABLE_MZ_SOURCES_OID: u32 = 16710; pub const TABLE_MZ_SINKS_OID: u32 = 16711; pub const TABLE_MZ_VIEWS_OID: u32 = 16712; -pub const TABLE_MZ_MATERIALIZED_VIEWS_OID: u32 = 16713; +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; diff --git a/test/0dt/mzcompose.py b/test/0dt/mzcompose.py index 5a9647ced1df2..ec7a7dc5645d1 100644 --- a/test/0dt/mzcompose.py +++ b/test/0dt/mzcompose.py @@ -1813,19 +1813,6 @@ def get_persist_shard_id(item_id: str, service: str) -> str: ), ): c.up("mz_new") - - new_mz_tables_gid = c.sql_query( - "SELECT id FROM mz_tables WHERE name = 'mz_tables'", - service="mz_new", - )[0][0] - new_mv_gid = c.sql_query( - "SELECT id FROM mz_materialized_views WHERE name = 'mv'", - service="mz_new", - )[0][0] - assert new_mz_tables_gid == mz_tables_gid - assert new_mv_gid == mv_gid - # mz_internal.mz_storage_shards won't update until this instance becomes the leader - c.await_mz_deployment_status(DeploymentStatus.READY_TO_PROMOTE, "mz_new") c.promote_mz("mz_new") c.await_mz_deployment_status(DeploymentStatus.IS_LEADER, "mz_new") diff --git a/test/sqllogictest/distinct_arrangements_mz_catalog_server.slt b/test/sqllogictest/distinct_arrangements_mz_catalog_server.slt index dcc80e99fe289..496e477f1c53c 100644 --- a/test/sqllogictest/distinct_arrangements_mz_catalog_server.slt +++ b/test/sqllogictest/distinct_arrangements_mz_catalog_server.slt @@ -90,6 +90,7 @@ ArrangeBy[[Column(0,␠"replica_id")]]-errors 5 ArrangeBy[[Column(0,␠"role_oid")]] 1 ArrangeBy[[Column(0,␠"schema_id")]] 6 ArrangeBy[[Column(0,␠"schema_id")]]-errors 6 +ArrangeBy[[Column(0,␠"schema_name")]] 1 ArrangeBy[[Column(0,␠"self")]] 1 ArrangeBy[[Column(0,␠"session_id")]] 1 ArrangeBy[[Column(0,␠"shard_id"),␠Column(2,␠"collection_timestamp")]] 1 @@ -109,7 +110,7 @@ ArrangeBy[[Column(1,␠"element_id")]] 2 ArrangeBy[[Column(1,␠"id")]] 1 ArrangeBy[[Column(1,␠"id")]]-errors 1 ArrangeBy[[Column(1,␠"id_to_use")]] 1 -ArrangeBy[[Column(1,␠"name")]] 1 +ArrangeBy[[Column(1,␠"name")]] 2 ArrangeBy[[Column(1,␠"name")]]-errors 1 ArrangeBy[[Column(1,␠"nspname")]] 1 ArrangeBy[[Column(1,␠"nspname")]]-errors 1 @@ -165,7 +166,7 @@ ArrangeBy[[Column(6,␠"schema_id")]] 1 ArrangeBy[[Column(6,␠"schema_id")]]-errors 1 ArrangeBy[[Column(7,␠"database_id")]] 1 ArrangeBy[[Column(9,␠"database_id")]] 1 -ArrangeBy[[]] 11 +ArrangeBy[[]] 13 Arranged␠DistinctBy 55 Arranged␠MinsMaxesHierarchical␠input 14 Arranged␠ReduceInaccumulable 3 diff --git a/test/sqllogictest/information_schema_tables.slt b/test/sqllogictest/information_schema_tables.slt index c23cd604ecf85..2543bcc71425d 100644 --- a/test/sqllogictest/information_schema_tables.slt +++ b/test/sqllogictest/information_schema_tables.slt @@ -182,7 +182,7 @@ BASE TABLE materialize mz_catalog mz_materialized_views -BASE TABLE +MATERIALIZED VIEW materialize mz_catalog mz_objects @@ -289,6 +289,10 @@ mz_aws_privatelink_connection_statuses VIEW materialize mz_internal +mz_builtin_materialized_views +VIEW +materialize +mz_internal mz_catalog_raw SOURCE materialize diff --git a/test/sqllogictest/mz_catalog_server_index_accounting.slt b/test/sqllogictest/mz_catalog_server_index_accounting.slt index bb358d195f562..8cc452f59d2fb 100644 --- a/test/sqllogictest/mz_catalog_server_index_accounting.slt +++ b/test/sqllogictest/mz_catalog_server_index_accounting.slt @@ -37,100 +37,100 @@ 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_cluster_deployment_lineage_ind CREATE␠INDEX␠"mz_cluster_deployment_lineage_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s738␠AS␠"mz_internal"."mz_cluster_deployment_lineage"]␠("cluster_id") +mz_cluster_deployment_lineage_ind CREATE␠INDEX␠"mz_cluster_deployment_lineage_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s741␠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_replica_frontiers_ind CREATE␠INDEX␠"mz_cluster_replica_frontiers_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s732␠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␠[s595␠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␠[s505␠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␠[s506␠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␠[s596␠AS␠"mz_internal"."mz_cluster_replica_name_history"]␠("id") -mz_cluster_replica_sizes_ind CREATE␠INDEX␠"mz_cluster_replica_sizes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s507␠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␠[s508␠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␠[s509␠AS␠"mz_internal"."mz_cluster_replica_statuses"]␠("replica_id") -mz_cluster_replicas_ind CREATE␠INDEX␠"mz_cluster_replicas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s504␠AS␠"mz_catalog"."mz_cluster_replicas"]␠("id") -mz_clusters_ind CREATE␠INDEX␠"mz_clusters_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s498␠AS␠"mz_catalog"."mz_clusters"]␠("id") -mz_columns_ind CREATE␠INDEX␠"mz_columns_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s469␠AS␠"mz_catalog"."mz_columns"]␠("name") -mz_comments_ind CREATE␠INDEX␠"mz_comments_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s521␠AS␠"mz_internal"."mz_comments"]␠("id") +mz_cluster_replica_frontiers_ind CREATE␠INDEX␠"mz_cluster_replica_frontiers_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s735␠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␠[s598␠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␠[s506␠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␠[s507␠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␠[s599␠AS␠"mz_internal"."mz_cluster_replica_name_history"]␠("id") +mz_cluster_replica_sizes_ind CREATE␠INDEX␠"mz_cluster_replica_sizes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s508␠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␠[s509␠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␠[s510␠AS␠"mz_internal"."mz_cluster_replica_statuses"]␠("replica_id") +mz_cluster_replicas_ind CREATE␠INDEX␠"mz_cluster_replicas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s505␠AS␠"mz_catalog"."mz_cluster_replicas"]␠("id") +mz_clusters_ind CREATE␠INDEX␠"mz_clusters_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s499␠AS␠"mz_catalog"."mz_clusters"]␠("id") +mz_columns_ind CREATE␠INDEX␠"mz_columns_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s472␠AS␠"mz_catalog"."mz_columns"]␠("name") +mz_comments_ind CREATE␠INDEX␠"mz_comments_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s522␠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") -mz_compute_dependencies_ind CREATE␠INDEX␠"mz_compute_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s721␠AS␠"mz_internal"."mz_compute_dependencies"]␠("dependency_id") +mz_compute_dependencies_ind CREATE␠INDEX␠"mz_compute_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s724␠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␠[s728␠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␠[s731␠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") -mz_connections_ind CREATE␠INDEX␠"mz_connections_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s502␠AS␠"mz_catalog"."mz_connections"]␠("schema_id") -mz_console_cluster_utilization_overview_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s724␠AS␠"mz_internal"."mz_console_cluster_utilization_overview"]␠("cluster_id") -mz_continual_tasks_ind CREATE␠INDEX␠"mz_continual_tasks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s524␠AS␠"mz_internal"."mz_continual_tasks"]␠("id") -mz_databases_ind CREATE␠INDEX␠"mz_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s467␠AS␠"mz_catalog"."mz_databases"]␠("name") +mz_connections_ind CREATE␠INDEX␠"mz_connections_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s503␠AS␠"mz_catalog"."mz_connections"]␠("schema_id") +mz_console_cluster_utilization_overview_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s727␠AS␠"mz_internal"."mz_console_cluster_utilization_overview"]␠("cluster_id") +mz_continual_tasks_ind CREATE␠INDEX␠"mz_continual_tasks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s527␠AS␠"mz_internal"."mz_continual_tasks"]␠("id") +mz_databases_ind CREATE␠INDEX␠"mz_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s470␠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␠[s712␠AS␠"mz_internal"."mz_frontiers"]␠("object_id") -mz_hydration_statuses_ind CREATE␠INDEX␠"mz_hydration_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s734␠AS␠"mz_internal"."mz_hydration_statuses"]␠("object_id",␠"replica_id") -mz_indexes_ind CREATE␠INDEX␠"mz_indexes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s470␠AS␠"mz_catalog"."mz_indexes"]␠("id") -mz_kafka_sources_ind CREATE␠INDEX␠"mz_kafka_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s464␠AS␠"mz_catalog"."mz_kafka_sources"]␠("id") -mz_materialized_views_ind CREATE␠INDEX␠"mz_materialized_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s482␠AS␠"mz_catalog"."mz_materialized_views"]␠("id") +mz_frontiers_ind CREATE␠INDEX␠"mz_frontiers_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s715␠AS␠"mz_internal"."mz_frontiers"]␠("object_id") +mz_hydration_statuses_ind CREATE␠INDEX␠"mz_hydration_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s737␠AS␠"mz_internal"."mz_hydration_statuses"]␠("object_id",␠"replica_id") +mz_indexes_ind CREATE␠INDEX␠"mz_indexes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s473␠AS␠"mz_catalog"."mz_indexes"]␠("id") +mz_kafka_sources_ind CREATE␠INDEX␠"mz_kafka_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s467␠AS␠"mz_catalog"."mz_kafka_sources"]␠("id") +mz_materialized_views_ind CREATE␠INDEX␠"mz_materialized_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s525␠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_notices_ind CREATE␠INDEX␠"mz_notices_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s804␠AS␠"mz_internal"."mz_notices"]␠("id") -mz_object_dependencies_ind CREATE␠INDEX␠"mz_object_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s465␠AS␠"mz_internal"."mz_object_dependencies"]␠("object_id") -mz_object_history_ind CREATE␠INDEX␠"mz_object_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s534␠AS␠"mz_internal"."mz_object_history"]␠("id") -mz_object_lifetimes_ind CREATE␠INDEX␠"mz_object_lifetimes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s535␠AS␠"mz_internal"."mz_object_lifetimes"]␠("id") -mz_object_transitive_dependencies_ind CREATE␠INDEX␠"mz_object_transitive_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s550␠AS␠"mz_internal"."mz_object_transitive_dependencies"]␠("object_id") -mz_objects_ind CREATE␠INDEX␠"mz_objects_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s531␠AS␠"mz_catalog"."mz_objects"]␠("schema_id") +mz_notices_ind CREATE␠INDEX␠"mz_notices_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s807␠AS␠"mz_internal"."mz_notices"]␠("id") +mz_object_dependencies_ind CREATE␠INDEX␠"mz_object_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s468␠AS␠"mz_internal"."mz_object_dependencies"]␠("object_id") +mz_object_history_ind CREATE␠INDEX␠"mz_object_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s537␠AS␠"mz_internal"."mz_object_history"]␠("id") +mz_object_lifetimes_ind CREATE␠INDEX␠"mz_object_lifetimes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s538␠AS␠"mz_internal"."mz_object_lifetimes"]␠("id") +mz_object_transitive_dependencies_ind CREATE␠INDEX␠"mz_object_transitive_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s553␠AS␠"mz_internal"."mz_object_transitive_dependencies"]␠("object_id") +mz_objects_ind CREATE␠INDEX␠"mz_objects_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s534␠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␠[s696␠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␠[s692␠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␠[s797␠AS␠"mz_catalog"."mz_recent_storage_usage"]␠("object_id") -mz_roles_ind CREATE␠INDEX␠"mz_roles_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s490␠AS␠"mz_catalog"."mz_roles"]␠("id") +mz_recent_activity_log_thinned_ind CREATE␠INDEX␠"mz_recent_activity_log_thinned_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s699␠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␠[s695␠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␠[s800␠AS␠"mz_catalog"."mz_recent_storage_usage"]␠("object_id") +mz_roles_ind CREATE␠INDEX␠"mz_roles_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s491␠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␠[s468␠AS␠"mz_catalog"."mz_schemas"]␠("database_id") -mz_secrets_ind CREATE␠INDEX␠"mz_secrets_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s501␠AS␠"mz_catalog"."mz_secrets"]␠("name") -mz_show_all_objects_ind CREATE␠INDEX␠"mz_show_all_objects_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s579␠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␠[s736␠AS␠"mz_internal"."mz_show_cluster_replicas"]␠("cluster") -mz_show_clusters_ind CREATE␠INDEX␠"mz_show_clusters_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s581␠AS␠"mz_internal"."mz_show_clusters"]␠("name") -mz_show_columns_ind CREATE␠INDEX␠"mz_show_columns_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s580␠AS␠"mz_internal"."mz_show_columns"]␠("id") -mz_show_connections_ind CREATE␠INDEX␠"mz_show_connections_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s589␠AS␠"mz_internal"."mz_show_connections"]␠("schema_id") -mz_show_databases_ind CREATE␠INDEX␠"mz_show_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s583␠AS␠"mz_internal"."mz_show_databases"]␠("name") -mz_show_indexes_ind CREATE␠INDEX␠"mz_show_indexes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s593␠AS␠"mz_internal"."mz_show_indexes"]␠("schema_id") -mz_show_materialized_views_ind CREATE␠INDEX␠"mz_show_materialized_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s592␠AS␠"mz_internal"."mz_show_materialized_views"]␠("schema_id") -mz_show_roles_ind CREATE␠INDEX␠"mz_show_roles_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s588␠AS␠"mz_internal"."mz_show_roles"]␠("name") -mz_show_schemas_ind CREATE␠INDEX␠"mz_show_schemas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s584␠AS␠"mz_internal"."mz_show_schemas"]␠("database_id") -mz_show_secrets_ind CREATE␠INDEX␠"mz_show_secrets_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s582␠AS␠"mz_internal"."mz_show_secrets"]␠("schema_id") -mz_show_sinks_ind CREATE␠INDEX␠"mz_show_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s591␠AS␠"mz_internal"."mz_show_sinks"]␠("schema_id") -mz_show_sources_ind CREATE␠INDEX␠"mz_show_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s590␠AS␠"mz_internal"."mz_show_sources"]␠("schema_id") -mz_show_tables_ind CREATE␠INDEX␠"mz_show_tables_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s585␠AS␠"mz_internal"."mz_show_tables"]␠("schema_id") -mz_show_types_ind CREATE␠INDEX␠"mz_show_types_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s587␠AS␠"mz_internal"."mz_show_types"]␠("schema_id") -mz_show_views_ind CREATE␠INDEX␠"mz_show_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s586␠AS␠"mz_internal"."mz_show_views"]␠("schema_id") -mz_sink_statistics_ind CREATE␠INDEX␠"mz_sink_statistics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s709␠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␠[s681␠AS␠"mz_internal"."mz_sink_status_history"]␠("sink_id") -mz_sink_statuses_ind CREATE␠INDEX␠"mz_sink_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s682␠AS␠"mz_internal"."mz_sink_statuses"]␠("id") -mz_sinks_ind CREATE␠INDEX␠"mz_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s480␠AS␠"mz_catalog"."mz_sinks"]␠("id") -mz_source_statistics_ind CREATE␠INDEX␠"mz_source_statistics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s707␠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␠[s705␠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␠[s683␠AS␠"mz_internal"."mz_source_status_history"]␠("source_id") -mz_source_statuses_ind CREATE␠INDEX␠"mz_source_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s700␠AS␠"mz_internal"."mz_source_statuses"]␠("id") -mz_sources_ind CREATE␠INDEX␠"mz_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s473␠AS␠"mz_catalog"."mz_sources"]␠("id") -mz_tables_ind CREATE␠INDEX␠"mz_tables_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s472␠AS␠"mz_catalog"."mz_tables"]␠("schema_id") -mz_types_ind CREATE␠INDEX␠"mz_types_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s484␠AS␠"mz_catalog"."mz_types"]␠("schema_id") -mz_views_ind CREATE␠INDEX␠"mz_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s481␠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␠[s716␠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␠[s522␠AS␠"mz_internal"."mz_webhook_sources"]␠("id") -pg_attrdef_all_databases_ind CREATE␠INDEX␠"pg_attrdef_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s621␠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␠[s614␠AS␠"mz_internal"."pg_attribute_all_databases"]␠("attrelid",␠"attname",␠"atttypid",␠"attlen",␠"attnum",␠"atttypmod",␠"attnotnull",␠"atthasdef",␠"attidentity",␠"attgenerated",␠"attisdropped",␠"attcollation",␠"database_name",␠"pg_type_database_name") -pg_authid_core_ind CREATE␠INDEX␠"pg_authid_core_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s631␠AS␠"mz_internal"."pg_authid_core"]␠("rolname") -pg_class_all_databases_ind CREATE␠INDEX␠"pg_class_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s602␠AS␠"mz_internal"."pg_class_all_databases"]␠("relname") -pg_description_all_databases_ind CREATE␠INDEX␠"pg_description_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s611␠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␠[s599␠AS␠"mz_internal"."pg_namespace_all_databases"]␠("nspname") -pg_type_all_databases_ind CREATE␠INDEX␠"pg_type_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s608␠AS␠"mz_internal"."pg_type_all_databases"]␠("oid") +mz_schemas_ind CREATE␠INDEX␠"mz_schemas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s471␠AS␠"mz_catalog"."mz_schemas"]␠("database_id") +mz_secrets_ind CREATE␠INDEX␠"mz_secrets_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s502␠AS␠"mz_catalog"."mz_secrets"]␠("name") +mz_show_all_objects_ind CREATE␠INDEX␠"mz_show_all_objects_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s582␠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␠[s739␠AS␠"mz_internal"."mz_show_cluster_replicas"]␠("cluster") +mz_show_clusters_ind CREATE␠INDEX␠"mz_show_clusters_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s584␠AS␠"mz_internal"."mz_show_clusters"]␠("name") +mz_show_columns_ind CREATE␠INDEX␠"mz_show_columns_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s583␠AS␠"mz_internal"."mz_show_columns"]␠("id") +mz_show_connections_ind CREATE␠INDEX␠"mz_show_connections_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s592␠AS␠"mz_internal"."mz_show_connections"]␠("schema_id") +mz_show_databases_ind CREATE␠INDEX␠"mz_show_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s586␠AS␠"mz_internal"."mz_show_databases"]␠("name") +mz_show_indexes_ind CREATE␠INDEX␠"mz_show_indexes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s596␠AS␠"mz_internal"."mz_show_indexes"]␠("schema_id") +mz_show_materialized_views_ind CREATE␠INDEX␠"mz_show_materialized_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s595␠AS␠"mz_internal"."mz_show_materialized_views"]␠("schema_id") +mz_show_roles_ind CREATE␠INDEX␠"mz_show_roles_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s591␠AS␠"mz_internal"."mz_show_roles"]␠("name") +mz_show_schemas_ind CREATE␠INDEX␠"mz_show_schemas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s587␠AS␠"mz_internal"."mz_show_schemas"]␠("database_id") +mz_show_secrets_ind CREATE␠INDEX␠"mz_show_secrets_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s585␠AS␠"mz_internal"."mz_show_secrets"]␠("schema_id") +mz_show_sinks_ind CREATE␠INDEX␠"mz_show_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s594␠AS␠"mz_internal"."mz_show_sinks"]␠("schema_id") +mz_show_sources_ind CREATE␠INDEX␠"mz_show_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s593␠AS␠"mz_internal"."mz_show_sources"]␠("schema_id") +mz_show_tables_ind CREATE␠INDEX␠"mz_show_tables_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s588␠AS␠"mz_internal"."mz_show_tables"]␠("schema_id") +mz_show_types_ind CREATE␠INDEX␠"mz_show_types_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s590␠AS␠"mz_internal"."mz_show_types"]␠("schema_id") +mz_show_views_ind CREATE␠INDEX␠"mz_show_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s589␠AS␠"mz_internal"."mz_show_views"]␠("schema_id") +mz_sink_statistics_ind CREATE␠INDEX␠"mz_sink_statistics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s712␠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␠[s684␠AS␠"mz_internal"."mz_sink_status_history"]␠("sink_id") +mz_sink_statuses_ind CREATE␠INDEX␠"mz_sink_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s685␠AS␠"mz_internal"."mz_sink_statuses"]␠("id") +mz_sinks_ind CREATE␠INDEX␠"mz_sinks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s483␠AS␠"mz_catalog"."mz_sinks"]␠("id") +mz_source_statistics_ind CREATE␠INDEX␠"mz_source_statistics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s710␠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␠[s708␠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␠[s686␠AS␠"mz_internal"."mz_source_status_history"]␠("source_id") +mz_source_statuses_ind CREATE␠INDEX␠"mz_source_statuses_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s703␠AS␠"mz_internal"."mz_source_statuses"]␠("id") +mz_sources_ind CREATE␠INDEX␠"mz_sources_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s476␠AS␠"mz_catalog"."mz_sources"]␠("id") +mz_tables_ind CREATE␠INDEX␠"mz_tables_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s475␠AS␠"mz_catalog"."mz_tables"]␠("schema_id") +mz_types_ind CREATE␠INDEX␠"mz_types_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s485␠AS␠"mz_catalog"."mz_types"]␠("schema_id") +mz_views_ind CREATE␠INDEX␠"mz_views_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s484␠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␠[s719␠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␠[s523␠AS␠"mz_internal"."mz_webhook_sources"]␠("id") +pg_attrdef_all_databases_ind CREATE␠INDEX␠"pg_attrdef_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s624␠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␠[s617␠AS␠"mz_internal"."pg_attribute_all_databases"]␠("attrelid",␠"attname",␠"atttypid",␠"attlen",␠"attnum",␠"atttypmod",␠"attnotnull",␠"atthasdef",␠"attidentity",␠"attgenerated",␠"attisdropped",␠"attcollation",␠"database_name",␠"pg_type_database_name") +pg_authid_core_ind CREATE␠INDEX␠"pg_authid_core_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s634␠AS␠"mz_internal"."pg_authid_core"]␠("rolname") +pg_class_all_databases_ind CREATE␠INDEX␠"pg_class_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s605␠AS␠"mz_internal"."pg_class_all_databases"]␠("relname") +pg_description_all_databases_ind CREATE␠INDEX␠"pg_description_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s614␠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␠[s602␠AS␠"mz_internal"."pg_namespace_all_databases"]␠("nspname") +pg_type_all_databases_ind CREATE␠INDEX␠"pg_type_all_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s611␠AS␠"mz_internal"."pg_type_all_databases"]␠("oid") # Record all transitive dependencies (tables, sources, views, mvs) of indexes on # the mz_catalog_server cluster. @@ -210,6 +210,13 @@ mz_audit_events object_type mz_audit_events occurred_at mz_audit_events user mz_base_types id +mz_builtin_materialized_views cluster_name +mz_builtin_materialized_views create_sql +mz_builtin_materialized_views definition +mz_builtin_materialized_views name +mz_builtin_materialized_views oid +mz_builtin_materialized_views privileges +mz_builtin_materialized_views schema_name mz_catalog_raw data mz_cluster_deployment_lineage cluster_id mz_cluster_deployment_lineage cluster_name diff --git a/test/sqlsmith/Dockerfile b/test/sqlsmith/Dockerfile index dd0d8c27808a3..0c5ecc11d038d 100644 --- a/test/sqlsmith/Dockerfile +++ b/test/sqlsmith/Dockerfile @@ -30,7 +30,7 @@ ADD https://api.github.com/repos/MaterializeInc/sqlsmith/git/refs/heads/master v # Build SQLsmith RUN git clone --single-branch --branch=master https://github.com/MaterializeInc/sqlsmith \ && cd sqlsmith \ - && git checkout 07ac467e1e53f482fb357ea5092c1cacd6c03248 \ + && git checkout 4eefcee6d766d87dda48a81c990066b13977f87e \ && rm -rf .git \ && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=c++ . \ && cmake --build . -j `nproc` diff --git a/test/testdrive/catalog.td b/test/testdrive/catalog.td index b557ffe080cf8..10e3a74b7f3e5 100644 --- a/test/testdrive/catalog.td +++ b/test/testdrive/catalog.td @@ -530,7 +530,6 @@ mz_kafka_sinks "" mz_kafka_sources "" mz_list_types "" mz_map_types "" -mz_materialized_views "" mz_operators "" mz_pseudo_types "" mz_role_auth "" @@ -561,6 +560,7 @@ name cluster comment mz_databases mz_catalog_server "" mz_role_members mz_catalog_server "" mz_schemas mz_catalog_server "" +mz_materialized_views mz_catalog_server "" # Check default sources, tables, and views in mz_catalog_unstable. @@ -629,6 +629,7 @@ mz_webhook_sources "" name comment ------------------------------------------------ mz_activity_log_thinned "" +mz_builtin_materialized_views "" mz_cluster_deployment_lineage "" mz_cluster_replica_history "" mz_cluster_replica_metrics "" @@ -816,7 +817,7 @@ test_table "" # `SHOW TABLES` and `mz_tables` should agree. > SELECT COUNT(*) FROM mz_tables WHERE id LIKE 's%' -57 +56 # 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%'