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>
Problem:
A metric sink was invisible,
mz_objectsdid not carry it, and therewas no way to read back the SQL that created it.
Solution:
SHOW METRIC SINKS [FROM <schema>] [IN CLUSTER <c>] [LIKE ...]listsname,
from, and cluster.SHOW [REDACTED] CREATE METRIC SINKreplayscreate_sql. Both requireenable_metric_sink.mz_internal.mz_metric_sinksexposes what the catalog knows about asink, shaped like
mz_catalog.mz_sinks, and joins intomz_objectsastype
metric-sink. It is a materialized view derived frommz_catalog_raw. It carriesowner_id, so a sink's owner is nowvisible in the catalog and its ownership checks are testable.
The relation carries only the columns something reads.
create_sqlandredacted_create_sqlhave no reader, andSHOW CREATEis how you getthe SQL back.
Testing:
metric_sink.sltcovers discovery and access control: themz_metric_sinksrow resolving to itsFROMrelation, cluster, schema,and owner,
mz_objectsandmz_show_all_objectsmembership, the threeSHOW METRIC SINKSfilters, theSHOW CREATEround-trip, the auditrows, and privileges.
The restart platform check reads
SHOW METRIC SINKSinstead ofprobing with a
CREATEexpected to fail.