Commit 5927a32
resolves #1360
### description
`WorkflowJobApi.create()` passes plain dicts to
`workspace_client.jobs.create(**converted_job_spec)`. the databricks
sdk's `jobs.create()` iterates tasks calling `v.as_dict()` on each
(confirmed via `JobsAPI.create` source inspection). plain dicts have no
`.as_dict()` which caused the `'dict' object has no attribute 'as_dict'`
error.
1. the fix uses `JobSettings.from_dict()` + `.as_shallow_dict()` to
convert the plain dict job spec into proper sdk dataclasses before
calling `jobs.create()`.
2. `as_shallow_dict()` is the correct choice here : it unpacks top-level
fields as kwargs (matching the `jobs.create()` signature) while keeping
nested values as typed `Task` / `NotebookTask` / etc. dataclasses that
satisfy `.as_dict()`.
3. this is the same pattern already used by `update_job_settings()` in
the same class.
**changes:**
- `dbt/adapters/databricks/api_client.py` - `WorkflowJobApi.create()`
now deserializes the dict via `JobSettings.from_dict()` and passes
`.as_shallow_dict()` to the sdk. inline comment documents the sdk
internals that make this the correct choice.
- `tests/unit/api_client/test_workflow_job_api.py` - tests strengthened
to assert `isinstance(task, Task)`, call `.as_dict()` on each task and
verify output (directly proving the original `AttributeError` cannot
recur), and add a new `test_create__invalid_job_spec_raises` covering
the `JobSettings.from_dict()` error path.
### checklist
- [x] i have run this code in development and it appears to resolve the
stated issue
- [x] this pr includes tests, or tests are not required/relevant for
this pr
- [x] i have updated the `CHANGELOG.md` and added information about my
change to the "dbt-databricks next" section.
---------
Signed-off-by: aarushisingh04 <aarushi07.singh@gmail.com>
Co-authored-by: tejassp-db <241722411+tejassp-db@users.noreply.github.com>
Co-authored-by: Shubham Dhal <shubham.dhal@databricks.com>
1 parent e2a85e6 commit 5927a32
File tree
3 files changed
+45
-17
lines changed- dbt/adapters/databricks
- tests/unit/api_client
3 files changed
+45
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
801 | 801 | | |
802 | 802 | | |
803 | 803 | | |
804 | | - | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
805 | 808 | | |
806 | 809 | | |
807 | 810 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
| |||
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
92 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
93 | 99 | | |
94 | 100 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
107 | 131 | | |
108 | 132 | | |
109 | 133 | | |
| |||
0 commit comments