You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
metric sinks: SHOW, catalog visibility, and RBAC (SQL-572)
Problem:
A metric sink was invisible, `mz_objects` did not carry it, and there
was no way to read back the SQL that created it.
Solution:
`SHOW METRIC SINKS [FROM <schema>] [IN CLUSTER <c>] [LIKE ...]` lists
name, `from`, and cluster. `SHOW [REDACTED] CREATE METRIC SINK` replays
`create_sql`. Both require `enable_metric_sink`.
`mz_internal.mz_metric_sinks` exposes what the catalog knows about a
sink, shaped like `mz_catalog.mz_sinks`, and joins into `mz_objects` as
type `metric-sink`. It is a materialized view derived from
`mz_catalog_raw`. It carries `owner_id`, so a sink's owner is now
visible in the catalog and its ownership checks are testable. Like
`mz_sinks`, it is indexed on `id` so the `mz_objects` union reuses the
arrangement.
The relation carries only the columns something reads. `create_sql` and
`redacted_create_sql` have no reader, and `SHOW CREATE` is how you get
the SQL back.
`enable_metric_sink` gates the DDL and the SHOW verbs, not the catalog
relation. `mz_metric_sinks` is always present and public, so with the
flag off it is simply empty.
Testing:
- `metric_sink.slt` covers discovery and access control: the
`mz_metric_sinks` row resolving to its `FROM` relation, cluster, schema,
and owner, `mz_objects` and `mz_show_all_objects` membership, the three
`SHOW METRIC SINKS` filters, the `SHOW CREATE` round-trip (plain and
redacted), the audit rows, and privileges.
- The restart platform check reads `SHOW METRIC SINKS` instead of
probing with a `CREATE` expected to fail.
Co-authored-by: Moritz Hoffmann <antiguru@gmail.com>
Copy file name to clipboardExpand all lines: doc/user/content/reference/system-catalog/mz_internal.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -716,6 +716,12 @@ The view is defined as the transitive closure of [`mz_object_dependencies`](#mz_
716
716
|`object_id`|[`text`]| The ID of the dependent object. Corresponds to [`mz_objects.id`](../mz_catalog/#mz_objects). |
717
717
|`referenced_object_id`|[`text`]| The ID of the (possibly transitively) referenced object. Corresponds to [`mz_objects.id`](../mz_catalog/#mz_objects). |
("oid","A PostgreSQL-compatible OID for the object."),
3456
3456
("schema_id","The ID of the schema to which the object belongs. Corresponds to `mz_schemas.id`."),
3457
3457
("name","The name of the object."),
3458
-
("type","The type of the object: one of `table`, `source`, `view`, `materialized-view`, `sink`, `index`, `connection`, `secret`, `type`, or `function`."),
3458
+
("type","The type of the object: one of `table`, `source`, `view`, `materialized-view`, `sink`, `metric-sink`, `index`, `connection`, `secret`, `type`, or `function`."),
3459
3459
("owner_id","The role ID of the owner of the object. Corresponds to `mz_roles.id`."),
3460
3460
("cluster_id","The ID of the cluster maintaining the source, materialized view, index, or sink. Corresponds to `mz_clusters.id`. `NULL` for other object types."),
3461
3461
("privileges","The privileges belonging to the object."),
0 commit comments