doc/user/content/sql/explain-schema.md
EXPLAIN KEY SCHEMA or EXPLAIN VALUE SCHEMA shows the generated schemas for a CREATE SINK statement without creating the sink.
{{< warning >}}
EXPLAIN is not part of Materialize's stable interface and is not subject to
our backwards compatibility guarantee. The syntax and output of EXPLAIN may
change arbitrarily in future versions of Materialize.
{{< /warning >}}
{{% include-syntax file="examples/explain_schema" example="syntax" %}}
When creating a an Avro-formatted Kafka sink, Materialize automatically generates Avro schemas for the message key and value and publishes them to a schema registry. This command shows what the generated schemas would look like, without creating the sink.
CREATE TABLE t (c1 int, c2 text);
COMMENT ON TABLE t IS 'materialize comment on t';
COMMENT ON COLUMN t.c2 IS 'materialize comment on t.c2';
EXPLAIN VALUE SCHEMA FOR
CREATE SINK
FROM t
INTO KAFKA CONNECTION kafka_conn (TOPIC 'test_avro_topic')
KEY (c1)
FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
ENVELOPE UPSERT;
Schema
--------------------------------------------
{ +
"type": "record", +
"name": "envelope", +
"doc": "materialize comment on t", +
"fields": [ +
{ +
"name": "c1", +
"type": [ +
"null", +
"int" +
] +
}, +
{ +
"name": "c2", +
"type": [ +
"null", +
"string" +
], +
"doc": "materialize comment on t.c2"+
} +
] +
}
The privileges required to execute this statement are:
{{% include-headless "/headless/sql-command-privileges/explain-schema" %}}