metric sinks: SHOW, catalog visibility, and RBAC (SQL-572) - #38149
Conversation
2599599 to
5eeeece
Compare
051c708 to
f34efdc
Compare
QA LLM Review1. HIGH -- new builtin index changes
|
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>
f34efdc to
abcf774
Compare
SangJunBak
left a comment
There was a problem hiding this comment.
A couple of nits, but nothing blocking! Good stuff!
|
|
||
| let query = format!( | ||
| "SELECT sinks.name, objs.name AS \"from\", clusters.name AS cluster | ||
| FROM mz_internal.mz_metric_sinks AS sinks |
There was a problem hiding this comment.
nit: Wonder if it's worth being a bit more verbose and labelling them as "metric_sinks" just to clearly differentiate from regular sinks
| ShowSelect::new( | ||
| scx, | ||
| query, | ||
| filter, | ||
| None, | ||
| // `from` is a reserved keyword, so the projection has to quote it. | ||
| Some(&["name", "\"from\"", "cluster"]), | ||
| ) | ||
| } |
There was a problem hiding this comment.
Couple nits:
- Noticing other objects (e.g. sources, sinks) have a different schema for their SHOW commands. Specifically just a "name" and "create_sql". Any reason we're making it more specific for metric sinks?
- Assuming we keep these columns, I feel like instead of "from", we should choose another word. Especially since it's already reserved and if people want to filter on it via sql, they'd have to escape on it too. Maybe "relation"?
There was a problem hiding this comment.
I'll switch from to relation.
But SHOW SINKS and SHOW SOURCES both return name, type, cluster and comment. The thing that is different here is that I am dropping type and comment. I think the "from/relation" makes sense instead of type here. And since the grammar rejects comments there is no need to add that column, for now
There was a problem hiding this comment.
Ah you're right. Sorry, I was diffing between show_create_source, the singular versions. relation sounds good to me too!
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.