|
| 1 | +# M2 Profile-Derived Adapter Dispatch Identity Slice |
| 2 | + |
| 3 | +This slice replaces dxt's temporary static adapter dispatch prefix list with a |
| 4 | +profile-derived adapter type for parse-time `adapter.dispatch(...)` dependency |
| 5 | +recording. It still records `depends_on.macros` only. It does not validate |
| 6 | +credentials, render secrets, open adapter connections, execute macros, implement |
| 7 | +project `dispatch:` config, compile `target.*`, or run materializations. |
| 8 | + |
| 9 | +## Upstream References |
| 10 | + |
| 11 | +dbt Core v1, branch `1.latest`, commit `566b75d`: |
| 12 | + |
| 13 | +- `core/dbt/config/runtime.py::load_profile` selects the project profile and |
| 14 | + passes CLI profile, target, and threads overrides into profile loading. |
| 15 | +- `core/dbt/config/profile.py::Profile.pick_profile_name`, |
| 16 | + `render_profile`, `from_raw_profile_info`, `_get_profile_data`, and |
| 17 | + `_credentials_from_profile` define profile-name selection, target selection, |
| 18 | + selected-output lookup, required `type`, and adapter plugin identity. |
| 19 | +- `core/dbt/config/profile.py::Profile.to_target_dict` and |
| 20 | + `core/dbt/context/target.py::TargetContext.target` define the common target |
| 21 | + context fields, including `type`, `name`, `target_name`, `profile_name`, and |
| 22 | + `threads`. |
| 23 | +- `core/dbt/config/runtime.py::RuntimeConfig.get_metadata` emits manifest |
| 24 | + metadata `adapter_type` from credentials. |
| 25 | +- `core/dbt/context/providers.py::BaseDatabaseWrapper._get_adapter_macro_prefixes` |
| 26 | + defines dispatch prefixes as adapter type hierarchy plus `default`. |
| 27 | +- `core/dbt/context/providers.py::BaseDatabaseWrapper.dispatch` rejects dotted |
| 28 | + macro names and deprecated `packages`, then searches |
| 29 | + `{adapter_prefix}__{macro_name}` candidates. |
| 30 | +- `core/dbt/clients/jinja_static.py::statically_parse_adapter_dispatch` uses the |
| 31 | + adapter wrapper to statically resolve literal dispatch calls into macro |
| 32 | + dependencies. |
| 33 | + |
| 34 | +dbt Core v2 / Fusion foundation, branch `main`, commit `0529e06`: |
| 35 | + |
| 36 | +- `crates/dbt-loader/src/load_profiles.rs::load_profiles` locates |
| 37 | + `profiles.yml`, selects profile and target, resolves profile data, and stores |
| 38 | + the adapter type in `DbtProfile`. |
| 39 | +- `crates/dbt-profile/src/resolve.rs` resolves profile name, target override, |
| 40 | + selected output, and adapter type as data. |
| 41 | +- `crates/dbt-schemas/src/schemas/profiles.rs::DbConfig::adapter_type` maps |
| 42 | + typed profile configuration into `AdapterType`. |
| 43 | +- `crates/dbt-adapter-core/src/lib.rs::AdapterType` defines adapter identity and |
| 44 | + accepts the Postgres naming forms. |
| 45 | +- `crates/dbt-jinja/minijinja/src/dispatch_object.rs::get_adapter_prefixes` |
| 46 | + defines Fusion's current parent-prefix fallback: `redshift -> postgres`, |
| 47 | + `databricks -> spark`, then `default`. |
| 48 | +- `crates/dbt-jinja/minijinja/src/dispatch_object.rs::DispatchObject::call` |
| 49 | + applies adapter prefixes during dispatch resolution. |
| 50 | + |
| 51 | +## dxt Ownership |
| 52 | + |
| 53 | +- `src/project/profile.zig` owns the narrow scalar profile/target adapter-type |
| 54 | + parser. |
| 55 | +- `src/project/config.zig` owns `dbt_project.yml` `profile:` discovery. |
| 56 | +- `src/project/loader.zig` resolves profile identity before loading macros and |
| 57 | + resources, so parse-time Jinja scanning sees the selected adapter type. |
| 58 | +- `src/project/jinja.zig` derives static dispatch prefixes from |
| 59 | + `Graph.adapter_type`. |
| 60 | +- `src/project/manifest.zig` emits manifest `metadata.adapter_type`. |
| 61 | + |
| 62 | +## Supported Surface |
| 63 | + |
| 64 | +- Select profile from CLI `--profile`, falling back to `dbt_project.yml` |
| 65 | + `profile:`. |
| 66 | +- Select target from CLI `--target`, falling back to profile `target:`, then |
| 67 | + `default`. |
| 68 | +- Read selected output scalar `type` from `profiles.yml`. |
| 69 | +- Normalize `postgresql` to dispatch adapter type `postgres`. |
| 70 | +- Use dispatch prefix order: |
| 71 | + - `redshift`, `postgres`, `default` |
| 72 | + - `databricks`, `spark`, `default` |
| 73 | + - selected adapter, `default` |
| 74 | +- Preserve the current `duckdb` default only when no profile file is found and |
| 75 | + no profile-related CLI flag requested profile loading. |
| 76 | + |
| 77 | +## Validation |
| 78 | + |
| 79 | +- Native Zig tests cover profile/target selection, missing profile/target/type |
| 80 | + errors, Postgres alias normalization, profile-derived dispatch prefix choice, |
| 81 | + and parent prefix fallback. |
| 82 | +- Pytest fixture `profile_adapter_dispatch` validates parse-time manifest |
| 83 | + `depends_on.macros` and `metadata.adapter_type` for default Postgres, explicit |
| 84 | + DuckDB, and Redshift parent fallback targets through the Zig binary. |
| 85 | +- Existing no-profile fixtures remain covered by the default DuckDB identity. |
| 86 | + |
| 87 | +## Stop Conditions |
| 88 | + |
| 89 | +- Do not render Jinja in `profiles.yml` in this slice. |
| 90 | +- Do not read host-global profile locations beyond the project or explicit |
| 91 | + `--profiles-dir` path. |
| 92 | +- Do not validate or emit credentials. |
| 93 | +- Do not implement project `dispatch:` config. |
| 94 | +- Do not execute dispatched macros, materializations, tests, or adapter SQL. |
| 95 | +- Do not add relation identity, quoting, `target.*`, `this`, catalog |
| 96 | + introspection, or `run_results.json`. |
0 commit comments