Skip to main content

Module transformers

Module transformers 

Source
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

TransformerWhen usedTransform example
FullyQualifyingTransformerTyped phase (default normalization)salesmaterialize.public.sales
FlatteningTransformerType-checking (single-schema container)materialize.public.sales"materialize.public.sales"
StagingTransformerBlue/green stagingmaterialize.public.salesmaterialize.public_v1.sales
ExplainTransformerExplain command (dedicated schema)materialize.public.salesmaterialize._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_deploy is 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§

ExplainTransformer
Transforms names for the explain command by placing all objects into a dedicated schema with flattened identifiers.
FlatteningTransformer
Transforms names to be flattened (database_schema_object).
FullyQualifyingTransformer
Transforms names to be fully qualified (database.schema.object).
StagingTransformer
Transforms names for staging environments by appending a suffix to schema names.

Traits§

ClusterTransformer
Extension trait for transformers that also transform cluster names.
NameTransformer
Trait for transforming object names in SQL AST nodes.