Expand description
Data-contract system for external dependencies.
When a project references objects it does not own (e.g. tables created by an
upstream ingestion pipeline), mz-deploy needs to know their column schemas so
it can type-check views that depend on them. This module manages that contract
through the types.lock file.
§Lock File Lifecycle
- Capture — Column schemas are queried from the live environment and
written to
types.lock. - Compile — The lock file is loaded and its schemas are used to resolve external dependency columns during compilation.
- Validate — During incremental typechecking, external dependency schemas are provided to the validation backend when dirty objects reference them.
§Compiler Integration
Incremental runtime typechecking is owned by
crate::project::compiler::typecheck. That subsystem persists per-object
validation artifacts for consumers such as explain and the LSP.
This module owns the types.lock contract format and the type vocabulary
it records.
§Key Types
Types— In-memory representation of atypes.lockfile: a map from fully-qualified object names to column schemas, plus optional object-level comments fromCOMMENT ONin the source database.ColumnType— A single column’s type, nullability, and optionalCOMMENT ON COLUMNdescription.data_type::DataType— A column’s type. Structural rather than a type name, because a record, an anonymous list, and an anonymous map have no spelling the SQL grammar accepts.stub— Turns a recorded schema back into a relation.
Modules§
- data_
type 🔒 - The type of a column in a data contract.
- stub 🔒
- DDL that recreates a recorded column schema as a relation.
Structs§
- Column
Lock 🔒 - On-disk form of a column: its name and nullability widened over the
type/of/fieldskeys ofcrate::types::data_type. - Column
Type - A single column’s type, nullability, and optional comment in a data contract.
- Object
Lock 🔒 - Types
- In-memory representation of a
types.lockfile. - Types
Lock 🔒 - TOML serialization format for types.lock
Enums§
- Object
Kind - The kind of database object recorded in a
types.lockentry. - Types
Error - Errors that can occur when reading, writing, or parsing
types.lockfiles.
Constants§
- BUILD_
DIR 🔒 - Directory name for mz-deploy build artifacts.
- COLUMN_
INDENT 🔒 - Indentation of a column entry inside a
columnsarray. - LOCK_
VERSION 🔒 - Highest
types.lockformat this binary understands.
Functions§
- escape_
toml_ 🔒string - Escape a string for use as a TOML basic string value.
- load_
types_ 🔒lock - Load the types.lock file from the specified directory. Returns an error if the file doesn’t exist or cannot be parsed.
- write_
column 🔒 - Render one column as a TOML inline table, breaking a record’s field list across lines.
- write_
field 🔒 - Render one record field. Fields carry no comment, so this is
write_columnover the field’s own keys. - write_
inline_ 🔒type - Render a container’s element type as a single-line inline table.
- write_
toml 🔒 - Hand-format a
TypesLockas TOML with per-kind sections and inline columns.