Problem
environment_suffix_target (schema/table/catalog) always appends the environment
name as a fixed suffix: f"{schema}__{env_name}" in
sqlmesh/core/snapshot/definition.py (schema_name_for_environment). There's no
way to control the resulting name beyond choosing which of the three levels gets
the suffix.
This is inconsistent with the physical layer, where physical_schema_mapping
already lets you map a model's schema (by regex) to an arbitrary target schema
name of your choosing.
Use case
Our org has an existing naming convention for personal/ad hoc schemas:
dev_<user> as a prefix. We can already point a model's physical table
anywhere via physical_schema_mapping, but the virtual layer view for a dev
environment is always <model_schema>__dev_<user> (suffix), which we can't
make consistent with our naming convention. environment_suffix_target: table
and : catalog don't help either, they move where the suffix goes, but it's
still always a suffix.
Proposal
Add a config option (e.g. a virtual_schema_mapping, analogous to
physical_schema_mapping) that lets users map a model's schema name to an
arbitrary virtual schema name/template for non-prod environments, instead of
being limited to the fixed <schema>__<environment> formula.
Default behavior (schema/table/catalog suffix modes) would stay unchanged for
anyone not setting this.
Problem
environment_suffix_target(schema/table/catalog) always appends the environmentname as a fixed suffix:
f"{schema}__{env_name}"insqlmesh/core/snapshot/definition.py(schema_name_for_environment). There's noway to control the resulting name beyond choosing which of the three levels gets
the suffix.
This is inconsistent with the physical layer, where
physical_schema_mappingalready lets you map a model's schema (by regex) to an arbitrary target schema
name of your choosing.
Use case
Our org has an existing naming convention for personal/ad hoc schemas:
dev_<user>as a prefix. We can already point a model's physical tableanywhere via
physical_schema_mapping, but the virtual layer view for a devenvironment is always
<model_schema>__dev_<user>(suffix), which we can'tmake consistent with our naming convention.
environment_suffix_target: tableand
: catalogdon't help either, they move where the suffix goes, but it'sstill always a suffix.
Proposal
Add a config option (e.g. a
virtual_schema_mapping, analogous tophysical_schema_mapping) that lets users map a model's schema name to anarbitrary virtual schema name/template for non-prod environments, instead of
being limited to the fixed
<schema>__<environment>formula.Default behavior (schema/table/catalog suffix modes) would stay unchanged for
anyone not setting this.