Skip to content

Commit

Permalink
catalog: Move builtin to catalog module
Browse files Browse the repository at this point in the history
This commit moves the mz_adapter::catalog::builtin module to
mz_catalog::builtin which cleans up some duplicate structs.
  • Loading branch information
jkosh44 committed Sep 18, 2023
1 parent 17d66c5 commit 4a88879
Show file tree
Hide file tree
Showing 16 changed files with 775 additions and 903 deletions.
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

745 changes: 720 additions & 25 deletions src/adapter/src/catalog.rs

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions src/adapter/src/catalog/builtin_table_updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ use mz_storage_types::sources::{
GenericSourceConnection, KafkaSourceConnection, PostgresSourceConnection,
};

use crate::catalog::builtin::{
use crate::catalog::{
AwsPrincipalContext, CatalogItem, CatalogState, ClusterVariant, Connection, DataSourceDesc,
Database, DefaultPrivilegeObject, Error, ErrorKind, Func, Index, MaterializedView, Sink,
StorageSinkConnectionState, Type, View, SYSTEM_CONN_ID,
};
use crate::coord::ConnMeta;
use crate::subscribe::ActiveSubscribe;
use mz_catalog::builtin::{
MZ_AGGREGATES, MZ_ARRAY_TYPES, MZ_AUDIT_EVENTS, MZ_AWS_PRIVATELINK_CONNECTIONS, MZ_BASE_TYPES,
MZ_CLUSTERS, MZ_CLUSTER_LINKS, MZ_CLUSTER_REPLICAS, MZ_CLUSTER_REPLICA_HEARTBEATS,
MZ_CLUSTER_REPLICA_METRICS, MZ_CLUSTER_REPLICA_SIZES, MZ_CLUSTER_REPLICA_STATUSES, MZ_COLUMNS,
Expand All @@ -50,13 +57,6 @@ use crate::catalog::builtin::{
MZ_SSH_TUNNEL_CONNECTIONS, MZ_STORAGE_USAGE_BY_SHARD, MZ_SUBSCRIPTIONS, MZ_SYSTEM_PRIVILEGES,
MZ_TABLES, MZ_TYPES, MZ_TYPE_PG_METADATA, MZ_VIEWS, MZ_WEBHOOKS_SOURCES,
};
use crate::catalog::{
AwsPrincipalContext, CatalogItem, CatalogState, ClusterVariant, Connection, DataSourceDesc,
Database, DefaultPrivilegeObject, Error, ErrorKind, Func, Index, MaterializedView, Sink,
StorageSinkConnectionState, Type, View, SYSTEM_CONN_ID,
};
use crate::coord::ConnMeta;
use crate::subscribe::ActiveSubscribe;

/// An update to a built-in table.
#[derive(Debug)]
Expand Down
9 changes: 5 additions & 4 deletions src/adapter/src/coord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ use tokio::sync::{mpsc, oneshot, watch, OwnedMutexGuard};
use tracing::{debug, info, info_span, span, warn, Instrument, Level, Span};
use uuid::Uuid;

use crate::catalog::builtin::{BUILTINS, MZ_VIEW_FOREIGN_KEYS, MZ_VIEW_KEYS};
use crate::catalog::{
self, AwsPrincipalContext, BuiltinMigrationMetadata, BuiltinTableUpdate, Catalog, CatalogItem,
ClusterReplicaSizeMap, DataSourceDesc, Source, StorageSinkConnectionState,
Expand All @@ -147,6 +146,7 @@ use crate::statement_logging::StatementEndedExecutionReason;
use crate::subscribe::ActiveSubscribe;
use crate::util::{ClientTransmitter, CompletedClientTransmitter, ComputeSinkId, ResultExt};
use crate::{flags, AdapterNotice, TimestampProvider};
use mz_catalog::builtin::{BUILTINS, MZ_VIEW_FOREIGN_KEYS, MZ_VIEW_KEYS};

pub(crate) mod dataflows;
use self::statement_logging::{StatementLogging, StatementLoggingId};
Expand Down Expand Up @@ -1209,9 +1209,10 @@ impl Coordinator {
// This is disabled for the moment because it has unusual upper
// advancement behavior.
// See: https://materializeinc.slack.com/archives/C01CFKM1QRF/p1660726837927649
let source_status_collection_id = Some(self.catalog().resolve_builtin_storage_collection(
&crate::catalog::builtin::MZ_SOURCE_STATUS_HISTORY,
));
let source_status_collection_id = Some(
self.catalog()
.resolve_builtin_storage_collection(&mz_catalog::builtin::MZ_SOURCE_STATUS_HISTORY),
);

let mut collections_to_create = Vec::new();

Expand Down
8 changes: 4 additions & 4 deletions src/adapter/src/coord/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,10 @@ impl Coordinator {
// Validate `sink.from` is in fact a storage collection
self.controller.storage.collection(sink.from)?;

let status_id =
Some(self.catalog().resolve_builtin_storage_collection(
&crate::catalog::builtin::MZ_SINK_STATUS_HISTORY,
));
let status_id = Some(
self.catalog()
.resolve_builtin_storage_collection(&mz_catalog::builtin::MZ_SINK_STATUS_HISTORY),
);

// The AsOf is used to determine at what time to snapshot reading from the persist collection. This is
// primarily relevant when we do _not_ want to include the snapshot in the sink. Choosing now will mean
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/src/coord/introspection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ use mz_sql::plan::{ExplainPlanPlan, ExplainTimestampPlan, Explainee, Plan, Subsc
use mz_sql::rbac;
use smallvec::SmallVec;

use crate::catalog::builtin::{MZ_INTROSPECTION_CLUSTER, MZ_SUPPORT_ROLE};
use crate::catalog::Catalog;
use crate::coord::TargetCluster;
use crate::notice::AdapterNotice;
use crate::session::Session;
use crate::AdapterError;
use mz_catalog::builtin::{MZ_INTROSPECTION_CLUSTER, MZ_SUPPORT_ROLE};

/// Checks whether or not we should automatically run a query on the `mz_introspection`
/// cluster, as opposed to whatever the current default cluster is.
Expand Down
4 changes: 2 additions & 2 deletions src/adapter/src/coord/sequencer/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl Coordinator {
for (source_id, source) in sources {
let source_status_collection_id =
Some(self.catalog().resolve_builtin_storage_collection(
&crate::catalog::builtin::MZ_SOURCE_STATUS_HISTORY,
&mz_catalog::builtin::MZ_SOURCE_STATUS_HISTORY,
));

let (data_source, status_collection_id) = match source.data_source {
Expand Down Expand Up @@ -4419,7 +4419,7 @@ impl Coordinator {
for (source_id, source) in sources {
let source_status_collection_id =
Some(self.catalog().resolve_builtin_storage_collection(
&crate::catalog::builtin::MZ_SOURCE_STATUS_HISTORY,
&mz_catalog::builtin::MZ_SOURCE_STATUS_HISTORY,
));

let (data_source, status_collection_id) = match source.data_source {
Expand Down
5 changes: 5 additions & 0 deletions src/catalog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@ publish = false
[dependencies]
futures = "0.3.25"
itertools = "0.10.5"
once_cell = "1.16.0"
mz-audit-log = { path = "../audit-log" }
mz-compute-client = { path = "../compute-client" }
mz-controller = { path = "../controller" }
mz-controller-types = { path = "../controller-types" }
mz-ore = { path = "../ore", features = ["chrono", "async", "tracing_"] }
mz-pgrepr = { path = "../pgrepr" }
mz-proto = { path = "../proto" }
mz-repr = { path = "../repr", features = ["tracing_"] }
mz-sql = { path = "../sql" }
mz-sql-parser = { path = "../sql-parser" }
mz-stash = { path = "../stash" }
mz-storage-client = { path = "../storage-client" }
mz-storage-types = { path = "../storage-types" }
proptest = { version = "1.0.0", default-features = false, features = ["std"] }
proptest-derive = { version = "0.3.0", features = ["boxed_union"] }
serde = "1.0.152"
serde_json = "1.0.89"
tracing = "0.1.37"
workspace-hack = { version = "0.0.0", path = "../workspace-hack" }

Expand Down
Loading

0 comments on commit 4a88879

Please sign in to comment.