ADR-0040: Per-model catalog¶
Architecture: Section 3, Pipeline
Amends ADR-0022.
Context¶
A model chooses its schema, but the catalog of its relation comes only from the target: the catalog option of the naming strategy, or the catalog option of the catalog plugin. A project that keeps each layer in its own catalog (for example pipeloom_bronze.tpch.orders and pipeloom_gold.tpch.revenue_by_region) cannot say so in YAML. The two path catalogs, filesystem and delta_path, also ignore the catalog of a target, so a catalog name set on them had no effect.
Options¶
- Where the catalog is resolved.
- Pass the model's catalog through the
NamingStrategyprotocol. Strategies could rewrite catalogs, but the protocol changes and the plugin API goes from (0, 4) to (0, 5), which breaks every installed plugin until it is rebuilt. - Resolve it in the core, after the strategy returns. The protocol and the API stay. Strategies cannot rewrite a model's catalog.
- Path catalogs.
- Map the catalog to a leading directory:
<root>/<catalog>/<schema>/<name>/. A target with no catalog keeps the old layout. - Add a diagnostic for a catalog on a path catalog. It is explicit, but it needs a new code, and it rejects a layout that has a natural meaning.
- Keep ignoring it. Nothing changes, but two layers in different catalogs would collide in one directory without a warning.
Decision¶
ModelSettingsandResolvedModelConfiggaincatalog: str | None, next toschema. It cascades like every other setting: model file, then folder_defaults.yml, thendefaults.models.- Compile calls
naming.relation(name, schema, identity)as before. When the resolved model catalog is set, it replaces the catalog of the returnedTargetRef; when it is unset, the strategy'scatalogoption stays.NamingStrategyandAPI_VERSIONdo not change, and strategies keep transforming only the schema (prefix, per_user). SparkSessionCatalogandUnityCatalogalready usetarget.catalog or self.catalogand need no code change. pipeloom creates schemas, never catalogs: a catalog must exist.FilesystemCatalogandDeltaPathCataloglay a table out at<root>/<catalog>/<schema>/<name>/when the target has a catalog, and at<root>/<schema>/<name>/when it has none.ensure_namespacefollows the same rule, and the catalog goes through the same directory-name check as the schema.- PLP412 (quarantine clash) compares
(catalog, schema, name). No new diagnostic code.
Consequences¶
- The resolved config gains a field, so node checksums and plan hashes change once, for every project, when it moves to this version.
- A naming strategy that has to rewrite catalogs (for example a per-user catalog) needs the protocol extended and a plugin API bump. It is not needed yet.
- A local Spark session needs each catalog registered in its conf (
spark.sql.catalog.<name>) before a run; on Databricks the catalogs and theUSE CATALOGgrants must exist. - Layout change on path catalogs: a project whose naming option set a catalog on
filesystemordelta_pathnow gets that catalog as a directory. It either moves its tables or removes the option. The CHANGELOG carries the migration note. - A source with a three-part
table: a.b.cis split into catalog, schema and name, so on a path catalog it now reads<root>/a/b/cinstead of<root>/b/c. Such a source either moves its files under a directory named after the catalog, or is written asb.c. - PLP412 compares the effective catalog and schema: the model's own value, else the
catalogandschemaoptions of the naming strategy.
Status¶
Accepted. Amended in 0.9 by ADR-0050.
Date¶
2026-11-05
Amendment 0.9 (ADR-0050)¶
catalog keeps its meaning and cascades through the layers of ADR-0050: the @model decorator, then the config of a properties entry, then the models: tree of pipeloom.yml (+catalog) from the folder nearest the model up to the root, then the project root +catalog, then the built-in default. _defaults.yml and defaults.models are removed with the legacy YAML path before 0.9.0; until then they map onto the folder and project layers. The rest of this decision (the catalog replaces the naming strategy's, path catalogs lay tables out under it) does not change.