tdfs4ds.deploy.variables¶
tdfs4ds.deploy.variables
¶
Databases as variables (0.3.8.15). Pure, no database.
A bundle never names a database. Every database the exported objects live in or read
becomes a variable, written {{VAR}} in the files:
FS_DB- the source store's table database,FS_VIEW_DB- its view database (the same value when the store is not split),DB_<NAME>- one per other database (sources outside the store).
An environment file gives each variable its value in one environment. SQL is rewritten
reference by reference (whole qualified names only, never a prefix of a longer name: the
rule of migration.rewrite._ref_pattern), so a bare column is never touched.
_PLACEHOLDER_RE
module-attribute
¶
Variables
¶
Database -> variable assignment for one source store.
table_db / view_db: the store's databases. rename: {default name or source
database: new variable name}. name_for(db, is_table) gives the variable of a database;
when the store is not split, tables get FS_DB and views FS_VIEW_DB (both hold the same
value in the source, possibly different ones in a target).
__init__
¶
_ref_pattern
¶
Case/quote-tolerant regex matching a fully-qualified db.obj reference,
as a whole name (never a prefix or a suffix of a longer one).
_schema_prefix_pattern
¶
Match schema.<object> capturing the (de-quoted) object token.
norm_name
¶
Uppercase, de-quoted, stripped — the canonical comparison form.
var_name_for_database
¶
DB_<NAME>: the database name upper-cased, every other character an underscore.
ident
¶
An object name as it is written after {{VAR}}.: bare when legal unquoted.
to_placeholders
¶
to_placeholders(text: str, refs: Dict[Tuple[str, str], str], db_fallback: Optional[Dict[str, str]] = None) -> str
text with every db.obj named in refs ({(DB, OBJ): VAR}, normalised keys) written
{{VAR}}.OBJ; then, with db_fallback ({DB: VAR}), any other db.<name> of those
databases. Whole qualified names only. Pure.
resolve_value
¶
{{VAR}} -> the raw value (a database name as it is, for a YAML field or a catalog value).
A non-string passes through; an unknown variable raises KeyError naming it.
resolve_sql
¶
{{VAR}} -> the database as an identifier (quoted only when needed), for SQL text.
resolve_deep
¶
Every string of a nested structure through :func:resolve_value.
expand_env
¶
${NAME} -> environ[NAME] in every string (secrets come from the CI secret store or the
shell, never from a file). An unset name stays as written, so it is visible in a report.
env_names
¶
The ${NAME} references of a structure (sorted), e.g. the credentials an environment needs.
reverse_refs
¶
{DB (normalised): VAR} for a database-level rewrite of target text; when two variables share
a value, the first of prefer wins, then the alphabetical order.