Expand description
Name transformation strategies for SQL AST normalization.
This module provides different strategies for transforming object names in SQL statements.
Each transformer implements the NameTransformer trait, allowing the NormalizingVisitor
to apply different transformation strategies using the same traversal logic.
§Strategies
| Transformer | When used | Transform example |
|---|---|---|
FullyQualifyingTransformer | Typed phase (default normalization) | sales → materialize.public.sales |
FlatteningTransformer | Type-checking (single-schema container) | materialize.public.sales → "materialize.public.sales" |
StagingTransformer | Blue/green staging | materialize.public.sales → materialize.public_v1.sales |
ExplainTransformer | Explain command (dedicated schema) | materialize.public.sales → materialize._mz_explain."materialize.public.sales" |
§StagingTransformer Rules
The staging transformer appends a suffix to schema and cluster names. It has special handling for objects that should not be transformed:
- External dependencies — objects not defined in the project are referenced as-is (they exist in production schemas).
- Non-deployed objects — when
objects_to_deployis set, objects outside that set are treated as external. - Replacement objects — objects in replacement schemas are deployed in-place, so references to them are not suffixed.
Key Insight: transform_own_name always suffixes, even for replacement
objects. The is_external exemption applies only to references to other
objects, not to the object’s own CREATE statement name.
Structs§
- Explain
Transformer - Transforms names for the explain command by placing all objects into a dedicated schema with flattened identifiers.
- Flattening
Transformer - Transforms names to be flattened (
database_schema_object). - Fully
Qualifying Transformer - Transforms names to be fully qualified (
database.schema.object). - Staging
Transformer - Transforms names for staging environments by appending a suffix to schema names.
Traits§
- Cluster
Transformer - Extension trait for transformers that also transform cluster names.
- Name
Transformer - Trait for transforming object names in SQL AST nodes.