Skip to content

Validate a JSON schema change with a small runbook ​

A JSON schema change should be tested against documents that exercise its actual contract. Coordinator DB can retain flexible JSON while validating declared typed paths. Missing declared paths and explicit JSON null receive the type default unless the path is Nullable.

Build representative cases ​

Include a valid document, a missing key, explicit null, a wrong type and a scalar where an object is expected. Add nested arrays or duplicate object keys when the source can contain them. Keep the examples synthetic so they can be shared safely.

sql
CREATE TABLE json_contract(doc JSON(id UInt64, nickname Nullable(String)));
INSERT INTO json_contract VALUES ('{"id":1,"nickname":"Ada"}'), ('{}');
SELECT doc.id, doc.nickname FROM json_contract FORMAT csv;

Check both SQL and file input ​

Run the same cases through the importer and selected format, not only literal SQL. Field names and statement settings can introduce a separate conversion rule. Verify extracted paths and exported values with the consuming application.

For a change to an existing column's declaration, create a replacement table and convert explicitly; changing a JSON document's shape is not automatic schema migration. Record how old documents map to the new contract and validate counts before changing application writes.

See JSON type, JSON functions and JSON loading.