Skip to main content

Module types

Module types 

Source
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

  1. Capture — Column schemas are queried from the live environment and written to types.lock.
  2. Compile — The lock file is loaded and its schemas are used to resolve external dependency columns during compilation.
  3. 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 a types.lock file: a map from fully-qualified object names to column schemas, plus optional object-level comments from COMMENT ON in the source database.
  • ColumnType — A single column’s type, nullability, and optional COMMENT ON COLUMN description.
  • 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§

ColumnLock 🔒
On-disk form of a column: its name and nullability widened over the type/of/fields keys of crate::types::data_type.
ColumnType
A single column’s type, nullability, and optional comment in a data contract.
ObjectLock 🔒
Types
In-memory representation of a types.lock file.
TypesLock 🔒
TOML serialization format for types.lock

Enums§

ObjectKind
The kind of database object recorded in a types.lock entry.
TypesError
Errors that can occur when reading, writing, or parsing types.lock files.

Constants§

BUILD_DIR 🔒
Directory name for mz-deploy build artifacts.
COLUMN_INDENT 🔒
Indentation of a column entry inside a columns array.
LOCK_VERSION 🔒
Highest types.lock format 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_column over 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 TypesLock as TOML with per-kind sections and inline columns.