Repository navigation
Conversation
Front-end for a declarative CREATE ASSERTION: grammar/AST, planning, and catalog/RBAC scaffolding, behind enable_create_assertion (default off). The feature bails at sequence time (AdapterError::Unsupported); catalog/audit arms for ObjectType::Assertion are unreachable! stubs since no assertion is persisted yet. Compiles clean (cargo check --workspace, 658 crates). Not functional yet. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adding ASSERTION to keywords.txt made `parse_object_type` greedily consume a bare `assertion` as ObjectType::Assertion, so `GRANT SELECT ON assertion TO alice` errored "Unsupported GRANT on ASSERTION" instead of treating `assertion` as a table name (its pre-feature default). parse_object_type's only caller is the GRANT/REVOKE path (DROP/SHOW use expect_object_type, which keeps its ASSERTION arm), so drop ASSERTION from parse_object_type. Bare `assertion` now falls back to a table name as before. Add GRANT and REVOKE regression cases for `assertion` to the acl datadriven test. Co-Authored-By: Claude Opus 4.8 <[email protected]>
acl.rs (plan_alter_default_privileges) says assertions have no privileges, but rbac.rs granted them SELECT in all_object_privileges and default_builtin_object_acl_mode. Align to acl.rs: for the MVP, assertions are system-maintained objects with no user-grantable privileges (owner + superuser only), matching the architect design (Phase 1 RBAC = owner + superuser; fine-grained SELECT on violations deferred). Violations are surfaced through mz_internal relations, not via SELECT on the assertion object. The create-time RBAC requirements for Plan::CreateAssertion (CREATE on schema + cluster, SELECT on referenced relations) are unchanged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Stage 1 of wiring up CREATE ASSERTION (declaration-only, behind enable_create_assertion). Adds a distinct CatalogItem::Assertion variant mirroring the MetricSink precedent, plus a real sequence_create_assertion that inserts a durable catalog object; DROP ASSERTION rides the generic drop path. - New memory::objects::Assertion (create_sql, global_id, raw_expr, resolved_ids, dependencies, cluster_id, target_replica); no optimizer plans / storage collection / dataflow this stage, so the item is non-storage, non-compute, non-hydratable and bootstrap/apply treat it as a no-op. - Durable catalog: proto CatalogItemType::Assertion, ObjectType::Assertion (top-level + audit_log_event_v1), CommentObject::Assertion; mz_audit_log ObjectType::Assertion; CATALOG_VERSION 94->95 with objects_v95 snapshot, no-op v94_to_v95 migration, and MZ_COMMENTS / audit-log CASE arms. - sequence_create_assertion runs a catalog txn inserting CatalogItem::Assertion; replaces the AdapterError::Unsupported bail. ExecuteResponse::CreatedAssertion. - Exhaustive-match churn across catalog/adapter/sql/pgwire/environmentd mirroring MetricSink. cargo check --workspace is green. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ogictest - objects_v95.txt: generated catalog encoding snapshot for the new CATALOG_VERSION, so test_proto_serialization_stability round-trips v95. - create_assertion.slt: Stage 1 create/drop behavioral test (feature-gated), observing the persisted catalog object via name-collision + if-not-exists semantics and confirming the base table is not tainted. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The durable item_type() classifier maps a persisted object's create_sql prefix to its CatalogItemType and panics on an unrecognized prefix. Stage 1 added CatalogItem::Assertion everywhere the compiler required it but missed this runtime match, so persisting any assertion panicked the coordinator at catalog_transact time. cargo check could not catch it; only an end-to-end run did. Add the ASSERTION arm. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Stage 2a observability for CREATE ASSERTION (behind enable_create_assertion): - mz_internal.mz_assertions: a BuiltinMaterializedView over mz_catalog_raw surfacing each declared assertion's id, oid, schema, name, bound cluster, CHECK/AS definition, owner, and privileges. Modeled on mz_materialized_views. - SHOW ASSERTIONS [IN CLUSTER ...]: lists assertions with their cluster. - SHOW CREATE ASSERTION <name>: returns the re-runnable create_sql. Extends the sqllogictest to exercise the new surface end to end and refreshes the builtin enumeration expectations (oid, information_schema.tables, catalog-server index accounting) for the new relation. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Skunkworks prototype of
CREATE ASSERTIONfor Materialize: declarative,continuously-maintained data-integrity constraints whose violations surface as a
non-tainting, queryable collection. Materialize's incremental engine makes the
per-DML cost that blocked every other RDBMS from shipping
ASSERTIONcheap.Demand came from the #feedback channel (Frank McSherry, Seth Wiesman, Brooklyn Data).
Description
First slice, behind
enable_create_assertion(default off):CREATE ASSERTION <name> [ON <rel>] CHECK (<expr>), with parser round-trip tests.ObjectType::Assertionarms areunreachable!stubs because nothing is persisted yet.Verification
cargo check --workspacegreen (658 crates);cargo check -p mz-environmentdgreen. Parser round-trip tests pass. Not yet functional end to end.Status / remaining work (in progress on this branch)
proto::ObjectType::Assertion, next field #19, per the catalog-protos hash-snapshot protocol); render the violations dataflow (reuse per-dataflow error streams); introspection relations; DROP/SHOW.assertion.acl.rs(no privileges) vsrbac.rs(grants SELECT).Draft / skunkworks. No reviewer requested.
🤖 Generated with Claude Code