Skip to main content

Module object_validation

Module object_validation 

Source
Expand description

Object validation and compiled-project assembly.

This module turns source-owned objects into validated compiled objects and assembles the full compiled project from those validated results.

Validation is defined per logical object:

  • classify statements and require exactly one primary create statement
  • validate names against the source-owned object key
  • normalize identifiers and dependencies into canonical qualified form
  • validate clusters, references, comments, and grants
  • resolve active profile variants and reject incompatible overrides

Project assembly validates database and schema setup statements on every invocation, groups validated objects by (database, schema), and enforces schema-wide invariants before producing a compiled project.

§Per-Object Validation (in validate_single_variant)

  1. Statement classification — exactly one main CREATE statement per file
  2. Name validation — object name matches file stem, FQN matches path
  3. Identifier format — lowercase, valid characters
  4. Name normalization — fully qualify all references via NormalizingVisitor
  5. Cluster validation — MVs, sinks, sources, indexes have required IN CLUSTER
  6. Reference validation — indexes, grants, comments reference the parent object

§Profile Variant Handling

Objects may have multiple file variants (e.g., conn.sql and conn#staging.sql). All variants are classified for type consistency, then only the active variant (matching profile or default) is fully validated. Views and materialized views do not allow profile overrides.

Modules§

clusters 🔒
Cluster validation for object statements.
identifiers 🔒
Identifier validation for database objects.
references 🔒
Reference validation for supporting statements.
schema_constraints 🔒
Schema-level constraint validation.

Structs§

DatabaseBuildMeta 🔒
SchemaBuildMeta 🔒

Functions§

assemble_project 🔒
classify_variant_object_type 🔒
Classify statements in a single variant and determine its object type. Returns (ObjectType, path) on success, or errors.
derive_replacement_schemas 🔒
Scan all schemas for SET api = stable statements and build the set of replacement schemas.
object_type_name 🔒
A human-readable name for an ObjectType.
validate_replacement_schemas 🔒
Validate replacement schemas derived from SET api = stable statements.
validate_single_variant 🔒
Validate a single variant’s statements fully and produce a compiled object.