Principle:173TECH Sayn Dev Prod Name Resolution
| Knowledge Sources | |
|---|---|
| Domains | DevOps, Data_Engineering |
| Last Updated | 2026-10-17 00:00 GMT |
Overview
Technique for resolving database object names differently in development and production environments through prefix, suffix, and override rules, with support for selectively using production objects during development.
Description
Dev/prod name resolution allows the same SAYN project to run against different database objects in development vs production without modifying SQL files. This is achieved through stringify rules that transform object names:
- Prefix: Prepend a string (e.g.,
dev_for dev schema prefix) - Suffix: Append a string
- Override: Full Jinja template replacement (e.g.,
dev_{table})
Additional mechanisms:
- from_prod: Glob patterns specifying which source tables should use production naming even in dev
- upstream_prod: CLI flag (
-u) that makes all sources not produced by executed tasks use production naming - Two-stringify system: Project-level defaults (prod) and profile-level overrides (dev)
Usage
Use this principle when a data platform must support parallel development and production environments sharing the same codebase. It is the right choice when developers need to test against production data sources while writing to development tables.
Theoretical Basis
The name resolution algorithm:
- Parse: Object string (e.g.,
"schema.table") is parsed into database, schema, table components - Check from_prod: Determine if the object should use production naming
- Match against
from_prodglob patterns - Check explicit
sources_from_prodset (from upstream_prod)
- Match against
- Apply stringify: Use
prod_stringifyordev_stringifybased on theis_prodflag
Stringify template construction:
- Default:
{table}(no modification) - With prefix:
prefix_table - With suffix:
table_suffix - With override: Jinja template (e.g.,
dev_{table})
upstream_prod logic:
Failed to parse (syntax error): {\displaystyle \text{sources\_from\_prod} = \text{exec\_sources} \setminus \text{exec\_outputs} }
Sources not produced by any executed task use production naming.
Practical Guide
In project.yaml (production defaults):
# No prefix/suffix = production uses bare names
table_prefix:
table_suffix:
In settings.yaml (dev profile):
profiles:
dev:
schema_prefix: dev
from_prod:
- "raw.*" # Use production raw tables
- "external.*" # Use production external tables
prod:
# No overrides = use production defaults
CLI usage:
# Use dev profile (schema_prefix: dev)
sayn run -p dev
# Use upstream_prod: sources not produced by executed tasks use prod names
sayn run -p dev -u